thread_dbP.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Private header for thread debug library. */
  2. #ifndef _THREAD_DBP_H
  3. #define _THREAD_DBP_H 1
  4. #include <string.h>
  5. #include <unistd.h>
  6. #include "proc_service.h"
  7. #include "thread_db.h"
  8. #include "../linuxthreads/descr.h"
  9. /* Indeces for the symbol names. */
  10. enum
  11. {
  12. PTHREAD_THREADS_EVENTS = 0,
  13. PTHREAD_LAST_EVENT,
  14. PTHREAD_HANDLES_NUM,
  15. PTHREAD_HANDLES,
  16. PTHREAD_KEYS,
  17. LINUXTHREADS_PTHREAD_THREADS_MAX,
  18. LINUXTHREADS_PTHREAD_KEYS_MAX,
  19. LINUXTHREADS_PTHREAD_SIZEOF_DESCR,
  20. LINUXTHREADS_CREATE_EVENT,
  21. LINUXTHREADS_DEATH_EVENT,
  22. LINUXTHREADS_REAP_EVENT,
  23. LINUXTHREADS_INITIAL_REPORT_EVENTS,
  24. LINUXTHREADS_VERSION,
  25. NUM_MESSAGES
  26. };
  27. /* Comment out the following for less verbose output. */
  28. #ifndef NDEBUG
  29. # define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n"))
  30. extern int __td_debug;
  31. #else
  32. # define LOG(c)
  33. #endif
  34. /* Handle for a process. This type is opaque. */
  35. struct td_thragent
  36. {
  37. /* Delivered by the debugger and we have to pass it back in the
  38. proc callbacks. */
  39. struct ps_prochandle *ph;
  40. /* Some cached information. */
  41. /* Address of the `__pthread_handles' array. */
  42. struct pthread_handle_struct *handles;
  43. /* Address of the `pthread_kyes' array. */
  44. struct pthread_key_struct *keys;
  45. /* Maximum number of threads. */
  46. int pthread_threads_max;
  47. /* Maximum number of thread-local data keys. */
  48. int pthread_keys_max;
  49. /* Size of 2nd level array for thread-local data keys. */
  50. int pthread_key_2ndlevel_size;
  51. /* Sizeof struct _pthread_descr_struct. */
  52. int sizeof_descr;
  53. /* Pointer to the `__pthread_threads_events' variable in the target. */
  54. psaddr_t pthread_threads_eventsp;
  55. /* Pointer to the `__pthread_last_event' variable in the target. */
  56. psaddr_t pthread_last_event;
  57. /* Pointer to the `__pthread_handles_num' variable. */
  58. psaddr_t pthread_handles_num;
  59. };
  60. /* Type used internally to keep track of thread agent descriptors. */
  61. struct agent_list
  62. {
  63. td_thragent_t *ta;
  64. struct agent_list *next;
  65. };
  66. /* List of all known descriptors. */
  67. extern struct agent_list *__td_agent_list;
  68. /* Function used to test for correct thread agent pointer. */
  69. static inline int
  70. ta_ok (const td_thragent_t *ta)
  71. {
  72. struct agent_list *runp = __td_agent_list;
  73. if (ta == NULL)
  74. return 0;
  75. while (runp != NULL && runp->ta != ta)
  76. runp = runp->next;
  77. return runp != NULL;
  78. }
  79. /* Internal wrapper around ps_pglobal_lookup. */
  80. extern int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr);
  81. #endif /* thread_dbP.h */