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):
Add describing comment. Return -1 if the qL packet is not
supported.
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);
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
}
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)
{
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;
sections. */
TRY_CATCH (except, RETURN_MASK_ERROR)
{
- target_find_new_threads ();
+ target_update_thread_list ();
}
if (except.reason < 0)
return 0;
}
-/* Implement the find_new_thread target_ops method. */
+/* Find new threads. */
static void
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. */
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;
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);
}
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;
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;
}
static void
-procfs_find_new_threads (struct target_ops *ops)
+procfs_update_thread_list (struct target_ops *ops)
{
procfs_status status;
pid_t pid;
if (ctl_fd == -1)
return;
+ prune_threads ();
+
pid = ptid_get_pid (inferior_ptid);
status.tid = 1;
if (!target_is_pushed (ops))
push_target (ops);
- procfs_find_new_threads (ops);
+ procfs_update_thread_list (ops);
}
static void
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);
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;
}
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"));
{
/* 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);
}
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,
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;
#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)
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);
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);
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);
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;
}
static void
-ravenscar_find_new_threads (struct target_ops *ops)
+ravenscar_update_thread_list (struct target_ops *ops)
{
ada_build_task_list ();
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;
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. */
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;
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);
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)
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)
{
}
/* 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);
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)
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;
if (ptid_get_pid (ptid) != -1)
inferior_ptid = ptid;
- target_find_new_threads ();
+ target_update_thread_list ();
break;
default:
}
\f
-/* 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;
}
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);
}
{
/* 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);
}
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;
}
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);
}
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)
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;
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;
}
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
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);
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
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. */
return 1;
}
-static void
+/* See gdbthreads.h. */
+
+void
prune_threads (void)
{
struct thread_info *tp, *next;
void
update_thread_list (void)
{
- prune_threads ();
- target_find_new_threads ();
+ target_update_thread_list ();
update_threads_executing ();
}