Rename current_inferior as current_thread in gdbserver

GDB has a function named "current_inferior" and gdbserver has a global
variable named "current_inferior", but the two are not equivalent;
indeed, gdbserver does not have any real equivalent of what GDB calls
an inferior.  What gdbserver's "current_inferior" is actually pointing
to is a structure describing the current thread.  This commit renames
current_inferior as current_thread in gdbserver to clarify this.  It
also renames the function "set_desired_inferior" to "set_desired_thread"
and renames various local variables from foo_inferior to foo_thread.

gdb/gdbserver/ChangeLog:

	* inferiors.h (current_inferior): Renamed as...
	(current_thread): New variable.  All uses updated.
	* linux-low.c (get_pc): Renamed saved_inferior as saved_thread.
	(maybe_move_out_of_jump_pad): Likewise.
	(cancel_breakpoint): Likewise.
	(linux_low_filter_event): Likewise.
	(wait_for_sigstop): Likewise.
	(linux_resume_one_lwp): Likewise.
	(need_step_over_p): Likewise.
	(start_step_over): Likewise.
	(linux_stabilize_threads): Renamed save_inferior as saved_thread.
	* linux-x86-low.c (x86_linux_update_xmltarget): Likewise.
	* proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread
	and save_inferior as saved_thread.
	* regcache.c (get_thread_regcache): Renamed saved_inferior as
	saved_thread.
	(regcache_invalidate_thread): Likewise.
	* remote-utils.c (prepare_resume_reply): Likewise.
	* thread-db.c (thread_db_get_tls_address): Likewise.
	(disable_thread_event_reporting): Likewise.
	(remove_thread_event_breakpoints): Likewise.
	* tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior
	as saved_thread.
	* target.h (set_desired_inferior): Renamed as...
	(set_desired_thread): New declaration.  All uses updated.
	* server.c (myresume): Updated comment to reference thread instead
	of inferior.
	(handle_serial_event): Likewise.
	(handle_target_event): Likewise.
This commit is contained in:
Gary Benson
2014-09-10 10:37:11 +01:00
parent 635856f584
commit 0bfdf32fa1
28 changed files with 277 additions and 245 deletions

View File

@@ -1,3 +1,35 @@
2014-09-16 Gary Benson <gbenson@redhat.com>
* inferiors.h (current_inferior): Renamed as...
(current_thread): New variable. All uses updated.
* linux-low.c (get_pc): Renamed saved_inferior as saved_thread.
(maybe_move_out_of_jump_pad): Likewise.
(cancel_breakpoint): Likewise.
(linux_low_filter_event): Likewise.
(wait_for_sigstop): Likewise.
(linux_resume_one_lwp): Likewise.
(need_step_over_p): Likewise.
(start_step_over): Likewise.
(linux_stabilize_threads): Renamed save_inferior as saved_thread.
* linux-x86-low.c (x86_linux_update_xmltarget): Likewise.
* proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread
and save_inferior as saved_thread.
* regcache.c (get_thread_regcache): Renamed saved_inferior as
saved_thread.
(regcache_invalidate_thread): Likewise.
* remote-utils.c (prepare_resume_reply): Likewise.
* thread-db.c (thread_db_get_tls_address): Likewise.
(disable_thread_event_reporting): Likewise.
(remove_thread_event_breakpoints): Likewise.
* tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior
as saved_thread.
* target.h (set_desired_inferior): Renamed as...
(set_desired_thread): New declaration. All uses updated.
* server.c (myresume): Updated comment to reference thread instead
of inferior.
(handle_serial_event): Likewise.
(handle_target_event): Likewise.
2014-09-12 Tom Tromey <tromey@redhat.com> 2014-09-12 Tom Tromey <tromey@redhat.com>
Gary Benson <gbenson@redhat.com> Gary Benson <gbenson@redhat.com>

View File

@@ -80,6 +80,6 @@ struct thread_info *get_first_thread (void);
struct thread_info *find_thread_ptid (ptid_t ptid); struct thread_info *find_thread_ptid (ptid_t ptid);
/* Get current thread ID (Linux task ID). */ /* Get current thread ID (Linux task ID). */
#define current_ptid (current_inferior->entry.id) #define current_ptid (current_thread->entry.id)
#endif /* GDB_THREAD_H */ #endif /* GDB_THREAD_H */

View File

@@ -25,7 +25,7 @@
struct inferior_list all_processes; struct inferior_list all_processes;
struct inferior_list all_threads; struct inferior_list all_threads;
struct thread_info *current_inferior; struct thread_info *current_thread;
#define get_thread(inf) ((struct thread_info *)(inf)) #define get_thread(inf) ((struct thread_info *)(inf))
@@ -115,8 +115,8 @@ add_thread (ptid_t thread_id, void *target_data)
add_inferior_to_list (&all_threads, &new_thread->entry); add_inferior_to_list (&all_threads, &new_thread->entry);
if (current_inferior == NULL) if (current_thread == NULL)
current_inferior = new_thread; current_thread = new_thread;
new_thread->target_data = target_data; new_thread->target_data = target_data;
@@ -267,7 +267,7 @@ clear_inferiors (void)
clear_dlls (); clear_dlls ();
current_inferior = NULL; current_thread = NULL;
} }
struct process_info * struct process_info *
@@ -355,6 +355,6 @@ get_thread_process (struct thread_info *thread)
struct process_info * struct process_info *
current_process (void) current_process (void)
{ {
gdb_assert (current_inferior != NULL); gdb_assert (current_thread != NULL);
return get_thread_process (current_inferior); return get_thread_process (current_thread);
} }

View File

@@ -77,7 +77,7 @@ struct process_info
#define lwpid_of(inf) ptid_get_lwp ((inf)->entry.id) #define lwpid_of(inf) ptid_get_lwp ((inf)->entry.id)
/* Return a pointer to the process that corresponds to the current /* Return a pointer to the process that corresponds to the current
thread (current_inferior). It is an error to call this if there is thread (current_thread). It is an error to call this if there is
no current thread selected. */ no current thread selected. */
struct process_info *current_process (void); struct process_info *current_process (void);
@@ -121,7 +121,7 @@ int one_inferior_p (struct inferior_list *list);
#define ALL_PROCESSES(cur, tmp) \ #define ALL_PROCESSES(cur, tmp) \
ALL_INFERIORS_TYPE (struct process_info, &all_processes, cur, tmp) ALL_INFERIORS_TYPE (struct process_info, &all_processes, cur, tmp)
extern struct thread_info *current_inferior; extern struct thread_info *current_thread;
void remove_inferior (struct inferior_list *list, void remove_inferior (struct inferior_list *list,
struct inferior_list_entry *entry); struct inferior_list_entry *entry);

View File

@@ -697,7 +697,7 @@ aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
struct aarch64_dr_update_callback_param param; struct aarch64_dr_update_callback_param param;
/* Only update the threads of this process. */ /* Only update the threads of this process. */
param.pid = pid_of (current_inferior); param.pid = pid_of (current_thread);
param.is_watchpoint = is_watchpoint; param.is_watchpoint = is_watchpoint;
param.idx = idx; param.idx = idx;
@@ -1038,7 +1038,7 @@ aarch64_stopped_data_address (void)
int pid, i; int pid, i;
struct aarch64_debug_reg_state *state; struct aarch64_debug_reg_state *state;
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
/* Get the siginfo. */ /* Get the siginfo. */
if (ptrace (PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0) if (ptrace (PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0)
@@ -1186,7 +1186,7 @@ aarch64_arch_setup (void)
current_process ()->tdesc = tdesc_aarch64; current_process ()->tdesc = tdesc_aarch64;
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
iov.iov_base = &dreg_state; iov.iov_base = &dreg_state;
iov.iov_len = sizeof (dreg_state); iov.iov_len = sizeof (dreg_state);

View File

@@ -282,7 +282,7 @@ static const unsigned long arm_eabi_breakpoint = 0xe7f001f0;
static int static int
arm_breakpoint_at (CORE_ADDR where) arm_breakpoint_at (CORE_ADDR where)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
unsigned long cpsr; unsigned long cpsr;
collect_register_by_name (regcache, "cpsr", &cpsr); collect_register_by_name (regcache, "cpsr", &cpsr);
@@ -325,7 +325,7 @@ arm_breakpoint_at (CORE_ADDR where)
static CORE_ADDR static CORE_ADDR
arm_reinsert_addr (void) arm_reinsert_addr (void)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
unsigned long pc; unsigned long pc;
collect_register_by_name (regcache, "lr", &pc); collect_register_by_name (regcache, "lr", &pc);
return pc; return pc;
@@ -537,7 +537,7 @@ update_registers_callback (struct inferior_list_entry *entry, void *arg)
struct update_registers_data *data = (struct update_registers_data *) arg; struct update_registers_data *data = (struct update_registers_data *) arg;
/* Only update the threads of the current process. */ /* Only update the threads of the current process. */
if (pid_of (thread) == pid_of (current_inferior)) if (pid_of (thread) == pid_of (current_thread))
{ {
/* The actual update is done later just before resuming the lwp, /* The actual update is done later just before resuming the lwp,
we just mark that the registers need updating. */ we just mark that the registers need updating. */
@@ -655,7 +655,7 @@ arm_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
static int static int
arm_stopped_by_watchpoint (void) arm_stopped_by_watchpoint (void)
{ {
struct lwp_info *lwp = get_thread_lwp (current_inferior); struct lwp_info *lwp = get_thread_lwp (current_thread);
siginfo_t siginfo; siginfo_t siginfo;
/* We must be able to set hardware watchpoints. */ /* We must be able to set hardware watchpoints. */
@@ -664,7 +664,7 @@ arm_stopped_by_watchpoint (void)
/* Retrieve siginfo. */ /* Retrieve siginfo. */
errno = 0; errno = 0;
ptrace (PTRACE_GETSIGINFO, lwpid_of (current_inferior), 0, &siginfo); ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread), 0, &siginfo);
if (errno != 0) if (errno != 0)
return 0; return 0;
@@ -690,7 +690,7 @@ arm_stopped_by_watchpoint (void)
static CORE_ADDR static CORE_ADDR
arm_stopped_data_address (void) arm_stopped_data_address (void)
{ {
struct lwp_info *lwp = get_thread_lwp (current_inferior); struct lwp_info *lwp = get_thread_lwp (current_thread);
return lwp->arch_private->stopped_data_address; return lwp->arch_private->stopped_data_address;
} }
@@ -796,7 +796,7 @@ arm_get_hwcap (unsigned long *valp)
static const struct target_desc * static const struct target_desc *
arm_read_description (void) arm_read_description (void)
{ {
int pid = lwpid_of (current_inferior); int pid = lwpid_of (current_thread);
/* Query hardware watchpoint/breakpoint capabilities. */ /* Query hardware watchpoint/breakpoint capabilities. */
arm_linux_init_hwbp_cap (pid); arm_linux_init_hwbp_cap (pid);

View File

@@ -102,7 +102,7 @@ cris_breakpoint_at (CORE_ADDR where)
static CORE_ADDR static CORE_ADDR
cris_reinsert_addr (void) cris_reinsert_addr (void)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
unsigned long pc; unsigned long pc;
collect_register_by_name (regcache, "srp", &pc); collect_register_by_name (regcache, "srp", &pc);
return pc; return pc;

View File

@@ -103,7 +103,7 @@ cris_breakpoint_at (CORE_ADDR where)
static CORE_ADDR static CORE_ADDR
cris_reinsert_addr (void) cris_reinsert_addr (void)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
unsigned long pc; unsigned long pc;
collect_register_by_name (regcache, "srp", &pc); collect_register_by_name (regcache, "srp", &pc);
return pc; return pc;
@@ -166,7 +166,7 @@ cris_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
unsigned long ccs; unsigned long ccs;
struct regcache *regcache; struct regcache *regcache;
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
/* Read watchpoints are set as access watchpoints, because of GDB's /* Read watchpoints are set as access watchpoints, because of GDB's
inability to deal with pure read watchpoints. */ inability to deal with pure read watchpoints. */
@@ -239,7 +239,7 @@ cris_remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int len,
struct regcache *regcache; struct regcache *regcache;
unsigned long bp_d_regs[12]; unsigned long bp_d_regs[12];
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
/* Read watchpoints are set as access watchpoints, because of GDB's /* Read watchpoints are set as access watchpoints, because of GDB's
inability to deal with pure read watchpoints. */ inability to deal with pure read watchpoints. */
@@ -316,7 +316,7 @@ static int
cris_stopped_by_watchpoint (void) cris_stopped_by_watchpoint (void)
{ {
unsigned long exs; unsigned long exs;
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
collect_register_by_name (regcache, "exs", &exs); collect_register_by_name (regcache, "exs", &exs);
@@ -327,7 +327,7 @@ static CORE_ADDR
cris_stopped_data_address (void) cris_stopped_data_address (void)
{ {
unsigned long eda; unsigned long eda;
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
collect_register_by_name (regcache, "eda", &eda); collect_register_by_name (regcache, "eda", &eda);

View File

@@ -457,23 +457,23 @@ handle_extended_wait (struct lwp_info *event_child, int wstat)
static CORE_ADDR static CORE_ADDR
get_pc (struct lwp_info *lwp) get_pc (struct lwp_info *lwp)
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
struct regcache *regcache; struct regcache *regcache;
CORE_ADDR pc; CORE_ADDR pc;
if (the_low_target.get_pc == NULL) if (the_low_target.get_pc == NULL)
return 0; return 0;
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = get_lwp_thread (lwp); current_thread = get_lwp_thread (lwp);
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
pc = (*the_low_target.get_pc) (regcache); pc = (*the_low_target.get_pc) (regcache);
if (debug_threads) if (debug_threads)
debug_printf ("pc is 0x%lx\n", (long) pc); debug_printf ("pc is 0x%lx\n", (long) pc);
current_inferior = saved_inferior; current_thread = saved_thread;
return pc; return pc;
} }
@@ -1467,10 +1467,10 @@ linux_fast_tracepoint_collecting (struct lwp_info *lwp,
static int static int
maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat) maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = get_lwp_thread (lwp); current_thread = get_lwp_thread (lwp);
if ((wstat == NULL if ((wstat == NULL
|| (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP)) || (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP))
@@ -1483,7 +1483,7 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
if (debug_threads) if (debug_threads)
debug_printf ("Checking whether LWP %ld needs to move out of the " debug_printf ("Checking whether LWP %ld needs to move out of the "
"jump pad.\n", "jump pad.\n",
lwpid_of (current_inferior)); lwpid_of (current_thread));
r = linux_fast_tracepoint_collecting (lwp, &status); r = linux_fast_tracepoint_collecting (lwp, &status);
@@ -1509,8 +1509,8 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
if (debug_threads) if (debug_threads)
debug_printf ("Checking whether LWP %ld needs to move out of " debug_printf ("Checking whether LWP %ld needs to move out of "
"the jump pad...it does\n", "the jump pad...it does\n",
lwpid_of (current_inferior)); lwpid_of (current_thread));
current_inferior = saved_inferior; current_thread = saved_thread;
return 1; return 1;
} }
@@ -1539,18 +1539,18 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
|| WSTOPSIG (*wstat) == SIGFPE || WSTOPSIG (*wstat) == SIGFPE
|| WSTOPSIG (*wstat) == SIGBUS || WSTOPSIG (*wstat) == SIGBUS
|| WSTOPSIG (*wstat) == SIGSEGV) || WSTOPSIG (*wstat) == SIGSEGV)
&& ptrace (PTRACE_GETSIGINFO, lwpid_of (current_inferior), && ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
(PTRACE_TYPE_ARG3) 0, &info) == 0 (PTRACE_TYPE_ARG3) 0, &info) == 0
/* Final check just to make sure we don't clobber /* Final check just to make sure we don't clobber
the siginfo of non-kernel-sent signals. */ the siginfo of non-kernel-sent signals. */
&& (uintptr_t) info.si_addr == lwp->stop_pc) && (uintptr_t) info.si_addr == lwp->stop_pc)
{ {
info.si_addr = (void *) (uintptr_t) status.tpoint_addr; info.si_addr = (void *) (uintptr_t) status.tpoint_addr;
ptrace (PTRACE_SETSIGINFO, lwpid_of (current_inferior), ptrace (PTRACE_SETSIGINFO, lwpid_of (current_thread),
(PTRACE_TYPE_ARG3) 0, &info); (PTRACE_TYPE_ARG3) 0, &info);
} }
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
(*the_low_target.set_pc) (regcache, status.tpoint_addr); (*the_low_target.set_pc) (regcache, status.tpoint_addr);
lwp->stop_pc = status.tpoint_addr; lwp->stop_pc = status.tpoint_addr;
@@ -1581,9 +1581,9 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
if (debug_threads) if (debug_threads)
debug_printf ("Checking whether LWP %ld needs to move out of the " debug_printf ("Checking whether LWP %ld needs to move out of the "
"jump pad...no\n", "jump pad...no\n",
lwpid_of (current_inferior)); lwpid_of (current_thread));
current_inferior = saved_inferior; current_thread = saved_thread;
return 0; return 0;
} }
@@ -1700,31 +1700,31 @@ dequeue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
static int static int
cancel_breakpoint (struct lwp_info *lwp) cancel_breakpoint (struct lwp_info *lwp)
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
/* There's nothing to do if we don't support breakpoints. */ /* There's nothing to do if we don't support breakpoints. */
if (!supports_breakpoints ()) if (!supports_breakpoints ())
return 0; return 0;
/* breakpoint_at reads from current inferior. */ /* breakpoint_at reads from current inferior. */
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = get_lwp_thread (lwp); current_thread = get_lwp_thread (lwp);
if ((*the_low_target.breakpoint_at) (lwp->stop_pc)) if ((*the_low_target.breakpoint_at) (lwp->stop_pc))
{ {
if (debug_threads) if (debug_threads)
debug_printf ("CB: Push back breakpoint for %s\n", debug_printf ("CB: Push back breakpoint for %s\n",
target_pid_to_str (ptid_of (current_inferior))); target_pid_to_str (ptid_of (current_thread)));
/* Back up the PC if necessary. */ /* Back up the PC if necessary. */
if (the_low_target.decr_pc_after_break) if (the_low_target.decr_pc_after_break)
{ {
struct regcache *regcache struct regcache *regcache
= get_thread_regcache (current_inferior, 1); = get_thread_regcache (current_thread, 1);
(*the_low_target.set_pc) (regcache, lwp->stop_pc); (*the_low_target.set_pc) (regcache, lwp->stop_pc);
} }
current_inferior = saved_inferior; current_thread = saved_thread;
return 1; return 1;
} }
else else
@@ -1732,10 +1732,10 @@ cancel_breakpoint (struct lwp_info *lwp)
if (debug_threads) if (debug_threads)
debug_printf ("CB: No breakpoint found at %s for [%s]\n", debug_printf ("CB: No breakpoint found at %s for [%s]\n",
paddress (lwp->stop_pc), paddress (lwp->stop_pc),
target_pid_to_str (ptid_of (current_inferior))); target_pid_to_str (ptid_of (current_thread)));
} }
current_inferior = saved_inferior; current_thread = saved_thread;
return 0; return 0;
} }
@@ -1780,14 +1780,14 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat)
proc = find_process_pid (pid_of (thread)); proc = find_process_pid (pid_of (thread));
if (proc->private->new_inferior) if (proc->private->new_inferior)
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
the_low_target.arch_setup (); the_low_target.arch_setup ();
current_inferior = saved_inferior; current_thread = saved_thread;
proc->private->new_inferior = 0; proc->private->new_inferior = 0;
} }
@@ -1802,16 +1802,16 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat)
if (debug_threads if (debug_threads
&& the_low_target.get_pc != NULL) && the_low_target.get_pc != NULL)
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
struct regcache *regcache; struct regcache *regcache;
CORE_ADDR pc; CORE_ADDR pc;
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
pc = (*the_low_target.get_pc) (regcache); pc = (*the_low_target.get_pc) (regcache);
debug_printf ("linux_low_filter_event: pc is 0x%lx\n", (long) pc); debug_printf ("linux_low_filter_event: pc is 0x%lx\n", (long) pc);
current_inferior = saved_inferior; current_thread = saved_thread;
} }
child->stop_pc = get_stop_pc (child); child->stop_pc = get_stop_pc (child);
@@ -1841,10 +1841,10 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat)
} }
else else
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
child->stopped_by_watchpoint child->stopped_by_watchpoint
= the_low_target.stopped_by_watchpoint (); = the_low_target.stopped_by_watchpoint ();
@@ -1858,7 +1858,7 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat)
child->stopped_data_address = 0; child->stopped_data_address = 0;
} }
current_inferior = saved_inferior; current_thread = saved_thread;
} }
} }
@@ -2047,7 +2047,7 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
*wstatp = event_child->status_pending; *wstatp = event_child->status_pending;
event_child->status_pending_p = 0; event_child->status_pending_p = 0;
event_child->status_pending = 0; event_child->status_pending = 0;
current_inferior = event_thread; current_thread = event_thread;
return lwpid_of (event_thread); return lwpid_of (event_thread);
} }
@@ -2151,7 +2151,7 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
sigprocmask (SIG_SETMASK, &prev_mask, NULL); sigprocmask (SIG_SETMASK, &prev_mask, NULL);
current_inferior = event_thread; current_thread = event_thread;
/* Check for thread exit. */ /* Check for thread exit. */
if (! WIFSTOPPED (*wstatp)) if (! WIFSTOPPED (*wstatp))
@@ -2408,7 +2408,7 @@ static ptid_t linux_wait_1 (ptid_t ptid,
static void static void
linux_stabilize_threads (void) linux_stabilize_threads (void)
{ {
struct thread_info *save_inferior; struct thread_info *saved_thread;
struct thread_info *thread_stuck; struct thread_info *thread_stuck;
thread_stuck thread_stuck
@@ -2423,7 +2423,7 @@ linux_stabilize_threads (void)
return; return;
} }
save_inferior = current_inferior; saved_thread = current_thread;
stabilizing_threads = 1; stabilizing_threads = 1;
@@ -2444,13 +2444,13 @@ linux_stabilize_threads (void)
if (ourstatus.kind == TARGET_WAITKIND_STOPPED) if (ourstatus.kind == TARGET_WAITKIND_STOPPED)
{ {
lwp = get_thread_lwp (current_inferior); lwp = get_thread_lwp (current_thread);
/* Lock it. */ /* Lock it. */
lwp->suspended++; lwp->suspended++;
if (ourstatus.value.sig != GDB_SIGNAL_0 if (ourstatus.value.sig != GDB_SIGNAL_0
|| current_inferior->last_resume_kind == resume_stop) || current_thread->last_resume_kind == resume_stop)
{ {
wstat = W_STOPCODE (gdb_signal_to_host (ourstatus.value.sig)); wstat = W_STOPCODE (gdb_signal_to_host (ourstatus.value.sig));
enqueue_one_deferred_signal (lwp, &wstat); enqueue_one_deferred_signal (lwp, &wstat);
@@ -2462,7 +2462,7 @@ linux_stabilize_threads (void)
stabilizing_threads = 0; stabilizing_threads = 0;
current_inferior = save_inferior; current_thread = saved_thread;
if (debug_threads) if (debug_threads)
{ {
@@ -2575,7 +2575,7 @@ retry:
return null_ptid; return null_ptid;
} }
event_child = get_thread_lwp (current_inferior); event_child = get_thread_lwp (current_thread);
/* linux_wait_for_event only returns an exit status for the last /* linux_wait_for_event only returns an exit status for the last
child of a process. Report it. */ child of a process. Report it. */
@@ -2590,7 +2590,7 @@ retry:
{ {
debug_printf ("linux_wait_1 ret = %s, exited with " debug_printf ("linux_wait_1 ret = %s, exited with "
"retcode %d\n", "retcode %d\n",
target_pid_to_str (ptid_of (current_inferior)), target_pid_to_str (ptid_of (current_thread)),
WEXITSTATUS (w)); WEXITSTATUS (w));
debug_exit (); debug_exit ();
} }
@@ -2604,13 +2604,13 @@ retry:
{ {
debug_printf ("linux_wait_1 ret = %s, terminated with " debug_printf ("linux_wait_1 ret = %s, terminated with "
"signal %d\n", "signal %d\n",
target_pid_to_str (ptid_of (current_inferior)), target_pid_to_str (ptid_of (current_thread)),
WTERMSIG (w)); WTERMSIG (w));
debug_exit (); debug_exit ();
} }
} }
return ptid_of (current_inferior); return ptid_of (current_thread);
} }
/* If this event was not handled before, and is not a SIGTRAP, we /* If this event was not handled before, and is not a SIGTRAP, we
@@ -2684,17 +2684,17 @@ retry:
if (debug_threads) if (debug_threads)
debug_printf ("Got signal %d for LWP %ld. Check if we need " debug_printf ("Got signal %d for LWP %ld. Check if we need "
"to defer or adjust it.\n", "to defer or adjust it.\n",
WSTOPSIG (w), lwpid_of (current_inferior)); WSTOPSIG (w), lwpid_of (current_thread));
/* Allow debugging the jump pad itself. */ /* Allow debugging the jump pad itself. */
if (current_inferior->last_resume_kind != resume_step if (current_thread->last_resume_kind != resume_step
&& maybe_move_out_of_jump_pad (event_child, &w)) && maybe_move_out_of_jump_pad (event_child, &w))
{ {
enqueue_one_deferred_signal (event_child, &w); enqueue_one_deferred_signal (event_child, &w);
if (debug_threads) if (debug_threads)
debug_printf ("Signal %d for LWP %ld deferred (in jump pad)\n", debug_printf ("Signal %d for LWP %ld deferred (in jump pad)\n",
WSTOPSIG (w), lwpid_of (current_inferior)); WSTOPSIG (w), lwpid_of (current_thread));
linux_resume_one_lwp (event_child, 0, 0, NULL); linux_resume_one_lwp (event_child, 0, 0, NULL);
goto retry; goto retry;
@@ -2706,7 +2706,7 @@ retry:
if (debug_threads) if (debug_threads)
debug_printf ("LWP %ld was trying to move out of the jump pad (%d). " debug_printf ("LWP %ld was trying to move out of the jump pad (%d). "
"Check if we're already there.\n", "Check if we're already there.\n",
lwpid_of (current_inferior), lwpid_of (current_thread),
event_child->collecting_fast_tracepoint); event_child->collecting_fast_tracepoint);
trace_event = 1; trace_event = 1;
@@ -2768,11 +2768,11 @@ retry:
{ {
debug_printf ("linux_wait_1 ret = %s, stopped " debug_printf ("linux_wait_1 ret = %s, stopped "
"while stabilizing threads\n", "while stabilizing threads\n",
target_pid_to_str (ptid_of (current_inferior))); target_pid_to_str (ptid_of (current_thread)));
debug_exit (); debug_exit ();
} }
return ptid_of (current_inferior); return ptid_of (current_thread);
} }
} }
} }
@@ -2790,7 +2790,7 @@ retry:
/* FIXME drow/2002-06-09: Get signal numbers from the inferior's /* FIXME drow/2002-06-09: Get signal numbers from the inferior's
thread library? */ thread library? */
if (WIFSTOPPED (w) if (WIFSTOPPED (w)
&& current_inferior->last_resume_kind != resume_step && current_thread->last_resume_kind != resume_step
&& ( && (
#if defined (USE_THREAD_DB) && !defined (__ANDROID__) #if defined (USE_THREAD_DB) && !defined (__ANDROID__)
(current_process ()->private->thread_db != NULL (current_process ()->private->thread_db != NULL
@@ -2800,15 +2800,15 @@ retry:
#endif #endif
(pass_signals[gdb_signal_from_host (WSTOPSIG (w))] (pass_signals[gdb_signal_from_host (WSTOPSIG (w))]
&& !(WSTOPSIG (w) == SIGSTOP && !(WSTOPSIG (w) == SIGSTOP
&& current_inferior->last_resume_kind == resume_stop)))) && current_thread->last_resume_kind == resume_stop))))
{ {
siginfo_t info, *info_p; siginfo_t info, *info_p;
if (debug_threads) if (debug_threads)
debug_printf ("Ignored signal %d for LWP %ld.\n", debug_printf ("Ignored signal %d for LWP %ld.\n",
WSTOPSIG (w), lwpid_of (current_inferior)); WSTOPSIG (w), lwpid_of (current_thread));
if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_inferior), if (ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread),
(PTRACE_TYPE_ARG3) 0, &info) == 0) (PTRACE_TYPE_ARG3) 0, &info) == 0)
info_p = &info; info_p = &info;
else else
@@ -2832,7 +2832,7 @@ retry:
reporting the event to GDB. If we don't, we're out of luck, GDB reporting the event to GDB. If we don't, we're out of luck, GDB
won't see the breakpoint hit. */ won't see the breakpoint hit. */
report_to_gdb = (!maybe_internal_trap report_to_gdb = (!maybe_internal_trap
|| (current_inferior->last_resume_kind == resume_step || (current_thread->last_resume_kind == resume_step
&& !in_step_range) && !in_step_range)
|| event_child->stopped_by_watchpoint || event_child->stopped_by_watchpoint
|| (!step_over_finished && !in_step_range || (!step_over_finished && !in_step_range
@@ -2870,7 +2870,7 @@ retry:
if (the_low_target.set_pc != NULL) if (the_low_target.set_pc != NULL)
{ {
struct regcache *regcache struct regcache *regcache
= get_thread_regcache (current_inferior, 1); = get_thread_regcache (current_thread, 1);
(*the_low_target.set_pc) (regcache, event_child->stop_pc); (*the_low_target.set_pc) (regcache, event_child->stop_pc);
} }
@@ -2891,7 +2891,7 @@ retry:
if (debug_threads) if (debug_threads)
{ {
if (current_inferior->last_resume_kind == resume_step) if (current_thread->last_resume_kind == resume_step)
{ {
if (event_child->step_range_start == event_child->step_range_end) if (event_child->step_range_start == event_child->step_range_end)
debug_printf ("GDB wanted to single-step, reporting event.\n"); debug_printf ("GDB wanted to single-step, reporting event.\n");
@@ -2924,8 +2924,8 @@ retry:
select_event_lwp (&event_child); select_event_lwp (&event_child);
/* current_inferior and event_child must stay in sync. */ /* current_thread and event_child must stay in sync. */
current_inferior = get_lwp_thread (event_child); current_thread = get_lwp_thread (event_child);
event_child->status_pending_p = 0; event_child->status_pending_p = 0;
w = event_child->status_pending; w = event_child->status_pending;
@@ -2961,7 +2961,7 @@ retry:
ourstatus->kind = TARGET_WAITKIND_STOPPED; ourstatus->kind = TARGET_WAITKIND_STOPPED;
if (current_inferior->last_resume_kind == resume_stop if (current_thread->last_resume_kind == resume_stop
&& WSTOPSIG (w) == SIGSTOP) && WSTOPSIG (w) == SIGSTOP)
{ {
/* A thread that has been requested to stop by GDB with vCont;t, /* A thread that has been requested to stop by GDB with vCont;t,
@@ -2969,7 +2969,7 @@ retry:
SIGSTOP is an implementation detail. */ SIGSTOP is an implementation detail. */
ourstatus->value.sig = GDB_SIGNAL_0; ourstatus->value.sig = GDB_SIGNAL_0;
} }
else if (current_inferior->last_resume_kind == resume_stop else if (current_thread->last_resume_kind == resume_stop
&& WSTOPSIG (w) != SIGSTOP) && WSTOPSIG (w) != SIGSTOP)
{ {
/* A thread that has been requested to stop by GDB with vCont;t, /* A thread that has been requested to stop by GDB with vCont;t,
@@ -2986,12 +2986,12 @@ retry:
if (debug_threads) if (debug_threads)
{ {
debug_printf ("linux_wait_1 ret = %s, %d, %d\n", debug_printf ("linux_wait_1 ret = %s, %d, %d\n",
target_pid_to_str (ptid_of (current_inferior)), target_pid_to_str (ptid_of (current_thread)),
ourstatus->kind, ourstatus->value.sig); ourstatus->kind, ourstatus->value.sig);
debug_exit (); debug_exit ();
} }
return ptid_of (current_inferior); return ptid_of (current_thread);
} }
/* Get rid of any pending event in the pipe. */ /* Get rid of any pending event in the pipe. */
@@ -3159,14 +3159,14 @@ mark_lwp_dead (struct lwp_info *lwp, int wstat)
static void static void
wait_for_sigstop (void) wait_for_sigstop (void)
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
ptid_t saved_tid; ptid_t saved_tid;
int wstat; int wstat;
int ret; int ret;
saved_inferior = current_inferior; saved_thread = current_thread;
if (saved_inferior != NULL) if (saved_thread != NULL)
saved_tid = saved_inferior->entry.id; saved_tid = saved_thread->entry.id;
else else
saved_tid = null_ptid; /* avoid bogus unused warning */ saved_tid = null_ptid; /* avoid bogus unused warning */
@@ -3180,8 +3180,8 @@ wait_for_sigstop (void)
&wstat, __WALL); &wstat, __WALL);
gdb_assert (ret == -1); gdb_assert (ret == -1);
if (saved_inferior == NULL || linux_thread_alive (saved_tid)) if (saved_thread == NULL || linux_thread_alive (saved_tid))
current_inferior = saved_inferior; current_thread = saved_thread;
else else
{ {
if (debug_threads) if (debug_threads)
@@ -3192,12 +3192,12 @@ wait_for_sigstop (void)
/* We can't change the current inferior behind GDB's back, /* We can't change the current inferior behind GDB's back,
otherwise, a subsequent command may apply to the wrong otherwise, a subsequent command may apply to the wrong
process. */ process. */
current_inferior = NULL; current_thread = NULL;
} }
else else
{ {
/* Set a valid thread as current. */ /* Set a valid thread as current. */
set_desired_inferior (0); set_desired_thread (0);
} }
} }
} }
@@ -3325,7 +3325,7 @@ linux_resume_one_lwp (struct lwp_info *lwp,
int step, int signal, siginfo_t *info) int step, int signal, siginfo_t *info)
{ {
struct thread_info *thread = get_lwp_thread (lwp); struct thread_info *thread = get_lwp_thread (lwp);
struct thread_info *saved_inferior; struct thread_info *saved_thread;
int fast_tp_collecting; int fast_tp_collecting;
if (lwp->stopped == 0) if (lwp->stopped == 0)
@@ -3374,8 +3374,8 @@ linux_resume_one_lwp (struct lwp_info *lwp,
return; return;
} }
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
if (debug_threads) if (debug_threads)
debug_printf ("Resuming lwp %ld (%s, signal %d, stop %s)\n", debug_printf ("Resuming lwp %ld (%s, signal %d, stop %s)\n",
@@ -3465,7 +3465,7 @@ linux_resume_one_lwp (struct lwp_info *lwp,
if (debug_threads && the_low_target.get_pc != NULL) if (debug_threads && the_low_target.get_pc != NULL)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
CORE_ADDR pc = (*the_low_target.get_pc) (regcache); CORE_ADDR pc = (*the_low_target.get_pc) (regcache);
debug_printf (" resuming from pc 0x%lx\n", (long) pc); debug_printf (" resuming from pc 0x%lx\n", (long) pc);
} }
@@ -3506,7 +3506,7 @@ linux_resume_one_lwp (struct lwp_info *lwp,
of coercing an 8 byte integer to a 4 byte pointer. */ of coercing an 8 byte integer to a 4 byte pointer. */
(PTRACE_TYPE_ARG4) (uintptr_t) signal); (PTRACE_TYPE_ARG4) (uintptr_t) signal);
current_inferior = saved_inferior; current_thread = saved_thread;
if (errno) if (errno)
{ {
/* ESRCH from ptrace either means that the thread was already /* ESRCH from ptrace either means that the thread was already
@@ -3635,7 +3635,7 @@ need_step_over_p (struct inferior_list_entry *entry, void *dummy)
{ {
struct thread_info *thread = (struct thread_info *) entry; struct thread_info *thread = (struct thread_info *) entry;
struct lwp_info *lwp = get_thread_lwp (thread); struct lwp_info *lwp = get_thread_lwp (thread);
struct thread_info *saved_inferior; struct thread_info *saved_thread;
CORE_ADDR pc; CORE_ADDR pc;
/* LWPs which will not be resumed are not interesting, because we /* LWPs which will not be resumed are not interesting, because we
@@ -3704,8 +3704,8 @@ need_step_over_p (struct inferior_list_entry *entry, void *dummy)
return 0; return 0;
} }
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
/* We can only step over breakpoints we know about. */ /* We can only step over breakpoints we know about. */
if (breakpoint_here (pc) || fast_tracepoint_jump_here (pc)) if (breakpoint_here (pc) || fast_tracepoint_jump_here (pc))
@@ -3722,7 +3722,7 @@ need_step_over_p (struct inferior_list_entry *entry, void *dummy)
" GDB breakpoint at 0x%s; skipping step over\n", " GDB breakpoint at 0x%s; skipping step over\n",
lwpid_of (thread), paddress (pc)); lwpid_of (thread), paddress (pc));
current_inferior = saved_inferior; current_thread = saved_thread;
return 0; return 0;
} }
else else
@@ -3734,7 +3734,7 @@ need_step_over_p (struct inferior_list_entry *entry, void *dummy)
/* We've found an lwp that needs stepping over --- return 1 so /* We've found an lwp that needs stepping over --- return 1 so
that find_inferior stops looking. */ that find_inferior stops looking. */
current_inferior = saved_inferior; current_thread = saved_thread;
/* If the step over is cancelled, this is set again. */ /* If the step over is cancelled, this is set again. */
lwp->need_step_over = 0; lwp->need_step_over = 0;
@@ -3742,7 +3742,7 @@ need_step_over_p (struct inferior_list_entry *entry, void *dummy)
} }
} }
current_inferior = saved_inferior; current_thread = saved_thread;
if (debug_threads) if (debug_threads)
debug_printf ("Need step over [LWP %ld]? No, no breakpoint found" debug_printf ("Need step over [LWP %ld]? No, no breakpoint found"
@@ -3774,7 +3774,7 @@ static int
start_step_over (struct lwp_info *lwp) start_step_over (struct lwp_info *lwp)
{ {
struct thread_info *thread = get_lwp_thread (lwp); struct thread_info *thread = get_lwp_thread (lwp);
struct thread_info *saved_inferior; struct thread_info *saved_thread;
CORE_ADDR pc; CORE_ADDR pc;
int step; int step;
@@ -3794,8 +3794,8 @@ start_step_over (struct lwp_info *lwp)
shouldn't care about. */ shouldn't care about. */
pc = get_pc (lwp); pc = get_pc (lwp);
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
lwp->bp_reinsert = pc; lwp->bp_reinsert = pc;
uninsert_breakpoints_at (pc); uninsert_breakpoints_at (pc);
@@ -3812,7 +3812,7 @@ start_step_over (struct lwp_info *lwp)
step = 0; step = 0;
} }
current_inferior = saved_inferior; current_thread = saved_thread;
linux_resume_one_lwp (lwp, step, 0, NULL); linux_resume_one_lwp (lwp, step, 0, NULL);
@@ -4243,7 +4243,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
regset = regsets_info->regsets; regset = regsets_info->regsets;
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
while (regset->size >= 0) while (regset->size >= 0)
{ {
void *buf, *data; void *buf, *data;
@@ -4314,7 +4314,7 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
regset = regsets_info->regsets; regset = regsets_info->regsets;
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
while (regset->size >= 0) while (regset->size >= 0)
{ {
void *buf, *data; void *buf, *data;
@@ -4459,7 +4459,7 @@ fetch_register (const struct usrregs_info *usrregs,
& -sizeof (PTRACE_XFER_TYPE)); & -sizeof (PTRACE_XFER_TYPE));
buf = alloca (size); buf = alloca (size);
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE)) for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{ {
errno = 0; errno = 0;
@@ -4509,7 +4509,7 @@ store_register (const struct usrregs_info *usrregs,
else else
collect_register (regcache, regno, buf); collect_register (regcache, regno, buf);
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE)) for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE))
{ {
errno = 0; errno = 0;
@@ -4649,7 +4649,7 @@ linux_store_registers (struct regcache *regcache, int regno)
static int static int
linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
{ {
int pid = lwpid_of (current_inferior); int pid = lwpid_of (current_thread);
register PTRACE_XFER_TYPE *buffer; register PTRACE_XFER_TYPE *buffer;
register CORE_ADDR addr; register CORE_ADDR addr;
register int count; register int count;
@@ -4750,7 +4750,7 @@ linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *) register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *)
alloca (count * sizeof (PTRACE_XFER_TYPE)); alloca (count * sizeof (PTRACE_XFER_TYPE));
int pid = lwpid_of (current_inferior); int pid = lwpid_of (current_thread);
if (len == 0) if (len == 0)
{ {
@@ -4845,7 +4845,7 @@ linux_request_interrupt (void)
{ {
int lwpid; int lwpid;
lwpid = lwpid_of (current_inferior); lwpid = lwpid_of (current_thread);
kill_lwp (lwpid, SIGINT); kill_lwp (lwpid, SIGINT);
} }
else else
@@ -4860,7 +4860,7 @@ linux_read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len)
{ {
char filename[PATH_MAX]; char filename[PATH_MAX];
int fd, n; int fd, n;
int pid = lwpid_of (current_inferior); int pid = lwpid_of (current_thread);
xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid); xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
@@ -4915,7 +4915,7 @@ linux_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
static int static int
linux_stopped_by_watchpoint (void) linux_stopped_by_watchpoint (void)
{ {
struct lwp_info *lwp = get_thread_lwp (current_inferior); struct lwp_info *lwp = get_thread_lwp (current_thread);
return lwp->stopped_by_watchpoint; return lwp->stopped_by_watchpoint;
} }
@@ -4923,7 +4923,7 @@ linux_stopped_by_watchpoint (void)
static CORE_ADDR static CORE_ADDR
linux_stopped_data_address (void) linux_stopped_data_address (void)
{ {
struct lwp_info *lwp = get_thread_lwp (current_inferior); struct lwp_info *lwp = get_thread_lwp (current_thread);
return lwp->stopped_data_address; return lwp->stopped_data_address;
} }
@@ -4944,7 +4944,7 @@ static int
linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p) linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
{ {
unsigned long text, text_end, data; unsigned long text, text_end, data;
int pid = lwpid_of (get_thread_lwp (current_inferior)); int pid = lwpid_of (get_thread_lwp (current_thread));
errno = 0; errno = 0;
@@ -5013,10 +5013,10 @@ linux_xfer_siginfo (const char *annex, unsigned char *readbuf,
siginfo_t siginfo; siginfo_t siginfo;
char inf_siginfo[sizeof (siginfo_t)]; char inf_siginfo[sizeof (siginfo_t)];
if (current_inferior == NULL) if (current_thread == NULL)
return -1; return -1;
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
if (debug_threads) if (debug_threads)
debug_printf ("%s siginfo for lwp %d.\n", debug_printf ("%s siginfo for lwp %d.\n",
@@ -5241,7 +5241,7 @@ linux_qxfer_spu (const char *annex, unsigned char *readbuf,
unsigned const char *writebuf, unsigned const char *writebuf,
CORE_ADDR offset, int len) CORE_ADDR offset, int len)
{ {
long pid = lwpid_of (current_inferior); long pid = lwpid_of (current_thread);
char buf[128]; char buf[128];
int fd = 0; int fd = 0;
int ret = 0; int ret = 0;
@@ -5324,7 +5324,7 @@ static int
linux_read_loadmap (const char *annex, CORE_ADDR offset, linux_read_loadmap (const char *annex, CORE_ADDR offset,
unsigned char *myaddr, unsigned int len) unsigned char *myaddr, unsigned int len)
{ {
int pid = lwpid_of (current_inferior); int pid = lwpid_of (current_thread);
int addr = -1; int addr = -1;
struct target_loadmap *data = NULL; struct target_loadmap *data = NULL;
unsigned int actual_length, copy_length; unsigned int actual_length, copy_length;
@@ -5791,7 +5791,7 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
if (readbuf == NULL) if (readbuf == NULL)
return -1; return -1;
pid = lwpid_of (current_inferior); pid = lwpid_of (current_thread);
xsnprintf (filename, sizeof filename, "/proc/%d/exe", pid); xsnprintf (filename, sizeof filename, "/proc/%d/exe", pid);
is_elf64 = elf_64_file_p (filename, &machine); is_elf64 = elf_64_file_p (filename, &machine);
lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets; lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets;

View File

@@ -126,7 +126,7 @@ mips_read_description (void)
{ {
if (have_dsp < 0) if (have_dsp < 0)
{ {
int pid = lwpid_of (current_inferior); int pid = lwpid_of (current_thread);
errno = 0; errno = 0;
ptrace (PTRACE_PEEKUSER, pid, DSP_CONTROL, 0); ptrace (PTRACE_PEEKUSER, pid, DSP_CONTROL, 0);
@@ -272,7 +272,7 @@ static const unsigned int mips_breakpoint = 0x0005000d;
static CORE_ADDR static CORE_ADDR
mips_reinsert_addr (void) mips_reinsert_addr (void)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
union mips_register ra; union mips_register ra;
collect_register_by_name (regcache, "r31", ra.buf); collect_register_by_name (regcache, "r31", ra.buf);
return register_size (regcache->tdesc, 0) == 4 ? ra.reg32 : ra.reg64; return register_size (regcache->tdesc, 0) == 4 ? ra.reg32 : ra.reg64;
@@ -404,7 +404,7 @@ mips_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
enum target_hw_bp_type watch_type; enum target_hw_bp_type watch_type;
uint32_t irw; uint32_t irw;
lwpid = lwpid_of (current_inferior); lwpid = lwpid_of (current_thread);
if (!mips_linux_read_watch_registers (lwpid, if (!mips_linux_read_watch_registers (lwpid,
&private->watch_readback, &private->watch_readback,
&private->watch_readback_valid, &private->watch_readback_valid,
@@ -506,7 +506,7 @@ mips_stopped_by_watchpoint (void)
struct arch_process_info *private = proc->private->arch_private; struct arch_process_info *private = proc->private->arch_private;
int n; int n;
int num_valid; int num_valid;
long lwpid = lwpid_of (current_inferior); long lwpid = lwpid_of (current_thread);
if (!mips_linux_read_watch_registers (lwpid, if (!mips_linux_read_watch_registers (lwpid,
&private->watch_readback, &private->watch_readback,
@@ -534,7 +534,7 @@ mips_stopped_data_address (void)
struct arch_process_info *private = proc->private->arch_private; struct arch_process_info *private = proc->private->arch_private;
int n; int n;
int num_valid; int num_valid;
long lwpid = lwpid_of (current_inferior); long lwpid = lwpid_of (current_thread);
/* On MIPS we don't know the low order 3 bits of the data address. /* On MIPS we don't know the low order 3 bits of the data address.
GDB does not support remote targets that can't report the GDB does not support remote targets that can't report the

View File

@@ -127,7 +127,7 @@ static CORE_ADDR
nios2_reinsert_addr (void) nios2_reinsert_addr (void)
{ {
union nios2_register ra; union nios2_register ra;
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
collect_register_by_name (regcache, "ra", ra.buf); collect_register_by_name (regcache, "ra", ra.buf);
return ra.reg32; return ra.reg32;

View File

@@ -422,7 +422,7 @@ s390_arch_setup (void)
struct regset_info *regset; struct regset_info *regset;
/* Check whether the kernel supports extra register sets. */ /* Check whether the kernel supports extra register sets. */
int pid = pid_of (current_inferior); int pid = pid_of (current_thread);
int have_regset_last_break int have_regset_last_break
= s390_check_regset (pid, NT_S390_LAST_BREAK, 8); = s390_check_regset (pid, NT_S390_LAST_BREAK, 8);
int have_regset_system_call int have_regset_system_call

View File

@@ -263,7 +263,7 @@ sparc_breakpoint_at (CORE_ADDR where)
static CORE_ADDR static CORE_ADDR
sparc_reinsert_addr (void) sparc_reinsert_addr (void)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 1); struct regcache *regcache = get_thread_regcache (current_thread, 1);
CORE_ADDR lr; CORE_ADDR lr;
/* O7 is the equivalent to the 'lr' of other archs. */ /* O7 is the equivalent to the 'lr' of other archs. */
collect_register_by_name (regcache, "o7", &lr); collect_register_by_name (regcache, "o7", &lr);

View File

@@ -158,7 +158,7 @@ tile_regs_info (void)
static void static void
tile_arch_setup (void) tile_arch_setup (void)
{ {
int pid = pid_of (current_inferior); int pid = pid_of (current_thread);
unsigned int machine; unsigned int machine;
int is_elf64 = linux_pid_exe_is_elf_64_file (pid, &machine); int is_elf64 = linux_pid_exe_is_elf_64_file (pid, &machine);

View File

@@ -231,7 +231,7 @@ static /*const*/ int i386_regmap[] =
static int static int
is_64bit_tdesc (void) is_64bit_tdesc (void)
{ {
struct regcache *regcache = get_thread_regcache (current_inferior, 0); struct regcache *regcache = get_thread_regcache (current_thread, 0);
return register_size (regcache->tdesc, 0) == 8; return register_size (regcache->tdesc, 0) == 8;
} }
@@ -590,7 +590,7 @@ static void
x86_dr_low_set_addr (int regnum, CORE_ADDR addr) x86_dr_low_set_addr (int regnum, CORE_ADDR addr)
{ {
/* Only update the threads of this process. */ /* Only update the threads of this process. */
int pid = pid_of (current_inferior); int pid = pid_of (current_thread);
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
@@ -602,7 +602,7 @@ x86_dr_low_set_addr (int regnum, CORE_ADDR addr)
static CORE_ADDR static CORE_ADDR
x86_dr_low_get_addr (int regnum) x86_dr_low_get_addr (int regnum)
{ {
ptid_t ptid = ptid_of (current_inferior); ptid_t ptid = ptid_of (current_thread);
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
@@ -615,7 +615,7 @@ static void
x86_dr_low_set_control (unsigned long control) x86_dr_low_set_control (unsigned long control)
{ {
/* Only update the threads of this process. */ /* Only update the threads of this process. */
int pid = pid_of (current_inferior); int pid = pid_of (current_thread);
find_inferior (&all_threads, update_debug_registers_callback, &pid); find_inferior (&all_threads, update_debug_registers_callback, &pid);
} }
@@ -625,7 +625,7 @@ x86_dr_low_set_control (unsigned long control)
static unsigned long static unsigned long
x86_dr_low_get_control (void) x86_dr_low_get_control (void)
{ {
ptid_t ptid = ptid_of (current_inferior); ptid_t ptid = ptid_of (current_thread);
return x86_linux_dr_get (ptid, DR_CONTROL); return x86_linux_dr_get (ptid, DR_CONTROL);
} }
@@ -636,7 +636,7 @@ x86_dr_low_get_control (void)
static unsigned long static unsigned long
x86_dr_low_get_status (void) x86_dr_low_get_status (void)
{ {
ptid_t ptid = ptid_of (current_inferior); ptid_t ptid = ptid_of (current_thread);
return x86_linux_dr_get (ptid, DR_STATUS); return x86_linux_dr_get (ptid, DR_STATUS);
} }
@@ -1219,7 +1219,7 @@ x86_siginfo_fixup (siginfo_t *native, void *inf, int direction)
{ {
#ifdef __x86_64__ #ifdef __x86_64__
unsigned int machine; unsigned int machine;
int tid = lwpid_of (current_inferior); int tid = lwpid_of (current_thread);
int is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine); int is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine);
/* Is the inferior 32-bit? If so, then fixup the siginfo object. */ /* Is the inferior 32-bit? If so, then fixup the siginfo object. */
@@ -1302,7 +1302,7 @@ x86_linux_read_description (void)
static uint64_t xcr0; static uint64_t xcr0;
struct regset_info *regset; struct regset_info *regset;
tid = lwpid_of (current_inferior); tid = lwpid_of (current_thread);
is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine); is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine);
@@ -1475,7 +1475,7 @@ x86_arch_setup_process_callback (struct inferior_list_entry *entry)
int pid = ptid_get_pid (entry->id); int pid = ptid_get_pid (entry->id);
/* Look up any thread of this processes. */ /* Look up any thread of this processes. */
current_inferior current_thread
= (struct thread_info *) find_inferior (&all_threads, = (struct thread_info *) find_inferior (&all_threads,
same_process_callback, &pid); same_process_callback, &pid);
@@ -1488,7 +1488,7 @@ x86_arch_setup_process_callback (struct inferior_list_entry *entry)
static void static void
x86_linux_update_xmltarget (void) x86_linux_update_xmltarget (void)
{ {
struct thread_info *save_inferior = current_inferior; struct thread_info *saved_thread = current_thread;
/* Before changing the register cache's internal layout, flush the /* Before changing the register cache's internal layout, flush the
contents of the current valid caches back to the threads, and contents of the current valid caches back to the threads, and
@@ -1497,7 +1497,7 @@ x86_linux_update_xmltarget (void)
for_each_inferior (&all_processes, x86_arch_setup_process_callback); for_each_inferior (&all_processes, x86_arch_setup_process_callback);
current_inferior = save_inferior; current_thread = saved_thread;
} }
/* Process qSupported query, "xmlRegisters=". Update the buffer size for /* Process qSupported query, "xmlRegisters=". Update the buffer size for

View File

@@ -338,9 +338,9 @@ lynx_resume (struct thread_resume *resume_info, size_t n)
/* The ptid might still be minus_one_ptid; this can happen between /* The ptid might still be minus_one_ptid; this can happen between
the moment we create the inferior or attach to a process, and the moment we create the inferior or attach to a process, and
the moment we resume its execution for the first time. It is the moment we resume its execution for the first time. It is
fine to use the current_inferior's ptid in those cases. */ fine to use the current_thread's ptid in those cases. */
if (ptid_equal (ptid, minus_one_ptid)) if (ptid_equal (ptid, minus_one_ptid))
ptid = thread_to_gdb_id (current_inferior); ptid = thread_to_gdb_id (current_thread);
regcache_invalidate (); regcache_invalidate ();
@@ -413,7 +413,7 @@ lynx_wait_1 (ptid_t ptid, struct target_waitstatus *status, int options)
ptid_t new_ptid; ptid_t new_ptid;
if (ptid_equal (ptid, minus_one_ptid)) if (ptid_equal (ptid, minus_one_ptid))
pid = lynx_ptid_get_pid (thread_to_gdb_id (current_inferior)); pid = lynx_ptid_get_pid (thread_to_gdb_id (current_thread));
else else
pid = BUILDPID (lynx_ptid_get_pid (ptid), lynx_ptid_get_tid (ptid)); pid = BUILDPID (lynx_ptid_get_pid (ptid), lynx_ptid_get_tid (ptid));
@@ -582,7 +582,7 @@ static void
lynx_fetch_registers (struct regcache *regcache, int regno) lynx_fetch_registers (struct regcache *regcache, int regno)
{ {
struct lynx_regset_info *regset = lynx_target_regsets; struct lynx_regset_info *regset = lynx_target_regsets;
ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); ptid_t inferior_ptid = thread_to_gdb_id (current_thread);
lynx_debug ("lynx_fetch_registers (regno = %d)", regno); lynx_debug ("lynx_fetch_registers (regno = %d)", regno);
@@ -607,7 +607,7 @@ static void
lynx_store_registers (struct regcache *regcache, int regno) lynx_store_registers (struct regcache *regcache, int regno)
{ {
struct lynx_regset_info *regset = lynx_target_regsets; struct lynx_regset_info *regset = lynx_target_regsets;
ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); ptid_t inferior_ptid = thread_to_gdb_id (current_thread);
lynx_debug ("lynx_store_registers (regno = %d)", regno); lynx_debug ("lynx_store_registers (regno = %d)", regno);
@@ -643,7 +643,7 @@ lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
int buf; int buf;
const int xfer_size = sizeof (buf); const int xfer_size = sizeof (buf);
CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size; CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size;
ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); ptid_t inferior_ptid = thread_to_gdb_id (current_thread);
while (addr < memaddr + len) while (addr < memaddr + len)
{ {
@@ -676,7 +676,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
int buf; int buf;
const int xfer_size = sizeof (buf); const int xfer_size = sizeof (buf);
CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size; CORE_ADDR addr = memaddr & -(CORE_ADDR) xfer_size;
ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); ptid_t inferior_ptid = thread_to_gdb_id (current_thread);
while (addr < memaddr + len) while (addr < memaddr + len)
{ {
@@ -710,7 +710,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
static void static void
lynx_request_interrupt (void) lynx_request_interrupt (void)
{ {
ptid_t inferior_ptid = thread_to_gdb_id (current_inferior); ptid_t inferior_ptid = thread_to_gdb_id (current_thread);
kill (lynx_ptid_get_pid (inferior_ptid), SIGINT); kill (lynx_ptid_get_pid (inferior_ptid), SIGINT);
} }

View File

@@ -995,7 +995,7 @@ check_gdb_bp_preconditions (char z_type, int *err)
*err = 1; *err = 1;
return 0; return 0;
} }
else if (current_inferior == NULL) else if (current_thread == NULL)
{ {
*err = -1; *err = -1;
return 0; return 0;
@@ -1212,7 +1212,7 @@ gdb_condition_true_at_breakpoint_z_type (char z_type, CORE_ADDR addr)
if (bp->cond_list == NULL) if (bp->cond_list == NULL)
return 1; return 1;
ctx.regcache = get_thread_regcache (current_inferior, 1); ctx.regcache = get_thread_regcache (current_thread, 1);
ctx.tframe = NULL; ctx.tframe = NULL;
ctx.tpoint = NULL; ctx.tpoint = NULL;
@@ -1336,7 +1336,7 @@ run_breakpoint_commands_z_type (char z_type, CORE_ADDR addr)
if (bp == NULL) if (bp == NULL)
return 1; return 1;
ctx.regcache = get_thread_regcache (current_inferior, 1); ctx.regcache = get_thread_regcache (current_thread, 1);
ctx.tframe = NULL; ctx.tframe = NULL;
ctx.tpoint = NULL; ctx.tpoint = NULL;

View File

@@ -622,12 +622,12 @@ nto_fetch_registers (struct regcache *regcache, int regno)
if (regno >= the_low_target.num_regs) if (regno >= the_low_target.num_regs)
return; return;
if (current_inferior == NULL) if (current_thread == NULL)
{ {
TRACE ("current_inferior is NULL\n"); TRACE ("current_thread is NULL\n");
return; return;
} }
ptid = thread_to_gdb_id (current_inferior); ptid = thread_to_gdb_id (current_thread);
if (!nto_set_thread (ptid)) if (!nto_set_thread (ptid))
return; return;
@@ -669,12 +669,12 @@ nto_store_registers (struct regcache *regcache, int regno)
TRACE ("%s (regno:%d)\n", __func__, regno); TRACE ("%s (regno:%d)\n", __func__, regno);
if (current_inferior == NULL) if (current_thread == NULL)
{ {
TRACE ("current_inferior is NULL\n"); TRACE ("current_thread is NULL\n");
return; return;
} }
ptid = thread_to_gdb_id (current_inferior); ptid = thread_to_gdb_id (current_thread);
if (!nto_set_thread (ptid)) if (!nto_set_thread (ptid))
return; return;
@@ -861,11 +861,11 @@ nto_stopped_by_watchpoint (void)
int ret = 0; int ret = 0;
TRACE ("%s\n", __func__); TRACE ("%s\n", __func__);
if (nto_inferior.ctl_fd != -1 && current_inferior != NULL) if (nto_inferior.ctl_fd != -1 && current_thread != NULL)
{ {
ptid_t ptid; ptid_t ptid;
ptid = thread_to_gdb_id (current_inferior); ptid = thread_to_gdb_id (current_thread);
if (nto_set_thread (ptid)) if (nto_set_thread (ptid))
{ {
const int watchmask = _DEBUG_FLAG_TRACE_RD | _DEBUG_FLAG_TRACE_WR const int watchmask = _DEBUG_FLAG_TRACE_RD | _DEBUG_FLAG_TRACE_WR
@@ -893,11 +893,11 @@ nto_stopped_data_address (void)
CORE_ADDR ret = (CORE_ADDR)0; CORE_ADDR ret = (CORE_ADDR)0;
TRACE ("%s\n", __func__); TRACE ("%s\n", __func__);
if (nto_inferior.ctl_fd != -1 && current_inferior != NULL) if (nto_inferior.ctl_fd != -1 && current_thread != NULL)
{ {
ptid_t ptid; ptid_t ptid;
ptid = thread_to_gdb_id (current_inferior); ptid = thread_to_gdb_id (current_thread);
if (nto_set_thread (ptid)) if (nto_set_thread (ptid))
{ {

View File

@@ -101,20 +101,20 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
{ {
#ifdef HAVE_REGSETS #ifdef HAVE_REGSETS
struct lwp_info *lwp; struct lwp_info *lwp;
struct thread_info *reg_inferior, *save_inferior; struct thread_info *reg_thread, *saved_thread;
struct regcache *regcache; struct regcache *regcache;
lwp = find_lwp_pid (pid_to_ptid (lwpid)); lwp = find_lwp_pid (pid_to_ptid (lwpid));
if (lwp == NULL) if (lwp == NULL)
return PS_ERR; return PS_ERR;
reg_inferior = get_lwp_thread (lwp); reg_thread = get_lwp_thread (lwp);
save_inferior = current_inferior; saved_thread = current_thread;
current_inferior = reg_inferior; current_thread = reg_thread;
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
gregset_info ()->fill_function (regcache, gregset); gregset_info ()->fill_function (regcache, gregset);
current_inferior = save_inferior; current_thread = saved_thread;
return PS_OK; return PS_OK;
#else #else
return PS_ERR; return PS_ERR;
@@ -157,5 +157,5 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset)
pid_t pid_t
ps_getpid (gdb_ps_prochandle_t ph) ps_getpid (gdb_ps_prochandle_t ph)
{ {
return pid_of (current_inferior); return pid_of (current_thread);
} }

View File

@@ -49,11 +49,11 @@ get_thread_regcache (struct thread_info *thread, int fetch)
if (fetch && regcache->registers_valid == 0) if (fetch && regcache->registers_valid == 0)
{ {
struct thread_info *saved_inferior = current_inferior; struct thread_info *saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
fetch_inferior_registers (regcache, -1); fetch_inferior_registers (regcache, -1);
current_inferior = saved_inferior; current_thread = saved_thread;
regcache->registers_valid = 1; regcache->registers_valid = 1;
} }
@@ -80,11 +80,11 @@ regcache_invalidate_thread (struct thread_info *thread)
if (regcache->registers_valid) if (regcache->registers_valid)
{ {
struct thread_info *saved_inferior = current_inferior; struct thread_info *saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
store_inferior_registers (regcache, -1); store_inferior_registers (regcache, -1);
current_inferior = saved_inferior; current_thread = saved_thread;
} }
regcache->registers_valid = 0; regcache->registers_valid = 0;
@@ -108,7 +108,7 @@ void
regcache_invalidate (void) regcache_invalidate (void)
{ {
/* Only update the threads of the current process. */ /* Only update the threads of the current process. */
int pid = ptid_get_pid (current_inferior->entry.id); int pid = ptid_get_pid (current_thread->entry.id);
find_inferior (&all_threads, regcache_invalidate_one, &pid); find_inferior (&all_threads, regcache_invalidate_one, &pid);
} }

View File

@@ -686,7 +686,7 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
} }
/* Check for an input interrupt while we're here. */ /* Check for an input interrupt while we're here. */
if (cc == '\003' && current_inferior != NULL) if (cc == '\003' && current_thread != NULL)
(*the_target->request_interrupt) (); (*the_target->request_interrupt) ();
} }
while (cc != '+'); while (cc != '+');
@@ -741,7 +741,7 @@ input_interrupt (int unused)
cc = read_prim (&c, 1); cc = read_prim (&c, 1);
if (cc != 1 || c != '\003' || current_inferior == NULL) if (cc != 1 || c != '\003' || current_thread == NULL)
{ {
fprintf (stderr, "input_interrupt, count = %d c = %d ('%c')\n", fprintf (stderr, "input_interrupt, count = %d c = %d ('%c')\n",
cc, c, c); cc, c, c);
@@ -1106,20 +1106,20 @@ prepare_resume_reply (char *buf, ptid_t ptid,
{ {
case TARGET_WAITKIND_STOPPED: case TARGET_WAITKIND_STOPPED:
{ {
struct thread_info *saved_inferior; struct thread_info *saved_thread;
const char **regp; const char **regp;
struct regcache *regcache; struct regcache *regcache;
sprintf (buf, "T%02x", status->value.sig); sprintf (buf, "T%02x", status->value.sig);
buf += strlen (buf); buf += strlen (buf);
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = find_thread_ptid (ptid); current_thread = find_thread_ptid (ptid);
regp = current_target_desc ()->expedite_regs; regp = current_target_desc ()->expedite_regs;
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
if (the_target->stopped_by_watchpoint != NULL if (the_target->stopped_by_watchpoint != NULL
&& (*the_target->stopped_by_watchpoint) ()) && (*the_target->stopped_by_watchpoint) ())
@@ -1196,7 +1196,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
dlls_changed = 0; dlls_changed = 0;
} }
current_inferior = saved_inferior; current_thread = saved_thread;
} }
break; break;
case TARGET_WAITKIND_EXITED: case TARGET_WAITKIND_EXITED:

View File

@@ -268,8 +268,8 @@ start_inferior (char **argv)
if (last_status.kind != TARGET_WAITKIND_STOPPED) if (last_status.kind != TARGET_WAITKIND_STOPPED)
return signal_pid; return signal_pid;
current_inferior->last_resume_kind = resume_stop; current_thread->last_resume_kind = resume_stop;
current_inferior->last_status = last_status; current_thread->last_status = last_status;
} }
while (last_status.value.sig != GDB_SIGNAL_TRAP); while (last_status.value.sig != GDB_SIGNAL_TRAP);
@@ -283,8 +283,8 @@ start_inferior (char **argv)
if (last_status.kind != TARGET_WAITKIND_EXITED if (last_status.kind != TARGET_WAITKIND_EXITED
&& last_status.kind != TARGET_WAITKIND_SIGNALLED) && last_status.kind != TARGET_WAITKIND_SIGNALLED)
{ {
current_inferior->last_resume_kind = resume_stop; current_thread->last_resume_kind = resume_stop;
current_inferior->last_status = last_status; current_thread->last_status = last_status;
} }
return signal_pid; return signal_pid;
@@ -322,8 +322,8 @@ attach_inferior (int pid)
&& last_status.value.sig == GDB_SIGNAL_STOP) && last_status.value.sig == GDB_SIGNAL_STOP)
last_status.value.sig = GDB_SIGNAL_TRAP; last_status.value.sig = GDB_SIGNAL_TRAP;
current_inferior->last_resume_kind = resume_stop; current_thread->last_resume_kind = resume_stop;
current_inferior->last_status = last_status; current_thread->last_status = last_status;
} }
return 0; return 0;
@@ -2316,7 +2316,7 @@ handle_v_cont (char *own_buf)
cont_thread = resume_info[0].thread; cont_thread = resume_info[0].thread;
else else
cont_thread = minus_one_ptid; cont_thread = minus_one_ptid;
set_desired_inferior (0); set_desired_thread (0);
resume (resume_info, n); resume (resume_info, n);
free (resume_info); free (resume_info);
@@ -2370,7 +2370,7 @@ resume (struct thread_resume *actions, size_t num_actions)
if (last_status.kind != TARGET_WAITKIND_EXITED if (last_status.kind != TARGET_WAITKIND_EXITED
&& last_status.kind != TARGET_WAITKIND_SIGNALLED && last_status.kind != TARGET_WAITKIND_SIGNALLED
&& last_status.kind != TARGET_WAITKIND_NO_RESUMED) && last_status.kind != TARGET_WAITKIND_NO_RESUMED)
current_inferior->last_status = last_status; current_thread->last_status = last_status;
/* From the client's perspective, all-stop mode always stops all /* From the client's perspective, all-stop mode always stops all
threads implicitly (and the target backend has already done threads implicitly (and the target backend has already done
@@ -2609,7 +2609,7 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
return; return;
} }
/* Resume inferior and wait for another event. In non-stop mode, /* Resume thread and wait for another event. In non-stop mode,
don't really wait here, but return immediatelly to the event don't really wait here, but return immediatelly to the event
loop. */ loop. */
static void static void
@@ -2619,7 +2619,7 @@ myresume (char *own_buf, int step, int sig)
int n = 0; int n = 0;
int valid_cont_thread; int valid_cont_thread;
set_desired_inferior (0); set_desired_thread (0);
valid_cont_thread = (!ptid_equal (cont_thread, null_ptid) valid_cont_thread = (!ptid_equal (cont_thread, null_ptid)
&& !ptid_equal (cont_thread, minus_one_ptid)); && !ptid_equal (cont_thread, minus_one_ptid));
@@ -2840,7 +2840,7 @@ handle_status (char *own_buf)
/* GDB assumes the current thread is the thread we're /* GDB assumes the current thread is the thread we're
reporting the status for. */ reporting the status for. */
general_thread = thread->id; general_thread = thread->id;
set_desired_inferior (1); set_desired_thread (1);
gdb_assert (tp->last_status.kind != TARGET_WAITKIND_IGNORE); gdb_assert (tp->last_status.kind != TARGET_WAITKIND_IGNORE);
prepare_resume_reply (own_buf, tp->entry.id, &tp->last_status); prepare_resume_reply (own_buf, tp->entry.id, &tp->last_status);
@@ -3542,7 +3542,7 @@ process_serial_event (void)
last_status.value.integer = 0; last_status.value.integer = 0;
last_ptid = pid_to_ptid (pid); last_ptid = pid_to_ptid (pid);
current_inferior = NULL; current_thread = NULL;
} }
else else
{ {
@@ -3623,7 +3623,7 @@ process_serial_event (void)
} }
general_thread = thread_id; general_thread = thread_id;
set_desired_inferior (1); set_desired_thread (1);
} }
else if (own_buf[1] == 'c') else if (own_buf[1] == 'c')
cont_thread = thread_id; cont_thread = thread_id;
@@ -3655,8 +3655,8 @@ process_serial_event (void)
{ {
struct regcache *regcache; struct regcache *regcache;
set_desired_inferior (1); set_desired_thread (1);
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
registers_to_string (regcache, own_buf); registers_to_string (regcache, own_buf);
} }
break; break;
@@ -3668,8 +3668,8 @@ process_serial_event (void)
{ {
struct regcache *regcache; struct regcache *regcache;
set_desired_inferior (1); set_desired_thread (1);
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
registers_from_string (regcache, &own_buf[1]); registers_from_string (regcache, &own_buf[1]);
write_ok (own_buf); write_ok (own_buf);
} }
@@ -3897,9 +3897,9 @@ handle_serial_event (int err, gdb_client_data client_data)
if (process_serial_event () < 0) if (process_serial_event () < 0)
return -1; return -1;
/* Be sure to not change the selected inferior behind GDB's back. /* Be sure to not change the selected thread behind GDB's back.
Important in the non-stop mode asynchronous protocol. */ Important in the non-stop mode asynchronous protocol. */
set_desired_inferior (1); set_desired_thread (1);
return 0; return 0;
} }
@@ -3936,8 +3936,8 @@ handle_target_event (int err, gdb_client_data client_data)
/* We're reporting this thread as stopped. Update its /* We're reporting this thread as stopped. Update its
"want-stopped" state to what the client wants, until it "want-stopped" state to what the client wants, until it
gets a new resume action. */ gets a new resume action. */
current_inferior->last_resume_kind = resume_stop; current_thread->last_resume_kind = resume_stop;
current_inferior->last_status = last_status; current_thread->last_status = last_status;
} }
if (forward_event) if (forward_event)
@@ -3984,9 +3984,9 @@ handle_target_event (int err, gdb_client_data client_data)
} }
} }
/* Be sure to not change the selected inferior behind GDB's back. /* Be sure to not change the selected thread behind GDB's back.
Important in the non-stop mode asynchronous protocol. */ Important in the non-stop mode asynchronous protocol. */
set_desired_inferior (1); set_desired_thread (1);
return 0; return 0;
} }

View File

@@ -24,7 +24,7 @@
struct target_ops *the_target; struct target_ops *the_target;
void void
set_desired_inferior (int use_general) set_desired_thread (int use_general)
{ {
struct thread_info *found; struct thread_info *found;
@@ -34,9 +34,9 @@ set_desired_inferior (int use_general)
found = find_thread_ptid (cont_thread); found = find_thread_ptid (cont_thread);
if (found == NULL) if (found == NULL)
current_inferior = get_first_thread (); current_thread = get_first_thread ();
else else
current_inferior = found; current_thread = found;
} }
int int

View File

@@ -544,7 +544,7 @@ int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
int len); int len);
void set_desired_inferior (int id); void set_desired_thread (int id);
const char *target_pid_to_str (ptid_t); const char *target_pid_to_str (ptid_t);

View File

@@ -56,7 +56,7 @@ copy_target_description (struct target_desc *dest,
const struct target_desc * const struct target_desc *
current_target_desc (void) current_target_desc (void)
{ {
if (current_inferior == NULL) if (current_thread == NULL)
return &default_description; return &default_description;
return current_process ()->tdesc; return current_process ()->tdesc;

View File

@@ -210,9 +210,9 @@ thread_db_create_event (CORE_ADDR where)
/* If we do not know about the main thread yet, this would be a good time to /* If we do not know about the main thread yet, this would be a good time to
find it. We need to do this to pick up the main thread before any newly find it. We need to do this to pick up the main thread before any newly
created threads. */ created threads. */
lwp = get_thread_lwp (current_inferior); lwp = get_thread_lwp (current_thread);
if (lwp->thread_known == 0) if (lwp->thread_known == 0)
find_one_thread (current_inferior->entry.id); find_one_thread (current_thread->entry.id);
/* msg.event == TD_EVENT_CREATE */ /* msg.event == TD_EVENT_CREATE */
@@ -494,7 +494,7 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
psaddr_t addr; psaddr_t addr;
td_err_e err; td_err_e err;
struct lwp_info *lwp; struct lwp_info *lwp;
struct thread_info *saved_inferior; struct thread_info *saved_thread;
struct process_info *proc; struct process_info *proc;
struct thread_db *thread_db; struct thread_db *thread_db;
@@ -517,8 +517,8 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
if (!lwp->thread_known) if (!lwp->thread_known)
return TD_NOTHR; return TD_NOTHR;
saved_inferior = current_inferior; saved_thread = current_thread;
current_inferior = thread; current_thread = thread;
if (load_module != 0) if (load_module != 0)
{ {
@@ -541,7 +541,7 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
addr = (char *) addr + offset; addr = (char *) addr + offset;
} }
current_inferior = saved_inferior; current_thread = saved_thread;
if (err == TD_OK) if (err == TD_OK)
{ {
*address = (CORE_ADDR) (uintptr_t) addr; *address = (CORE_ADDR) (uintptr_t) addr;
@@ -869,7 +869,7 @@ switch_to_process (struct process_info *proc)
{ {
int pid = pid_of (proc); int pid = pid_of (proc);
current_inferior = current_thread =
(struct thread_info *) find_inferior (&all_threads, (struct thread_info *) find_inferior (&all_threads,
any_thread_of, &pid); any_thread_of, &pid);
} }
@@ -893,7 +893,7 @@ disable_thread_event_reporting (struct process_info *proc)
if (td_ta_clear_event_p != NULL) if (td_ta_clear_event_p != NULL)
{ {
struct thread_info *saved_inferior = current_inferior; struct thread_info *saved_thread = current_thread;
td_thr_events_t events; td_thr_events_t events;
switch_to_process (proc); switch_to_process (proc);
@@ -903,7 +903,7 @@ disable_thread_event_reporting (struct process_info *proc)
td_event_fillset (&events); td_event_fillset (&events);
(*td_ta_clear_event_p) (thread_db->thread_agent, &events); (*td_ta_clear_event_p) (thread_db->thread_agent, &events);
current_inferior = saved_inferior; current_thread = saved_thread;
} }
} }
} }
@@ -915,14 +915,14 @@ remove_thread_event_breakpoints (struct process_info *proc)
if (thread_db->td_create_bp != NULL) if (thread_db->td_create_bp != NULL)
{ {
struct thread_info *saved_inferior = current_inferior; struct thread_info *saved_thread = current_thread;
switch_to_process (proc); switch_to_process (proc);
delete_breakpoint (thread_db->td_create_bp); delete_breakpoint (thread_db->td_create_bp);
thread_db->td_create_bp = NULL; thread_db->td_create_bp = NULL;
current_inferior = saved_inferior; current_thread = saved_thread;
} }
} }

View File

@@ -3979,19 +3979,19 @@ gdb_agent_about_to_close (int pid)
if (!maybe_write_ipa_not_loaded (buf)) if (!maybe_write_ipa_not_loaded (buf))
{ {
struct thread_info *save_inferior; struct thread_info *saved_thread;
save_inferior = current_inferior; saved_thread = current_thread;
/* Find any thread which belongs to process PID. */ /* Find any thread which belongs to process PID. */
current_inferior = (struct thread_info *) current_thread = (struct thread_info *)
find_inferior (&all_threads, same_process_p, &pid); find_inferior (&all_threads, same_process_p, &pid);
strcpy (buf, "close"); strcpy (buf, "close");
run_inferior_command (buf, strlen (buf) + 1); run_inferior_command (buf, strlen (buf) + 1);
current_inferior = save_inferior; current_thread = saved_thread;
} }
} }
@@ -4001,7 +4001,7 @@ gdb_agent_about_to_close (int pid)
static void static void
cmd_qtminftpilen (char *packet) cmd_qtminftpilen (char *packet)
{ {
if (current_inferior == NULL) if (current_thread == NULL)
{ {
/* Indicate that the minimum length is currently unknown. */ /* Indicate that the minimum length is currently unknown. */
strcpy (packet, "0"); strcpy (packet, "0");
@@ -7259,9 +7259,9 @@ gdb_agent_helper_thread (void *arg)
/* Sleep endlessly to wait the whole inferior stops. This /* Sleep endlessly to wait the whole inferior stops. This
thread can not exit because GDB or GDBserver may still need thread can not exit because GDB or GDBserver may still need
'current_inferior' (representing this thread) to access 'current_thread' (representing this thread) to access
inferior memory. Otherwise, this thread exits earlier than inferior memory. Otherwise, this thread exits earlier than
other threads, and 'current_inferior' is set to NULL. */ other threads, and 'current_thread' is set to NULL. */
while (1) while (1)
sleep (10); sleep (10);
} }

View File

@@ -111,7 +111,7 @@ static void win32_add_all_dlls (void);
/* Get the thread ID from the current selected inferior (the current /* Get the thread ID from the current selected inferior (the current
thread). */ thread). */
static ptid_t static ptid_t
current_inferior_ptid (void) current_thread_ptid (void)
{ {
return current_ptid; return current_ptid;
} }
@@ -461,7 +461,7 @@ static void
child_fetch_inferior_registers (struct regcache *regcache, int r) child_fetch_inferior_registers (struct regcache *regcache, int r)
{ {
int regno; int regno;
win32_thread_info *th = thread_rec (current_inferior_ptid (), TRUE); win32_thread_info *th = thread_rec (current_thread_ptid (), TRUE);
if (r == -1 || r > NUM_REGS) if (r == -1 || r > NUM_REGS)
child_fetch_inferior_registers (regcache, NUM_REGS); child_fetch_inferior_registers (regcache, NUM_REGS);
else else
@@ -475,7 +475,7 @@ static void
child_store_inferior_registers (struct regcache *regcache, int r) child_store_inferior_registers (struct regcache *regcache, int r)
{ {
int regno; int regno;
win32_thread_info *th = thread_rec (current_inferior_ptid (), TRUE); win32_thread_info *th = thread_rec (current_thread_ptid (), TRUE);
if (r == -1 || r == 0 || r > NUM_REGS) if (r == -1 || r == 0 || r > NUM_REGS)
child_store_inferior_registers (regcache, NUM_REGS); child_store_inferior_registers (regcache, NUM_REGS);
else else
@@ -1461,7 +1461,7 @@ get_child_debug_event (struct target_waitstatus *ourstatus)
child_delete_thread (current_event.dwProcessId, child_delete_thread (current_event.dwProcessId,
current_event.dwThreadId); current_event.dwThreadId);
current_inferior = (struct thread_info *) all_threads.head; current_thread = (struct thread_info *) all_threads.head;
return 1; return 1;
case CREATE_PROCESS_DEBUG_EVENT: case CREATE_PROCESS_DEBUG_EVENT:
@@ -1563,7 +1563,7 @@ get_child_debug_event (struct target_waitstatus *ourstatus)
} }
ptid = debug_event_ptid (&current_event); ptid = debug_event_ptid (&current_event);
current_inferior = current_thread =
(struct thread_info *) find_inferior_id (&all_threads, ptid); (struct thread_info *) find_inferior_id (&all_threads, ptid);
return 1; return 1;
} }
@@ -1604,7 +1604,7 @@ win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
OUTMSG2 (("Child Stopped with signal = %d \n", OUTMSG2 (("Child Stopped with signal = %d \n",
ourstatus->value.sig)); ourstatus->value.sig));
regcache = get_thread_regcache (current_inferior, 1); regcache = get_thread_regcache (current_thread, 1);
child_fetch_inferior_registers (regcache, -1); child_fetch_inferior_registers (regcache, -1);
return debug_event_ptid (&current_event); return debug_event_ptid (&current_event);
default: default: