232 if (
pid == info->pid)
238 if (info->handle != NULL)
239 dlclose (info->handle);
241 xfree (info->filename);
278 return "generic 'call succeeded'";
280 return "generic error";
282 return "no thread to satisfy query";
284 return "no sync handle to satisfy query";
286 return "no LWP to satisfy query";
288 return "invalid process handle";
290 return "invalid thread handle";
292 return "invalid synchronization handle";
294 return "invalid thread agent";
296 return "invalid key";
298 return "no event message for getmsg";
300 return "FPU register set not available";
302 return "application not linked with libthread";
304 return "requested event is not supported";
306 return "capability not available";
308 return "debugger service failed";
310 return "operation not applicable to";
312 return "no thread-specific data for this thread";
314 return "malloc failed";
316 return "only part of register set was written/read";
318 return "X register set not available for this thread";
319 #ifdef THREAD_DB_HAS_TD_NOTALLOC 321 return "thread has not yet allocated TLS for given module";
323 #ifdef THREAD_DB_HAS_TD_VERSION 325 return "versions of libpthread and libthread_db do not match";
327 #ifdef THREAD_DB_HAS_TD_NOTLS 329 return "there is no TLS segment in the given module";
332 snprintf (buf,
sizeof (buf),
"unknown thread_db error '%d'",
err);
362 error (
_(
"Cannot find user-level thread for LWP %ld: %s"),
367 error (
_(
"thread_get_info_callback: cannot get thread info: %s"),
401 warning (
_(
"Symbol \"%s\" not found in libthread_db: %s"),
416 int err, got, retval = 0;
419 if (version_msym.
minsym == NULL)
428 retval = (sscanf (
version,
"%d.%d", &major, &minor) == 2
429 && (major < ver_major_min
430 || (major == ver_major_min && minor < ver_minor_min)));
456 "Warning: thread_db_find_new_threads_silently: ");
477 _(
"Warning: couldn't activate thread debugging " 478 "using libthread_db: "));
496 if (dladdr (addr, &info) != 0)
497 return info.dli_fname;
515 #define TDB_VERBOSE_DLSYM(info, func) \ 516 info->func ## _p = (func ## _ftype *) verbose_dlsym (info->handle, #func) 518 #define TDB_DLSYM(info, func) \ 519 info->func ## _p = (func ## _ftype *) dlsym (info->handle, #func) 533 warning (
_(
"Cannot initialize libthread_db: %s"),
554 #ifdef THREAD_DB_HAS_TD_VERSION 590 #undef TDB_VERBOSE_DLSYM 654 _(
"Trying host libthread_db library: %s.\n"),
657 if (check_auto_load_safe)
659 if (access (library, R_OK) != 0)
670 "library \"%s\" from explicit " 676 handle = dlopen (library, RTLD_NOW);
702 if (strchr (library,
'/') != NULL)
727 if (obj_name[0] !=
'/')
729 warning (
_(
"Expected absolute pathname for libpthread in the" 730 " inferior, but got %s."), obj_name);
734 alloc_len = (strlen (obj_name)
735 + (subdir ? strlen (subdir) + 1 : 0)
737 path = (
char *)
xmalloc (alloc_len);
740 strcpy (path, obj_name);
741 cp = strrchr (path,
'/');
817 memcpy (path, dir, dir_len);
844 const int pdir_len =
sizeof (
"$pdir") - 1;
847 this_dir_len = strlen (this_dir);
849 if (strncmp (this_dir,
"$pdir", pdir_len) == 0
850 && (this_dir[pdir_len] ==
'\0' 851 || this_dir[pdir_len] ==
'/'))
854 struct cleanup *free_subdir_cleanup
857 if (this_dir[pdir_len] ==
'/')
859 subdir = (
char *)
xmalloc (strlen (this_dir));
861 strcpy (subdir, this_dir + pdir_len + 1);
868 else if (strcmp (this_dir,
"$sdir") == 0)
889 _(
"thread_db_load_search returning %d\n"), rc);
936 warning (
_(
"Unable to find libthread_db matching inferior's thread" 937 " library, thread debugging will not be available."));
959 for (i = 1; i < NSIG; i++)
961 if (sigismember (&mask, i))
1026 warning (
_ (
"Target and debugger are in different PID " 1027 "namespaces; thread lists and other data are " 1028 "likely unreliable. " 1029 "Connect to gdbserver inside the container."));
1099 target_beneath->
to_detach (target_beneath, args, from_tty);
1119 switch (ourstatus->
kind)
1183 error (
_(
"find_new_threads_callback: cannot get thread info: %s"),
1196 "thread_db: skipping exited and " 1197 "joined thread (0x%lx)\n",
1198 (
unsigned long) ti.
ti_tid);
1223 if (tgid != -1 && tgid != info->
pid)
1229 if (tp == NULL || tp->
priv == NULL)
1267 "Warning: find_new_threads_once: ");
1275 _(
"Found %d new threads in iteration %d.\n"),
1307 for (i = 0, loop = 0; loop < 4 &&
err ==
TD_OK; ++i, ++loop)
1350 if (thread == NULL || thread->
executing)
1382 static char buf[64];
1385 snprintf (buf,
sizeof (buf),
"Thread 0x%lx (LWP %ld)",
1402 if (info->
priv == NULL)
1429 if (handle_len !=
sizeof (handle_tid))
1430 error (
_(
"Thread handle size mismatch: %d vs %zu (from libthread_db)"),
1431 handle_len,
sizeof (handle_tid));
1433 handle_tid = * (
const thread_t *) thread_handle;
1478 _(
"No TLS library support"));
1493 _(
"TLS load module not found"));
1502 address = (
char *) address +
offset;
1505 #ifdef THREAD_DB_HAS_TD_NOTALLOC 1512 _(
"TLS not allocated yet"));
1523 return (bfd_get_sign_extend_vma (
exec_bfd) > 0
1543 ptid_t ptid,
int step,
enum gdb_signal signo)
1559 beneath->
to_resume (beneath, ptid, step, signo);
1586 const char *cs = args ? args :
"";
1588 unsigned info_count, unique_filenames;
1589 size_t max_filename_len, max_pids_len, pids_len;
1596 error (
_(
"'info auto-load libthread-db' does not accept any parameters"));
1609 array[info_count++] = info;
1613 qsort (array, info_count,
sizeof (*array),
1619 unique_filenames = 0;
1620 max_filename_len = 0;
1623 for (i = 0; i < info_count; i++)
1626 size_t this_pid_len;
1628 for (this_pid_len = 0;
pid != 0;
pid /= 10)
1631 if (i == 0 || strcmp (array[i - 1]->filename, array[i]->filename) != 0)
1634 max_filename_len = std::max (max_filename_len,
1635 strlen (array[i]->filename));
1639 pids_len -= strlen (
", ");
1640 max_pids_len = std::max (max_pids_len, pids_len);
1644 pids_len += this_pid_len + strlen (
", ");
1648 pids_len -= strlen (
", ");
1649 max_pids_len = std::max (max_pids_len, pids_len);
1659 "LinuxThreadDbTable");
1669 for (i = 0; i < info_count;)
1678 while (i < info_count && strcmp (info->
filename,
1681 if (pids_end !=
pids)
1687 &
pids[max_pids_len + 1] - pids_end,
1688 "%u", array[i]->
pid);
1703 if (info_count == 0)
1704 uiout->
message (
_(
"No auto-loaded libthread-db.\n"));
1747 Set search path for libthread_db."),
_(
"\ 1748 Show the current search path or libthread_db."),
_(
"\ 1749 This path is used to search for libthread_db to be loaded into \ 1751 Its value is a colon (':') separate list of directories to search.\n\ 1752 Setting the search path to an empty list resets it to its default value."),
1759 Set libthread-db debugging."),
_(
"\ 1760 Show libthread-db debugging."),
_(
"\ 1761 When non-zero, libthread-db debugging is enabled."),
1768 Enable or disable auto-loading of inferior specific libthread_db."),
_(
"\ 1769 Show whether auto-loading inferior specific libthread_db is enabled."),
_(
"\ 1770 If enabled, libthread_db will be searched in 'set libthread-db-search-path'\n\ 1771 locations to load libthread_db compatible with the inferior.\n\ 1772 Standard system libthread_db still gets loaded even with this option off.\n\ 1773 This options has security implications for untrusted inferiors."),
1779 _(
"Print the list of loaded inferior specific libthread_db.\n\ 1780 Usage: info auto-load libthread-db"),
static int try_thread_db_load_1(struct thread_db_info *info)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
void linux_unstop_all_lwps(void)
td_thr_tls_get_addr_ftype * td_thr_tls_get_addr_p
static void thread_db_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal signo)
#define TD_THR_LOWEST_PRIORITY
static void thread_db_find_new_threads_1(ptid_t ptid)
#define target_has_registers
static const char * dladdr_to_soname(const void *addr)
struct thread_info * find_thread_ptid(ptid_t ptid)
td_thragent_t * thread_agent
static int auto_load_thread_db
int linux_proc_task_list_dir_exists(pid_t pid)
static struct target_ops thread_db_ops
static int thread_db_find_new_threads_silently(ptid_t ptid)
void field_string(const char *fldname, const char *string)
void lin_thread_get_thread_signals(sigset_t *set)
int ptid_get_pid(const ptid_t &ptid)
static void thread_db_mourn_inferior(struct target_ops *ops)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
struct objfile * separate_debug_objfile_backlink
#define BMSYMBOL_VALUE_ADDRESS(symbol)
void warning(const char *fmt,...)
static int try_thread_db_load_from_dir(const char *dir, size_t dir_len)
static void set_libthread_db_search_path(const char *ignored, int from_tty, struct cmd_list_element *c)
void push_target(struct target_ops *t)
static void * verbose_dlsym(void *handle, const char *name)
static void init_thread_db_ops(void)
struct thread_info * add_thread_with_info(ptid_t ptid, struct private_thread_info *)
td_thr_tlsbase_ftype * td_thr_tlsbase_p
int unpush_target(struct target_ops *t)
static void check_thread_signals(void)
struct cmd_list_element ** auto_load_set_cmdlist_get(void)
void _initialize_thread_db(void)
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
#define target_can_run(t)
td_ta_map_lwp2thr_ftype * td_ta_map_lwp2thr_p
const char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
#define TDB_DLSYM(info, func)
struct thread_info *(* to_thread_handle_to_thread_info)(struct target_ops *, const gdb_byte *, int, struct inferior *inf) TARGET_DEFAULT_RETURN(NULL)
char auto_load_info_scripts_pattern_nl[]
int need_stale_parent_threads_check
gdb::unique_xmalloc_ptr< char > gdb_realpath(const char *filename)
char * skip_spaces(char *chp)
td_init_ftype * td_init_p
static ptid_t thread_db_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *ourstatus, int options)
static int info_auto_load_libthread_db_compare(const void *ap, const void *bp)
int target_has_execution_1(ptid_t the_ptid)
void text(const char *string)
td_err_e td_ta_map_lwp2thr(const td_thragent_t *__ta, lwpid_t __lwpid, td_thrhandle_t *__th)
td_err_e td_thr_tlsbase(const td_thrhandle_t *__th, unsigned long int __modid, psaddr_t *__base)
int thread_db_notice_clone(ptid_t parent, ptid_t child)
ptid_t ptid_build(int pid, long lwp, long tid)
void add_setshow_zuinteger_cmd(const char *name, enum command_class theclass, unsigned 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 null_cleanup(void *arg)
struct observer * observer_attach_inferior_created(observer_inferior_created_ftype *f)
struct cmd_list_element * setlist
static struct thread_info * thread_db_thread_handle_to_thread_info(struct target_ops *ops, const gdb_byte *thread_handle, int handle_len, struct inferior *inf)
static int try_thread_db_load_from_pdir_1(struct objfile *obj, const char *subdir)
td_err_e() td_thr_get_info_ftype(const td_thrhandle_t *th, td_thrinfo_t *infop)
#define VEC_iterate(T, V, I, P)
static int inferior_has_bug(const char *ver_symbol, int ver_major_min, int ver_minor_min)
static int thread_db_load(void)
#define CATCH(EXCEPTION, MASK)
struct target_ops current_target
struct thread_db_info * info
int linux_ns_same(pid_t pid, enum linux_ns_type type)
void complete_target_initialization(struct target_ops *t)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
static const char * thread_db_err_str(td_err_e err)
static thread_db_thread_info * get_thread_db_thread_info(thread_info *thread)
struct thread_info * any_live_thread_of_process(int pid)
thread_info(inferior *inf, ptid_t ptid)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
void(* to_resume)(struct target_ops *, ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
struct cmd_list_element * showlist
CORE_ADDR(* to_get_thread_local_address)(struct target_ops *ops, ptid_t ptid, CORE_ADDR load_module_addr, CORE_ADDR offset) TARGET_DEFAULT_NORETURN(generic_tls_error())
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
struct td_thragent td_thragent_t
int linux_proc_get_tgid(pid_t lwpid)
enum gdb_signal gdb_signal_from_host(int)
#define TDB_VERBOSE_DLSYM(info, func)
struct ps_prochandle proc_handle
static int find_new_threads_callback(const td_thrhandle_t *th_p, void *data)
static sigset_t thread_print_set
void exception_fprintf(struct ui_file *file, struct gdb_exception e, const char *prefix,...)
td_thr_get_info_ftype * td_thr_get_info_p
static int thread_db_load_search(void)
td_err_e() td_ta_map_lwp2thr_ftype(const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
#define target_has_execution
static void thread_db_inferior_created(struct target_ops *target, int from_tty)
static void thread_db_update_thread_list(struct target_ops *ops)
void linux_stop_and_wait_all_lwps(void)
struct target_ops * find_target_beneath(struct target_ops *t)
int file_is_auto_load_safe(const char *filename, const char *debug_fmt,...)
static struct thread_db_info * add_thread_db_info(void *handle)
static int try_thread_db_load(const char *library, int check_auto_load_safe)
void printf_unfiltered(const char *format,...)
struct cmd_list_element * setdebuglist
static struct thread_info * record_thread(struct thread_db_info *info, struct thread_info *tp, ptid_t ptid, const td_thrhandle_t *th_p, const td_thrinfo_t *ti_p)
static void info_auto_load_libthread_db(const char *args, int from_tty)
void(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
const char * objfile_name(const struct objfile *objfile)
long ptid_get_lwp(const ptid_t &ptid)
static int find_new_threads_once(struct thread_db_info *info, int iteration, td_err_e *errp)
td_err_e() td_ta_new_ftype(struct ps_prochandle *ps, td_thragent_t **ta)
void check_for_thread_db(void)
#define TD_THR_ANY_USER_FLAGS
static void delete_thread_db_info(int pid)
static ptid_t thread_db_get_ada_task_ptid(struct target_ops *self, long lwp, long thread)
static void show_auto_load_thread_db(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void(* to_mourn_inferior)(struct target_ops *) TARGET_DEFAULT_FUNC(default_mourn_inferior)
td_err_e td_ta_thr_iter(const td_thragent_t *__ta, td_thr_iter_f *__callback, void *__cbdata_p, td_thr_state_e __state, int __ti_pri, sigset_t *__ti_sigmask_p, unsigned int __ti_user_flags)
const char *(* to_extra_thread_info)(struct target_ops *, struct thread_info *) TARGET_DEFAULT_RETURN(NULL)
static const char * thread_db_extra_thread_info(struct target_ops *self, struct thread_info *info)
#define ALL_NON_EXITED_THREADS(T)
static void thread_db_find_new_threads_2(ptid_t ptid, int until_no_new)
std::unique_ptr< private_thread_info > priv
int xsnprintf(char *str, size_t size, const char *format,...)
static void thread_db_detach(struct target_ops *ops, const char *args, int from_tty)
enum target_waitkind kind
td_ta_new_ftype * td_ta_new_p
td_ta_thr_iter_ftype * td_ta_thr_iter_p
struct minimal_symbol * minsym
td_err_e td_thr_get_info(const td_thrhandle_t *__th, td_thrinfo_t *__infop)
char * safe_strerror(int)
td_err_e td_ta_new(struct ps_prochandle *__ps, td_thragent_t **__ta)
static struct thread_info * thread_from_lwp(ptid_t ptid)
int libpthread_name_p(const char *name)
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)
static constexpr ptid_t lwp
static void show_libthread_db_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void message(const char *format,...) ATTRIBUTE_PRINTF(2
struct thread_db_info * thread_db_list
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int procinfo_t mach_msg_type_number_t data_t mach_msg_type_number_t threadwaitsCnt mach_port_t kern_return_t data_t mach_msg_type_number_t procenvCnt mach_port_t kern_return_t pidarray_t pids
static const char * thread_db_pid_to_str(struct target_ops *ops, ptid_t ptid)
td_err_e td_thr_tls_get_addr(const td_thrhandle_t *__th, psaddr_t __map_address, size_t __offset, psaddr_t *__address)
int ptid_equal(const ptid_t &ptid1, const ptid_t &ptid2)
static int has_libpthread(void)
td_err_e() td_thr_tls_get_addr_ftype(const td_thrhandle_t *th, psaddr_t map_address, size_t offset, psaddr_t *address)
const char * to_shortname
static char * libthread_db_search_path
static int try_thread_db_load_from_pdir(const char *subdir)
static CORE_ADDR thread_db_get_thread_local_address(struct target_ops *ops, ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset)
static int try_thread_db_load_from_sdir(void)
struct observer * observer_attach_new_objfile(observer_new_objfile_ftype *f)
void add_setshow_optional_filename_cmd(const char *name, enum command_class theclass, char **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)
struct cmd_list_element * showdebuglist
int signal_print_update(int signo, int state)
static void update_thread_state(thread_db_thread_info *priv, const td_thrinfo_t *ti_p)
struct thread_db_info * next
static unsigned int libthread_db_debug
int to_has_thread_control
static void thread_db_new_objfile(struct objfile *objfile)
int signal_stop_update(int signo, int state)
struct cleanup * make_cleanup_free_char_ptr_vec(VEC(char_ptr) *char_ptr_vec)
#define ALL_OBJFILES(obj)
struct cmd_list_element ** auto_load_show_cmdlist_get(void)
static void check_pid_namespace_match(void)
td_err_e() td_init_ftype(void)
void(* to_update_thread_list)(struct target_ops *) TARGET_DEFAULT_IGNORE()
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_FUNC(default_target_wait)
ptid_t(* to_get_ada_task_ptid)(struct target_ops *, long lwp, long thread) TARGET_DEFAULT_FUNC(default_get_ada_task_ptid)
int target_read_string(CORE_ADDR memaddr, char **string, int len, int *errnop)
td_err_e() td_thr_tlsbase_ftype(const td_thrhandle_t *th, unsigned long int modid, psaddr_t *base)
void error(const char *fmt,...)
#define LIBTHREAD_DB_SEARCH_PATH
td_err_e() td_ta_thr_iter_ftype(const td_thragent_t *ta, td_thr_iter_f *callback, void *cbdata_p, td_thr_state_e state, int ti_pri, sigset_t *ti_sigmask_p, unsigned int ti_user_flags)
void throw_error(enum errors error, const char *fmt,...)
static struct thread_db_info * get_thread_db_info(int pid)
struct target_ops * beneath
void do_cleanups(struct cleanup *old_chain)
static sigset_t thread_stop_set
struct cmd_list_element ** auto_load_info_cmdlist_get(void)
static int thread_signals