33 #ifndef USE_LIBTHREAD_DB_DIRECTLY 53 #ifndef USE_LIBTHREAD_DB_DIRECTLY 81 return "generic 'call succeeded'";
83 return "generic error";
85 return "no thread to satisfy query";
87 return "no sync handle to satisfy query";
89 return "no LWP to satisfy query";
91 return "invalid process handle";
93 return "invalid thread handle";
95 return "invalid synchronization handle";
97 return "invalid thread agent";
101 return "no event message for getmsg";
103 return "FPU register set not available";
105 return "application not linked with libthread";
107 return "requested event is not supported";
109 return "capability not available";
111 return "debugger service failed";
113 return "operation not applicable to";
115 return "no thread-specific data for this thread";
117 return "malloc failed";
119 return "only part of register set was written/read";
121 return "X register set not available for this thread";
122 #ifdef HAVE_TD_VERSION 124 return "version mismatch between libthread_db and libpthread";
127 xsnprintf (buf,
sizeof (buf),
"unknown thread_db error '%d'", err);
141 return "stopped by debugger";
151 return "stopped by debugger AND blocked";
153 xsnprintf (buf,
sizeof (buf),
"unknown thread_db state %d", state);
174 if (lwp->thread_known)
180 error (
"Cannot get thread handle for LWP %d: %s",
185 error (
"Cannot get thread info for LWP %d: %s",
194 warning (
"PID mismatch! Expected %ld, got %ld",
195 (
long) lwpid, (
long) ti.
ti_lid);
204 lwp->thread_known = 1;
206 lwp->thread_handle = ti.
ti_tid;
228 warning (
"Could not attach to thread %ld (LWP %d): %s\n",
236 lwp->thread_known = 1;
238 lwp->thread_handle = ti_p->
ti_tid;
287 "joined thread (0x%lx)\n",
288 (
unsigned long) ti.
ti_tid);
324 for (loop = 0, iteration = 0; loop < 4; ++loop, ++iteration)
326 int new_thread_count = 0;
337 new_thread_count, iteration);
339 if (new_thread_count != 0)
358 const char **sym_list;
408 if (!lwp->thread_known)
410 if (!lwp->thread_known)
416 if (load_module != 0)
434 addr = (
char *) addr +
offset;
471 *handle = (
gdb_byte *) &lwp->thread_handle;
472 *handle_len = sizeof (lwp->thread_handle);
476 #ifdef USE_LIBTHREAD_DB_DIRECTLY 534 #define CHK(required, a) \ 540 debug_printf ("dlsym: %s\n", dlerror ()); \ 544 proc->priv->thread_db = NULL; \ 551 #define TDB_DLSYM(tdb, func) \ 552 tdb->func ## _p = (func ## _ftype *) dlsym (tdb->handle, #func) 589 dladdr_to_soname (
const void *addr)
593 if (dladdr (addr, &info) != 0)
594 return info.dli_fname;
606 debug_printf (
"Trying host libthread_db library: %s.\n",
608 handle = dlopen (library, RTLD_NOW);
621 td_init = dlsym (handle,
"td_init");
624 const char *
const libpath = dladdr_to_soname (
td_init);
627 debug_printf (
"Host %s resolved to: %s.\n", library, libpath);
661 char *cp = (
char *)
xmalloc (dir_len + 1);
663 memcpy (cp, dir, dir_len);
665 warning (
_(
"libthread-db-search-path component too long," 666 " ignored: %s."), cp);
671 memcpy (path, dir, dir_len);
695 const int pdir_len =
sizeof (
"$pdir") - 1;
698 this_dir_len = strlen (this_dir);
700 if (strncmp (this_dir,
"$pdir", pdir_len) == 0
701 && (this_dir[pdir_len] ==
'\0' 702 || this_dir[pdir_len] ==
'/'))
708 else if (strcmp (this_dir,
"$sdir") == 0)
728 debug_printf (
"thread_db_load_search returning %d\n", rc);
789 #ifndef USE_LIBTHREAD_DB_DIRECTLY 792 "td_ta_clear_event");
797 if (td_ta_clear_event_p != NULL)
835 #ifndef USE_LIBTHREAD_DB_DIRECTLY 841 if (td_ta_delete_p != NULL)
844 #ifndef USE_LIBTHREAD_DB_DIRECTLY 859 const char *cmd =
"set libthread-db-search-path";
860 size_t cmd_len = strlen (cmd);
862 if (strncmp (mon, cmd, cmd_len) == 0
863 && (mon[cmd_len] ==
'\0' 864 || mon[cmd_len] ==
' '))
866 const char *cp = mon + cmd_len;
872 while (isspace (*cp))
909 warning (
"Cannot find thread after clone.\n");
#define TD_THR_LOWEST_PRIORITY
struct thread_info * current_thread
static int attach_thread(const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
void monitor_output(const char *msg)
struct thread_info * find_thread_ptid(ptid_t ptid)
int linux_proc_task_list_dir_exists(pid_t pid)
static char * libthread_db_search_path
void warning(const char *fmt,...)
void thread_db_notice_clone(struct thread_info *parent_thr, ptid_t child_ptid)
struct lwp_info * find_lwp_pid(ptid_t ptid)
int all_symbols_looked_up
static void thread_db_look_up_symbols(void)
td_ta_thr_iter_ftype * td_ta_thr_iter_p
struct thread_info * find_any_thread_of_pid(int pid)
static void switch_to_process(struct process_info *proc)
int thread_db_handle_monitor_command(char *mon)
#define get_thread_lwp(thr)
static int pid_of(const thread_info *thread)
static int try_thread_db_load_1(void *handle)
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)
void thread_db_mourn(struct process_info *proc)
#define TDB_DLSYM(tdb, func)
char * xstrdup(const char *s)
ptid_t ptid_build(int pid, long lwp, long tid)
const char **() td_symbol_list_ftype(void)
static int maybe_attach_thread(const td_thrhandle_t *th_p, td_thrinfo_t *ti_p, int *counter)
scoped_restore_tmpl< T > make_scoped_restore(T *var)
static int try_thread_db_load(const char *library)
td_err_e() td_thr_get_info_ftype(const td_thrhandle_t *th, td_thrinfo_t *infop)
#define VEC_iterate(T, V, I, P)
const char ** td_symbol_list(void)
char * linux_ptrace_attach_fail_reason_string(ptid_t ptid, int err)
td_ta_map_lwp2thr_ftype * td_ta_map_lwp2thr_p
struct thread_db * thread_db
td_thr_tls_get_addr_ftype * td_thr_tls_get_addr_p
void free_char_ptr_vec(VEC(char_ptr) *char_ptr_vec)
ptid_t pid_to_ptid(int pid)
struct td_thragent td_thragent_t
static int find_one_thread(ptid_t)
td_err_e() td_ta_delete_ftype(td_thragent_t *)
td_thr_get_info_ftype * td_thr_get_info_p
int look_up_one_symbol(const char *name, CORE_ADDR *addrp, int may_ask_gdb)
td_err_e td_ta_delete(td_thragent_t *__ta)
td_err_e td_ta_clear_event(const td_thragent_t *__ta, td_thr_events_t *__event)
static int try_thread_db_load_from_sdir(void)
#define td_event_fillset(setp)
td_err_e() td_ta_map_lwp2thr_ftype(const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
static int thread_db_load_search(void)
td_thragent_t * thread_agent
struct process_info * current_process(void)
struct process_info_private * priv
static int try_thread_db_load_from_dir(const char *dir, size_t dir_len)
td_ta_new_ftype * td_ta_new_p
long ptid_get_lwp(const ptid_t &ptid)
td_err_e() td_ta_new_ftype(struct ps_prochandle *ps, td_thragent_t **ta)
td_err_e() td_ta_clear_event_ftype(const td_thragent_t *ta, td_thr_events_t *event)
#define TD_THR_ANY_USER_FLAGS
bool thread_db_thread_handle(ptid_t ptid, gdb_byte **handle, int *handle_len)
int thread_db_get_tls_address(struct thread_info *thread, CORE_ADDR offset, CORE_ADDR load_module, CORE_ADDR *address)
int linux_attach_lwp(ptid_t ptid)
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)
int thread_db_look_up_one_symbol(const char *name, CORE_ADDR *addrp)
static void thread_db_find_new_threads(void)
int xsnprintf(char *str, size_t size, const char *format,...)
td_err_e td_thr_get_info(const td_thrhandle_t *__th, td_thrinfo_t *__infop)
td_err_e td_ta_new(struct ps_prochandle *__ps, td_thragent_t **__ta)
static const char * thread_db_err_str(td_err_e err)
static void disable_thread_event_reporting(struct process_info *proc)
td_thr_tlsbase_ftype * td_thr_tlsbase_p
static int find_new_threads_callback(const td_thrhandle_t *th_p, void *data)
td_err_e td_thr_tls_get_addr(const td_thrhandle_t *__th, psaddr_t __map_address, size_t __offset, psaddr_t *__address)
td_err_e() td_thr_tls_get_addr_ftype(const td_thrhandle_t *th, psaddr_t map_address, size_t offset, psaddr_t *address)
void thread_db_detach(struct process_info *proc)
void debug_printf(const char *fmt,...)
td_symbol_list_ftype * td_symbol_list_p
struct ps_prochandle proc_handle
td_err_e() td_thr_tlsbase_ftype(const td_thrhandle_t *th, unsigned long int modid, psaddr_t *base)
void error(const char *fmt,...)
struct process_info * get_thread_process(const struct thread_info *thread)
#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)
struct thread_info * thread