53#include <proc_service.h>
74 N_(
"Solaris threads and pthread."),
75 N_(
"Solaris threads and pthread support.")
88 void resume (ptid_t,
int,
enum gdb_signal)
override;
99 const gdb_byte *writebuf,
100 ULONGEST offset, ULONGEST len,
101 ULONGEST *xfered_len)
override;
150 sigset_t *ti_sigmask_p,
151 unsigned ti_user_flags);
158 prfpregset_t *fpregset);
162 const caddr_t xregset);
164 const sigset_t ti_sigmask);
168 const uchar_t ti_pending_flag,
169 const sigset_t ti_pending);
171 const prfpregset_t *fpregset);
173 const caddr_t xregset);
183 const prgregset_t
regset);
220 {
TD_OK,
"generic \"call succeeded\"" },
221 {
TD_ERR,
"generic error." },
222 {
TD_NOTHR,
"no thread can be found to satisfy query" },
223 {
TD_NOSV,
"no synch. variable can be found to satisfy query" },
224 {
TD_NOLWP,
"no lwp can be found to satisfy query" },
225 {
TD_BADPH,
"invalid process handle" },
226 {
TD_BADTH,
"invalid thread handle" },
227 {
TD_BADSH,
"invalid synchronization handle" },
228 {
TD_BADTA,
"invalid thread agent" },
230 {
TD_NOMSG,
"td_thr_event_getmsg() called when there was no message" },
231 {
TD_NOFPREGS,
"FPU register set not available for given thread" },
233 {
TD_NOEVENT,
"requested event is not supported" },
235 {
TD_DBERR,
"Debugger service failed" },
236 {
TD_NOAPLIC,
"Operation not applicable to" },
237 {
TD_NOTSD,
"No thread specific data for this thread" },
239 {
TD_PARTIALREG,
"Only part of register set was written/read" },
240 {
TD_NOXREGS,
"X register set not available for given thread" }
242 const int td_err_size =
sizeof td_err_table /
sizeof (
struct string_map);
246 for (i = 0; i < td_err_size; i++)
247 if (td_err_table[i].
num == errcode)
248 return td_err_table[i].
str;
250 xsnprintf (buf,
sizeof (buf),
"Unknown libthread_db error code: %d",
262 static struct string_map td_thr_state_table[] =
273 const int td_thr_state_table_size =
274 sizeof td_thr_state_table /
sizeof (
struct string_map);
278 for (i = 0; i < td_thr_state_table_size; i++)
279 if (td_thr_state_table[i].
num == statecode)
280 return td_thr_state_table[i].
str;
282 xsnprintf (buf,
sizeof (buf),
"Unknown libthread_db state code: %d",
302 if (thread_id.lwp_p ())
310 else if (val !=
TD_OK)
311 error (_(
"thread_to_lwp: td_ta_map_id2thr %s"),
td_err_string (val));
316 else if (val !=
TD_OK)
317 error (_(
"thread_to_lwp: td_thr_get_info: %s"),
td_err_string (val));
321 if (default_lwp != -1)
322 return ptid_t (default_lwp);
323 error (_(
"thread_to_lwp: thread state not active: %s"),
327 return ptid_t (thread_id.pid (), ti.
ti_lid, 0);
353 else if (val !=
TD_OK)
354 error (_(
"lwp_to_thread: td_ta_map_lwp2thr: %s."),
td_err_string (val));
359 else if (val !=
TD_OK)
360 error (_(
"lwp_to_thread: td_thr_validate: %s."),
td_err_string (val));
365 else if (val !=
TD_OK)
366 error (_(
"lwp_to_thread: td_thr_get_info: %s."),
td_err_string (val));
368 return ptid_t (lwp.pid (), 0 , ti.
ti_tid);
390 inf->unpush_target (
this);
402 scoped_restore save_inferior_ptid = make_scoped_restore (&
inferior_ptid);
408 if (ptid.pid () != -1)
410 ptid_t save_ptid = ptid;
413 if (ptid.pid () == -2)
414 error (_(
"This version of Solaris can't start inactive threads."));
416 warning (_(
"Specified thread %s seems to have terminated"),
417 pulongest (save_ptid.tid ()));
428 target_wait_flags options)
430 if (ptid.pid () != -1)
432 ptid_t ptid_for_warning = ptid;
435 if (ptid.pid () == -2)
436 error (_(
"This version of Solaris can't start inactive threads."));
438 warning (_(
"Specified thread %s seems to have terminated"),
439 pulongest (ptid_for_warning.tid ()));
442 ptid_t rtnval =
beneath ()->
wait (ptid, ourstatus, options);
448 if (thr_ptid.pid () != -1)
478 prfpregset_t fpregset;
491 thread = ptid.tid ();
493 error (_(
"sol_thread_fetch_registers: thread == 0"));
497 error (_(
"sol_thread_fetch_registers: td_ta_map_id2thr: %s"),
504 error (_(
"sol_thread_fetch_registers: td_thr_getgregs %s"),
514 error (_(
"sol_thread_fetch_registers: td_thr_getfpregs %s"),
532 prfpregset_t fpregset;
543 thread = ptid.tid ();
547 error (_(
"sol_thread_store_registers: td_ta_map_id2thr %s"),
554 error (_(
"sol_thread_store_registers: td_thr_getgregs %s"),
558 error (_(
"sol_thread_store_registers: td_thr_getfpregs %s"),
567 error (_(
"sol_thread_store_registers: td_thr_setgregs %s"),
571 error (_(
"sol_thread_store_registers: td_thr_setfpregs %s"),
581 const char *annex, gdb_byte *readbuf,
582 const gdb_byte *writebuf,
583 ULONGEST offset, ULONGEST len,
584 ULONGEST *xfered_len)
586 scoped_restore save_inferior_ptid = make_scoped_restore (&
inferior_ptid);
599 writebuf, offset, len, xfered_len);
641 gdb_printf (_(
"[Thread debugging using libthread_db enabled]\n"));
649 if (ptid.pid () != -1)
656 warning (_(
"Cannot initialize thread debugging library: %s"),
761 const char *ld_symbol_name, psaddr_t *ld_symbol_addr)
777 gdb_byte *buf,
int size)
781 scoped_restore save_inferior_ptid = make_scoped_restore (&
inferior_ptid);
793#if defined (__sparcv9)
805 return (ret == 0 ? PS_OK : PS_ERR);
820 const void *buf,
size_t size)
837 const void *buf,
size_t size)
862 const prgregset_t gregset)
882 va_start (args, fmt);
915 prfpregset_t *fpregset)
932 const prfpregset_t * fpregset)
953 *data_model = PR_MODEL_UNKNOWN;
955 *data_model = PR_MODEL_ILP32;
957 *data_model = PR_MODEL_LP64;
974 if (lwp.pid () == -1)
975 return string_printf (
"Thread %s (defunct)",
976 pulongest (ptid.tid ()));
977 else if (lwp.pid () != -2)
978 return string_printf (
"Thread %s (LWP %ld)",
979 pulongest (ptid.tid ()), lwp.lwp ());
981 return string_printf (
"Thread %s ",
982 pulongest (ptid.tid ()));
984 else if (ptid.lwp () != 0)
985 return string_printf (
"LWP %ld ", ptid.lwp ());
987 return string_printf (
"process %d ", ptid.pid ());
1001 if (retval !=
TD_OK)
1100 warning (_(
"info sol-thread: failed to get info for thread."));
1122 ULONGEST *tid = (ULONGEST *) data;
1124 if (thread->
ptid.tid () == *tid)
1156 dlhandle = dlopen (
"libthread_db.so.1", RTLD_NOW);
1161 if (!(p_##X = (X ## _ftype *) dlsym (dlhandle, #X))) \
1197[GDB will not be able to debug user-mode threads: %s]\n", dlerror ());
void supply_gregset(struct regcache *regcache, const gdb_gregset_t *gregsetp)
void fill_gregset(const struct regcache *regcache, gdb_gregset_t *gregsetp, int regno)
void supply_fpregset(struct regcache *regcache, const gdb_fpregset_t *fpregsetp)
void fill_fpregset(const struct regcache *regcache, gdb_fpregset_t *fpregsetp, int regno)
struct gdbarch * target_gdbarch(void)
thread_info * find_thread(ptid_t ptid)
int unpush_target(struct target_ops *t)
void push_target(struct target_ops *t)
struct process_stratum_target * process_target()
void mourn_inferior() override
void store_registers(struct regcache *, int) override
void resume(ptid_t, int, enum gdb_signal) override
enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override
void fetch_registers(struct regcache *, int) override
void detach(inferior *, int) override
std::string pid_to_str(ptid_t) override
ptid_t get_ada_task_ptid(long lwp, ULONGEST thread) override
bool thread_alive(ptid_t ptid) override
ptid_t wait(ptid_t, struct target_waitstatus *, target_wait_flags) override
void update_thread_list() override
const target_info & info() const override
strata stratum() const override
struct cmd_list_element * maintenanceinfolist
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct thread_info * add_thread(process_stratum_target *targ, ptid_t ptid)
struct thread_info * iterate_over_threads(thread_callback_func, void *)
td_err_e td_thr_setprio(const td_thrhandle_t *__th, int __prio)
pthread_key_t thread_key_t
td_err_e td_ta_tsd_iter(const td_thragent_t *__ta, td_key_iter_f *__ki, void *__p)
td_err_e td_thr_getxregs(const td_thrhandle_t *__th, void *__xregs)
td_err_e td_thr_setgregs(const td_thrhandle_t *__th, prgregset_t __gregs)
int td_key_iter_f(thread_key_t, void(*)(void *), void *)
td_err_e td_thr_getfpregs(const td_thrhandle_t *__th, prfpregset_t *__regset)
td_err_e td_ta_map_id2thr(const td_thragent_t *__ta, pthread_t __pt, td_thrhandle_t *__th)
#define TD_THR_LOWEST_PRIORITY
td_err_e td_thr_sigsetmask(const td_thrhandle_t *__th, const sigset_t *__ss)
int td_thr_iter_f(const td_thrhandle_t *, void *)
td_err_e td_thr_setfpregs(const td_thrhandle_t *__th, const prfpregset_t *__fpregs)
td_err_e td_ta_new(struct ps_prochandle *__ps, td_thragent_t **__ta)
td_err_e td_thr_setxregs(const td_thrhandle_t *__th, const void *__addr)
td_err_e td_thr_tsd(const td_thrhandle_t *__th, const thread_key_t __tk, void **__data)
td_err_e td_ta_get_nthreads(const td_thragent_t *__ta, int *__np)
struct td_thragent td_thragent_t
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)
td_err_e td_thr_getxregsize(const td_thrhandle_t *__th, int *__sizep)
td_err_e td_ta_get_ph(const td_thragent_t *__ta, struct ps_prochandle **__ph)
td_err_e td_ta_map_lwp2thr(const td_thragent_t *__ta, lwpid_t __lwpid, td_thrhandle_t *__th)
td_err_e td_thr_setsigpending(const td_thrhandle_t *__th, unsigned char __n, const sigset_t *__ss)
#define TD_THR_ANY_USER_FLAGS
td_err_e td_thr_validate(const td_thrhandle_t *__th)
td_err_e td_thr_getgregs(const td_thrhandle_t *__th, prgregset_t __gregs)
td_err_e td_ta_delete(td_thragent_t *__ta)
td_err_e td_thr_get_info(const td_thrhandle_t *__th, td_thrinfo_t *__infop)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
GDB_FPREGSET_T gdb_fpregset_t
GDB_GREGSET_T gdb_gregset_t
struct inferior * current_inferior(void)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
observable< struct objfile * > new_objfile
ptid_t procfs_first_available(void)
struct program_space * current_program_space
struct regcache * get_thread_arch_regcache(process_stratum_target *target, ptid_t ptid, struct gdbarch *gdbarch)
td_err_e td_thr_getfpregs_ftype(const td_thrhandle_t *th_p, prfpregset_t *fpregset)
static td_thr_validate_ftype * p_td_thr_validate
td_err_e td_ta_tsd_iter_ftype(const td_thragent_t *ta_p, td_key_iter_f *cb, void *cbdata_p)
ps_err_e ps_lgetxregsize(struct ps_prochandle *ph, lwpid_t lwpid, int *xregsize)
static td_thr_getgregs_ftype * p_td_thr_getgregs
td_err_e td_thr_setfpregs_ftype(const td_thrhandle_t *th_p, const prfpregset_t *fpregset)
static td_log_ftype * p_td_log
ps_err_e ps_pcontinue(struct ps_prochandle *ph)
ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lwpid)
static td_ta_delete_ftype * p_td_ta_delete
td_err_e td_thr_setprio_ftype(const td_thrhandle_t *th_p, const int ti_pri)
static td_ta_new_ftype * p_td_ta_new
ps_err_e ps_lcontinue(struct ps_prochandle *ph, lwpid_t lwpid)
td_err_e td_thr_setxregs_ftype(const td_thrhandle_t *th_p, const caddr_t xregset)
static td_thr_sigsetmask_ftype * p_td_thr_sigsetmask
td_err_e td_ta_map_id2thr_ftype(const td_thragent_t *ta_p, thread_t tid, td_thrhandle_t *th_p)
td_err_e td_thr_validate_ftype(const td_thrhandle_t *th_p)
static ptid_t lwp_to_thread(ptid_t lwp)
static td_thr_setprio_ftype * p_td_thr_setprio
static td_thr_setxregs_ftype * p_td_thr_setxregs
static sol_thread_target sol_thread_ops
static td_ta_get_ph_ftype * p_td_ta_get_ph
void _initialize_sol_thread()
static td_thragent_t * main_ta
static const char * td_state_string(td_thr_state_e statecode)
static ps_err_e rw_common(int dowrite, const struct ps_prochandle *ph, psaddr_t addr, gdb_byte *buf, int size)
ps_err_e ps_lgetxregs(struct ps_prochandle *ph, lwpid_t lwpid, caddr_t xregset)
static td_thr_tsd_ftype * p_td_thr_tsd
static int info_cb(const td_thrhandle_t *th, void *s)
ps_err_e ps_ptwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf, size_t size)
ps_err_e ps_lgetfpregs(struct ps_prochandle *ph, lwpid_t lwpid, prfpregset_t *fpregset)
td_err_e td_ta_thr_iter_ftype(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)
static int sol_thread_active
td_err_e td_thr_getgregs_ftype(const td_thrhandle_t *th_p, prgregset_t regset)
static const target_info thread_db_target_info
static td_ta_thr_iter_ftype * p_td_ta_thr_iter
void ps_plog(const char *fmt,...)
td_err_e td_ta_new_ftype(const struct ps_prochandle *ph_p, td_thragent_t **ta_pp)
td_err_e td_init_ftype(void)
ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset)
static td_thr_getxregsize_ftype * p_td_thr_getxregsize
static int sol_update_thread_list_callback(const td_thrhandle_t *th, void *ignored)
ps_err_e ps_ptread(struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t size)
ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lwpid, const prfpregset_t *fpregset)
static int thread_db_find_thread_from_tid(struct thread_info *thread, void *data)
static void check_for_thread_db(void)
td_err_e td_thr_tsd_ftype(const td_thrhandle_t *th_p, const thread_key_t key, void **data_pp)
static td_thr_setfpregs_ftype * p_td_thr_setfpregs
static td_ta_tsd_iter_ftype * p_td_ta_tsd_iter
static void sol_thread_new_objfile(struct objfile *objfile)
ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t size)
void td_log_ftype(const int on_off)
static td_ta_get_nthreads_ftype * p_td_ta_get_nthreads
ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *ld_object_name, const char *ld_symbol_name, psaddr_t *ld_symbol_addr)
td_err_e td_ta_map_lwp2thr_ftype(const td_thragent_t *ta_p, lwpid_t lwpid, td_thrhandle_t *th_p)
static td_thr_get_info_ftype * p_td_thr_get_info
static td_thr_getfpregs_ftype * p_td_thr_getfpregs
ps_err_e ps_pstop(struct ps_prochandle *ph)
td_err_e td_ta_get_ph_ftype(const td_thragent_t *ta_p, struct ps_prochandle **ph_pp)
ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf, size_t size)
static td_thr_setgregs_ftype * p_td_thr_setgregs
static td_ta_map_id2thr_ftype * p_td_ta_map_id2thr
td_err_e td_thr_setgregs_ftype(const td_thrhandle_t *th_p, const prgregset_t regset)
static td_init_ftype * p_td_init
td_err_e td_ta_get_nthreads_ftype(const td_thragent_t *ta_p, int *nthread_p)
static struct ps_prochandle main_ph
ps_err_e ps_lsetxregs(struct ps_prochandle *ph, lwpid_t lwpid, caddr_t xregset)
ps_err_e ps_pdmodel(struct ps_prochandle *ph, int *data_model)
td_err_e td_thr_setsigpending_ftype(const td_thrhandle_t *th_p, const uchar_t ti_pending_flag, const sigset_t ti_pending)
td_err_e td_thr_getxregs_ftype(const td_thrhandle_t *th_p, const caddr_t xregset)
static const char * td_err_string(td_err_e errcode)
static td_thr_getxregs_ftype * p_td_thr_getxregs
ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lwpid, const prgregset_t gregset)
static ptid_t thread_to_lwp(ptid_t thread_id, int default_lwp)
static void info_solthreads(const char *args, int from_tty)
static td_ta_map_lwp2thr_ftype * p_td_ta_map_lwp2thr
td_err_e td_thr_get_info_ftype(const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
td_err_e td_thr_getxregsize_ftype(const td_thrhandle_t *th_p, int *xregsize)
td_err_e td_thr_sigsetmask_ftype(const td_thrhandle_t *th_p, const sigset_t ti_sigmask)
td_err_e td_ta_delete_ftype(td_thragent_t *ta_p)
static td_thr_setsigpending_ftype * p_td_thr_setsigpending
CORE_ADDR value_address() const
struct minimal_symbol * minsym
const char * print_name() const
virtual ptid_t wait(ptid_t, struct target_waitstatus *, target_wait_flags options) TARGET_DEFAULT_FUNC(default_target_wait)
virtual void fetch_registers(struct regcache *, int) TARGET_DEFAULT_IGNORE()
virtual void detach(inferior *, int) TARGET_DEFAULT_IGNORE()
target_ops * beneath() const
virtual void store_registers(struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
virtual enum target_xfer_status xfer_partial(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)
virtual void resume(ptid_t, int TARGET_DEBUG_PRINTER(target_debug_print_step), enum gdb_signal) TARGET_DEFAULT_NORETURN(noprocess())
virtual void update_thread_list() TARGET_DEFAULT_IGNORE()
virtual void mourn_inferior() TARGET_DEFAULT_FUNC(default_mourn_inferior)
virtual bool thread_alive(ptid_t ptid) TARGET_DEFAULT_RETURN(false)
target_waitkind kind() const
void target_fetch_registers(struct regcache *regcache, int regno)
void target_update_thread_list(void)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
int target_thread_alive(ptid_t ptid)
void target_store_registers(struct regcache *regcache, int regno)
void gdb_vprintf(struct ui_file *stream, const char *format, va_list args)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)