Home | History | Annotate | Download | only in gdb-7.1.x
      1 /*
      2  * Copyright 2006 The Android Open Source Project
      3  */
      4 
      5 #ifndef _LIBTHREAD_DB__THREAD_DB_H
      6 #define _LIBTHREAD_DB__THREAD_DB_H
      7 
      8 #include <pthread.h>
      9 #include <signal.h>
     10 #include <stdint.h>
     11 #include <sys/types.h>
     12 
     13 typedef void *psaddr_t;
     14 #define HAVE_PSADDR_T 1
     15 
     16 typedef pid_t lwpid_t;
     17 #define HAVE_LWPID_T 1
     18 
     19 #define TD_THR_ANY_USER_FLAGS       0xffffffff
     20 #define TD_THR_LOWEST_PRIORITY      -20
     21 #define TD_SIGNO_MASK               NULL
     22 
     23 /* td_err_e values */
     24 enum {
     25     TD_OK,
     26     TD_ERR,
     27     TD_NOTHR,
     28     TD_NOSV,
     29     TD_NOLWP,
     30     TD_BADPH,
     31     TD_BADTH,
     32     TD_BADSH,
     33     TD_BADTA,
     34     TD_BADKEY,
     35     TD_NOMSG,
     36     TD_NOFPREGS,
     37     TD_NOLIBTHREAD,
     38     TD_NOEVENT,
     39     TD_NOCAPAB,
     40     TD_DBERR,
     41     TD_NOAPLIC,
     42     TD_NOTSD,
     43     TD_MALLOC,
     44     TD_PARTIALREG,
     45     TD_NOXREGS,
     46     TD_VERSION
     47 };
     48 
     49 /*
     50  * td_event_e values
     51  * NOTE: There is a max of 32 events
     52  */
     53 enum {
     54     TD_CREATE,
     55     TD_DEATH
     56 };
     57 
     58 /* td_thr_state_e values */
     59 enum {
     60     TD_THR_ANY_STATE,
     61     TD_THR_UNKNOWN,
     62     TD_THR_SLEEP,
     63     TD_THR_ZOMBIE
     64 };
     65 
     66 typedef int32_t td_err_e;
     67 typedef uint32_t td_event_e;
     68 typedef uint32_t td_notify_e;
     69 typedef uint32_t td_thr_state_e;
     70 typedef pthread_t thread_t;
     71 
     72 typedef struct
     73 {
     74     pid_t pid;
     75     struct ps_prochandle *ph;
     76 } td_thragent_t;
     77 
     78 typedef struct
     79 {
     80     pid_t pid;
     81     pid_t tid;
     82 } td_thrhandle_t;
     83 
     84 typedef struct
     85 {
     86     td_event_e event;
     87     td_thrhandle_t const * th_p;
     88     union {
     89         void * data;
     90     } msg;
     91 } td_event_msg_t;
     92 
     93 typedef struct
     94 {
     95     uint32_t events;
     96 } td_thr_events_t;
     97 
     98 typedef struct
     99 {
    100     union {
    101         void * bptaddr;
    102     } u;
    103 } td_notify_t;
    104 
    105 typedef struct
    106 {
    107     td_thr_state_e ti_state;
    108     thread_t ti_tid; // pthread's id for the thread
    109     int32_t ti_lid; // the kernel's id for the thread
    110 } td_thrinfo_t;
    111 
    112 
    113 #define td_event_emptyset(set) \
    114     (set)->events = 0
    115 
    116 #define td_event_fillset(set) \
    117     (set)->events = 0xffffffff
    118 
    119 #define td_event_addset(set, n) \
    120     (set)->events |= (1 << n)
    121 
    122 
    123 typedef int td_thr_iter_f(td_thrhandle_t const *, void *);
    124 
    125 
    126 struct ps_prochandle;
    127 
    128 #ifdef __cplusplus
    129 extern "C"{
    130 #endif
    131 
    132 extern td_err_e td_ta_new(struct ps_prochandle * proc_handle, td_thragent_t ** thread_agent);
    133 
    134 extern td_err_e td_ta_delete(td_thragent_t * ta);
    135 
    136 extern td_err_e td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * event);
    137 
    138 extern td_err_e td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * notify);
    139 
    140 extern td_err_e td_ta_clear_event(const td_thragent_t * ta_arg,
    141 				  td_thr_events_t * event);
    142 
    143 extern td_err_e td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event);
    144 
    145 extern td_err_e td_ta_map_lwp2thr(td_thragent_t const * agent, lwpid_t lwpid,
    146 				  td_thrhandle_t *th);
    147 
    148 extern td_err_e td_thr_get_info(td_thrhandle_t const * handle,
    149 				td_thrinfo_t * info);
    150 
    151 extern td_err_e td_thr_event_enable(td_thrhandle_t const * handle,
    152 				    td_event_e event);
    153 
    154 extern td_err_e td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,
    155                                td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags);
    156 
    157 extern char const ** td_symbol_list(void);
    158 
    159 extern td_err_e td_thr_event_enable(td_thrhandle_t const * handle, td_event_e event);
    160 
    161 extern td_err_e td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info);
    162 
    163 extern td_err_e td_thr_tls_get_addr(const td_thrhandle_t * th,
    164 				    psaddr_t map_address, size_t offset,
    165 				    psaddr_t * address);
    166 
    167 #ifdef __cplusplus
    168 }
    169 #endif
    170 
    171 #endif
    172