mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 10:03:47 +08:00
Push pruning old threads down to the target
When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
This commit is contained in:
parent
6dc54d9124
commit
e8032dde10
@ -1,3 +1,57 @@
|
||||
2014-10-15 Pedro Alves <palves@redhat.com>
|
||||
|
||||
* ada-tasks.c (print_ada_task_info, task_command_1): Adjust.
|
||||
* bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ...
|
||||
(bsd_uthread_update_thread_list): ... this. Call prune_threads.
|
||||
(bsd_uthread_target): Adjust.
|
||||
* corelow.c (core_open): Adjust.
|
||||
* dec-thread.c (dec_thread_find_new_threads): Update comment.
|
||||
(dec_thread_update_thread_list): New function.
|
||||
(init_dec_thread_ops): Adjust.
|
||||
* gdbthread.h (prune_threads): New declaration.
|
||||
* linux-thread-db.c (thread_db_find_new_threads): Rename to ...
|
||||
(thread_db_update_thread_list): ... this. Call prune_threads.
|
||||
(init_thread_db_ops): Adjust.
|
||||
* nto-procfs.c (procfs_find_new_threads): Rename to ...
|
||||
(procfs_update_thread_list): ... this. Call prune_threads.
|
||||
(procfs_attach, procfs_create_inferior, init_procfs_targets):
|
||||
Adjust.
|
||||
* obsd-nat.c (obsd_find_new_threads): Rename to ...
|
||||
(obsd_update_thread_list): ... this. Call prune_threads.
|
||||
(obsd_add_target): Adjust.
|
||||
* procfs.c (procfs_target): Adjust.
|
||||
(procfs_notice_thread): Update comment.
|
||||
(procfs_find_new_threads): Rename to ...
|
||||
(procfs_update_thread_list): ... this. Call prune_threads.
|
||||
* ravenscar-thread.c (ravenscar_update_inferior_ptid): Update
|
||||
comment.
|
||||
(ravenscar_wait): Adjust.
|
||||
(ravenscar_find_new_threads): Rename to ...
|
||||
(ravenscar_update_thread_list): ... this. Call prune_threads.
|
||||
(init_ravenscar_thread_ops): Adjust.
|
||||
* record-btrace.c (record_btrace_find_new_threads): Rename to ...
|
||||
(record_btrace_update_thread_list): ... this. Adjust comment.
|
||||
(init_record_btrace_ops): Adjust.
|
||||
* remote.c (remote_threads_info): Rename to ...
|
||||
(remote_update_thread_list): ... this. Call prune_threads.
|
||||
(remote_start_remote, extended_remote_attach_1, init_remote_ops):
|
||||
Adjust.
|
||||
* sol-thread.c (check_for_thread_db): Adjust.
|
||||
(sol_find_new_threads_callback): Rename to ...
|
||||
(sol_update_thread_list_callback): ... this.
|
||||
(sol_find_new_threads): Rename to ...
|
||||
(sol_update_thread_list): ... this. Call prune_threads. Adjust.
|
||||
(sol_get_ada_task_ptid, init_sol_thread_ops): Adjust.
|
||||
* target-delegates.c: Regenerate.
|
||||
* target.c (target_find_new_threads): Rename to ...
|
||||
(target_update_thread_list): ... this.
|
||||
* target.h (struct target_ops): Rename to_find_new_threads field
|
||||
to to_update_thread_list.
|
||||
(target_find_new_threads): Rename to ...
|
||||
(target_update_thread_list): ... this.
|
||||
* thread.c (prune_threads): Make extern.
|
||||
(update_thread_list): Adjust.
|
||||
|
||||
2014-10-15 Pedro Alves <palves@redhat.com>
|
||||
|
||||
* remote.c (remote_get_threadlist, remote_threadlist_iterator):
|
||||
|
@ -1025,7 +1025,7 @@ print_ada_task_info (struct ui_out *uiout,
|
||||
take a --thread argument. However, in order to be able to
|
||||
provide that thread ID, the thread list must be up to date
|
||||
first. */
|
||||
target_find_new_threads ();
|
||||
target_update_thread_list ();
|
||||
|
||||
data = get_ada_tasks_inferior_data (inf);
|
||||
|
||||
@ -1291,7 +1291,7 @@ task_command_1 (char *taskno_str, int from_tty, struct inferior *inf)
|
||||
to the thread associated to our task if GDB does not know about
|
||||
that thread, we need to make sure that any new threads gets added
|
||||
to the thread list. */
|
||||
target_find_new_threads ();
|
||||
target_update_thread_list ();
|
||||
|
||||
/* Verify that the ptid of the task we want to switch to is valid
|
||||
(in other words, a ptid that GDB knows about). Otherwise, we will
|
||||
|
@ -412,12 +412,14 @@ bsd_uthread_thread_alive (struct target_ops *ops, ptid_t ptid)
|
||||
}
|
||||
|
||||
static void
|
||||
bsd_uthread_find_new_threads (struct target_ops *ops)
|
||||
bsd_uthread_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
pid_t pid = ptid_get_pid (inferior_ptid);
|
||||
int offset = bsd_uthread_thread_next_offset;
|
||||
CORE_ADDR addr;
|
||||
|
||||
prune_threads ();
|
||||
|
||||
addr = bsd_uthread_read_memory_address (bsd_uthread_thread_list_addr);
|
||||
while (addr != 0)
|
||||
{
|
||||
@ -516,7 +518,7 @@ bsd_uthread_target (void)
|
||||
t->to_wait = bsd_uthread_wait;
|
||||
t->to_resume = bsd_uthread_resume;
|
||||
t->to_thread_alive = bsd_uthread_thread_alive;
|
||||
t->to_find_new_threads = bsd_uthread_find_new_threads;
|
||||
t->to_update_thread_list = bsd_uthread_update_thread_list;
|
||||
t->to_extra_thread_info = bsd_uthread_extra_thread_info;
|
||||
t->to_pid_to_str = bsd_uthread_pid_to_str;
|
||||
t->to_stratum = thread_stratum;
|
||||
|
@ -413,7 +413,7 @@ core_open (const char *arg, int from_tty)
|
||||
sections. */
|
||||
TRY_CATCH (except, RETURN_MASK_ERROR)
|
||||
{
|
||||
target_find_new_threads ();
|
||||
target_update_thread_list ();
|
||||
}
|
||||
|
||||
if (except.reason < 0)
|
||||
|
@ -394,7 +394,7 @@ dec_thread_add_gdb_thread (struct thread_info *info, void *context)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Implement the find_new_thread target_ops method. */
|
||||
/* Find new threads. */
|
||||
|
||||
static void
|
||||
dec_thread_find_new_threads (struct target_ops *ops)
|
||||
@ -412,6 +412,21 @@ dec_thread_find_new_threads (struct target_ops *ops)
|
||||
}
|
||||
}
|
||||
|
||||
/* Implement the update_thread_list target_ops method. */
|
||||
|
||||
static void
|
||||
dec_thread_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
int i;
|
||||
struct dec_thread_info *info;
|
||||
|
||||
/* Delete dead threads. */
|
||||
prune_threads ();
|
||||
|
||||
/* Now find new threads. */
|
||||
dec_thread_find_new_threads (ops);
|
||||
}
|
||||
|
||||
/* Resynchronize the list of threads known by GDB with the actual
|
||||
list of threads reported by libpthread_debug. */
|
||||
|
||||
@ -717,7 +732,7 @@ init_dec_thread_ops (void)
|
||||
dec_thread_ops.to_store_registers = dec_thread_store_registers;
|
||||
dec_thread_ops.to_mourn_inferior = dec_thread_mourn_inferior;
|
||||
dec_thread_ops.to_thread_alive = dec_thread_thread_alive;
|
||||
dec_thread_ops.to_find_new_threads = dec_thread_find_new_threads;
|
||||
dec_thread_ops.to_update_thread_list = dec_thread_update_thread_list;
|
||||
dec_thread_ops.to_pid_to_str = dec_thread_pid_to_str;
|
||||
dec_thread_ops.to_stratum = thread_stratum;
|
||||
dec_thread_ops.to_get_ada_task_ptid = dec_thread_get_ada_task_ptid;
|
||||
|
@ -444,6 +444,10 @@ extern struct thread_info* inferior_thread (void);
|
||||
|
||||
extern void update_thread_list (void);
|
||||
|
||||
/* Delete any thread the target says is no longer alive. */
|
||||
|
||||
extern void prune_threads (void);
|
||||
|
||||
/* Return true if PC is in the stepping range of THREAD. */
|
||||
|
||||
int pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread);
|
||||
|
@ -1717,11 +1717,13 @@ update_thread_core (struct lwp_info *info, void *closure)
|
||||
}
|
||||
|
||||
static void
|
||||
thread_db_find_new_threads (struct target_ops *ops)
|
||||
thread_db_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
struct thread_db_info *info;
|
||||
struct inferior *inf;
|
||||
|
||||
prune_threads ();
|
||||
|
||||
ALL_INFERIORS (inf)
|
||||
{
|
||||
struct thread_info *thread;
|
||||
@ -2074,7 +2076,7 @@ init_thread_db_ops (void)
|
||||
thread_db_ops.to_wait = thread_db_wait;
|
||||
thread_db_ops.to_resume = thread_db_resume;
|
||||
thread_db_ops.to_mourn_inferior = thread_db_mourn_inferior;
|
||||
thread_db_ops.to_find_new_threads = thread_db_find_new_threads;
|
||||
thread_db_ops.to_update_thread_list = thread_db_update_thread_list;
|
||||
thread_db_ops.to_pid_to_str = thread_db_pid_to_str;
|
||||
thread_db_ops.to_stratum = thread_stratum;
|
||||
thread_db_ops.to_has_thread_control = tc_schedlock;
|
||||
|
@ -307,7 +307,7 @@ update_thread_private_data (struct thread_info *new_thread,
|
||||
}
|
||||
|
||||
static void
|
||||
procfs_find_new_threads (struct target_ops *ops)
|
||||
procfs_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
procfs_status status;
|
||||
pid_t pid;
|
||||
@ -318,6 +318,8 @@ procfs_find_new_threads (struct target_ops *ops)
|
||||
if (ctl_fd == -1)
|
||||
return;
|
||||
|
||||
prune_threads ();
|
||||
|
||||
pid = ptid_get_pid (inferior_ptid);
|
||||
|
||||
status.tid = 1;
|
||||
@ -631,7 +633,7 @@ procfs_attach (struct target_ops *ops, const char *args, int from_tty)
|
||||
if (!target_is_pushed (ops))
|
||||
push_target (ops);
|
||||
|
||||
procfs_find_new_threads (ops);
|
||||
procfs_update_thread_list (ops);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1195,7 +1197,7 @@ procfs_create_inferior (struct target_ops *ops, char *exec_file,
|
||||
close (fds[2]);
|
||||
|
||||
inferior_ptid = do_attach (pid_to_ptid (pid));
|
||||
procfs_find_new_threads (ops);
|
||||
procfs_update_thread_list (ops);
|
||||
|
||||
inf = current_inferior ();
|
||||
inferior_appeared (inf, pid);
|
||||
@ -1440,7 +1442,7 @@ init_procfs_targets (void)
|
||||
t->to_mourn_inferior = procfs_mourn_inferior;
|
||||
t->to_pass_signals = procfs_pass_signals;
|
||||
t->to_thread_alive = procfs_thread_alive;
|
||||
t->to_find_new_threads = procfs_find_new_threads;
|
||||
t->to_update_thread_list = procfs_update_thread_list;
|
||||
t->to_pid_to_str = procfs_pid_to_str;
|
||||
t->to_stop = procfs_stop;
|
||||
t->to_have_continuable_watchpoint = 1;
|
||||
|
@ -50,11 +50,13 @@ obsd_pid_to_str (struct target_ops *ops, ptid_t ptid)
|
||||
}
|
||||
|
||||
static void
|
||||
obsd_find_new_threads (struct target_ops *ops)
|
||||
obsd_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
pid_t pid = ptid_get_pid (inferior_ptid);
|
||||
struct ptrace_thread_state pts;
|
||||
|
||||
prune_threads ();
|
||||
|
||||
if (ptrace (PT_GET_THREAD_FIRST, pid, (caddr_t)&pts, sizeof pts) == -1)
|
||||
perror_with_name (("ptrace"));
|
||||
|
||||
@ -168,7 +170,7 @@ obsd_add_target (struct target_ops *t)
|
||||
{
|
||||
/* Override some methods to support threads. */
|
||||
t->to_pid_to_str = obsd_pid_to_str;
|
||||
t->to_find_new_threads = obsd_find_new_threads;
|
||||
t->to_update_thread_list = obsd_update_thread_list;
|
||||
t->to_wait = obsd_wait;
|
||||
add_target (t);
|
||||
}
|
||||
|
10
gdb/procfs.c
10
gdb/procfs.c
@ -133,7 +133,7 @@ static target_xfer_partial_ftype procfs_xfer_partial;
|
||||
|
||||
static int procfs_thread_alive (struct target_ops *ops, ptid_t);
|
||||
|
||||
static void procfs_find_new_threads (struct target_ops *ops);
|
||||
static void procfs_update_thread_list (struct target_ops *ops);
|
||||
static char *procfs_pid_to_str (struct target_ops *, ptid_t);
|
||||
|
||||
static int proc_find_memory_regions (struct target_ops *self,
|
||||
@ -196,7 +196,7 @@ procfs_target (void)
|
||||
t->to_files_info = procfs_files_info;
|
||||
t->to_stop = procfs_stop;
|
||||
|
||||
t->to_find_new_threads = procfs_find_new_threads;
|
||||
t->to_update_thread_list = procfs_update_thread_list;
|
||||
t->to_thread_alive = procfs_thread_alive;
|
||||
t->to_pid_to_str = procfs_pid_to_str;
|
||||
|
||||
@ -4646,7 +4646,7 @@ procfs_inferior_created (struct target_ops *ops, int from_tty)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Callback for find_new_threads. Calls "add_thread". */
|
||||
/* Callback for update_thread_list. Calls "add_thread". */
|
||||
|
||||
static int
|
||||
procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr)
|
||||
@ -4663,10 +4663,12 @@ procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr)
|
||||
back to GDB to add to its list. */
|
||||
|
||||
static void
|
||||
procfs_find_new_threads (struct target_ops *ops)
|
||||
procfs_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
procinfo *pi;
|
||||
|
||||
prune_threads ();
|
||||
|
||||
/* Find procinfo for main process. */
|
||||
pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
|
||||
proc_update_threads (pi);
|
||||
|
@ -52,7 +52,7 @@ static const char first_task_name[] = "system__tasking__debug__first_task";
|
||||
static const char ravenscar_runtime_initializer[] =
|
||||
"system__bb__threads__initialize";
|
||||
|
||||
static void ravenscar_find_new_threads (struct target_ops *ops);
|
||||
static void ravenscar_update_thread_list (struct target_ops *ops);
|
||||
static ptid_t ravenscar_running_thread (void);
|
||||
static char *ravenscar_extra_thread_info (struct target_ops *self,
|
||||
struct thread_info *tp);
|
||||
@ -91,7 +91,7 @@ ravenscar_update_inferior_ptid (void)
|
||||
gdb_assert (!ptid_equal (inferior_ptid, null_ptid));
|
||||
|
||||
/* The running thread may not have been added to
|
||||
system.tasking.debug's list yet; so ravenscar_find_new_threads
|
||||
system.tasking.debug's list yet; so ravenscar_update_thread_list
|
||||
may not always add it to the thread list. Add it here. */
|
||||
if (!find_thread_ptid (inferior_ptid))
|
||||
add_thread (inferior_ptid);
|
||||
@ -201,7 +201,7 @@ ravenscar_wait (struct target_ops *ops, ptid_t ptid,
|
||||
if (status->kind != TARGET_WAITKIND_EXITED
|
||||
&& status->kind != TARGET_WAITKIND_SIGNALLED)
|
||||
{
|
||||
ravenscar_find_new_threads (ops);
|
||||
ravenscar_update_thread_list (ops);
|
||||
ravenscar_update_inferior_ptid ();
|
||||
}
|
||||
return inferior_ptid;
|
||||
@ -218,7 +218,7 @@ ravenscar_add_thread (struct ada_task_info *task)
|
||||
}
|
||||
|
||||
static void
|
||||
ravenscar_find_new_threads (struct target_ops *ops)
|
||||
ravenscar_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
ada_build_task_list ();
|
||||
|
||||
@ -368,7 +368,7 @@ init_ravenscar_thread_ops (void)
|
||||
ravenscar_ops.to_store_registers = ravenscar_store_registers;
|
||||
ravenscar_ops.to_prepare_to_store = ravenscar_prepare_to_store;
|
||||
ravenscar_ops.to_thread_alive = ravenscar_thread_alive;
|
||||
ravenscar_ops.to_find_new_threads = ravenscar_find_new_threads;
|
||||
ravenscar_ops.to_update_thread_list = ravenscar_update_thread_list;
|
||||
ravenscar_ops.to_pid_to_str = ravenscar_pid_to_str;
|
||||
ravenscar_ops.to_extra_thread_info = ravenscar_extra_thread_info;
|
||||
ravenscar_ops.to_get_ada_task_ptid = ravenscar_get_ada_task_ptid;
|
||||
|
@ -1790,18 +1790,18 @@ record_btrace_decr_pc_after_break (struct target_ops *ops,
|
||||
return ops->beneath->to_decr_pc_after_break (ops->beneath, gdbarch);
|
||||
}
|
||||
|
||||
/* The to_find_new_threads method of target record-btrace. */
|
||||
/* The to_update_thread_list method of target record-btrace. */
|
||||
|
||||
static void
|
||||
record_btrace_find_new_threads (struct target_ops *ops)
|
||||
record_btrace_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
/* Don't expect new threads if we're replaying. */
|
||||
/* We don't add or remove threads during replay. */
|
||||
if (record_btrace_is_replaying (ops))
|
||||
return;
|
||||
|
||||
/* Forward the request. */
|
||||
ops = ops->beneath;
|
||||
ops->to_find_new_threads (ops);
|
||||
ops->to_update_thread_list (ops);
|
||||
}
|
||||
|
||||
/* The to_thread_alive method of target record-btrace. */
|
||||
@ -1963,7 +1963,7 @@ init_record_btrace_ops (void)
|
||||
ops->to_get_tailcall_unwinder = &record_btrace_to_get_tailcall_unwinder;
|
||||
ops->to_resume = record_btrace_resume;
|
||||
ops->to_wait = record_btrace_wait;
|
||||
ops->to_find_new_threads = record_btrace_find_new_threads;
|
||||
ops->to_update_thread_list = record_btrace_update_thread_list;
|
||||
ops->to_thread_alive = record_btrace_thread_alive;
|
||||
ops->to_goto_record_begin = record_btrace_goto_begin;
|
||||
ops->to_goto_record_end = record_btrace_goto_end;
|
||||
|
17
gdb/remote.c
17
gdb/remote.c
@ -2753,16 +2753,19 @@ remote_get_threads_with_qthreadinfo (struct target_ops *ops,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Implement the to_find_new_threads function for the remote
|
||||
/* Implement the to_update_thread_list function for the remote
|
||||
targets. */
|
||||
|
||||
static void
|
||||
remote_threads_info (struct target_ops *ops)
|
||||
remote_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
struct remote_state *rs = get_remote_state ();
|
||||
struct threads_listing_context context;
|
||||
struct cleanup *old_chain;
|
||||
|
||||
/* Delete GDB-side threads no longer found on the target. */
|
||||
prune_threads ();
|
||||
|
||||
context.items = NULL;
|
||||
old_chain = make_cleanup (clear_threads_listing_context, &context);
|
||||
|
||||
@ -2776,7 +2779,7 @@ remote_threads_info (struct target_ops *ops)
|
||||
int i;
|
||||
struct thread_item *item;
|
||||
|
||||
/* Add threads we don't know about yet to our list. */
|
||||
/* Now add threads we don't know about yet to our list. */
|
||||
for (i = 0;
|
||||
VEC_iterate (thread_item_t, context.items, i, item);
|
||||
++i)
|
||||
@ -3424,7 +3427,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
|
||||
controlling. We default to adding them in the running state.
|
||||
The '?' query below will then tell us about which threads are
|
||||
stopped. */
|
||||
remote_threads_info (target);
|
||||
remote_update_thread_list (target);
|
||||
}
|
||||
else if (packet_support (PACKET_QNonStop) == PACKET_ENABLE)
|
||||
{
|
||||
@ -3476,7 +3479,7 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
|
||||
}
|
||||
|
||||
/* Fetch thread list. */
|
||||
target_find_new_threads ();
|
||||
target_update_thread_list ();
|
||||
|
||||
/* Let the stub know that we want it to return the thread. */
|
||||
set_continue_thread (minus_one_ptid);
|
||||
@ -4446,7 +4449,7 @@ extended_remote_attach_1 (struct target_ops *target, const char *args,
|
||||
struct thread_info *thread;
|
||||
|
||||
/* Get list of threads. */
|
||||
remote_threads_info (target);
|
||||
remote_update_thread_list (target);
|
||||
|
||||
thread = first_thread_of_process (pid);
|
||||
if (thread)
|
||||
@ -11456,7 +11459,7 @@ Specify the serial device it is connected to\n\
|
||||
remote_ops.to_pass_signals = remote_pass_signals;
|
||||
remote_ops.to_program_signals = remote_program_signals;
|
||||
remote_ops.to_thread_alive = remote_thread_alive;
|
||||
remote_ops.to_find_new_threads = remote_threads_info;
|
||||
remote_ops.to_update_thread_list = remote_update_thread_list;
|
||||
remote_ops.to_pid_to_str = remote_pid_to_str;
|
||||
remote_ops.to_extra_thread_info = remote_threads_extra_info;
|
||||
remote_ops.to_get_ada_task_ptid = remote_get_ada_task_ptid;
|
||||
|
@ -624,7 +624,7 @@ check_for_thread_db (void)
|
||||
if (ptid_get_pid (ptid) != -1)
|
||||
inferior_ptid = ptid;
|
||||
|
||||
target_find_new_threads ();
|
||||
target_update_thread_list ();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1056,11 +1056,11 @@ solaris_pid_to_str (struct target_ops *ops, ptid_t ptid)
|
||||
}
|
||||
|
||||
|
||||
/* Worker bee for find_new_threads. Callback function that gets
|
||||
/* Worker bee for update_thread_list. Callback function that gets
|
||||
called once per user-level thread (i.e. not for LWP's). */
|
||||
|
||||
static int
|
||||
sol_find_new_threads_callback (const td_thrhandle_t *th, void *ignored)
|
||||
sol_update_thread_list_callback (const td_thrhandle_t *th, void *ignored)
|
||||
{
|
||||
td_err_e retval;
|
||||
td_thrinfo_t ti;
|
||||
@ -1078,15 +1078,18 @@ sol_find_new_threads_callback (const td_thrhandle_t *th, void *ignored)
|
||||
}
|
||||
|
||||
static void
|
||||
sol_find_new_threads (struct target_ops *ops)
|
||||
sol_update_thread_list (struct target_ops *ops)
|
||||
{
|
||||
struct target_ops *beneath = find_target_beneath (ops);
|
||||
|
||||
/* First Find any new LWP's. */
|
||||
beneath->to_find_new_threads (beneath);
|
||||
/* Delete dead threads. */
|
||||
prune_threads ();
|
||||
|
||||
/* Find any new LWP's. */
|
||||
beneath->to_update_thread_list (beneath);
|
||||
|
||||
/* Then find any new user-level threads. */
|
||||
p_td_ta_thr_iter (main_ta, sol_find_new_threads_callback, (void *) 0,
|
||||
p_td_ta_thr_iter (main_ta, sol_update_thread_list_callback, (void *) 0,
|
||||
TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
|
||||
TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
|
||||
}
|
||||
@ -1200,7 +1203,7 @@ sol_get_ada_task_ptid (struct target_ops *self, long lwp, long thread)
|
||||
{
|
||||
/* The list of threads is probably not up to date. Find any
|
||||
thread that is missing from the list, and try again. */
|
||||
sol_find_new_threads (¤t_target);
|
||||
sol_update_thread_list (¤t_target);
|
||||
thread_info = iterate_over_threads (thread_db_find_thread_from_tid,
|
||||
&thread);
|
||||
}
|
||||
@ -1225,7 +1228,7 @@ init_sol_thread_ops (void)
|
||||
sol_thread_ops.to_mourn_inferior = sol_thread_mourn_inferior;
|
||||
sol_thread_ops.to_thread_alive = sol_thread_alive;
|
||||
sol_thread_ops.to_pid_to_str = solaris_pid_to_str;
|
||||
sol_thread_ops.to_find_new_threads = sol_find_new_threads;
|
||||
sol_thread_ops.to_update_thread_list = sol_update_thread_list;
|
||||
sol_thread_ops.to_stratum = thread_stratum;
|
||||
sol_thread_ops.to_get_ada_task_ptid = sol_get_ada_task_ptid;
|
||||
sol_thread_ops.to_magic = OPS_MAGIC;
|
||||
|
@ -1302,23 +1302,23 @@ debug_thread_alive (struct target_ops *self, ptid_t arg1)
|
||||
}
|
||||
|
||||
static void
|
||||
delegate_find_new_threads (struct target_ops *self)
|
||||
delegate_update_thread_list (struct target_ops *self)
|
||||
{
|
||||
self = self->beneath;
|
||||
self->to_find_new_threads (self);
|
||||
self->to_update_thread_list (self);
|
||||
}
|
||||
|
||||
static void
|
||||
tdefault_find_new_threads (struct target_ops *self)
|
||||
tdefault_update_thread_list (struct target_ops *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
debug_find_new_threads (struct target_ops *self)
|
||||
debug_update_thread_list (struct target_ops *self)
|
||||
{
|
||||
fprintf_unfiltered (gdb_stdlog, "-> %s->to_find_new_threads (...)\n", debug_target.to_shortname);
|
||||
debug_target.to_find_new_threads (&debug_target);
|
||||
fprintf_unfiltered (gdb_stdlog, "<- %s->to_find_new_threads (", debug_target.to_shortname);
|
||||
fprintf_unfiltered (gdb_stdlog, "-> %s->to_update_thread_list (...)\n", debug_target.to_shortname);
|
||||
debug_target.to_update_thread_list (&debug_target);
|
||||
fprintf_unfiltered (gdb_stdlog, "<- %s->to_update_thread_list (", debug_target.to_shortname);
|
||||
target_debug_print_struct_target_ops_p (&debug_target);
|
||||
fputs_unfiltered (")\n", gdb_stdlog);
|
||||
}
|
||||
@ -3828,8 +3828,8 @@ install_delegators (struct target_ops *ops)
|
||||
ops->to_program_signals = delegate_program_signals;
|
||||
if (ops->to_thread_alive == NULL)
|
||||
ops->to_thread_alive = delegate_thread_alive;
|
||||
if (ops->to_find_new_threads == NULL)
|
||||
ops->to_find_new_threads = delegate_find_new_threads;
|
||||
if (ops->to_update_thread_list == NULL)
|
||||
ops->to_update_thread_list = delegate_update_thread_list;
|
||||
if (ops->to_pid_to_str == NULL)
|
||||
ops->to_pid_to_str = delegate_pid_to_str;
|
||||
if (ops->to_extra_thread_info == NULL)
|
||||
@ -4062,7 +4062,7 @@ install_dummy_methods (struct target_ops *ops)
|
||||
ops->to_pass_signals = tdefault_pass_signals;
|
||||
ops->to_program_signals = tdefault_program_signals;
|
||||
ops->to_thread_alive = tdefault_thread_alive;
|
||||
ops->to_find_new_threads = tdefault_find_new_threads;
|
||||
ops->to_update_thread_list = tdefault_update_thread_list;
|
||||
ops->to_pid_to_str = default_pid_to_str;
|
||||
ops->to_extra_thread_info = tdefault_extra_thread_info;
|
||||
ops->to_thread_name = tdefault_thread_name;
|
||||
@ -4205,7 +4205,7 @@ init_debug_target (struct target_ops *ops)
|
||||
ops->to_pass_signals = debug_pass_signals;
|
||||
ops->to_program_signals = debug_program_signals;
|
||||
ops->to_thread_alive = debug_thread_alive;
|
||||
ops->to_find_new_threads = debug_find_new_threads;
|
||||
ops->to_update_thread_list = debug_update_thread_list;
|
||||
ops->to_pid_to_str = debug_pid_to_str;
|
||||
ops->to_extra_thread_info = debug_extra_thread_info;
|
||||
ops->to_thread_name = debug_thread_name;
|
||||
|
@ -3048,9 +3048,9 @@ target_thread_alive (ptid_t ptid)
|
||||
}
|
||||
|
||||
void
|
||||
target_find_new_threads (void)
|
||||
target_update_thread_list (void)
|
||||
{
|
||||
current_target.to_find_new_threads (¤t_target);
|
||||
current_target.to_update_thread_list (¤t_target);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -563,7 +563,7 @@ struct target_ops
|
||||
|
||||
int (*to_thread_alive) (struct target_ops *, ptid_t ptid)
|
||||
TARGET_DEFAULT_RETURN (0);
|
||||
void (*to_find_new_threads) (struct target_ops *)
|
||||
void (*to_update_thread_list) (struct target_ops *)
|
||||
TARGET_DEFAULT_IGNORE ();
|
||||
char *(*to_pid_to_str) (struct target_ops *, ptid_t)
|
||||
TARGET_DEFAULT_FUNC (default_pid_to_str);
|
||||
@ -1568,9 +1568,9 @@ extern void target_program_signals (int nsig, unsigned char *program_signals);
|
||||
|
||||
extern int target_thread_alive (ptid_t ptid);
|
||||
|
||||
/* Query for new threads and add them to the thread list. */
|
||||
/* Sync the target's threads with GDB's thread list. */
|
||||
|
||||
extern void target_find_new_threads (void);
|
||||
extern void target_update_thread_list (void);
|
||||
|
||||
/* Make target stop in a continuable fashion. (For instance, under
|
||||
Unix, this should act like SIGSTOP). Note that this function is
|
||||
|
@ -68,7 +68,6 @@ static int thread_alive (struct thread_info *);
|
||||
static void info_threads_command (char *, int);
|
||||
static void thread_apply_command (char *, int);
|
||||
static void restore_current_thread (ptid_t);
|
||||
static void prune_threads (void);
|
||||
|
||||
/* Data to cleanup thread array. */
|
||||
|
||||
@ -622,7 +621,9 @@ thread_alive (struct thread_info *tp)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
/* See gdbthreads.h. */
|
||||
|
||||
void
|
||||
prune_threads (void)
|
||||
{
|
||||
struct thread_info *tp, *next;
|
||||
@ -1586,8 +1587,7 @@ update_threads_executing (void)
|
||||
void
|
||||
update_thread_list (void)
|
||||
{
|
||||
prune_threads ();
|
||||
target_find_new_threads ();
|
||||
target_update_thread_list ();
|
||||
update_threads_executing ();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user