diff options
author | Gary Benson <gbenson@redhat.com> | 2014-09-10 10:37:11 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2014-09-16 15:57:13 +0100 |
commit | 0bfdf32fa101021ad0d11dd3ae945c823f4b07ac (patch) | |
tree | 8789d5ff75836459b77f6ae88ff06ada3b6c300c /gdb/gdbserver | |
parent | 635856f584de7af4b21bb72688c05cd6d9a0aec6 (diff) | |
download | gdb-0bfdf32fa101021ad0d11dd3ae945c823f4b07ac.zip gdb-0bfdf32fa101021ad0d11dd3ae945c823f4b07ac.tar.gz gdb-0bfdf32fa101021ad0d11dd3ae945c823f4b07ac.tar.bz2 |
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.
Diffstat (limited to 'gdb/gdbserver')
28 files changed, 277 insertions, 245 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index f88eb31..f244123 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -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> Gary Benson <gbenson@redhat.com> diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index fe0a75e..8290ec1 100644 --- a/gdb/gdbserver/gdbthread.h +++ b/gdb/gdbserver/gdbthread.h @@ -80,6 +80,6 @@ struct thread_info *get_first_thread (void); struct thread_info *find_thread_ptid (ptid_t ptid); /* 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 */ diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index 29a07e0..379c51d 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -25,7 +25,7 @@ struct inferior_list all_processes; struct inferior_list all_threads; -struct thread_info *current_inferior; +struct thread_info *current_thread; #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); - if (current_inferior == NULL) - current_inferior = new_thread; + if (current_thread == NULL) + current_thread = new_thread; new_thread->target_data = target_data; @@ -267,7 +267,7 @@ clear_inferiors (void) clear_dlls (); - current_inferior = NULL; + current_thread = NULL; } struct process_info * @@ -355,6 +355,6 @@ get_thread_process (struct thread_info *thread) struct process_info * current_process (void) { - gdb_assert (current_inferior != NULL); - return get_thread_process (current_inferior); + gdb_assert (current_thread != NULL); + return get_thread_process (current_thread); } diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h index f584339..317119d 100644 --- a/gdb/gdbserver/inferiors.h +++ b/gdb/gdbserver/inferiors.h @@ -77,7 +77,7 @@ struct process_info #define lwpid_of(inf) ptid_get_lwp ((inf)->entry.id) /* 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. */ struct process_info *current_process (void); @@ -121,7 +121,7 @@ int one_inferior_p (struct inferior_list *list); #define 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, struct inferior_list_entry *entry); diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index ca096b0..654b319 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -697,7 +697,7 @@ aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state, struct aarch64_dr_update_callback_param param; /* 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.idx = idx; @@ -1038,7 +1038,7 @@ aarch64_stopped_data_address (void) int pid, i; struct aarch64_debug_reg_state *state; - pid = lwpid_of (current_inferior); + pid = lwpid_of (current_thread); /* Get the siginfo. */ if (ptrace (PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0) @@ -1186,7 +1186,7 @@ aarch64_arch_setup (void) current_process ()->tdesc = tdesc_aarch64; - pid = lwpid_of (current_inferior); + pid = lwpid_of (current_thread); iov.iov_base = &dreg_state; iov.iov_len = sizeof (dreg_state); diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index c4cfbd4..8b72523 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -282,7 +282,7 @@ static const unsigned long arm_eabi_breakpoint = 0xe7f001f0; static int 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; collect_register_by_name (regcache, "cpsr", &cpsr); @@ -325,7 +325,7 @@ arm_breakpoint_at (CORE_ADDR where) static CORE_ADDR 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; collect_register_by_name (regcache, "lr", &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; /* 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, 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 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; /* We must be able to set hardware watchpoints. */ @@ -664,7 +664,7 @@ arm_stopped_by_watchpoint (void) /* Retrieve siginfo. */ errno = 0; - ptrace (PTRACE_GETSIGINFO, lwpid_of (current_inferior), 0, &siginfo); + ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread), 0, &siginfo); if (errno != 0) return 0; @@ -690,7 +690,7 @@ arm_stopped_by_watchpoint (void) static CORE_ADDR 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; } @@ -796,7 +796,7 @@ arm_get_hwcap (unsigned long *valp) static const struct target_desc * arm_read_description (void) { - int pid = lwpid_of (current_inferior); + int pid = lwpid_of (current_thread); /* Query hardware watchpoint/breakpoint capabilities. */ arm_linux_init_hwbp_cap (pid); diff --git a/gdb/gdbserver/linux-cris-low.c b/gdb/gdbserver/linux-cris-low.c index 2abd987..177db99 100644 --- a/gdb/gdbserver/linux-cris-low.c +++ b/gdb/gdbserver/linux-cris-low.c @@ -102,7 +102,7 @@ cris_breakpoint_at (CORE_ADDR where) static CORE_ADDR 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; collect_register_by_name (regcache, "srp", &pc); return pc; diff --git a/gdb/gdbserver/linux-crisv32-low.c b/gdb/gdbserver/linux-crisv32-low.c index 203b1ba..aaefe50 100644 --- a/gdb/gdbserver/linux-crisv32-low.c +++ b/gdb/gdbserver/linux-crisv32-low.c @@ -103,7 +103,7 @@ cris_breakpoint_at (CORE_ADDR where) static CORE_ADDR 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; collect_register_by_name (regcache, "srp", &pc); return pc; @@ -166,7 +166,7 @@ cris_insert_point (enum raw_bkpt_type type, CORE_ADDR addr, unsigned long ccs; 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 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; 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 inability to deal with pure read watchpoints. */ @@ -316,7 +316,7 @@ static int cris_stopped_by_watchpoint (void) { 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); @@ -327,7 +327,7 @@ static CORE_ADDR cris_stopped_data_address (void) { 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); diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index ec3260e..705edde 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -457,23 +457,23 @@ handle_extended_wait (struct lwp_info *event_child, int wstat) static CORE_ADDR get_pc (struct lwp_info *lwp) { - struct thread_info *saved_inferior; + struct thread_info *saved_thread; struct regcache *regcache; CORE_ADDR pc; if (the_low_target.get_pc == NULL) return 0; - saved_inferior = current_inferior; - current_inferior = get_lwp_thread (lwp); + saved_thread = current_thread; + 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); if (debug_threads) debug_printf ("pc is 0x%lx\n", (long) pc); - current_inferior = saved_inferior; + current_thread = saved_thread; return pc; } @@ -1467,10 +1467,10 @@ linux_fast_tracepoint_collecting (struct lwp_info *lwp, static int 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; - current_inferior = get_lwp_thread (lwp); + saved_thread = current_thread; + current_thread = get_lwp_thread (lwp); if ((wstat == NULL || (WIFSTOPPED (*wstat) && WSTOPSIG (*wstat) != SIGTRAP)) @@ -1483,7 +1483,7 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat) if (debug_threads) debug_printf ("Checking whether LWP %ld needs to move out of the " "jump pad.\n", - lwpid_of (current_inferior)); + lwpid_of (current_thread)); 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) debug_printf ("Checking whether LWP %ld needs to move out of " "the jump pad...it does\n", - lwpid_of (current_inferior)); - current_inferior = saved_inferior; + lwpid_of (current_thread)); + current_thread = saved_thread; return 1; } @@ -1539,18 +1539,18 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat) || WSTOPSIG (*wstat) == SIGFPE || WSTOPSIG (*wstat) == SIGBUS || WSTOPSIG (*wstat) == SIGSEGV) - && ptrace (PTRACE_GETSIGINFO, lwpid_of (current_inferior), + && ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread), (PTRACE_TYPE_ARG3) 0, &info) == 0 /* Final check just to make sure we don't clobber the siginfo of non-kernel-sent signals. */ && (uintptr_t) info.si_addr == lwp->stop_pc) { 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); } - regcache = get_thread_regcache (current_inferior, 1); + regcache = get_thread_regcache (current_thread, 1); (*the_low_target.set_pc) (regcache, 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) debug_printf ("Checking whether LWP %ld needs to move out of the " "jump pad...no\n", - lwpid_of (current_inferior)); + lwpid_of (current_thread)); - current_inferior = saved_inferior; + current_thread = saved_thread; return 0; } @@ -1700,31 +1700,31 @@ dequeue_one_deferred_signal (struct lwp_info *lwp, int *wstat) static int 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. */ if (!supports_breakpoints ()) return 0; /* breakpoint_at reads from current inferior. */ - saved_inferior = current_inferior; - current_inferior = get_lwp_thread (lwp); + saved_thread = current_thread; + current_thread = get_lwp_thread (lwp); if ((*the_low_target.breakpoint_at) (lwp->stop_pc)) { if (debug_threads) 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. */ if (the_low_target.decr_pc_after_break) { struct regcache *regcache - = get_thread_regcache (current_inferior, 1); + = get_thread_regcache (current_thread, 1); (*the_low_target.set_pc) (regcache, lwp->stop_pc); } - current_inferior = saved_inferior; + current_thread = saved_thread; return 1; } else @@ -1732,10 +1732,10 @@ cancel_breakpoint (struct lwp_info *lwp) if (debug_threads) debug_printf ("CB: No breakpoint found at %s for [%s]\n", 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; } @@ -1780,14 +1780,14 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat) proc = find_process_pid (pid_of (thread)); if (proc->private->new_inferior) { - struct thread_info *saved_inferior; + struct thread_info *saved_thread; - saved_inferior = current_inferior; - current_inferior = thread; + saved_thread = current_thread; + current_thread = thread; the_low_target.arch_setup (); - current_inferior = saved_inferior; + current_thread = saved_thread; proc->private->new_inferior = 0; } @@ -1802,16 +1802,16 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat) if (debug_threads && the_low_target.get_pc != NULL) { - struct thread_info *saved_inferior; + struct thread_info *saved_thread; struct regcache *regcache; CORE_ADDR pc; - saved_inferior = current_inferior; - current_inferior = thread; - regcache = get_thread_regcache (current_inferior, 1); + saved_thread = current_thread; + current_thread = thread; + regcache = get_thread_regcache (current_thread, 1); pc = (*the_low_target.get_pc) (regcache); 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); @@ -1841,10 +1841,10 @@ linux_low_filter_event (ptid_t filter_ptid, int lwpid, int wstat) } else { - struct thread_info *saved_inferior; + struct thread_info *saved_thread; - saved_inferior = current_inferior; - current_inferior = thread; + saved_thread = current_thread; + current_thread = thread; child->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; } - 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; event_child->status_pending_p = 0; event_child->status_pending = 0; - current_inferior = event_thread; + current_thread = 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); - current_inferior = event_thread; + current_thread = event_thread; /* Check for thread exit. */ if (! WIFSTOPPED (*wstatp)) @@ -2408,7 +2408,7 @@ static ptid_t linux_wait_1 (ptid_t ptid, static void linux_stabilize_threads (void) { - struct thread_info *save_inferior; + struct thread_info *saved_thread; struct thread_info *thread_stuck; thread_stuck @@ -2423,7 +2423,7 @@ linux_stabilize_threads (void) return; } - save_inferior = current_inferior; + saved_thread = current_thread; stabilizing_threads = 1; @@ -2444,13 +2444,13 @@ linux_stabilize_threads (void) if (ourstatus.kind == TARGET_WAITKIND_STOPPED) { - lwp = get_thread_lwp (current_inferior); + lwp = get_thread_lwp (current_thread); /* Lock it. */ lwp->suspended++; 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)); enqueue_one_deferred_signal (lwp, &wstat); @@ -2462,7 +2462,7 @@ linux_stabilize_threads (void) stabilizing_threads = 0; - current_inferior = save_inferior; + current_thread = saved_thread; if (debug_threads) { @@ -2575,7 +2575,7 @@ retry: 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 child of a process. Report it. */ @@ -2590,7 +2590,7 @@ retry: { debug_printf ("linux_wait_1 ret = %s, exited with " "retcode %d\n", - target_pid_to_str (ptid_of (current_inferior)), + target_pid_to_str (ptid_of (current_thread)), WEXITSTATUS (w)); debug_exit (); } @@ -2604,13 +2604,13 @@ retry: { debug_printf ("linux_wait_1 ret = %s, terminated with " "signal %d\n", - target_pid_to_str (ptid_of (current_inferior)), + target_pid_to_str (ptid_of (current_thread)), WTERMSIG (w)); 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 @@ -2684,17 +2684,17 @@ retry: if (debug_threads) debug_printf ("Got signal %d for LWP %ld. Check if we need " "to defer or adjust it.\n", - WSTOPSIG (w), lwpid_of (current_inferior)); + WSTOPSIG (w), lwpid_of (current_thread)); /* 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)) { enqueue_one_deferred_signal (event_child, &w); if (debug_threads) 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); goto retry; @@ -2706,7 +2706,7 @@ retry: if (debug_threads) debug_printf ("LWP %ld was trying to move out of the jump pad (%d). " "Check if we're already there.\n", - lwpid_of (current_inferior), + lwpid_of (current_thread), event_child->collecting_fast_tracepoint); trace_event = 1; @@ -2768,11 +2768,11 @@ retry: { debug_printf ("linux_wait_1 ret = %s, stopped " "while stabilizing threads\n", - target_pid_to_str (ptid_of (current_inferior))); + target_pid_to_str (ptid_of (current_thread))); 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 thread library? */ if (WIFSTOPPED (w) - && current_inferior->last_resume_kind != resume_step + && current_thread->last_resume_kind != resume_step && ( #if defined (USE_THREAD_DB) && !defined (__ANDROID__) (current_process ()->private->thread_db != NULL @@ -2800,15 +2800,15 @@ retry: #endif (pass_signals[gdb_signal_from_host (WSTOPSIG (w))] && !(WSTOPSIG (w) == SIGSTOP - && current_inferior->last_resume_kind == resume_stop)))) + && current_thread->last_resume_kind == resume_stop)))) { siginfo_t info, *info_p; if (debug_threads) 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) info_p = &info; else @@ -2832,7 +2832,7 @@ retry: reporting the event to GDB. If we don't, we're out of luck, GDB won't see the breakpoint hit. */ report_to_gdb = (!maybe_internal_trap - || (current_inferior->last_resume_kind == resume_step + || (current_thread->last_resume_kind == resume_step && !in_step_range) || event_child->stopped_by_watchpoint || (!step_over_finished && !in_step_range @@ -2870,7 +2870,7 @@ retry: if (the_low_target.set_pc != NULL) { 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); } @@ -2891,7 +2891,7 @@ retry: 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) debug_printf ("GDB wanted to single-step, reporting event.\n"); @@ -2924,8 +2924,8 @@ retry: select_event_lwp (&event_child); - /* current_inferior and event_child must stay in sync. */ - current_inferior = get_lwp_thread (event_child); + /* current_thread and event_child must stay in sync. */ + current_thread = get_lwp_thread (event_child); event_child->status_pending_p = 0; w = event_child->status_pending; @@ -2961,7 +2961,7 @@ retry: ourstatus->kind = TARGET_WAITKIND_STOPPED; - if (current_inferior->last_resume_kind == resume_stop + if (current_thread->last_resume_kind == resume_stop && WSTOPSIG (w) == SIGSTOP) { /* A thread that has been requested to stop by GDB with vCont;t, @@ -2969,7 +2969,7 @@ retry: SIGSTOP is an implementation detail. */ 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) { /* A thread that has been requested to stop by GDB with vCont;t, @@ -2986,12 +2986,12 @@ retry: if (debug_threads) { 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); debug_exit (); } - return ptid_of (current_inferior); + return ptid_of (current_thread); } /* Get rid of any pending event in the pipe. */ @@ -3159,14 +3159,14 @@ mark_lwp_dead (struct lwp_info *lwp, int wstat) static void wait_for_sigstop (void) { - struct thread_info *saved_inferior; + struct thread_info *saved_thread; ptid_t saved_tid; int wstat; int ret; - saved_inferior = current_inferior; - if (saved_inferior != NULL) - saved_tid = saved_inferior->entry.id; + saved_thread = current_thread; + if (saved_thread != NULL) + saved_tid = saved_thread->entry.id; else saved_tid = null_ptid; /* avoid bogus unused warning */ @@ -3180,8 +3180,8 @@ wait_for_sigstop (void) &wstat, __WALL); gdb_assert (ret == -1); - if (saved_inferior == NULL || linux_thread_alive (saved_tid)) - current_inferior = saved_inferior; + if (saved_thread == NULL || linux_thread_alive (saved_tid)) + current_thread = saved_thread; else { if (debug_threads) @@ -3192,12 +3192,12 @@ wait_for_sigstop (void) /* We can't change the current inferior behind GDB's back, otherwise, a subsequent command may apply to the wrong process. */ - current_inferior = NULL; + current_thread = NULL; } else { /* 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) { struct thread_info *thread = get_lwp_thread (lwp); - struct thread_info *saved_inferior; + struct thread_info *saved_thread; int fast_tp_collecting; if (lwp->stopped == 0) @@ -3374,8 +3374,8 @@ linux_resume_one_lwp (struct lwp_info *lwp, return; } - saved_inferior = current_inferior; - current_inferior = thread; + saved_thread = current_thread; + current_thread = thread; if (debug_threads) 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) { - 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); 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. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); - current_inferior = saved_inferior; + current_thread = saved_thread; if (errno) { /* 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 lwp_info *lwp = get_thread_lwp (thread); - struct thread_info *saved_inferior; + struct thread_info *saved_thread; CORE_ADDR pc; /* 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; } - saved_inferior = current_inferior; - current_inferior = thread; + saved_thread = current_thread; + current_thread = thread; /* We can only step over breakpoints we know about. */ 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", lwpid_of (thread), paddress (pc)); - current_inferior = saved_inferior; + current_thread = saved_thread; return 0; } 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 that find_inferior stops looking. */ - current_inferior = saved_inferior; + current_thread = saved_thread; /* If the step over is cancelled, this is set again. */ 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) debug_printf ("Need step over [LWP %ld]? No, no breakpoint found" @@ -3774,7 +3774,7 @@ static int start_step_over (struct lwp_info *lwp) { struct thread_info *thread = get_lwp_thread (lwp); - struct thread_info *saved_inferior; + struct thread_info *saved_thread; CORE_ADDR pc; int step; @@ -3794,8 +3794,8 @@ start_step_over (struct lwp_info *lwp) shouldn't care about. */ pc = get_pc (lwp); - saved_inferior = current_inferior; - current_inferior = thread; + saved_thread = current_thread; + current_thread = thread; lwp->bp_reinsert = pc; uninsert_breakpoints_at (pc); @@ -3812,7 +3812,7 @@ start_step_over (struct lwp_info *lwp) step = 0; } - current_inferior = saved_inferior; + current_thread = saved_thread; 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; - pid = lwpid_of (current_inferior); + pid = lwpid_of (current_thread); while (regset->size >= 0) { void *buf, *data; @@ -4314,7 +4314,7 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info, regset = regsets_info->regsets; - pid = lwpid_of (current_inferior); + pid = lwpid_of (current_thread); while (regset->size >= 0) { void *buf, *data; @@ -4459,7 +4459,7 @@ fetch_register (const struct usrregs_info *usrregs, & -sizeof (PTRACE_XFER_TYPE)); buf = alloca (size); - pid = lwpid_of (current_inferior); + pid = lwpid_of (current_thread); for (i = 0; i < size; i += sizeof (PTRACE_XFER_TYPE)) { errno = 0; @@ -4509,7 +4509,7 @@ store_register (const struct usrregs_info *usrregs, else 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)) { errno = 0; @@ -4649,7 +4649,7 @@ linux_store_registers (struct regcache *regcache, int regno) static int 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 CORE_ADDR addr; 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 *) alloca (count * sizeof (PTRACE_XFER_TYPE)); - int pid = lwpid_of (current_inferior); + int pid = lwpid_of (current_thread); if (len == 0) { @@ -4845,7 +4845,7 @@ linux_request_interrupt (void) { int lwpid; - lwpid = lwpid_of (current_inferior); + lwpid = lwpid_of (current_thread); kill_lwp (lwpid, SIGINT); } else @@ -4860,7 +4860,7 @@ linux_read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len) { char filename[PATH_MAX]; int fd, n; - int pid = lwpid_of (current_inferior); + int pid = lwpid_of (current_thread); 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 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; } @@ -4923,7 +4923,7 @@ linux_stopped_by_watchpoint (void) static CORE_ADDR 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; } @@ -4944,7 +4944,7 @@ static int linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p) { 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; @@ -5013,10 +5013,10 @@ linux_xfer_siginfo (const char *annex, unsigned char *readbuf, siginfo_t siginfo; char inf_siginfo[sizeof (siginfo_t)]; - if (current_inferior == NULL) + if (current_thread == NULL) return -1; - pid = lwpid_of (current_inferior); + pid = lwpid_of (current_thread); if (debug_threads) 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, CORE_ADDR offset, int len) { - long pid = lwpid_of (current_inferior); + long pid = lwpid_of (current_thread); char buf[128]; int fd = 0; int ret = 0; @@ -5324,7 +5324,7 @@ static int linux_read_loadmap (const char *annex, CORE_ADDR offset, unsigned char *myaddr, unsigned int len) { - int pid = lwpid_of (current_inferior); + int pid = lwpid_of (current_thread); int addr = -1; struct target_loadmap *data = NULL; unsigned int actual_length, copy_length; @@ -5791,7 +5791,7 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, if (readbuf == NULL) return -1; - pid = lwpid_of (current_inferior); + pid = lwpid_of (current_thread); xsnprintf (filename, sizeof filename, "/proc/%d/exe", pid); is_elf64 = elf_64_file_p (filename, &machine); lmo = is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets; diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index 377284b..0fc8cb4 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -126,7 +126,7 @@ mips_read_description (void) { if (have_dsp < 0) { - int pid = lwpid_of (current_inferior); + int pid = lwpid_of (current_thread); errno = 0; ptrace (PTRACE_PEEKUSER, pid, DSP_CONTROL, 0); @@ -272,7 +272,7 @@ static const unsigned int mips_breakpoint = 0x0005000d; static CORE_ADDR 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; collect_register_by_name (regcache, "r31", ra.buf); 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; uint32_t irw; - lwpid = lwpid_of (current_inferior); + lwpid = lwpid_of (current_thread); if (!mips_linux_read_watch_registers (lwpid, &private->watch_readback, &private->watch_readback_valid, @@ -506,7 +506,7 @@ mips_stopped_by_watchpoint (void) struct arch_process_info *private = proc->private->arch_private; int n; int num_valid; - long lwpid = lwpid_of (current_inferior); + long lwpid = lwpid_of (current_thread); if (!mips_linux_read_watch_registers (lwpid, &private->watch_readback, @@ -534,7 +534,7 @@ mips_stopped_data_address (void) struct arch_process_info *private = proc->private->arch_private; int n; 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. GDB does not support remote targets that can't report the diff --git a/gdb/gdbserver/linux-nios2-low.c b/gdb/gdbserver/linux-nios2-low.c index 54dde72..1d28844 100644 --- a/gdb/gdbserver/linux-nios2-low.c +++ b/gdb/gdbserver/linux-nios2-low.c @@ -127,7 +127,7 @@ static CORE_ADDR nios2_reinsert_addr (void) { 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); return ra.reg32; diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c index c891a6d..79fa6c0 100644 --- a/gdb/gdbserver/linux-s390-low.c +++ b/gdb/gdbserver/linux-s390-low.c @@ -422,7 +422,7 @@ s390_arch_setup (void) struct regset_info *regset; /* 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 = s390_check_regset (pid, NT_S390_LAST_BREAK, 8); int have_regset_system_call diff --git a/gdb/gdbserver/linux-sparc-low.c b/gdb/gdbserver/linux-sparc-low.c index f2fc8cb..351d280 100644 --- a/gdb/gdbserver/linux-sparc-low.c +++ b/gdb/gdbserver/linux-sparc-low.c @@ -263,7 +263,7 @@ sparc_breakpoint_at (CORE_ADDR where) static CORE_ADDR 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; /* O7 is the equivalent to the 'lr' of other archs. */ collect_register_by_name (regcache, "o7", &lr); diff --git a/gdb/gdbserver/linux-tile-low.c b/gdb/gdbserver/linux-tile-low.c index c292c27..a7673c3 100644 --- a/gdb/gdbserver/linux-tile-low.c +++ b/gdb/gdbserver/linux-tile-low.c @@ -158,7 +158,7 @@ tile_regs_info (void) static void tile_arch_setup (void) { - int pid = pid_of (current_inferior); + int pid = pid_of (current_thread); unsigned int machine; int is_elf64 = linux_pid_exe_is_elf_64_file (pid, &machine); diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index a66f61e..838e7c9 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -231,7 +231,7 @@ static /*const*/ int i386_regmap[] = static int 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; } @@ -590,7 +590,7 @@ static void x86_dr_low_set_addr (int regnum, CORE_ADDR addr) { /* 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); @@ -602,7 +602,7 @@ x86_dr_low_set_addr (int regnum, CORE_ADDR addr) static CORE_ADDR 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); @@ -615,7 +615,7 @@ static void x86_dr_low_set_control (unsigned long control) { /* 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); } @@ -625,7 +625,7 @@ x86_dr_low_set_control (unsigned long control) static unsigned long 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); } @@ -636,7 +636,7 @@ x86_dr_low_get_control (void) static unsigned long 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); } @@ -1219,7 +1219,7 @@ x86_siginfo_fixup (siginfo_t *native, void *inf, int direction) { #ifdef __x86_64__ 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); /* 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; 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); @@ -1475,7 +1475,7 @@ x86_arch_setup_process_callback (struct inferior_list_entry *entry) int pid = ptid_get_pid (entry->id); /* Look up any thread of this processes. */ - current_inferior + current_thread = (struct thread_info *) find_inferior (&all_threads, same_process_callback, &pid); @@ -1488,7 +1488,7 @@ x86_arch_setup_process_callback (struct inferior_list_entry *entry) static 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 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); - current_inferior = save_inferior; + current_thread = saved_thread; } /* Process qSupported query, "xmlRegisters=". Update the buffer size for diff --git a/gdb/gdbserver/lynx-low.c b/gdb/gdbserver/lynx-low.c index 0b0ff47..96dea03 100644 --- a/gdb/gdbserver/lynx-low.c +++ b/gdb/gdbserver/lynx-low.c @@ -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 moment we create the inferior or attach to a process, and 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)) - ptid = thread_to_gdb_id (current_inferior); + ptid = thread_to_gdb_id (current_thread); regcache_invalidate (); @@ -413,7 +413,7 @@ lynx_wait_1 (ptid_t ptid, struct target_waitstatus *status, int options) ptid_t new_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 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) { 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); @@ -607,7 +607,7 @@ static void lynx_store_registers (struct regcache *regcache, int regno) { 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); @@ -643,7 +643,7 @@ lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) int buf; const int xfer_size = sizeof (buf); 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) { @@ -676,7 +676,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len) int buf; const int xfer_size = sizeof (buf); 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) { @@ -710,7 +710,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len) static 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); } diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c index 07f9b20..d7481c4 100644 --- a/gdb/gdbserver/mem-break.c +++ b/gdb/gdbserver/mem-break.c @@ -995,7 +995,7 @@ check_gdb_bp_preconditions (char z_type, int *err) *err = 1; return 0; } - else if (current_inferior == NULL) + else if (current_thread == NULL) { *err = -1; return 0; @@ -1212,7 +1212,7 @@ gdb_condition_true_at_breakpoint_z_type (char z_type, CORE_ADDR addr) if (bp->cond_list == NULL) return 1; - ctx.regcache = get_thread_regcache (current_inferior, 1); + ctx.regcache = get_thread_regcache (current_thread, 1); ctx.tframe = NULL; ctx.tpoint = NULL; @@ -1336,7 +1336,7 @@ run_breakpoint_commands_z_type (char z_type, CORE_ADDR addr) if (bp == NULL) return 1; - ctx.regcache = get_thread_regcache (current_inferior, 1); + ctx.regcache = get_thread_regcache (current_thread, 1); ctx.tframe = NULL; ctx.tpoint = NULL; diff --git a/gdb/gdbserver/nto-low.c b/gdb/gdbserver/nto-low.c index 0afaec7..a6516a8 100644 --- a/gdb/gdbserver/nto-low.c +++ b/gdb/gdbserver/nto-low.c @@ -622,12 +622,12 @@ nto_fetch_registers (struct regcache *regcache, int regno) if (regno >= the_low_target.num_regs) return; - if (current_inferior == NULL) + if (current_thread == NULL) { - TRACE ("current_inferior is NULL\n"); + TRACE ("current_thread is NULL\n"); return; } - ptid = thread_to_gdb_id (current_inferior); + ptid = thread_to_gdb_id (current_thread); if (!nto_set_thread (ptid)) return; @@ -669,12 +669,12 @@ nto_store_registers (struct regcache *regcache, int 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; } - ptid = thread_to_gdb_id (current_inferior); + ptid = thread_to_gdb_id (current_thread); if (!nto_set_thread (ptid)) return; @@ -861,11 +861,11 @@ nto_stopped_by_watchpoint (void) int ret = 0; 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 = thread_to_gdb_id (current_inferior); + ptid = thread_to_gdb_id (current_thread); if (nto_set_thread (ptid)) { 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; 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 = thread_to_gdb_id (current_inferior); + ptid = thread_to_gdb_id (current_thread); if (nto_set_thread (ptid)) { diff --git a/gdb/gdbserver/proc-service.c b/gdb/gdbserver/proc-service.c index 5a6dc4e..dcaf013 100644 --- a/gdb/gdbserver/proc-service.c +++ b/gdb/gdbserver/proc-service.c @@ -101,20 +101,20 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) { #ifdef HAVE_REGSETS struct lwp_info *lwp; - struct thread_info *reg_inferior, *save_inferior; + struct thread_info *reg_thread, *saved_thread; struct regcache *regcache; lwp = find_lwp_pid (pid_to_ptid (lwpid)); if (lwp == NULL) return PS_ERR; - reg_inferior = get_lwp_thread (lwp); - save_inferior = current_inferior; - current_inferior = reg_inferior; - regcache = get_thread_regcache (current_inferior, 1); + reg_thread = get_lwp_thread (lwp); + saved_thread = current_thread; + current_thread = reg_thread; + regcache = get_thread_regcache (current_thread, 1); gregset_info ()->fill_function (regcache, gregset); - current_inferior = save_inferior; + current_thread = saved_thread; return PS_OK; #else return PS_ERR; @@ -157,5 +157,5 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) pid_t ps_getpid (gdb_ps_prochandle_t ph) { - return pid_of (current_inferior); + return pid_of (current_thread); } diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index ad66ff7..718ae8c 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -49,11 +49,11 @@ get_thread_regcache (struct thread_info *thread, int fetch) 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); - current_inferior = saved_inferior; + current_thread = saved_thread; regcache->registers_valid = 1; } @@ -80,11 +80,11 @@ regcache_invalidate_thread (struct thread_info *thread) 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); - current_inferior = saved_inferior; + current_thread = saved_thread; } regcache->registers_valid = 0; @@ -108,7 +108,7 @@ void regcache_invalidate (void) { /* 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); } diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 81b9af3..373fc15 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -686,7 +686,7 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif) } /* 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) (); } while (cc != '+'); @@ -741,7 +741,7 @@ input_interrupt (int unused) 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", cc, c, c); @@ -1106,20 +1106,20 @@ prepare_resume_reply (char *buf, ptid_t ptid, { case TARGET_WAITKIND_STOPPED: { - struct thread_info *saved_inferior; + struct thread_info *saved_thread; const char **regp; struct regcache *regcache; sprintf (buf, "T%02x", status->value.sig); 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; - regcache = get_thread_regcache (current_inferior, 1); + regcache = get_thread_regcache (current_thread, 1); if (the_target->stopped_by_watchpoint != NULL && (*the_target->stopped_by_watchpoint) ()) @@ -1196,7 +1196,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, dlls_changed = 0; } - current_inferior = saved_inferior; + current_thread = saved_thread; } break; case TARGET_WAITKIND_EXITED: diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 8d95761..522d6f6 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -268,8 +268,8 @@ start_inferior (char **argv) if (last_status.kind != TARGET_WAITKIND_STOPPED) return signal_pid; - current_inferior->last_resume_kind = resume_stop; - current_inferior->last_status = last_status; + current_thread->last_resume_kind = resume_stop; + current_thread->last_status = last_status; } while (last_status.value.sig != GDB_SIGNAL_TRAP); @@ -283,8 +283,8 @@ start_inferior (char **argv) if (last_status.kind != TARGET_WAITKIND_EXITED && last_status.kind != TARGET_WAITKIND_SIGNALLED) { - current_inferior->last_resume_kind = resume_stop; - current_inferior->last_status = last_status; + current_thread->last_resume_kind = resume_stop; + current_thread->last_status = last_status; } return signal_pid; @@ -322,8 +322,8 @@ attach_inferior (int pid) && last_status.value.sig == GDB_SIGNAL_STOP) last_status.value.sig = GDB_SIGNAL_TRAP; - current_inferior->last_resume_kind = resume_stop; - current_inferior->last_status = last_status; + current_thread->last_resume_kind = resume_stop; + current_thread->last_status = last_status; } return 0; @@ -2316,7 +2316,7 @@ handle_v_cont (char *own_buf) cont_thread = resume_info[0].thread; else cont_thread = minus_one_ptid; - set_desired_inferior (0); + set_desired_thread (0); resume (resume_info, n); free (resume_info); @@ -2370,7 +2370,7 @@ resume (struct thread_resume *actions, size_t num_actions) if (last_status.kind != TARGET_WAITKIND_EXITED && last_status.kind != TARGET_WAITKIND_SIGNALLED && 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 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; } -/* 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 loop. */ static void @@ -2619,7 +2619,7 @@ myresume (char *own_buf, int step, int sig) int n = 0; int valid_cont_thread; - set_desired_inferior (0); + set_desired_thread (0); valid_cont_thread = (!ptid_equal (cont_thread, null_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 reporting the status for. */ general_thread = thread->id; - set_desired_inferior (1); + set_desired_thread (1); gdb_assert (tp->last_status.kind != TARGET_WAITKIND_IGNORE); 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_ptid = pid_to_ptid (pid); - current_inferior = NULL; + current_thread = NULL; } else { @@ -3623,7 +3623,7 @@ process_serial_event (void) } general_thread = thread_id; - set_desired_inferior (1); + set_desired_thread (1); } else if (own_buf[1] == 'c') cont_thread = thread_id; @@ -3655,8 +3655,8 @@ process_serial_event (void) { struct regcache *regcache; - set_desired_inferior (1); - regcache = get_thread_regcache (current_inferior, 1); + set_desired_thread (1); + regcache = get_thread_regcache (current_thread, 1); registers_to_string (regcache, own_buf); } break; @@ -3668,8 +3668,8 @@ process_serial_event (void) { struct regcache *regcache; - set_desired_inferior (1); - regcache = get_thread_regcache (current_inferior, 1); + set_desired_thread (1); + regcache = get_thread_regcache (current_thread, 1); registers_from_string (regcache, &own_buf[1]); write_ok (own_buf); } @@ -3897,9 +3897,9 @@ handle_serial_event (int err, gdb_client_data client_data) if (process_serial_event () < 0) 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. */ - set_desired_inferior (1); + set_desired_thread (1); 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 "want-stopped" state to what the client wants, until it gets a new resume action. */ - current_inferior->last_resume_kind = resume_stop; - current_inferior->last_status = last_status; + current_thread->last_resume_kind = resume_stop; + current_thread->last_status = last_status; } 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. */ - set_desired_inferior (1); + set_desired_thread (1); return 0; } diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c index e51b7db..c95b2f0 100644 --- a/gdb/gdbserver/target.c +++ b/gdb/gdbserver/target.c @@ -24,7 +24,7 @@ struct target_ops *the_target; void -set_desired_inferior (int use_general) +set_desired_thread (int use_general) { struct thread_info *found; @@ -34,9 +34,9 @@ set_desired_inferior (int use_general) found = find_thread_ptid (cont_thread); if (found == NULL) - current_inferior = get_first_thread (); + current_thread = get_first_thread (); else - current_inferior = found; + current_thread = found; } int diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index a08b753..5e29b7f 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -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 len); -void set_desired_inferior (int id); +void set_desired_thread (int id); const char *target_pid_to_str (ptid_t); diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c index 0c56f5c..298f5ce 100644 --- a/gdb/gdbserver/tdesc.c +++ b/gdb/gdbserver/tdesc.c @@ -56,7 +56,7 @@ copy_target_description (struct target_desc *dest, const struct target_desc * current_target_desc (void) { - if (current_inferior == NULL) + if (current_thread == NULL) return &default_description; return current_process ()->tdesc; diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c index eabfe20..a704933 100644 --- a/gdb/gdbserver/thread-db.c +++ b/gdb/gdbserver/thread-db.c @@ -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 find it. We need to do this to pick up the main thread before any newly created threads. */ - lwp = get_thread_lwp (current_inferior); + lwp = get_thread_lwp (current_thread); if (lwp->thread_known == 0) - find_one_thread (current_inferior->entry.id); + find_one_thread (current_thread->entry.id); /* msg.event == TD_EVENT_CREATE */ @@ -494,7 +494,7 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, psaddr_t addr; td_err_e err; struct lwp_info *lwp; - struct thread_info *saved_inferior; + struct thread_info *saved_thread; struct process_info *proc; 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) return TD_NOTHR; - saved_inferior = current_inferior; - current_inferior = thread; + saved_thread = current_thread; + current_thread = thread; if (load_module != 0) { @@ -541,7 +541,7 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, addr = (char *) addr + offset; } - current_inferior = saved_inferior; + current_thread = saved_thread; if (err == TD_OK) { *address = (CORE_ADDR) (uintptr_t) addr; @@ -869,7 +869,7 @@ switch_to_process (struct process_info *proc) { int pid = pid_of (proc); - current_inferior = + current_thread = (struct thread_info *) find_inferior (&all_threads, any_thread_of, &pid); } @@ -893,7 +893,7 @@ disable_thread_event_reporting (struct process_info *proc) 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; switch_to_process (proc); @@ -903,7 +903,7 @@ disable_thread_event_reporting (struct process_info *proc) td_event_fillset (&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) { - struct thread_info *saved_inferior = current_inferior; + struct thread_info *saved_thread = current_thread; switch_to_process (proc); delete_breakpoint (thread_db->td_create_bp); thread_db->td_create_bp = NULL; - current_inferior = saved_inferior; + current_thread = saved_thread; } } diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 2e83d71..b6ab53f 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -3979,19 +3979,19 @@ gdb_agent_about_to_close (int pid) 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. */ - current_inferior = (struct thread_info *) + current_thread = (struct thread_info *) find_inferior (&all_threads, same_process_p, &pid); strcpy (buf, "close"); 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 cmd_qtminftpilen (char *packet) { - if (current_inferior == NULL) + if (current_thread == NULL) { /* Indicate that the minimum length is currently unknown. */ strcpy (packet, "0"); @@ -7259,9 +7259,9 @@ gdb_agent_helper_thread (void *arg) /* Sleep endlessly to wait the whole inferior stops. This 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 - other threads, and 'current_inferior' is set to NULL. */ + other threads, and 'current_thread' is set to NULL. */ while (1) sleep (10); } diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index 2242d5c..ee99fe4 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -111,7 +111,7 @@ static void win32_add_all_dlls (void); /* Get the thread ID from the current selected inferior (the current thread). */ static ptid_t -current_inferior_ptid (void) +current_thread_ptid (void) { return current_ptid; } @@ -461,7 +461,7 @@ static void child_fetch_inferior_registers (struct regcache *regcache, int r) { 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) child_fetch_inferior_registers (regcache, NUM_REGS); else @@ -475,7 +475,7 @@ static void child_store_inferior_registers (struct regcache *regcache, int r) { 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) child_store_inferior_registers (regcache, NUM_REGS); else @@ -1461,7 +1461,7 @@ get_child_debug_event (struct target_waitstatus *ourstatus) child_delete_thread (current_event.dwProcessId, current_event.dwThreadId); - current_inferior = (struct thread_info *) all_threads.head; + current_thread = (struct thread_info *) all_threads.head; return 1; case CREATE_PROCESS_DEBUG_EVENT: @@ -1563,7 +1563,7 @@ get_child_debug_event (struct target_waitstatus *ourstatus) } ptid = debug_event_ptid (¤t_event); - current_inferior = + current_thread = (struct thread_info *) find_inferior_id (&all_threads, ptid); return 1; } @@ -1604,7 +1604,7 @@ win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options) OUTMSG2 (("Child Stopped with signal = %d \n", ourstatus->value.sig)); - regcache = get_thread_regcache (current_inferior, 1); + regcache = get_thread_regcache (current_thread, 1); child_fetch_inferior_registers (regcache, -1); return debug_event_ptid (¤t_event); default: |