Update libthread_db for gdb-7.0 - DO NOT MERGE

Change-Id: Id02b29314109ad1bf6de3388f856af6da3f90d33
This commit is contained in:
David 'Digit' Turner 2010-03-19 16:01:28 -07:00
parent 410b2ae7fb
commit 20783c1428
2 changed files with 73 additions and 11 deletions

View File

@ -10,6 +10,8 @@
#include <stdint.h>
#include <sys/types.h>
typedef void *psaddr_t;
typedef pid_t lwpid_t;
#define TD_THR_ANY_USER_FLAGS 0xffffffff
#define TD_THR_LOWEST_PRIORITY -20
@ -67,6 +69,7 @@ typedef pthread_t thread_t;
typedef struct
{
pid_t pid;
struct ps_prochandle *ph;
} td_thragent_t;
typedef struct
@ -123,19 +126,37 @@ struct ps_prochandle;
extern "C"{
#endif
extern td_err_e td_ta_new(struct ps_prochandle const * proc_handle, td_thragent_t ** thread_agent);
extern td_err_e td_ta_new(struct ps_prochandle * proc_handle, td_thragent_t ** thread_agent);
extern td_err_e td_ta_delete(td_thragent_t * ta);
extern td_err_e td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * event);
extern td_err_e td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * notify);
extern td_err_e td_ta_clear_event(const td_thragent_t * ta_arg,
td_thr_events_t * event);
extern td_err_e td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event);
extern td_err_e td_ta_map_lwp2thr(td_thragent_t const * agent, lwpid_t lwpid,
td_thrhandle_t *th);
extern td_err_e td_thr_get_info(td_thrhandle_t const * handle,
td_thrinfo_t * info);
extern td_err_e td_thr_event_enable(td_thrhandle_t const * handle,
td_event_e event);
extern td_err_e td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags);
extern char const ** td_symbol_list(void);
extern td_err_e td_thr_tls_get_addr(const td_thrhandle_t * th,
psaddr_t map_address, size_t offset,
psaddr_t * address);
#ifdef __cplusplus
}
#endif

View File

@ -10,12 +10,7 @@
#include <stdio.h>
extern int ps_pglobal_lookup (void *, const char *obj, const char *name, void **sym_addr);
struct ps_prochandle
{
pid_t pid;
};
extern pid_t ps_getpid(struct ps_prochandle *ph);
/*
* This is the list of "special" symbols we care about whose addresses are
@ -41,7 +36,7 @@ td_symbol_list(void)
td_err_e
td_ta_new(struct ps_prochandle const * proc_handle, td_thragent_t ** agent_out)
td_ta_new(struct ps_prochandle * proc_handle, td_thragent_t ** agent_out)
{
td_thragent_t * agent;
@ -50,13 +45,25 @@ td_ta_new(struct ps_prochandle const * proc_handle, td_thragent_t ** agent_out)
return TD_MALLOC;
}
agent->pid = proc_handle->pid;
agent->pid = ps_getpid(proc_handle);
agent->ph = proc_handle;
*agent_out = agent;
return TD_OK;
}
td_err_e
td_ta_delete(td_thragent_t * ta)
{
free(ta);
// FIXME: anything else to do?
return TD_OK;
}
/* NOTE: not used by gdb 7.0 */
td_err_e
td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * events)
{
@ -64,8 +71,11 @@ td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * events)
}
/* NOTE: not used by gdb 7.0 */
static td_thrhandle_t gEventMsgHandle;
/* NOTE: not used by gdb 7.0 */
static int
_event_getmsg_helper(td_thrhandle_t const * handle, void * bkpt_addr)
{
@ -83,6 +93,8 @@ _event_getmsg_helper(td_thrhandle_t const * handle, void * bkpt_addr)
return 0;
}
/* NOTE: not used by gdb 7.0 */
td_err_e
td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event)
{
@ -106,6 +118,16 @@ td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event)
}
td_err_e
td_ta_map_lwp2thr(td_thragent_t const * agent, lwpid_t lwpid,
td_thrhandle_t *th)
{
th->pid = ps_getpid(agent->ph);
th->tid = lwpid;
return TD_OK;
}
td_err_e
td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info)
{
@ -117,6 +139,8 @@ td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info)
}
/* NOTE: not used by gdb 7.0 */
td_err_e
td_thr_event_enable(td_thrhandle_t const * handle, td_event_e event)
{
@ -125,6 +149,8 @@ td_thr_event_enable(td_thrhandle_t const * handle, td_event_e event)
}
/* NOTE: not used by gdb 7.0 */
td_err_e
td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * notify_out)
{
@ -148,6 +174,15 @@ td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * no
}
td_err_e
td_ta_clear_event(const td_thragent_t * ta_arg, td_thr_events_t * event)
{
/* Given that gdb 7.0 doesn't use thread events,
there's nothing we need to do here. */
return TD_OK;
}
td_err_e
td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags)
@ -170,8 +205,8 @@ td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
continue;
}
handle.tid = atoi(entry->d_name);
err = func(&handle, cookie);
if (err) {
if (func(&handle, cookie) != 0) {
err = TD_DBERR;
break;
}
}
@ -181,3 +216,9 @@ td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
return err;
}
td_err_e
td_thr_tls_get_addr(const td_thrhandle_t * th,
psaddr_t map_address, size_t offset, psaddr_t * address)
{
return TD_NOAPLIC; // FIXME: TODO
}