Replace the direct assignments to current_thread with
switch_to_thread. Use scoped_restore_current_thread when appropriate.
There is one instance remaining in linux-low.cc's wait_for_sigstop.
This will be handled in a separate patch.
Regression-tested on X86-64 Linux using the native-gdbserver and
native-extended-gdbserver board files.
13 files changed:
all_threads.push_back (new_thread);
if (current_thread == NULL)
all_threads.push_back (new_thread);
if (current_thread == NULL)
- current_thread = new_thread;
+ switch_to_thread (new_thread);
discard_queued_stop_replies (ptid_of (thread));
all_threads.remove (thread);
if (current_thread == thread)
discard_queued_stop_replies (ptid_of (thread));
all_threads.remove (thread);
if (current_thread == thread)
+ switch_to_thread (nullptr);
free_one_thread (thread);
}
free_one_thread (thread);
}
+ switch_to_thread (nullptr);
switch_to_thread (process_stratum_target *ops, ptid_t ptid)
{
gdb_assert (ptid != minus_one_ptid);
switch_to_thread (process_stratum_target *ops, ptid_t ptid)
{
gdb_assert (ptid != minus_one_ptid);
- current_thread = find_thread_ptid (ptid);
+ switch_to_thread (find_thread_ptid (ptid));
{
int pid = pid_of (proc);
{
int pid = pid_of (proc);
- current_thread = find_any_thread_of_pid (pid);
+ switch_to_thread (find_any_thread_of_pid (pid));
}
/* See gdbsupport/common-inferior.h. */
}
/* See gdbsupport/common-inferior.h. */
void
linux_process_target::arch_setup_thread (thread_info *thread)
{
void
linux_process_target::arch_setup_thread (thread_info *thread)
{
- struct thread_info *saved_thread;
-
- saved_thread = current_thread;
- current_thread = thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
-
- current_thread = saved_thread;
/* Delete the execing process and all its threads. */
mourn (proc);
/* Delete the execing process and all its threads. */
mourn (proc);
+ switch_to_thread (nullptr);
/* Create a new process/lwp/thread. */
proc = add_linux_process (event_pid, 0);
/* Create a new process/lwp/thread. */
proc = add_linux_process (event_pid, 0);
CORE_ADDR
linux_process_target::get_pc (lwp_info *lwp)
{
CORE_ADDR
linux_process_target::get_pc (lwp_info *lwp)
{
- struct thread_info *saved_thread;
struct regcache *regcache;
CORE_ADDR pc;
if (!low_supports_breakpoints ())
return 0;
struct regcache *regcache;
CORE_ADDR pc;
if (!low_supports_breakpoints ())
return 0;
- saved_thread = current_thread;
- current_thread = get_lwp_thread (lwp);
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (get_lwp_thread (lwp));
regcache = get_thread_regcache (current_thread, 1);
pc = low_get_pc (regcache);
regcache = get_thread_regcache (current_thread, 1);
pc = low_get_pc (regcache);
if (debug_threads)
debug_printf ("pc is 0x%lx\n", (long) pc);
if (debug_threads)
debug_printf ("pc is 0x%lx\n", (long) pc);
- current_thread = saved_thread;
return pc;
}
void
linux_process_target::get_syscall_trapinfo (lwp_info *lwp, int *sysno)
{
return pc;
}
void
linux_process_target::get_syscall_trapinfo (lwp_info *lwp, int *sysno)
{
- struct thread_info *saved_thread;
struct regcache *regcache;
struct regcache *regcache;
- saved_thread = current_thread;
- current_thread = get_lwp_thread (lwp);
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (get_lwp_thread (lwp));
regcache = get_thread_regcache (current_thread, 1);
low_get_syscall_trapinfo (regcache, sysno);
if (debug_threads)
debug_printf ("get_syscall_trapinfo sysno %d\n", *sysno);
regcache = get_thread_regcache (current_thread, 1);
low_get_syscall_trapinfo (regcache, sysno);
if (debug_threads)
debug_printf ("get_syscall_trapinfo sysno %d\n", *sysno);
-
- current_thread = saved_thread;
{
CORE_ADDR pc;
CORE_ADDR sw_breakpoint_pc;
{
CORE_ADDR pc;
CORE_ADDR sw_breakpoint_pc;
- struct thread_info *saved_thread;
#if USE_SIGTRAP_SIGINFO
siginfo_t siginfo;
#endif
#if USE_SIGTRAP_SIGINFO
siginfo_t siginfo;
#endif
sw_breakpoint_pc = pc - low_decr_pc_after_break ();
/* breakpoint_at reads from the current thread. */
sw_breakpoint_pc = pc - low_decr_pc_after_break ();
/* breakpoint_at reads from the current thread. */
- saved_thread = current_thread;
- current_thread = get_lwp_thread (lwp);
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (get_lwp_thread (lwp));
#if USE_SIGTRAP_SIGINFO
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
#if USE_SIGTRAP_SIGINFO
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
- current_thread = saved_thread;
&& (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
|| lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT))
{
&& (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
|| lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT))
{
- struct thread_info *saved_thread;
CORE_ADDR pc;
int discard = 0;
CORE_ADDR pc;
int discard = 0;
- saved_thread = current_thread;
- current_thread = thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
- current_thread = saved_thread;
-
if (discard)
{
if (debug_threads)
if (discard)
{
if (debug_threads)
bool
linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
{
bool
linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
{
- struct thread_info *saved_thread;
-
- saved_thread = current_thread;
- current_thread = get_lwp_thread (lwp);
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (get_lwp_thread (lwp));
if ((wstat == NULL
|| (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))
if ((wstat == NULL
|| (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))
debug_printf ("Checking whether LWP %ld needs to move out of "
"the jump pad...it does\n",
lwpid_of (current_thread));
debug_printf ("Checking whether LWP %ld needs to move out of "
"the jump pad...it does\n",
lwpid_of (current_thread));
- current_thread = saved_thread;
"jump pad...no\n",
lwpid_of (current_thread));
"jump pad...no\n",
lwpid_of (current_thread));
- current_thread = saved_thread;
bool
linux_process_target::check_stopped_by_watchpoint (lwp_info *child)
{
bool
linux_process_target::check_stopped_by_watchpoint (lwp_info *child)
{
- struct thread_info *saved_thread = current_thread;
- current_thread = get_lwp_thread (child);
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (get_lwp_thread (child));
if (low_stopped_by_watchpoint ())
{
if (low_stopped_by_watchpoint ())
{
child->stopped_data_address = low_stopped_data_address ();
}
child->stopped_data_address = low_stopped_data_address ();
}
- current_thread = saved_thread;
-
return child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
}
return child->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
}
child_ptid = ptid_t (lwpid, lwpid);
child = add_lwp (child_ptid);
child->stopped = 1;
child_ptid = ptid_t (lwpid, lwpid);
child = add_lwp (child_ptid);
child->stopped = 1;
- current_thread = child->thread;
+ switch_to_thread (child->thread);
}
/* If we didn't find a process, one of two things presumably happened:
}
/* If we didn't find a process, one of two things presumably happened:
*wstatp = event_child->status_pending;
event_child->status_pending_p = 0;
event_child->status_pending = 0;
*wstatp = event_child->status_pending;
event_child->status_pending_p = 0;
event_child->status_pending = 0;
- current_thread = event_thread;
+ switch_to_thread (event_thread);
return lwpid_of (event_thread);
}
return lwpid_of (event_thread);
}
gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
gdb_sigmask (SIG_SETMASK, &prev_mask, NULL);
- current_thread = event_thread;
+ switch_to_thread (event_thread);
return lwpid_of (event_thread);
}
return lwpid_of (event_thread);
}
- thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
- current_thread = saved_thread;
-
if (debug_threads)
{
thread_stuck = find_thread ([this] (thread_info *thread)
if (debug_threads)
{
thread_stuck = find_thread ([this] (thread_info *thread)
select_event_lwp (&event_child);
/* current_thread and event_child must stay in sync. */
select_event_lwp (&event_child);
/* current_thread and event_child must stay in sync. */
- current_thread = get_lwp_thread (event_child);
+ switch_to_thread (get_lwp_thread (event_child));
event_child->status_pending_p = 0;
w = event_child->status_pending;
event_child->status_pending_p = 0;
w = event_child->status_pending;
void
linux_process_target::move_out_of_jump_pad (thread_info *thread)
{
void
linux_process_target::move_out_of_jump_pad (thread_info *thread)
{
- struct thread_info *saved_thread;
struct lwp_info *lwp = get_thread_lwp (thread);
int *wstat;
struct lwp_info *lwp = get_thread_lwp (thread);
int *wstat;
gdb_assert (lwp->stopped);
/* For gdb_breakpoint_here. */
gdb_assert (lwp->stopped);
/* For gdb_breakpoint_here. */
- saved_thread = current_thread;
- current_thread = thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
wstat = lwp->status_pending_p ? &lwp->status_pending : NULL;
wstat = lwp->status_pending_p ? &lwp->status_pending : NULL;
}
else
lwp_suspended_inc (lwp);
}
else
lwp_suspended_inc (lwp);
-
- current_thread = saved_thread;
struct thread_info *thread = get_lwp_thread (lwp);
struct regcache *regcache = get_thread_regcache (thread, 1);
struct thread_info *thread = get_lwp_thread (lwp);
struct regcache *regcache = get_thread_regcache (thread, 1);
- scoped_restore save_current_thread = make_scoped_restore (¤t_thread);
+ scoped_restore_current_thread restore_thread;
- current_thread = thread;
+ switch_to_thread (thread);
std::vector<CORE_ADDR> next_pcs = low_get_next_pcs (regcache);
for (CORE_ADDR pc : next_pcs)
std::vector<CORE_ADDR> next_pcs = low_get_next_pcs (regcache);
for (CORE_ADDR pc : next_pcs)
int signal, siginfo_t *info)
{
struct thread_info *thread = get_lwp_thread (lwp);
int signal, siginfo_t *info)
{
struct thread_info *thread = get_lwp_thread (lwp);
- struct thread_info *saved_thread;
int ptrace_request;
struct process_info *proc = get_thread_process (thread);
int ptrace_request;
struct process_info *proc = get_thread_process (thread);
- saved_thread = current_thread;
- current_thread = thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
/* This bit needs some thinking about. If we get a signal that
we must report while a single-step reinsert is still pending,
/* This bit needs some thinking about. If we get a signal that
we must report while a single-step reinsert is still pending,
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal);
- current_thread = saved_thread;
if (errno)
perror_with_name ("resuming thread");
if (errno)
perror_with_name ("resuming thread");
linux_process_target::thread_needs_step_over (thread_info *thread)
{
struct lwp_info *lwp = get_thread_lwp (thread);
linux_process_target::thread_needs_step_over (thread_info *thread)
{
struct lwp_info *lwp = get_thread_lwp (thread);
- struct thread_info *saved_thread;
CORE_ADDR pc;
struct process_info *proc = get_thread_process (thread);
CORE_ADDR pc;
struct process_info *proc = get_thread_process (thread);
- saved_thread = current_thread;
- current_thread = thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
/* We can only step over breakpoints we know about. */
if (breakpoint_here (pc) || fast_tracepoint_jump_here (pc))
/* We can only step over breakpoints we know about. */
if (breakpoint_here (pc) || fast_tracepoint_jump_here (pc))
" GDB breakpoint at 0x%s; skipping step over\n",
lwpid_of (thread), paddress (pc));
" GDB breakpoint at 0x%s; skipping step over\n",
lwpid_of (thread), paddress (pc));
- current_thread = saved_thread;
/* We've found an lwp that needs stepping over --- return 1 so
that find_thread stops looking. */
/* We've found an lwp that needs stepping over --- return 1 so
that find_thread stops looking. */
- current_thread = saved_thread;
-
- current_thread = saved_thread;
-
if (debug_threads)
debug_printf ("Need step over [LWP %ld]? No, no breakpoint found"
" at 0x%s\n",
if (debug_threads)
debug_printf ("Need step over [LWP %ld]? No, no breakpoint found"
" at 0x%s\n",
linux_process_target::start_step_over (lwp_info *lwp)
{
struct thread_info *thread = get_lwp_thread (lwp);
linux_process_target::start_step_over (lwp_info *lwp)
{
struct thread_info *thread = get_lwp_thread (lwp);
- struct thread_info *saved_thread;
if (debug_threads)
debug_printf ("Starting step-over on LWP %ld. Stopping all threads\n",
if (debug_threads)
debug_printf ("Starting step-over on LWP %ld. Stopping all threads\n",
shouldn't care about. */
pc = get_pc (lwp);
shouldn't care about. */
pc = get_pc (lwp);
- saved_thread = current_thread;
- current_thread = thread;
-
- lwp->bp_reinsert = pc;
- uninsert_breakpoints_at (pc);
- uninsert_fast_tracepoint_jumps_at (pc);
+ bool step = false;
+ {
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
- step = single_step (lwp);
+ lwp->bp_reinsert = pc;
+ uninsert_breakpoints_at (pc);
+ uninsert_fast_tracepoint_jumps_at (pc);
- current_thread = saved_thread;
+ step = single_step (lwp);
+ }
resume_one_lwp (lwp, step, 0, NULL);
resume_one_lwp (lwp, step, 0, NULL);
{
if (lwp->bp_reinsert != 0)
{
{
if (lwp->bp_reinsert != 0)
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
if (debug_threads)
debug_printf ("Finished step over.\n");
if (debug_threads)
debug_printf ("Finished step over.\n");
- current_thread = get_lwp_thread (lwp);
+ switch_to_thread (get_lwp_thread (lwp));
/* Reinsert any breakpoint at LWP->BP_REINSERT. Note that there
may be no breakpoint to reinsert there by now. */
/* Reinsert any breakpoint at LWP->BP_REINSERT. Note that there
may be no breakpoint to reinsert there by now. */
}
step_over_bkpt = null_ptid;
}
step_over_bkpt = null_ptid;
- current_thread = saved_thread;
void
x86_target::update_xmltarget ()
{
void
x86_target::update_xmltarget ()
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
/* Before changing the register cache's internal layout, flush the
contents of the current valid caches back to the threads, and
/* Before changing the register cache's internal layout, flush the
contents of the current valid caches back to the threads, and
int pid = proc->pid;
/* Look up any thread of this process. */
int pid = proc->pid;
/* Look up any thread of this process. */
- current_thread = find_any_thread_of_pid (pid);
+ switch_to_thread (find_any_thread_of_pid (pid));
-
- current_thread = saved_thread;
}
/* Process qSupported query, "xmlRegisters=". Update the buffer size for
}
/* Process qSupported query, "xmlRegisters=". Update the buffer size for
if (bp->type == single_step_breakpoint
&& ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
{
if (bp->type == single_step_breakpoint
&& ((struct single_step_breakpoint *) bp)->ptid == ptid_of (thread))
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
- current_thread = thread;
+ switch_to_thread (thread);
*bp_link = bp->next;
release_breakpoint (proc, bp);
bp = *bp_link;
*bp_link = bp->next;
release_breakpoint (proc, bp);
bp = *bp_link;
- current_thread = saved_thread;
reinsert breakpoint. */
if (bp->raw->refcount == 1)
{
reinsert breakpoint. */
if (bp->raw->refcount == 1)
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
- current_thread = thread;
+ switch_to_thread (thread);
uninsert_raw_breakpoint (bp->raw);
uninsert_raw_breakpoint (bp->raw);
- current_thread = saved_thread;
if (bp->raw->refcount == 1)
{
if (bp->raw->refcount == 1)
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
- current_thread = thread;
+ switch_to_thread (thread);
reinsert_raw_breakpoint (bp->raw);
reinsert_raw_breakpoint (bp->raw);
- current_thread = saved_thread;
}
if (find_thread_ptid (ptid_t (pid)))
}
if (find_thread_ptid (ptid_t (pid)))
- current_thread = find_thread_ptid (wptid);
+ switch_to_thread (find_thread_ptid (wptid));
if (code == TRAP_LWP && pst.pe_report_event == PTRACE_LWP_CREATE)
{
if (code == TRAP_LWP && pst.pe_report_event == PTRACE_LWP_CREATE)
{
{
#ifdef HAVE_REGSETS
struct lwp_info *lwp;
{
#ifdef HAVE_REGSETS
struct lwp_info *lwp;
- struct thread_info *reg_thread, *saved_thread;
struct regcache *regcache;
lwp = find_lwp_pid (ptid_t (lwpid));
if (lwp == NULL)
return PS_ERR;
struct regcache *regcache;
lwp = find_lwp_pid (ptid_t (lwpid));
if (lwp == NULL)
return PS_ERR;
- reg_thread = get_lwp_thread (lwp);
- saved_thread = current_thread;
- current_thread = reg_thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (get_lwp_thread (lwp));
regcache = get_thread_regcache (current_thread, 1);
gregset_info ()->fill_function (regcache, gregset);
regcache = get_thread_regcache (current_thread, 1);
gregset_info ()->fill_function (regcache, gregset);
- current_thread = saved_thread;
return PS_OK;
#else
return PS_ERR;
return PS_OK;
#else
return PS_ERR;
if (fetch && regcache->registers_valid == 0)
{
if (fetch && regcache->registers_valid == 0)
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
- current_thread = thread;
+ switch_to_thread (thread);
/* Invalidate all registers, to prevent stale left-overs. */
memset (regcache->register_status, REG_UNAVAILABLE,
regcache->tdesc->reg_defs.size ());
fetch_inferior_registers (regcache, -1);
/* Invalidate all registers, to prevent stale left-overs. */
memset (regcache->register_status, REG_UNAVAILABLE,
regcache->tdesc->reg_defs.size ());
fetch_inferior_registers (regcache, -1);
- current_thread = saved_thread;
regcache->registers_valid = 1;
}
regcache->registers_valid = 1;
}
if (regcache->registers_valid)
{
if (regcache->registers_valid)
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
- current_thread = thread;
+ switch_to_thread (thread);
store_inferior_registers (regcache, -1);
store_inferior_registers (regcache, -1);
- current_thread = saved_thread;
}
regcache->registers_valid = 0;
}
regcache->registers_valid = 0;
case TARGET_WAITKIND_SYSCALL_ENTRY:
case TARGET_WAITKIND_SYSCALL_RETURN:
{
case TARGET_WAITKIND_SYSCALL_ENTRY:
case TARGET_WAITKIND_SYSCALL_RETURN:
{
- struct thread_info *saved_thread;
const char **regp;
struct regcache *regcache;
const char **regp;
struct regcache *regcache;
- saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
switch_to_thread (the_target, ptid);
switch_to_thread (the_target, ptid);
buf += strlen (buf);
current_process ()->dlls_changed = false;
}
buf += strlen (buf);
current_process ()->dlls_changed = false;
}
-
- current_thread = saved_thread;
}
break;
case TARGET_WAITKIND_EXITED:
}
break;
case TARGET_WAITKIND_EXITED:
cs.last_status.set_exited (0);
cs.last_ptid = ptid_t (pid);
cs.last_status.set_exited (0);
cs.last_ptid = ptid_t (pid);
+ switch_to_thread (nullptr);
{
client_state &cs = get_client_state ();
{
client_state &cs = get_client_state ();
- scoped_restore save_current_thread
- = make_scoped_restore (¤t_thread);
+ scoped_restore_current_thread restore_thread;
scoped_restore save_current_general_thread
= make_scoped_restore (&cs.general_thread);
scoped_restore save_current_general_thread
= make_scoped_restore (&cs.general_thread);
if (strcmp ("qSymbol::", own_buf) == 0)
{
if (strcmp ("qSymbol::", own_buf) == 0)
{
- struct thread_info *save_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
/* For qSymbol, GDB only changes the current thread if the
previous current thread was of a different process. So if
/* For qSymbol, GDB only changes the current thread if the
previous current thread was of a different process. So if
exec in a non-leader thread. */
if (current_thread == NULL)
{
exec in a non-leader thread. */
if (current_thread == NULL)
{
+ thread_info *any_thread
= find_any_thread_of_pid (cs.general_thread.pid ());
= find_any_thread_of_pid (cs.general_thread.pid ());
+ switch_to_thread (any_thread);
/* Just in case, if we didn't find a thread, then bail out
instead of crashing. */
if (current_thread == NULL)
{
write_enn (own_buf);
/* Just in case, if we didn't find a thread, then bail out
instead of crashing. */
if (current_thread == NULL)
{
write_enn (own_buf);
- current_thread = save_thread;
if (current_thread != NULL)
the_target->look_up_symbols ();
if (current_thread != NULL)
the_target->look_up_symbols ();
- current_thread = save_thread;
-
strcpy (own_buf, "OK");
return;
}
strcpy (own_buf, "OK");
return;
}
client_state &cs = get_client_state ();
thread_info *found = find_thread_ptid (cs.general_thread);
client_state &cs = get_client_state ();
thread_info *found = find_thread_ptid (cs.general_thread);
- current_thread = found;
+ switch_to_thread (found);
return (current_thread != NULL);
}
return (current_thread != NULL);
}
- current_thread = thread;
+ switch_to_thread (thread);
cs.general_thread = ptid_of (thread);
return 0;
cs.general_thread = ptid_of (thread);
return 0;
psaddr_t addr;
td_err_e err;
struct lwp_info *lwp;
psaddr_t addr;
td_err_e err;
struct lwp_info *lwp;
- struct thread_info *saved_thread;
struct process_info *proc;
struct thread_db *thread_db;
struct process_info *proc;
struct thread_db *thread_db;
if (!lwp->thread_known)
return TD_NOTHR;
if (!lwp->thread_known)
return TD_NOTHR;
- saved_thread = current_thread;
- current_thread = thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
addr = (char *) addr + offset;
}
addr = (char *) addr + offset;
}
- current_thread = saved_thread;
if (err == TD_OK)
{
*address = (CORE_ADDR) (uintptr_t) addr;
if (err == TD_OK)
{
*address = (CORE_ADDR) (uintptr_t) addr;
if (td_ta_clear_event_p != NULL)
{
if (td_ta_clear_event_p != NULL)
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
td_thr_events_t events;
switch_to_process (proc);
td_thr_events_t events;
switch_to_process (proc);
in any events anymore. */
td_event_fillset (&events);
(*td_ta_clear_event_p) (thread_db->thread_agent, &events);
in any events anymore. */
td_event_fillset (&events);
(*td_ta_clear_event_p) (thread_db->thread_agent, &events);
-
- current_thread = saved_thread;
/* find_one_thread calls into libthread_db which accesses memory via
the current thread. Temporarily switch to a thread we know is
stopped. */
/* find_one_thread calls into libthread_db which accesses memory via
the current thread. Temporarily switch to a thread we know is
stopped. */
- scoped_restore restore_current_thread
- = make_scoped_restore (¤t_thread, parent_thr);
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (parent_thr);
if (!find_one_thread (child_ptid))
warning ("Cannot find thread after clone.");
if (!find_one_thread (child_ptid))
warning ("Cannot find thread after clone.");
if (!maybe_write_ipa_not_loaded (buf))
{
if (!maybe_write_ipa_not_loaded (buf))
{
- struct thread_info *saved_thread;
-
- saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
/* Find any thread which belongs to process PID. */
/* Find any thread which belongs to process PID. */
- current_thread = find_any_thread_of_pid (pid);
+ switch_to_thread (find_any_thread_of_pid (pid));
strcpy (buf, "close");
run_inferior_command (buf, strlen (buf) + 1);
strcpy (buf, "close");
run_inferior_command (buf, strlen (buf) + 1);
-
- current_thread = saved_thread;
*ourstatus = stop->status;
current_event = stop->event;
ptid = debug_event_ptid (¤t_event);
*ourstatus = stop->status;
current_event = stop->event;
ptid = debug_event_ptid (¤t_event);
- current_thread = find_thread_ptid (ptid);
+ switch_to_thread (find_thread_ptid (ptid));
child_delete_thread (current_event.dwProcessId,
current_event.dwThreadId);
child_delete_thread (current_event.dwProcessId,
current_event.dwThreadId);
- current_thread = get_first_thread ();
+ switch_to_thread (get_first_thread ());
return 1;
case CREATE_PROCESS_DEBUG_EVENT:
return 1;
case CREATE_PROCESS_DEBUG_EVENT:
ourstatus->set_spurious ();
}
else
ourstatus->set_spurious ();
}
else
- current_thread = find_thread_ptid (ptid);
+ switch_to_thread (find_thread_ptid (ptid));