/* Private header for thread debug library
- Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2003-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
#ifndef _THREAD_DBP_H
#define _THREAD_DBP_H 1
#include <assert.h>
#include "proc_service.h"
#include "thread_db.h"
-#include "../nptl/pthreadP.h" /* This is for *_BITMASK only. */
+#include <pthreadP.h> /* This is for *_BITMASK only. */
+#include <list.h>
+#include <gnu/lib-names.h>
+#include <libc-diag.h>
/* Indeces for the symbol names. */
enum
{
# define DB_STRUCT(type) SYM_SIZEOF_##type,
# define DB_STRUCT_FIELD(type, field) SYM_##type##_FIELD_##field,
+# define DB_STRUCT_FLEXIBLE_ARRAY(type, field) DB_STRUCT_FIELD (type, field)
# define DB_SYMBOL(name) SYM_##name,
# define DB_FUNCTION(name) SYM_##name,
# define DB_VARIABLE(name) SYM_##name, SYM_DESC_##name,
# include "structs.def"
# undef DB_STRUCT
# undef DB_STRUCT_FIELD
+# undef DB_STRUCT_FLEXIBLE_ARRAY
# undef DB_SYMBOL
# undef DB_FUNCTION
# undef DB_VARIABLE
uint32_t ta_sizeof_##type;
# define DB_STRUCT_FIELD(type, field) \
db_desc_t ta_field_##type##_##field;
+# define DB_STRUCT_FLEXIBLE_ARRAY(type, field) DB_STRUCT_FIELD (type, field)
# define DB_SYMBOL(name) \
psaddr_t ta_addr_##name;
# define DB_FUNCTION(name) \
# include "structs.def"
# undef DB_STRUCT
# undef DB_STRUCT_FIELD
+# undef DB_STRUCT_FLEXIBLE_ARRAY
# undef DB_FUNCTION
# undef DB_SYMBOL
# undef DB_VARIABLE
+ psaddr_t ta_addr__rtld_global;
+
/* The method of locating a thread's th_unique value. */
enum
{
}
-/* Internal wrapper around ps_pglobal_lookup. */
-extern ps_err_e td_lookup (struct ps_prochandle *ps,
- int idx, psaddr_t *sym_addr) attribute_hidden;
-
-
+/* Internal wrappers around ps_pglobal_lookup. */
+extern ps_err_e td_mod_lookup (struct ps_prochandle *ps, const char *modname,
+ int idx, psaddr_t *sym_addr) attribute_hidden;
+#define td_lookup(ps, idx, sym_addr) \
+ td_mod_lookup ((ps), LIBPTHREAD_SO, (idx), (sym_addr))
/* Store in psaddr_t VAR the address of inferior's symbol NAME. */
SYM_##type##_FIELD_##field, \
(psaddr_t) 0 + (idx), (ptr), &(var))
+/* With GCC 5.3 when compiling with -Os the compiler emits a warning
+ that slot may be used uninitialized. This is never the case since
+ the dynamic loader initializes the slotinfo list and
+ dtv_slotinfo_list will point slot at the first entry. Therefore
+ when DB_GET_FIELD_ADDRESS is called with a slot for ptr, the slot is
+ always initialized. */
+DIAG_PUSH_NEEDS_COMMENT;
+DIAG_IGNORE_Os_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
#define DB_GET_FIELD_ADDRESS(var, ta, ptr, type, field, idx) \
((var) = (ptr), _td_locate_field ((ta), (ta)->ta_field_##type##_##field, \
SYM_##type##_FIELD_##field, \
(psaddr_t) 0 + (idx), &(var)))
+DIAG_POP_NEEDS_COMMENT;
extern td_err_e _td_locate_field (td_thragent_t *ta,
db_desc_t desc, int descriptor_name,
extern td_err_e __td_ta_lookup_th_unique (const td_thragent_t *ta,
lwpid_t lwpid, td_thrhandle_t *th);
+/* Try to initialize TA->ta_addr__rtld_global. Return true on
+ success, false on failure (which may be cached). */
+bool __td_ta_rtld_global (td_thragent_t *ta) attribute_hidden;
+
+/* Obtain the address of the list_t fields _dl_stack_user and
+ _dl_stack_used in _rtld_global, or fall back to the global
+ variables of the same name (to support statically linked
+ programs). */
+td_err_e __td_ta_stack_user (td_thragent_t *ta, psaddr_t *plist)
+ attribute_hidden;
+td_err_e __td_ta_stack_used (td_thragent_t *ta, psaddr_t *plist)
+ attribute_hidden;
+
#endif /* thread_dbP.h */