/* Machine independent support for Solaris /proc (process file system) for GDB.
- Copyright (C) 1999-2022 Free Software Foundation, Inc.
+ Copyright (C) 1999-2023 Free Software Foundation, Inc.
Written by Michael Snyder at Cygnus Solutions.
Based on work by Fred Fish, Stu Grossman, Geoff Noer, and others.
bool info_proc (const char *, enum info_proc_what) override;
#if PR_MODEL_NATIVE == PR_MODEL_LP64
- int auxv_parse (gdb_byte **readptr,
- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
+ int auxv_parse (const gdb_byte **readptr,
+ const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
override;
#endif
is presented in 64-bit format. We need to provide a custom parser
to handle that. */
int
-procfs_target::auxv_parse (gdb_byte **readptr,
- gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
+procfs_target::auxv_parse (const gdb_byte **readptr,
+ const gdb_byte *endptr, CORE_ADDR *typep,
+ CORE_ADDR *valp)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
- gdb_byte *ptr = *readptr;
+ const gdb_byte *ptr = *readptr;
if (endptr == ptr)
return 0;
static void
dead_procinfo (procinfo *pi, const char *msg, int kill_p)
{
- char procfile[80];
-
- if (pi->pathname)
- print_sys_errmsg (pi->pathname, errno);
- else
- {
- xsnprintf (procfile, sizeof (procfile), "process %d", pi->pid);
- print_sys_errmsg (procfile, errno);
- }
+ print_sys_errmsg (pi->pathname, errno);
if (kill_p == KILL)
kill (pi->pid, SIGKILL);
(procinfo *pi,
int (*func) (procinfo *, procinfo *, void *),
void *ptr);
+static void proc_resume (procinfo *pi, ptid_t scope_ptid,
+ int step, enum gdb_signal signo);
static void
proc_warn (procinfo *pi, const char *func, int line)
inf = current_inferior ();
inferior_appeared (inf, pi->pid);
/* Let GDB know that the inferior was attached. */
- inf->attach_flag = 1;
+ inf->attach_flag = true;
/* Create a procinfo for the current lwp. */
lwpid = proc_get_current_thread (pi);
case PR_SYSENTRY:
if (what == SYS_lwp_exit)
{
- if (print_thread_events)
- gdb_printf (_("[%s exited]\n"),
- target_pid_to_str (retval).c_str ());
- delete_thread (find_thread_ptid (this, retval));
- target_continue_no_signal (ptid);
+ delete_thread (this->find_thread (retval));
+ proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
goto wait_again;
}
else if (what == SYS_exit)
i, sysargs[i]);
}
- /* How to keep going without returning to wfi: */
- target_continue_no_signal (ptid);
+ proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
goto wait_again;
}
break;
if (!in_thread_list (this, temp_ptid))
add_thread (this, temp_ptid);
- target_continue_no_signal (ptid);
+ proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
goto wait_again;
}
else if (what == SYS_lwp_exit)
{
- if (print_thread_events)
- gdb_printf (_("[%s exited]\n"),
- target_pid_to_str (retval).c_str ());
- delete_thread (find_thread_ptid (this, retval));
+ delete_thread (this->find_thread (retval));
status->set_spurious ();
return retval;
}
i, sysargs[i]);
}
- target_continue_no_signal (ptid);
+ proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
goto wait_again;
}
break;
return 0;
}
-/* Make the child process runnable. Normally we will then call
- procfs_wait and wait for it to stop again (unless gdb is async).
+/* Make child process PI runnable.
If STEP is true, then arrange for the child to stop again after
- executing a single instruction. If SIGNO is zero, then cancel any
- pending signal; if non-zero, then arrange for the indicated signal
- to be delivered to the child when it runs. If PID is -1, then
- allow any child thread to run; if non-zero, then allow only the
- indicated thread to run. (not implemented yet). */
+ executing a single instruction. SCOPE_PTID, STEP and SIGNO are
+ like in the target_resume interface. */
-void
-procfs_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
+static void
+proc_resume (procinfo *pi, ptid_t scope_ptid, int step, enum gdb_signal signo)
{
- procinfo *pi, *thread;
+ procinfo *thread;
int native_signo;
/* FIXME: Check/reword. */
So basically PR_STEP is the sole argument that must be passed
to proc_run_process. */
- /* Find procinfo for main process. */
- pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
-
- /* First cut: ignore pid argument. */
errno = 0;
/* Convert signal to host numbering. */
/* Void the process procinfo's caches. */
invalidate_cache (NULL, pi, NULL);
- if (ptid.pid () != -1)
+ if (scope_ptid.pid () != -1)
{
/* Resume a specific thread, presumably suppressing the
others. */
- thread = find_procinfo (ptid.pid (), ptid.lwp ());
+ thread = find_procinfo (scope_ptid.pid (), scope_ptid.lwp ());
if (thread != NULL)
{
if (thread->tid != 0)
}
}
+/* Implementation of target_ops::resume. */
+
+void
+procfs_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo)
+{
+ /* Find procinfo for main process. */
+ procinfo *pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
+
+ proc_resume (pi, scope_ptid, step, signo);
+}
+
/* Set up to trace signals in the child process. */
void
gdb_printf (_("\tUsing the running image of %s %s via /proc.\n"),
inf->attach_flag? "attached": "child",
- target_pid_to_str (inferior_ptid).c_str ());
+ target_pid_to_str (ptid_t (inf->pid)).c_str ());
}
/* Make it die. Wait for it to die. Clean up after it. Note: this
len = p1 - p;
else
len = strlen (p);
- strncpy (tryname, p, len);
+ memcpy (tryname, p, len);
tryname[len] = '\0';
strcat (tryname, "/");
strcat (tryname, shell_file);
{
ptid_t gdb_threadid = ptid_t (pi->pid, thread->tid, 0);
- thread_info *thr = find_thread_ptid (&the_procfs_target, gdb_threadid);
+ thread_info *thr = the_procfs_target.find_thread (gdb_threadid);
if (thr == NULL || thr->state == THREAD_EXITED)
add_thread (&the_procfs_target, gdb_threadid);
(map->pr_mflags & MA_WRITE) != 0,
(map->pr_mflags & MA_EXEC) != 0,
1, /* MODIFIED is unknown, pass it as true. */
+ false,
data);
}