]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl_db/thread_dbP.h
test-container: Fix "unused code" warnings on HURD
[thirdparty/glibc.git] / nptl_db / thread_dbP.h
index 64266200f0b3dcb9d2084c8c8311ceb094ab5006..820e1e65ce2951643b1127dcabdf272d8a5e528e 100644 (file)
@@ -1,5 +1,5 @@
 /* Private header for thread debug library
-   Copyright (C) 2003 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
@@ -13,9 +13,8 @@
    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
@@ -57,7 +61,7 @@ enum
 
 /* Comment out the following for less verbose output.  */
 #ifndef NDEBUG
-# define LOG(c) if (__td_debug) __libc_write (2, c "\n", strlen (c "\n"))
+# define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n"))
 extern int __td_debug attribute_hidden;
 #else
 # define LOG(c)
@@ -66,7 +70,7 @@ extern int __td_debug attribute_hidden;
 
 #define DB_DESC_SIZE(desc)     ((desc)[0])
 #define DB_DESC_NELEM(desc)    ((desc)[1])
-#define DB_DESC_OFFSET(desc)   ((int32_t) (desc)[2])
+#define DB_DESC_OFFSET(desc)   ((desc)[2])
 #define DB_SIZEOF_DESC         (3 * sizeof (uint32_t))
 #define DB_DEFINE_DESC(name, size, nelem, offset) \
   const uint32_t name[3] = { (size), (nelem), (offset) }
@@ -88,6 +92,7 @@ struct td_thragent
   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) \
@@ -98,10 +103,13 @@ struct td_thragent
 # 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
     {
@@ -139,11 +147,11 @@ ta_ok (const td_thragent_t *ta)
 }
 
 
-/* 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.  */
@@ -159,10 +167,19 @@ extern ps_err_e td_lookup (struct ps_prochandle *ps,
                   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,
@@ -251,4 +268,20 @@ extern td_err_e _td_store_value_local (td_thragent_t *ta,
 extern td_err_e _td_check_sizeof (td_thragent_t *ta, uint32_t *sizep,
                                  int sizep_name) attribute_hidden;
 
+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 */