thread_dbP.h 2.4 KB

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