db_info.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* This file is included by pthread_create.c to define in libpthread
  2. all the magic symbols required by libthread_db.
  3. Copyright (C) 2003-2026 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <https://www.gnu.org/licenses/>. */
  16. #include <stdint.h>
  17. #include "thread_dbP.h"
  18. #include <tls.h>
  19. #include <ldsodefs.h>
  20. typedef struct pthread pthread;
  21. typedef struct pthread_key_struct pthread_key_struct;
  22. typedef struct pthread_key_data pthread_key_data;
  23. typedef struct
  24. {
  25. struct pthread_key_data data[PTHREAD_KEY_2NDLEVEL_SIZE];
  26. }
  27. pthread_key_data_level2;
  28. typedef struct
  29. {
  30. union dtv dtv[UINT32_MAX / 2 / sizeof (union dtv)]; /* No constant bound. */
  31. } dtv;
  32. typedef struct link_map link_map;
  33. typedef struct rtld_global rtld_global;
  34. typedef struct dtv_slotinfo_list dtv_slotinfo_list;
  35. typedef struct dtv_slotinfo dtv_slotinfo;
  36. #define schedparam_sched_priority schedparam.sched_priority
  37. #define eventbuf_eventmask eventbuf.eventmask
  38. #define eventbuf_eventmask_event_bits eventbuf.eventmask.event_bits
  39. #define DESC(name, offset, obj) \
  40. DB_DEFINE_DESC (name, 8 * sizeof (obj), 1, offset);
  41. #define ARRAY_DESC(name, offset, obj) \
  42. DB_DEFINE_DESC (name, \
  43. 8 * sizeof (obj)[0], sizeof (obj) / sizeof (obj)[0], \
  44. offset);
  45. /* Flexible arrays do not have a length that can be determined. */
  46. #define FLEXIBLE_ARRAY_DESC(name, offset, obj) \
  47. DB_DEFINE_DESC (name, 8 * sizeof (obj)[0], 0, offset);
  48. #if TLS_TCB_AT_TP
  49. # define dtvp header.dtv
  50. #elif TLS_DTV_AT_TP
  51. /* Special case hack. If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB
  52. containing the DTV at the TP, but actually the TCB lies behind the TP,
  53. i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. */
  54. DESC (_thread_db_pthread_dtvp,
  55. TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
  56. - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
  57. #endif
  58. #define DB_STRUCT(type) \
  59. const uint32_t _thread_db_sizeof_##type = sizeof (type);
  60. #define DB_STRUCT_FIELD(type, field) \
  61. DESC (_thread_db_##type##_##field, \
  62. offsetof (type, field), ((type *) 0)->field)
  63. #define DB_STRUCT_ARRAY_FIELD(type, field) \
  64. ARRAY_DESC (_thread_db_##type##_##field, \
  65. offsetof (type, field), ((type *) 0)->field)
  66. #define DB_STRUCT_FLEXIBLE_ARRAY(type, field) \
  67. FLEXIBLE_ARRAY_DESC (_thread_db_##type##_##field, \
  68. offsetof (type, field), ((type *) 0)->field)
  69. #define DB_VARIABLE(name) DESC (_thread_db_##name, 0, name)
  70. #define DB_ARRAY_VARIABLE(name) ARRAY_DESC (_thread_db_##name, 0, name)
  71. #define DB_SYMBOL(name) /* Nothing. */
  72. #define DB_FUNCTION(name) /* Nothing. */
  73. #include "structs.def"
  74. #undef DB_STRUCT
  75. #undef DB_STRUCT_FIELD
  76. #undef DB_SYMBOL
  77. #undef DB_FUNCTION
  78. #undef DB_VARIABLE
  79. #undef DESC
  80. #ifdef DB_THREAD_SELF
  81. # ifdef DB_THREAD_SELF_INCLUDE
  82. # include DB_THREAD_SELF_INCLUDE
  83. # endif
  84. /* This macro is defined in the machine's tls.h using the three below. */
  85. # define CONST_THREAD_AREA(bits, value) \
  86. const uint32_t _thread_db_const_thread_area = (value);
  87. # define REGISTER_THREAD_AREA(bits, regofs, scale) \
  88. DB_DEFINE_DESC (_thread_db_register##bits##_thread_area, \
  89. bits, (scale), (regofs));
  90. # define REGISTER(bits, size, regofs, bias) \
  91. DB_DEFINE_DESC (_thread_db_register##bits, size, (uint32_t)(bias), (regofs));
  92. DB_THREAD_SELF
  93. #endif