36 #include <sys/types.h> 85 const std::vector<thread_info *> &
m_thrds;
162 return (ss_bps != NULL
449 if (tp->ptid ==
ptid)
457 if (!tp->deletable ())
559 if ((*callback) (tp, data))
844 struct value *lastval = NULL;
1056 int any_started = 0;
1105 error (
_(
"No thread selected."));
1109 error (
_(
"The current thread has terminated"));
1117 error (
_(
"Selected thread is running."));
1161 if (requested_threads != NULL && *requested_threads !=
'\0')
1176 if (requested_threads != NULL && *requested_threads !=
'\0')
1177 error (
_(
"Requested thread not found in requested process"));
1193 int global_ids,
int pid,
1194 int show_global_ids)
1198 const char *extra_info, *
name, *target_id;
1213 list_emitter.
emplace (uiout,
"threads");
1221 global_ids,
pid, tp))
1229 if (requested_threads == NULL || *requested_threads ==
'\0')
1230 uiout->
message (
_(
"No threads.\n"));
1232 uiout->
message (
_(
"No threads match '%s'.\n"),
1237 table_emitter.
emplace (uiout, show_global_ids ? 5 : 4,
1238 n_threads,
"threads");
1242 if (show_global_ids)
1257 global_ids,
pid, tp))
1264 if (tp->
ptid == current_ptid)
1298 if (extra_info &&
name)
1301 else if (extra_info)
1302 contents =
string_printf (
"%s (%s)", target_id, extra_info);
1306 contents = target_id;
1312 uiout->
text (
"(running)\n");
1326 const char *state =
"stopped";
1343 if (
pid == -1 && requested_threads == NULL)
1356 The current thread <Thread ID %s> has terminated. See `help thread'.\n",
1360 No selected thread. See `help thread'.\n");
1381 int show_global_ids = 0;
1387 show_global_ids = 1;
1460 if (frame_level == -1)
1472 count = frame_level;
1502 warning (
_(
"Couldn't restore frame #%d in " 1503 "current thread. Bottom (innermost) frame selected:"),
1658 if (cmd == NULL || *cmd ==
'\000')
1659 error (
_(
"Please specify a command following the thread ID list"));
1671 std::vector<thread_info *> thr_list_cpy;
1672 thr_list_cpy.reserve (tc);
1679 thr_list_cpy.push_back (tp);
1689 std::sort (thr_list_cpy.begin (), thr_list_cpy.end (),
tp_array_compar);
1711 const char *cmd = NULL;
1714 if (tidlist == NULL || *tidlist ==
'\000')
1715 error (
_(
"Please specify a thread ID list"));
1720 int inf_num, thr_start, thr_end;
1730 error (
_(
"Please specify a command following the thread ID list"));
1732 if (tidlist == cmd || !isalpha (cmd[0]))
1742 int inf_num, thr_num;
1744 parser.
get_tid (&inf_num, &thr_num);
1753 warning (
_(
"Unknown inferior %d"), inf_num);
1760 if (thr_num >=
inf->highest_thread_num)
1771 warning (
_(
"Unknown thread %d.%d"), inf_num, thr_num);
1773 warning (
_(
"Unknown thread %d"), thr_num);
1800 error (
_(
"No thread selected"));
1848 error (
_(
"No thread selected"));
1854 info->
name = arg ? xstrdup (arg) : NULL;
1864 unsigned long match = 0;
1866 if (arg == NULL || *arg ==
'\0')
1867 error (
_(
"Command requires an argument."));
1871 error (
_(
"Invalid regexp (%s): %s"), tmp, arg);
1876 if (tp->
name != NULL && re_exec (tp->
name))
1884 if (tmp != NULL && re_exec (tmp))
1892 if (tmp != NULL && re_exec (tmp))
1900 if (tmp != NULL && re_exec (tmp))
1918 _(
"Printing of thread events is %s.\n"),
1928 error (
_(
"Thread ID %s has terminated."), tidstr);
1943 user_selected_what selection)
1956 uiout->
text (
"[Switching to thread ");
1967 uiout->
text (
"(running)\n");
2010 static struct value *
2030 static struct value *
2041 static struct value *
2075 _(
"Display currently known threads.\n\ 2076 Usage: info threads [-gid] [ID]...\n\ 2077 -gid: Show global thread IDs.\n\ 2078 If ID is given, it is a space-separated list of IDs of threads to display.\n\ 2079 Otherwise, all threads are displayed."));
2082 Use this command to switch between threads.\n\ 2083 The new thread ID must be currently known."),
2087 _(
"Apply a command to a list of threads."),
2092 Apply a command to all threads.\n\ 2094 Usage: thread apply all [-ascending] <command>\n\ 2095 -ascending: Call <command> for all threads in ascending order.\n\ 2096 The default is descending order.\ 2098 &thread_apply_list);
2101 _(
"Set the current thread's name.\n\ 2102 Usage: thread name [NAME]\n\ 2103 If NAME is not given, then any existing name is removed."), &
thread_cmd_list);
2106 Find threads that match a regular expression.\n\ 2107 Usage: thread find REGEXP\n\ 2108 Will display thread ids whose name, target ID, or extra info matches REGEXP."),
2115 Set printing of thread events (such as thread start and exit)."),
_(
"\ 2116 Show printing of thread events (such as thread start and exit)."), NULL,
struct frame_info * frame_find_by_id(struct frame_id id)
void print_selected_thread_frame(struct ui_out *uiout, user_selected_what selection)
int target_thread_alive(ptid_t ptid)
#define target_has_registers
static struct thread_info * find_thread_id(struct inferior *inf, int thr_num)
struct cleanup * enable_thread_stack_temporaries(ptid_t ptid)
int ptid_is_pid(const 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
void update_thread_list(void)
ptid_t global_thread_id_to_ptid(int global_id)
struct frame_info * get_current_frame(void)
void field_string(const char *fldname, const char *string)
int ptid_get_pid(const ptid_t &ptid)
struct regcache * get_thread_regcache(ptid_t ptid)
void bpstat_clear(bpstat *bsp)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
int valid_global_thread_id(int global_id)
static void step_over_chain_remove(struct thread_info **list_p, struct thread_info *tp)
int number_is_in_list(const char *list, int number)
void warning(const char *fmt,...)
struct thread_info * add_thread(ptid_t ptid)
void thread_fsm_delete(struct thread_fsm *self)
value_vec * stack_temporaries
void set_stop_requested(ptid_t ptid, int stop)
int in_thread_list(ptid_t ptid)
void ATTRIBUTE_NORETURN invalid_thread_id_error(const char *string)
void field_skip(const char *fldname)
void finish_thread_state_cleanup(void *arg)
static void thread_apply_all_command(const char *cmd, int from_tty)
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
void select_frame(struct frame_info *fi)
static void thread_apply_command(const char *tidlist, int from_tty)
void * memset(T *s, int c, size_t n)=delete
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
int is_executing(ptid_t ptid)
void observer_notify_user_selected_context_changed(user_selected_what selection)
bool get_tid(int *inf_num, int *thr_num)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
void delete_thread_silent(ptid_t ptid)
bool tid_is_qualified() const
int tid_is_in_list(const char *list, int default_inferior, int inf_num, int thr_num)
void thread_fsm_clean_up(struct thread_fsm *self, struct thread_info *thread)
char * get_print_cell(void)
#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)
void thread_command(const char *tidstr, int from_tty)
char * skip_spaces(char *chp)
class thread_info * m_thread
static void switch_to_thread(thread_info *thr)
static int threads_executing
void text(const char *string)
static bool tp_array_compar_ascending
void printf_filtered(const char *format,...)
void thread_step_over_chain_remove(struct thread_info *tp)
~scoped_restore_current_thread()
void set_current_program_space(struct program_space *pspace)
void execute_command(const char *, int)
struct thread_info * add_thread_silent(ptid_t ptid)
static void disable_thread_stack_temporaries(void *data)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
int frame_id_eq(struct frame_id l, struct frame_id r)
static struct value * global_thread_id_make_value(struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
struct thread_info * next
#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)
void thread_select(const char *tidstr, thread_info *tp)
struct cmd_list_element * thread_cmd_list
int thread_is_in_step_over_chain(struct thread_info *tp)
thread_suspend_state suspend
void btrace_teardown(struct thread_info *tp)
bool get_tid_range(int *inf_num, int *thr_start, int *thr_end)
static int live_threads_count(void)
struct breakpoint * exception_resume_breakpoint
const char * print_thread_id(struct thread_info *thr)
void init_thread_list(void)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
struct frame_info * find_relative_frame(struct frame_info *, int *)
static void thread_name_command(const char *arg, int from_tty)
thread_info(inferior *inf, ptid_t ptid)
const char * cur_tok() const
static int set_running_thread(struct thread_info *tp, int running)
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
const gdb_byte * value_contents_all(struct value *value)
void observer_notify_target_resumed(ptid_t ptid)
virtual ~private_thread_info()=0
static struct value * thread_num_make_value_helper(struct gdbarch *gdbarch, int global)
bool in_star_range() const
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 inferior * inferior_list
scoped_inc_dec_ref(const std::vector< thread_info *> &thrds)
void _initialize_thread(void)
void push_thread_stack_temporary(ptid_t ptid, struct value *v)
static void update_threads_executing(void)
struct target_waitstatus pending_follow
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)
bool can_access_registers_ptid(ptid_t ptid)
void observer_notify_new_thread(struct thread_info *t)
struct thread_fsm * thread_fsm
int show_inferior_qualified_tids(void)
static int highest_thread_num
struct cmd_list_element * setprintlist
#define target_has_memory
void init(const char *tidlist, int default_inferior)
struct thread_info * find_thread_by_handle(struct value *thread_handle, struct inferior *inf)
static struct thread_info * new_thread(struct inferior *inf, ptid_t ptid)
void printf_unfiltered(const char *format,...)
struct thread_info * step_over_queue_head
int is_running(ptid_t ptid)
void annotate_thread_changed(void)
int show_thread_that_caused_stop(void)
static void print_thread_info_1(struct ui_out *uiout, const char *requested_threads, int global_ids, int pid, int show_global_ids)
struct thread_info * iterate_over_threads(int(*callback)(struct thread_info *, void *), void *data)
struct thread_info * step_over_prev
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)
static void set_thread_exited(thread_info *tp, int silent)
void thread_cancel_execution_command(struct thread_info *thr)
static const struct internalvar_funcs thread_funcs
void delete_exception_resume_breakpoint(struct thread_info *tp)
struct thread_info * thread_step_over_chain_next(struct thread_info *tp)
void switch_to_thread_no_regs(struct thread_info *thread)
const char * target_thread_name(struct thread_info *info)
struct value * get_last_thread_stack_temporary(ptid_t ptid)
void print_stack_frame(struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
scoped_restore_current_thread()
int breakpoint_has_location_inserted_here(struct breakpoint *bp, const address_space *aspace, CORE_ADDR pc)
struct thread_info * add_thread_with_info(ptid_t ptid, private_thread_info *priv)
struct thread_info * parse_thread_id(const char *tidstr, const char **end)
static void thread_find_command(const char *arg, int from_tty)
void target_update_thread_list(void)
static void clear_thread_inferior_resources(struct thread_info *tp)
void set_running(ptid_t ptid, int running)
T & emplace(Args &&... args)
static int thread_alive(struct thread_info *)
#define ALL_NON_EXITED_THREADS(T)
std::unique_ptr< private_thread_info > priv
static void info_threads_command(const char *arg, int from_tty)
int frame_relative_level(struct frame_info *fi)
int xsnprintf(char *str, size_t size, const char *format,...)
thread_control_state control
enum target_waitkind kind
void field_int(const char *fldname, int value)
CORE_ADDR regcache_read_pc(struct regcache *regcache)
frame_id m_selected_frame_id
static int should_print_thread(const char *requested_threads, int default_inf_num, int global_ids, int pid, struct thread_info *thr)
void validate_registers_access(void)
const char * target_pid_to_str(ptid_t ptid)
int is_stopped(ptid_t ptid)
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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void observer_notify_thread_exit(struct thread_info *t, int silent)
int thread_stack_temporaries_enabled_p(ptid_t ptid)
int thread_has_single_step_breakpoint_here(struct thread_info *tp, const address_space *aspace, CORE_ADDR addr)
void set_resumed(ptid_t ptid, int resumed)
void message(const char *format,...) ATTRIBUTE_PRINTF(2
void observer_notify_thread_ptid_changed(ptid_t old_ptid, ptid_t new_ptid)
std::string string_printf(const char *fmt,...)
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 switch_to_no_thread()
int target_core_of_thread(ptid_t ptid)
#define ALL_THREADS_BY_INFERIOR(inf, tp)
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 *)
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)
void thread_step_over_chain_enqueue(struct thread_info *tp)
const std::vector< thread_info * > & m_thrds
struct type * value_type(const struct value *value)
static void delete_thread_breakpoint(struct breakpoint **bp_p)
int ptid_to_global_thread_id(ptid_t ptid)
struct thread_info * target_thread_handle_to_thread_info(const gdb_byte *thread_handle, int handle_len, struct inferior *inf)
int stack_temporaries_enabled
static void step_over_chain_enqueue(struct thread_info **list_p, struct thread_info *tp)
struct thread_info * find_thread_global_id(int global_id)
struct target_waitstatus waitstatus
#define TYPE_LENGTH(thistype)
struct breakpoint * step_resume_breakpoint
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 thread_info * step_over_next
static struct value * thread_id_per_inf_num_make_value(struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
void annotate_new_thread(void)
int m_selected_frame_level
void delete_longjmp_breakpoint_at_next_stop(int thread)
int has_stack_frames(void)
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,...)
int check_for_argument(const char **str, const char *arg, int arg_len)
#define target_extra_thread_info(TP)
void thread_change_ptid(ptid_t old_ptid, ptid_t new_ptid)
void set_current_inferior(struct inferior *inf)
static void delete_at_next_stop(struct breakpoint **bp)
void delete_thread(ptid_t ptid)
void print_stack_frame_to_uiout(struct ui_out *uiout, struct frame_info *, int print_level, enum print_what print_what, int set_current_sal)
static const struct internalvar_funcs gthread_funcs
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)
static bool tp_array_compar(const thread_info *a, const thread_info *b)
void print_thread_info(struct ui_out *uiout, char *requested_threads, int pid)