+2020-06-22 Pedro Alves <palves@redhat.com>
+
+ PR gdb/25939
+ * procfs.c (procfs_target::wait): Don't reference inferior_ptid.
+ Use the current inferior instead. Don't return
+ TARGET_WAITKIND_SPURIOUS/inferior_ptid -- instead continue and
+ wait again.
+ * sol-thread.c (sol_thread_target::wait): Don't reference
+ inferior_ptid.
+ (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs)
+ (sol_update_thread_list_callback): Use the current inferior's pid
+ instead of inferior_ptid.
+
2020-06-21 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* procfs.c: Cleanup many comments.
retval = ptid_t (-1);
/* Find procinfo for main process. */
- pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
+
+ /* procfs_target currently only supports one inferior. */
+ inferior *inf = current_inferior ();
+
+ pi = find_procinfo_or_die (inf->pid, 0);
if (pi)
{
/* We must assume that the status is stale now... */
wait_retval = ::wait (&wstat); /* "wait" for the child's exit. */
/* Wrong child? */
- if (wait_retval != inferior_ptid.pid ())
+ if (wait_retval != inf->pid)
error (_("procfs: couldn't stop "
"process %d: wait returned %d."),
- inferior_ptid.pid (), wait_retval);
+ inf->pid, wait_retval);
/* FIXME: might I not just use waitpid?
Or try find_procinfo to see if I know about this child? */
retval = ptid_t (wait_retval);
printf_unfiltered (_("[%s exited]\n"),
target_pid_to_str (retval).c_str ());
delete_thread (find_thread_ptid (this, retval));
- status->kind = TARGET_WAITKIND_SPURIOUS;
- return retval;
+ target_continue_no_signal (ptid);
+ goto wait_again;
}
else if (what == SYS_exit)
{
- struct inferior *inf;
-
/* Handle SYS_exit call only. */
/* Stopped at entry to SYS_exit.
Make it runnable, resume it, then use
if (!proc_run_process (pi, 0, 0))
proc_error (pi, "target_wait, run_process", __LINE__);
- inf = find_inferior_pid (this, pi->pid);
if (inf->attach_flag)
{
/* Don't call wait: simulate waiting for exit,
return a "success" exit code. Bogus: what if
it returns something else? */
wstat = 0;
- retval = inferior_ptid; /* ? ? ? */
+ retval = ptid_t (inf->pid); /* ? ? ? */
}
else
{
i, sysargs[i]);
}
- if (status)
- {
- /* How to exit gracefully, returning "unknown
- event". */
- status->kind = TARGET_WAITKIND_SPURIOUS;
- return inferior_ptid;
- }
- else
- {
- /* How to keep going without returning to wfi: */
- target_continue_no_signal (ptid);
- goto wait_again;
- }
+ /* How to keep going without returning to wfi: */
+ target_continue_no_signal (ptid);
+ goto wait_again;
}
break;
case PR_SYSEXIT:
if (!in_thread_list (this, temp_ptid))
add_thread (this, temp_ptid);
- /* Return to WFI, but tell it to immediately resume. */
- status->kind = TARGET_WAITKIND_SPURIOUS;
- return inferior_ptid;
+ target_continue_no_signal (ptid);
+ goto wait_again;
}
else if (what == SYS_lwp_exit)
{
i, sysargs[i]);
}
- status->kind = TARGET_WAITKIND_SPURIOUS;
- return inferior_ptid;
+ target_continue_no_signal (ptid);
+ goto wait_again;
}
break;
case PR_REQUESTED:
/* Got this far without error: If retval isn't in the
threads database, add it. */
if (retval.pid () > 0
- && retval != inferior_ptid
&& !in_thread_list (this, retval))
{
/* We have a new thread. We need to add it both to
sol_thread_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
int options)
{
- ptid_t rtnval;
- ptid_t save_ptid;
-
- save_ptid = inferior_ptid;
- scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
-
- inferior_ptid = thread_to_lwp (inferior_ptid, main_ph.ptid.pid ());
- if (inferior_ptid.pid () == -1)
- inferior_ptid = procfs_first_available ();
-
if (ptid.pid () != -1)
{
ptid_t ptid_for_warning = ptid;
ptid_for_warning.tid ());
}
- rtnval = beneath ()->wait (ptid, ourstatus, options);
+ ptid_t rtnval = beneath ()->wait (ptid, ourstatus, options);
if (ourstatus->kind != TARGET_WAITKIND_EXITED)
{
/* Map the LWP of interest back to the appropriate thread ID. */
- rtnval = lwp_to_thread (rtnval);
- if (rtnval.pid () == -1)
- rtnval = save_ptid;
+ ptid_t thr_ptid = lwp_to_thread (rtnval);
+ if (thr_ptid.pid () != -1)
+ rtnval = thr_ptid;
/* See if we have a new thread. */
- if (rtnval.tid_p () && rtnval != save_ptid)
+ if (rtnval.tid_p ())
{
thread_info *thr = find_thread_ptid (current_inferior (), rtnval);
if (thr == NULL || thr->state == THREAD_EXITED)
ps_err_e
ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset)
{
- ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
+ ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
struct regcache *regcache
= get_thread_arch_regcache (current_inferior ()->process_target (),
ptid, target_gdbarch ());
ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid,
const prgregset_t gregset)
{
- ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
+ ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
struct regcache *regcache
= get_thread_arch_regcache (current_inferior ()->process_target (),
ptid, target_gdbarch ());
ps_lgetfpregs (struct ps_prochandle *ph, lwpid_t lwpid,
prfpregset_t *fpregset)
{
- ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
+ ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
struct regcache *regcache
= get_thread_arch_regcache (current_inferior ()->process_target (),
ptid, target_gdbarch ());
ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid,
const prfpregset_t * fpregset)
{
- ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
+ ptid_t ptid = ptid_t (current_inferior ()->pid, lwpid, 0);
struct regcache *regcache
= get_thread_arch_regcache (current_inferior ()->process_target (),
ptid, target_gdbarch ());
if (retval != TD_OK)
return -1;
- ptid_t ptid = ptid_t (inferior_ptid.pid (), 0, ti.ti_tid);
+ ptid_t ptid = ptid_t (current_inferior ()->pid, 0, ti.ti_tid);
thread_info *thr = find_thread_ptid (current_inferior (), ptid);
if (thr == NULL || thr->state == THREAD_EXITED)
{