53 #include <proc_service.h>
54 #include <thread_db.h>
117 sigset_t *ti_sigmask_p,
118 unsigned ti_user_flags);
129 const caddr_t xregset);
131 const sigset_t ti_sigmask);
135 const uchar_t ti_pending_flag,
136 const sigset_t ti_pending);
140 const caddr_t xregset);
161 {
TD_OK,
"generic \"call succeeded\"" },
162 {
TD_ERR,
"generic error." },
163 {
TD_NOTHR,
"no thread can be found to satisfy query" },
164 {
TD_NOSV,
"no synch. variable can be found to satisfy query" },
165 {
TD_NOLWP,
"no lwp can be found to satisfy query" },
166 {
TD_BADPH,
"invalid process handle" },
167 {
TD_BADTH,
"invalid thread handle" },
168 {
TD_BADSH,
"invalid synchronization handle" },
169 {
TD_BADTA,
"invalid thread agent" },
171 {
TD_NOMSG,
"td_thr_event_getmsg() called when there was no message" },
172 {
TD_NOFPREGS,
"FPU register set not available for given thread" },
174 {
TD_NOEVENT,
"requested event is not supported" },
176 {
TD_DBERR,
"Debugger service failed" },
177 {
TD_NOAPLIC,
"Operation not applicable to" },
178 {
TD_NOTSD,
"No thread specific data for this thread" },
180 {
TD_PARTIALREG,
"Only part of register set was written/read" },
181 {
TD_NOXREGS,
"X register set not available for given thread" }
183 const int td_err_size =
sizeof td_err_table /
sizeof (
struct string_map);
187 for (i = 0; i < td_err_size; i++)
188 if (td_err_table[i].
num == errcode)
189 return td_err_table[i].
str;
191 xsnprintf (buf,
sizeof (buf),
"Unknown libthread_db error code: %d",
203 static struct string_map td_thr_state_table[] =
214 const int td_thr_state_table_size =
215 sizeof td_thr_state_table /
sizeof (
struct string_map);
219 for (i = 0; i < td_thr_state_table_size; i++)
220 if (td_thr_state_table[i].
num == statecode)
221 return td_thr_state_table[i].
str;
223 xsnprintf (buf,
sizeof (buf),
"Unknown libthread_db state code: %d",
251 else if (val !=
TD_OK)
257 else if (val !=
TD_OK)
262 if (default_lwp != -1)
264 error (
_(
"thread_to_lwp: thread state not active: %s"),
294 else if (val !=
TD_OK)
300 else if (val !=
TD_OK)
306 else if (val !=
TD_OK)
329 sol_thread_active = 0;
332 beneath->
to_detach (beneath, args, from_tty);
359 error (
_(
"This version of Solaris can't start inactive threads."));
361 warning (
_(
"Specified thread %ld seems to have terminated"),
365 beneath->
to_resume (beneath, ptid, step, signo);
395 error (
_(
"This version of Solaris can't start inactive threads."));
397 warning (
_(
"Specified thread %ld seems to have terminated"),
401 rtnval = beneath->
to_wait (beneath, ptid, ourstatus, options);
450 error (
_(
"sol_thread_fetch_registers: thread == 0"));
454 error (
_(
"sol_thread_fetch_registers: td_ta_map_id2thr: %s"),
461 error (
_(
"sol_thread_fetch_registers: td_thr_getgregs %s"),
471 error (
_(
"sol_thread_fetch_registers: td_thr_getfpregs %s"),
506 error (
_(
"sol_thread_store_registers: td_ta_map_id2thr %s"),
519 error (
_(
"sol_thread_store_registers: td_thr_getgregs %s"),
523 error (
_(
"sol_thread_store_registers: td_thr_getfpregs %s"),
535 error (
_(
"sol_thread_store_registers: td_thr_setgregs %s"),
539 error (
_(
"sol_thread_store_registers: td_thr_setfpregs %s"),
549 const char *annex,
gdb_byte *readbuf,
570 writebuf, offset, len, xfered_len);
591 if (sol_thread_active)
620 sol_thread_active = 1;
631 warning (
_(
"Cannot initialize thread debugging library: %s"),
657 sol_thread_active = 0;
710 #ifdef PROC_SERVICE_IS_OLD
765 const char *ld_symbol_name, gdb_ps_addr_t *ld_symbol_addr)
798 #if defined (__sparcv9)
801 if (bfd_get_arch_size (
exec_bfd) == 32)
819 gdb_ps_read_buf_t buf, gdb_ps_size_t
size)
821 return rw_common (0, ph, addr, buf, size);
828 gdb_ps_write_buf_t buf, gdb_ps_size_t
size)
837 gdb_ps_read_buf_t buf, gdb_ps_size_t
size)
839 return rw_common (0, ph, addr, buf, size);
846 gdb_ps_write_buf_t buf, gdb_ps_size_t
size)
901 va_start (args, fmt);
980 ps_pdmodel (gdb_ps_prochandle_t ph,
int *data_model)
983 *data_model = PR_MODEL_UNKNOWN;
984 else if (bfd_get_arch_size (
exec_bfd) == 32)
985 *data_model = PR_MODEL_ILP32;
987 *data_model = PR_MODEL_LP64;
993 #if (defined(__i386__) || defined(__x86_64__)) && defined (sun)
1001 ps_lgetLDT (gdb_ps_prochandle_t ph,
lwpid_t lwpid,
1017 memcpy (pldt, ret,
sizeof (
struct ssd));
1032 static char buf[100];
1041 xsnprintf (buf,
sizeof (buf),
"Thread %ld (defunct)",
1044 xsnprintf (buf,
sizeof (buf),
"Thread %ld (LWP %ld)",
1047 xsnprintf (buf,
sizeof (buf),
"Thread %ld ",
1070 if (retval !=
TD_OK)
1166 warning (
_(
"info sol-thread: failed to get info for thread."));
1188 long *tid = (
long *) data;
1202 if (thread_info == NULL)
1213 return (thread_info->
ptid);
1247 dlhandle = dlopen (
"libthread_db.so.1", RTLD_NOW);
1251 #define resolve(X) \
1252 if (!(p_##X = dlsym (dlhandle, #X))) \
1290 [GDB will not be able to debug user-mode threads: %s]\n", dlerror ());
struct gdbarch * target_gdbarch(void)
static td_err_e(* p_td_thr_setfpregs)(const td_thrhandle_t *th_p, const prfpregset_t *fpregset)
ps_err_e ps_pglobal_lookup(gdb_ps_prochandle_t ph, const char *ld_object_name, const char *ld_symbol_name, gdb_ps_addr_t *ld_symbol_addr)
int target_thread_alive(ptid_t ptid)
static td_err_e(* p_td_ta_new)(const struct ps_prochandle *ph_p, td_thragent_t **ta_pp)
ptid_t procfs_first_available(void)
#define TD_THR_LOWEST_PRIORITY
static td_err_e(* p_td_thr_get_info)(const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
static td_err_e(* p_td_ta_thr_iter)(const td_thragent_t *ta_p, td_thr_iter_f *cb, void *cbdata_p, td_thr_state_e state, int ti_pri, sigset_t *ti_sigmask_p, unsigned ti_user_flags)
td_err_e td_thr_getxregs(const td_thrhandle_t *__th, void *__xregs)
static td_err_e(* p_td_ta_get_ph)(const td_thragent_t *ta_p, struct ps_prochandle **ph_pp)
static int info_cb(const td_thrhandle_t *th, void *s)
struct thread_info * add_thread(ptid_t ptid)
ps_err_e ps_lgetxregsize(gdb_ps_prochandle_t ph, lwpid_t lwpid, int *xregsize)
void _initialize_sol_thread(void)
ps_err_e ps_lgetfpregs(gdb_ps_prochandle_t ph, lwpid_t lwpid, prfpregset_t *fpregset)
int td_key_iter_f(thread_key_t, void(*)(void *), void *)
ps_err_e ps_lcontinue(gdb_ps_prochandle_t ph, lwpid_t lwpid)
td_err_e td_ta_get_nthreads(const td_thragent_t *__ta, int *__np)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
void fill_gregset(const struct regcache *regcache, gdb_gregset_t *gregsetp, int regno)
static td_err_e(* p_td_ta_map_id2thr)(const td_thragent_t *ta_p, thread_t tid, td_thrhandle_t *th_p)
static char * solaris_pid_to_str(struct target_ops *ops, ptid_t ptid)
static int sol_thread_alive(struct target_ops *ops, ptid_t ptid)
static char * td_state_string(td_thr_state_e statecode)
#define BMSYMBOL_VALUE_ADDRESS(symbol)
void warning(const char *fmt,...)
char *(* to_pid_to_str)(struct target_ops *, ptid_t) TARGET_DEFAULT_FUNC(default_pid_to_str)
static td_err_e(* p_td_thr_setsigpending)(const td_thrhandle_t *th_p, const uchar_t ti_pending_flag, const sigset_t ti_pending)
static td_err_e(* p_td_thr_sigsetmask)(const td_thrhandle_t *th_p, const sigset_t ti_sigmask)
td_err_e td_thr_setgregs(const td_thrhandle_t *__th, prgregset_t __gregs)
void push_target(struct target_ops *t)
struct cmd_list_element * maintenanceinfolist
static td_err_e(* p_td_thr_setprio)(const td_thrhandle_t *th_p, const int ti_pri)
static td_err_e(* p_td_thr_getxregs)(const td_thrhandle_t *th_p, const caddr_t xregset)
td_err_e td_thr_setsigpending(const td_thrhandle_t *__th, unsigned char __n, const sigset_t *__ss)
int unpush_target(struct target_ops *t)
static td_err_e(* p_td_thr_setgregs)(const td_thrhandle_t *th_p, const prgregset_t regset)
#define target_can_run(t)
static void sol_thread_new_objfile(struct objfile *objfile)
static td_err_e(* p_td_thr_validate)(const td_thrhandle_t *th_p)
static void(* p_td_log)(const int on_off)
struct ps_prochandle * gdb_ps_prochandle_t
td_err_e td_ta_get_ph(const td_thragent_t *__ta, struct ps_prochandle **__ph)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_NORETURN(noprocess())
void target_fetch_registers(struct regcache *regcache, int regno)
ps_err_e ps_ptread(gdb_ps_prochandle_t ph, gdb_ps_addr_t addr, gdb_ps_read_buf_t buf, gdb_ps_size_t size)
td_err_e td_thr_getxregsize(const td_thrhandle_t *__th, int *__sizep)
td_err_e td_thr_setprio(const td_thrhandle_t *__th, int __prio)
pthread_key_t thread_key_t
void fill_fpregset(const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regno)
td_err_e td_ta_map_lwp2thr(const td_thragent_t *__ta, lwpid_t __lwpid, td_thrhandle_t *__th)
static td_err_e(* p_td_ta_tsd_iter)(const td_thragent_t *ta_p, td_key_iter_f *cb, void *cbdata_p)
void printf_filtered(const char *format,...)
static ptid_t sol_get_ada_task_ptid(struct target_ops *self, long lwp, long thread)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
const void * gdb_ps_write_buf_t
static td_err_e(* p_td_thr_getxregsize)(const td_thrhandle_t *th_p, int *xregsize)
ptid_t ptid_build(int pid, long lwp, long tid)
static ptid_t sol_thread_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *ourstatus, int options)
static td_err_e(* p_td_thr_tsd)(const td_thrhandle_t *th_p, const thread_key_t key, void **data_pp)
td_err_e td_thr_getfpregs(const td_thrhandle_t *__th, prfpregset_t *__regset)
ps_err_e ps_pstop(gdb_ps_prochandle_t ph)
int in_thread_list(ptid_t ptid)
struct thread_info * iterate_over_threads(thread_callback_func, void *)
#define MSYMBOL_PRINT_NAME(symbol)
gdb_fpregset_t prfpregset_t
ps_err_e ps_lsetregs(gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset)
struct cleanup * save_inferior_ptid(void)
void ps_plog(const char *fmt,...)
struct target_ops current_target
int td_thr_iter_f(const td_thrhandle_t *, void *)
void complete_target_initialization(struct target_ops *t)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t err
GDB_GREGSET_T gdb_gregset_t
td_err_e td_thr_sigsetmask(const td_thrhandle_t *__th, const sigset_t *__ss)
void vfprintf_filtered(struct ui_file *stream, const char *format, va_list args)
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())
static td_err_e(* p_td_thr_getgregs)(const td_thrhandle_t *th_p, prgregset_t regset)
GDB_FPREGSET_T gdb_fpregset_t
static void sol_thread_store_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
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)
void supply_gregset(struct regcache *regcache, const gdb_gregset_t *gregsetp)
static void init_sol_thread_ops(void)
static td_err_e(* p_td_ta_get_nthreads)(const td_thragent_t *ta_p, int *nthread_p)
struct td_thragent td_thragent_t
static char * td_err_string(td_err_e errcode)
ps_err_e ps_lgetregs(gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
ps_err_e ps_lsetfpregs(gdb_ps_prochandle_t ph, lwpid_t lwpid, const prfpregset_t *fpregset)
td_err_e td_ta_delete(td_thragent_t *__ta)
td_err_e td_thr_getgregs(const td_thrhandle_t *__th, prgregset_t __gregs)
static td_err_e(* p_td_thr_getfpregs)(const td_thrhandle_t *th_p, prfpregset_t *fpregset)
static void sol_thread_detach(struct target_ops *ops, const char *args, int from_tty)
ps_err_e ps_lsetxregs(gdb_ps_prochandle_t ph, lwpid_t lwpid, caddr_t xregset)
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
static td_thragent_t * main_ta
struct target_ops * find_target_beneath(struct target_ops *t)
void printf_unfiltered(const char *format,...)
void(* to_detach)(struct target_ops *ops, const char *, int) TARGET_DEFAULT_IGNORE()
static ptid_t thread_to_lwp(ptid_t thread_id, int default_lwp)
static ptid_t lwp_to_thread(ptid_t lwp)
static void info_solthreads(char *args, int from_tty)
#define TD_THR_ANY_USER_FLAGS
static int sol_update_thread_list_callback(const td_thrhandle_t *th, void *ignored)
int ptid_get_pid(ptid_t ptid)
td_err_e td_ta_tsd_iter(const td_thragent_t *__ta, td_key_iter_f *__ki, void *__p)
gdb_gregset_t prgregset_t
td_err_e td_thr_setxregs(const td_thrhandle_t *__th, const void *__addr)
void target_update_thread_list(void)
static int thread_db_find_thread_from_tid(struct thread_info *thread, void *data)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
long ptid_get_tid(ptid_t ptid)
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)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
td_err_e td_thr_validate(const td_thrhandle_t *__th)
int xsnprintf(char *str, size_t size, const char *format,...)
enum target_waitkind kind
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
static td_err_e(* p_td_ta_delete)(td_thragent_t *ta_p)
struct ui_file * gdb_stderr
struct minimal_symbol * minsym
ps_err_e ps_pdwrite(gdb_ps_prochandle_t ph, gdb_ps_addr_t addr, gdb_ps_write_buf_t buf, gdb_ps_size_t size)
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)
td_err_e td_thr_setfpregs(const td_thrhandle_t *__th, const prfpregset_t *__fpregs)
ps_err_e ps_ptwrite(gdb_ps_prochandle_t ph, gdb_ps_addr_t addr, gdb_ps_write_buf_t buf, gdb_ps_size_t size)
static ps_err_e rw_common(int dowrite, const struct ps_prochandle *ph, gdb_ps_addr_t addr, gdb_byte *buf, int size)
static void sol_update_thread_list(struct target_ops *ops)
static int sol_thread_active
td_err_e td_ta_map_id2thr(const td_thragent_t *__ta, pthread_t __pt, td_thrhandle_t *__th)
static struct ps_prochandle main_ph
static void check_for_thread_db(void)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
int is_exited(ptid_t ptid)
const char * to_shortname
ps_err_e ps_lstop(gdb_ps_prochandle_t ph, lwpid_t lwpid)
struct target_ops sol_thread_ops
unsigned long long ULONGEST
void target_store_registers(struct regcache *regcache, int regno)
static enum target_xfer_status sol_thread_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
ps_err_e ps_lgetxregs(gdb_ps_prochandle_t ph, lwpid_t lwpid, caddr_t xregset)
static void sol_thread_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regnum)
struct observer * observer_attach_new_objfile(observer_new_objfile_ftype *f)
long ptid_get_lwp(ptid_t ptid)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
static td_err_e(* p_td_init)(void)
int(* to_thread_alive)(struct target_ops *, ptid_t ptid) TARGET_DEFAULT_RETURN(0)
ps_err_e ps_pcontinue(gdb_ps_prochandle_t ph)
static td_err_e(* p_td_ta_map_lwp2thr)(const td_thragent_t *ta_p, lwpid_t lwpid, td_thrhandle_t *th_p)
td_err_e td_thr_tsd(const td_thrhandle_t *__th, const thread_key_t __tk, void **__data)
void(* to_update_thread_list)(struct target_ops *) TARGET_DEFAULT_IGNORE()
static td_err_e(* p_td_thr_setxregs)(const td_thrhandle_t *th_p, const caddr_t xregset)
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
static void sol_thread_mourn_inferior(struct target_ops *ops)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
int ptid_tid_p(ptid_t ptid)
ptid_t(* to_get_ada_task_ptid)(struct target_ops *, long lwp, long thread) TARGET_DEFAULT_FUNC(default_get_ada_task_ptid)
int ptid_lwp_p(ptid_t ptid)
static void sol_thread_resume(struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal signo)
void error(const char *fmt,...)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
struct target_ops * beneath
void do_cleanups(struct cleanup *old_chain)
struct regcache * get_thread_arch_regcache(ptid_t ptid, struct gdbarch *gdbarch)
ps_err_e ps_pdread(gdb_ps_prochandle_t ph, gdb_ps_addr_t addr, gdb_ps_read_buf_t buf, gdb_ps_size_t size)
void supply_fpregset(struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
const ULONGEST const LONGEST len