return 0;
}
+/* Get the inferior associated to LWP. Must be called with an LWP that has
+ an associated inferior. Always return non-nullptr. */
+
+static inferior *
+lwp_inferior (const lwp_info *lwp)
+{
+ inferior *inf = find_inferior_ptid (linux_target, lwp->ptid);
+ gdb_assert (inf != nullptr);
+ return inf;
+}
+
/* Return non-zero if LP has a wait status pending. Discard the
pending event and resume the LWP if the event that originally
caused the stop became uninteresting. */
}
#if !USE_SIGTRAP_SIGINFO
- else if (!breakpoint_inserted_here_p (regcache->aspace (), pc))
+ else if (!breakpoint_inserted_here_p (lwp_inferior (lp)->aspace, pc))
{
linux_nat_debug_printf ("previous breakpoint of %s, at %s gone",
lp->ptid.to_string ().c_str (),
if (!linux_target->low_status_is_event (lp->status))
return;
- inferior *inf = find_inferior_ptid (linux_target, lp->ptid);
+ inferior *inf = lwp_inferior (lp);
if (inf->starting_up)
return;
}
#else
if ((!lp->step || lp->stop_pc == sw_bp_pc)
- && software_breakpoint_inserted_here_p (regcache->aspace (),
- sw_bp_pc))
+ && software_breakpoint_inserted_here_p (inf->aspace, sw_bp_pc))
{
/* The LWP was either continued, or stepped a software
breakpoint instruction. */
lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
}
- if (hardware_breakpoint_inserted_here_p (regcache->aspace (), pc))
+ if (hardware_breakpoint_inserted_here_p (inf->aspace, pc))
lp->stop_reason = TARGET_STOPPED_BY_HW_BREAKPOINT;
if (lp->stop_reason == TARGET_STOPPED_BY_NO_REASON)
static int
resume_stopped_resumed_lwps (struct lwp_info *lp, const ptid_t wait_ptid)
{
- inferior *inf = find_inferior_ptid (linux_target, lp->ptid);
+ inferior *inf = lwp_inferior (lp);
if (!lp->stopped)
{
immediately, and we're not waiting for this LWP. */
if (!lp->ptid.matches (wait_ptid))
{
- if (breakpoint_inserted_here_p (regcache->aspace (), pc))
+ if (breakpoint_inserted_here_p (inf->aspace, pc))
leave_stopped = 1;
}
iterate_over_lwps (ptid, linux_nat_stop_lwp);
}
-/* When requests are passed down from the linux-nat layer to the
- single threaded inf-ptrace layer, ptids of (lwpid,0,0) form are
- used. The address space pointer is stored in the inferior object,
- but the common code that is passed such ptid can't tell whether
- lwpid is a "main" process id or not (it assumes so). We reverse
- look up the "main" process id from the lwp here. */
-
-struct address_space *
-linux_nat_target::thread_address_space (ptid_t ptid)
-{
- struct lwp_info *lwp;
- struct inferior *inf;
- int pid;
-
- if (ptid.lwp () == 0)
- {
- /* An (lwpid,0,0) ptid. Look up the lwp object to get at the
- tgid. */
- lwp = find_lwp_pid (ptid);
- pid = lwp->ptid.pid ();
- }
- else
- {
- /* A (pid,lwpid,0) ptid. */
- pid = ptid.pid ();
- }
-
- inf = find_inferior_pid (this, pid);
- gdb_assert (inf != NULL);
- return inf->aspace;
-}
-
/* Return the cached value of the processor core for thread PTID. */
int