37 #include <sys/types.h>
157 return (ss_bps != NULL
202 highest_thread_num = 0;
207 for (tp = thread_list; tp; tp = tpnext)
214 threads_executing = 0;
225 tp =
xcalloc (1,
sizeof (*tp));
297 if (print_thread_events)
319 for (tp = thread_list; tp; tpprev = tp, tp = tp->
next)
358 thread_list = tp->
next;
384 for (tp = thread_list; tp; tp = tp->
next)
397 for (tp = thread_list; tp; tp = tp->
next)
424 for (tp = thread_list; tp; tp =
next)
427 if ((*callback) (tp, data))
440 for (tp = thread_list; tp; tp = tp->
next)
451 for (tp = thread_list; tp; tp = tp->
next)
463 for (tp = thread_list; tp; tp = tp->
next)
486 for (tp = thread_list; tp; tp = tp->
next)
501 for (tp = thread_list; tp; tp = tp->
next)
503 if (ret == NULL || tp->
num < ret->
num)
581 for (tp = thread_list; tp; tp = tp->
next)
587 current_thread = tp->
num;
595 if (current_thread != -1)
743 struct value *lastval = NULL;
784 for (tp = thread_list; tp; tp = tp->
next)
857 for (tp = thread_list; tp; tp = tp->
next)
870 threads_executing = 1;
874 threads_executing = 0;
893 for (tp = thread_list; tp; tp = tp->
next)
921 for (tp = thread_list; tp; tp = tp->
next)
983 char *extra_info, *
name, *target_id;
1001 for (tp = thread_list; tp; tp = tp->
next)
1017 if (requested_threads == NULL || *requested_threads ==
'\0')
1035 for (tp = thread_list; tp; tp = tp->
next)
1045 if (requested_threads != NULL && *requested_threads !=
'\0')
1046 error (
_(
"Requested thread not found in requested process"));
1051 current_thread = tp->
num;
1100 if (extra_info && name)
1101 contents =
xstrprintf (
"%s \"%s\" (%s)", target_id,
1103 else if (extra_info)
1104 contents =
xstrprintf (
"%s (%s)", target_id, extra_info);
1106 contents =
xstrprintf (
"%s \"%s\"", target_id, name);
1108 contents = xstrdup (target_id);
1130 char *state =
"stopped";
1148 if (pid == -1 && requested_threads == NULL)
1156 if (current_thread != -1 &&
is_exited (current_ptid))
1158 The current thread <Thread ID %d> has terminated. See `help thread'.\n",
1160 else if (thread_list
1161 && current_thread == -1
1164 No selected thread. See `help thread'.\n");
1230 if (frame_level == -1)
1242 count = frame_level;
1272 warning (
_(
"Couldn't restore frame #%d in "
1273 "current thread. Bottom (innermost) frame selected:"),
1349 for (k = 0; k != ta_cleanup->
count; k++)
1411 return ((((*ap)->num > (*bp)->num) - ((*ap)->num < (*bp)->num))
1412 * (tp_array_compar_ascending ? +1 : -1));
1431 tp_array_compar_ascending = 0;
1436 tp_array_compar_ascending = 1;
1439 if (cmd == NULL || *cmd ==
'\000')
1440 error (
_(
"Please specify a command following the thread ID list"));
1448 saved_cmd = xstrdup (cmd);
1478 ta_cleanup.
count = i;
1481 for (k = 0; k != i; k++)
1491 strcpy (cmd, saved_cmd);
1506 if (tidlist == NULL || *tidlist ==
'\000')
1507 error (
_(
"Please specify a thread ID list"));
1509 for (cmd = tidlist; *cmd !=
'\000' && !isalpha (*cmd); cmd++);
1512 error (
_(
"Please specify a command following the thread ID list"));
1516 saved_cmd = xstrdup (cmd);
1532 warning (
_(
"Unknown thread %d."), start);
1534 warning (
_(
"Thread %d has terminated."), start);
1544 strcpy (cmd, saved_cmd);
1560 error (
_(
"No thread selected"));
1589 error (
_(
"No thread selected"));
1595 info->
name = arg ? xstrdup (arg) : NULL;
1605 unsigned long match = 0;
1607 if (arg == NULL || *arg ==
'\0')
1608 error (
_(
"Command requires an argument."));
1612 error (
_(
"Invalid regexp (%s): %s"), tmp, arg);
1615 for (tp = thread_list; tp; tp = tp->
next)
1617 if (tp->
name != NULL && re_exec (tp->
name))
1625 if (tmp != NULL && re_exec (tmp))
1633 if (tmp != NULL && re_exec (tmp))
1641 if (tmp != NULL && re_exec (tmp))
1653 int print_thread_events = 1;
1659 _(
"Printing of thread events is %s.\n"),
1674 error (
_(
"Thread ID %d not known."), num);
1677 error (
_(
"Thread ID %d has terminated."), num);
1723 threads_executing = 0;
1728 threads_executing = 1;
1744 static struct value *
1751 (tp ? tp->
num : 0));
1772 _(
"Display currently known threads.\n\
1773 Usage: info threads [ID]...\n\
1774 Optional arguments are thread IDs with spaces between.\n\
1775 If no arguments, all threads are displayed."));
1778 Use this command to switch between threads.\n\
1779 The new thread ID must be currently known."),
1780 &thread_cmd_list,
"thread ", 1, &
cmdlist);
1783 _(
"Apply a command to a list of threads."),
1784 &thread_apply_list,
"thread apply ", 1, &thread_cmd_list);
1788 Apply a command to all threads.\n\
1790 Usage: thread apply all [-ascending] <command>\n\
1791 -ascending: Call <command> for all threads in ascending order.\n\
1792 The default is descending order.\
1794 &thread_apply_list);
1797 _(
"Set the current thread's name.\n\
1798 Usage: thread name [NAME]\n\
1799 If NAME is not given, then any existing name is removed."), &thread_cmd_list);
1802 Find threads that match a regular expression.\n\
1803 Usage: thread find REGEXP\n\
1804 Will display thread ids whose name, target ID, or extra info matches REGEXP."),
1810 &print_thread_events,
_(
"\
1811 Set printing of thread events (such as thread start and exit)."),
_(
"\
1812 Show printing of thread events (such as thread start and exit)."), NULL,
struct frame_info * frame_find_by_id(struct frame_id id)
int target_thread_alive(ptid_t ptid)
struct private_thread_info * priv
#define target_has_registers
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
void do_all_intermediate_continuations_thread(struct thread_info *thread, int err)
struct cleanup * enable_thread_stack_temporaries(ptid_t ptid)
int pid_to_thread_id(ptid_t ptid)
struct frame_info * get_selected_frame(const char *message)
int pc_in_thread_step_range(CORE_ADDR pc, struct thread_info *thread)
CORE_ADDR step_range_start
int ptid_is_pid(ptid_t ptid)
void update_thread_list(void)
void ui_out_field_int(struct ui_out *uiout, const char *fldname, int value)
struct frame_info * get_current_frame(void)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
static void do_restore_current_thread_cleanup(void *arg)
static void restore_current_thread_cleanup_dtor(void *arg)
struct regcache * get_thread_regcache(ptid_t ptid)
void bpstat_clear(bpstat *bsp)
static struct cleanup * cleanup_chain
struct target_waitstatus pending_follow
LONGEST value_as_long(struct value *val)
int number_is_in_list(const char *list, int number)
void warning(const char *fmt,...)
void thread_command(char *tidstr, int from_tty)
ptid_t thread_id_to_pid(int num)
struct thread_info * add_thread(ptid_t ptid)
void set_stop_requested(ptid_t ptid, int stop)
struct cleanup * make_cleanup_ui_out_table_begin_end(struct ui_out *ui_out, int nr_cols, int nr_rows, const char *tblid)
int in_thread_list(ptid_t ptid)
void finish_thread_state_cleanup(void *arg)
void select_frame(struct frame_info *fi)
int ui_out_is_mi_like_p(struct ui_out *uiout)
int is_executing(ptid_t ptid)
char * target_thread_name(struct thread_info *info)
void delete_thread_silent(ptid_t ptid)
#define VEC_safe_push(T, V, O)
struct inferior * find_inferior_ptid(ptid_t ptid)
struct cmd_list_element * cmdlist
void delete_step_resume_breakpoint(struct thread_info *tp)
char * target_pid_to_str(ptid_t ptid)
char * skip_spaces(char *chp)
void execute_command(char *, int)
static struct value * thread_id_make_value(struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
static int threads_executing
struct thread_info ** tp_array
struct thread_info * add_thread_with_info(ptid_t ptid, struct private_thread_info *priv)
void ui_out_text(struct ui_out *uiout, const char *string)
void printf_filtered(const char *format,...)
void set_current_program_space(struct program_space *pspace)
struct thread_info * add_thread_silent(ptid_t ptid)
static void disable_thread_stack_temporaries(void *data)
int frame_id_eq(struct frame_id l, struct frame_id r)
int check_for_argument(char **str, char *arg, int arg_len)
void switch_to_thread(ptid_t ptid)
int thread_has_single_step_breakpoint_here(struct thread_info *tp, struct address_space *aspace, CORE_ADDR addr)
#define VEC_iterate(T, V, I, P)
struct frame_id get_frame_id(struct frame_info *fi)
int thread_has_single_step_breakpoints_set(struct thread_info *tp)
struct cleanup * make_cleanup_dtor(make_cleanup_ftype *function, void *arg, make_cleanup_dtor_ftype *dtor)
void btrace_teardown(struct thread_info *tp)
void ui_out_field_skip(struct ui_out *uiout, const char *fldname)
void do_all_continuations_thread(struct thread_info *thread, int err)
struct breakpoint * exception_resume_breakpoint
struct cleanup * make_cleanup_ui_out_list_begin_end(struct ui_out *uiout, const char *id)
struct cleanup * make_cleanup_ui_out_tuple_begin_end(struct ui_out *uiout, const char *id)
void init_thread_list(void)
int stack_temporaries_enabled
struct program_space * pspace
void fprintf_filtered(struct ui_file *stream, const char *format,...)
struct frame_info * find_relative_frame(struct frame_info *, int *)
struct thread_info * find_thread_id(int num)
value_vec * stack_temporaries
void ui_out_message(struct ui_out *uiout, int verbosity, const char *format,...)
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
void observer_notify_target_resumed(ptid_t ptid)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
ptid_t pid_to_ptid(int pid)
static void info_threads_command(char *, int)
struct frame_info * get_selected_frame_if_set(void)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
int value_in_thread_stack_temporaries(struct value *val, ptid_t ptid)
struct thread_control_state control
static void thread_name_command(char *arg, int from_tty)
void _initialize_thread(void)
void push_thread_stack_temporary(ptid_t ptid, struct value *v)
static void update_threads_executing(void)
struct cmd_list_element * add_info(const char *name, cmd_cfunc_ftype *fun, const char *doc)
static int tp_array_compar_ascending
struct value * value_from_longest(struct type *type, LONGEST num)
struct thread_info * inferior_thread(void)
void finish_thread_state(ptid_t ptid)
void set_executing(ptid_t ptid, int executing)
static int do_captured_thread_select(struct ui_out *uiout, void *tidstr)
void observer_notify_new_thread(struct thread_info *t)
static void thread_apply_all_command(char *, int)
static int highest_thread_num
struct cmd_list_element * setprintlist
#define target_has_memory
char * xstrprintf(const char *format,...)
static struct thread_info * new_thread(ptid_t ptid)
void printf_unfiltered(const char *format,...)
int is_running(ptid_t ptid)
void annotate_thread_changed(void)
struct thread_info * iterate_over_threads(int(*callback)(struct thread_info *, void *), void *data)
void delete_single_step_breakpoints(struct thread_info *tp)
struct thread_info * find_thread_ptid(ptid_t ptid)
struct thread_info * first_thread_of_process(int pid)
void delete_exception_resume_breakpoint(struct thread_info *tp)
int ptid_get_pid(ptid_t ptid)
struct value * get_last_thread_stack_temporary(ptid_t ptid)
static void free_thread(struct thread_info *tp)
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
int catch_exceptions_with_msg(struct ui_out *func_uiout, catch_exceptions_ftype *func, void *func_args, char **gdberrmsg, return_mask mask)
static void restore_current_thread(ptid_t)
void target_update_thread_list(void)
static void clear_thread_inferior_resources(struct thread_info *tp)
void set_running(ptid_t ptid, int running)
static void thread_find_command(char *arg, int from_tty)
static int thread_alive(struct thread_info *)
int valid_thread_id(int num)
#define ALL_NON_EXITED_THREADS(T)
int frame_relative_level(struct frame_info *fi)
enum target_waitkind kind
CORE_ADDR regcache_read_pc(struct regcache *regcache)
struct frame_id selected_frame_id
int is_stopped(ptid_t ptid)
void observer_notify_thread_exit(struct thread_info *t, int silent)
int thread_stack_temporaries_enabled_p(ptid_t ptid)
void ui_out_table_header(struct ui_out *uiout, int width, enum ui_align alignment, const char *col_name, const char *colhdr)
void observer_notify_thread_ptid_changed(ptid_t old_ptid, ptid_t new_ptid)
struct breakpoint * single_step_breakpoints
struct thread_info * any_live_thread_of_process(int pid)
struct thread_info * any_thread_of_process(int pid)
struct inferior * find_inferior_id(int num)
struct cmd_list_element * showprintlist
static void thread_apply_command(char *, int)
int target_core_of_thread(ptid_t ptid)
static int is_thread_state(ptid_t ptid, enum thread_state state)
struct inferior * current_inferior(void)
void delete_exited_threads(void)
EXTERN_C char * re_comp(const char *)
struct value * parse_and_eval(const char *exp)
enum gdb_rc gdb_thread_select(struct ui_out *uiout, char *tidstr, char **error_message)
void observer_notify_thread_stop_requested(ptid_t ptid)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
int threads_are_executing(void)
static void delete_thread_breakpoint(struct breakpoint **bp_p)
void ui_out_field_string(struct ui_out *uiout, const char *fldname, const char *string)
void(* private_dtor)(struct private_thread_info *)
struct breakpoint * step_resume_breakpoint
void ui_out_table_body(struct ui_out *uiout)
enum gdb_rc gdb_list_thread_ids(struct ui_out *uiout, char **error_message)
static void restore_selected_frame(struct frame_id a_frame_id, int frame_level)
struct thread_info * thread_list
void reinit_frame_cache(void)
struct ui_out * current_uiout
static windows_thread_info * current_thread
void annotate_new_thread(void)
int get_number_or_range(struct get_number_or_range_state *state)
PTR xcalloc(size_t number, size_t size)
void delete_longjmp_breakpoint_at_next_stop(int thread)
void delete_breakpoint(struct breakpoint *bpt)
struct internalvar * create_internalvar_type_lazy(const char *name, const struct internalvar_funcs *funcs, void *data)
int is_exited(ptid_t ptid)
static void delete_thread_1(ptid_t ptid, int silent)
void error(const char *fmt,...)
static void set_thread_refcount(void *data)
static int tp_array_compar(const void *ap_voidp, const void *bp_voidp)
int breakpoint_has_location_inserted_here(struct breakpoint *bp, struct address_space *aspace, CORE_ADDR pc)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
#define target_extra_thread_info(TP)
static int do_captured_list_thread_ids(struct ui_out *uiout, void *arg)
void thread_change_ptid(ptid_t old_ptid, ptid_t new_ptid)
void set_current_inferior(struct inferior *inf)
void init_number_or_range(struct get_number_or_range_state *state, const char *string)
void do_cleanups(struct cleanup *old_chain)
static void delete_at_next_stop(struct breakpoint **bp)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void delete_thread(ptid_t ptid)
struct cleanup * make_cleanup_restore_current_thread(void)
struct thread_info * next
static void show_print_thread_events(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
#define ALL_THREADS_SAFE(T, TMP)
void print_thread_info(struct ui_out *uiout, char *requested_threads, int pid)