]> sourceware.org Git - glibc.git/commitdiff
nptl: Move __nptl_initial_report_events into ld.so/startup code
authorFlorian Weimer <fweimer@redhat.com>
Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 17 May 2021 08:04:06 +0000 (10:04 +0200)
The initialization of the report_events TCB field is now performed
in __tls_init_tp instead of __pthread_initialize_minimal_internal
(in libpthread).

The events interface is difficult to test because GDB stopped using it
in 2015.  The td_thr_get_info change to ignore lookup issues is enough
to support GDB with this change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
nptl/Versions
nptl/nptl-init.c
nptl/pthreadP.h
nptl_db/db_info.c
nptl_db/structs.def
nptl_db/td_thr_get_info.c
sysdeps/nptl/dl-tls_init_tp.c

index 1dd3fbc18cd4b85514710d35a6902126734fd239..fb3379b7882712adf0038f18a00d60e371edcfc7 100644 (file)
@@ -497,6 +497,7 @@ libpthread {
 
 ld {
   GLIBC_PRIVATE {
+     __nptl_initial_report_events;
      __nptl_set_robust_list_avail;
   }
 }
\ No newline at end of file
index 16fb66bdf55ed6cfd50a023109e124154379e234..f4b86fbfaf99f549fe6470d6865772fe6e9c688a 100644 (file)
@@ -96,21 +96,9 @@ sigcancel_handler (int sig, siginfo_t *si, void *ctx)
 extern void **__libc_dl_error_tsd (void) __attribute__ ((const));
 
 
-/* This can be set by the debugger before initialization is complete.  */
-static bool __nptl_initial_report_events __attribute_used__;
-
 void
 __pthread_initialize_minimal_internal (void)
 {
-  /* Partial initialization of the TCB already happened in TLS_INIT_TP
-     and __tls_init_tp.  */
-  struct pthread *pd = THREAD_SELF;
-
-  /* Before initializing GL (dl_stack_user), the debugger could not
-     find us and had to set __nptl_initial_report_events.  Propagate
-     its setting.  */
-  THREAD_SETMEM (pd, report_events, __nptl_initial_report_events);
-
   struct sigaction sa;
   __sigemptyset (&sa.sa_mask);
 
index 5b844f331aefe1d521b5bc4413780eebbdb39550..dc2aece37e2cac9e29ee7dc4544e8c6604ed9254 100644 (file)
@@ -328,6 +328,11 @@ extern int __pthread_attr_init (pthread_attr_t *attr);
 libc_hidden_proto (__pthread_attr_init)
 extern int __pthread_attr_init_2_0 (pthread_attr_t *attr);
 
+/* Part of the legacy thread events interface (which has been
+   superseded by PTRACE_O_TRACECLONE).  This can be set by the
+   debugger before initialization is complete.  */
+extern bool __nptl_initial_report_events;
+rtld_hidden_proto (__nptl_initial_report_events)
 
 /* Event handlers for libthread_db interface.  */
 extern void __nptl_create_event (void);
index bed6ed486ee2100b4ad5b702a9fef55a703ca432..b39aebb78c5d30afe4ec7db970336aada9be312a 100644 (file)
@@ -42,9 +42,6 @@ typedef struct rtld_global rtld_global;
 typedef struct dtv_slotinfo_list dtv_slotinfo_list;
 typedef struct dtv_slotinfo dtv_slotinfo;
 
-/* Actually static in nptl/init.c, but we only need it for typeof.  */
-extern bool __nptl_initial_report_events;
-
 #define schedparam_sched_priority schedparam.sched_priority
 
 #define eventbuf_eventmask eventbuf.eventmask
index 9173e1ab8f615d1027b7edce5d05adf39b03b326..275c12bc7a0dd65e6f2909155a931f979cb4933d 100644 (file)
@@ -80,7 +80,7 @@ DB_FUNCTION (__nptl_death_event)
 DB_SYMBOL (__nptl_threads_events)
 DB_MAIN_VARIABLE (__nptl_nthreads)
 DB_VARIABLE (__nptl_last_event)
-DB_VARIABLE (__nptl_initial_report_events)
+DB_RTLD_VARIABLE (__nptl_initial_report_events)
 
 DB_MAIN_ARRAY_VARIABLE (__pthread_keys)
 DB_STRUCT (pthread_key_struct)
index 002a22a5be8ba4f11f7c39f99cadf2c0765a64bb..01af021d2a11270464488b463be3f97a09e77d02 100644 (file)
@@ -41,8 +41,15 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop)
       schedpolicy = SCHED_OTHER;
       schedprio = 0;
       tid = 0;
-      err = DB_GET_VALUE (report_events, th->th_ta_p,
-                         __nptl_initial_report_events, 0);
+
+      /* Ignore errors to obtain the __nptl_initial_report_events
+        value because GDB no longer uses the events interface, and
+        other libthread_db consumers hopefully can handle different
+        libpthread/lds.o load orders.  */
+      report_events = 0;
+      (void) DB_GET_VALUE (report_events, th->th_ta_p,
+                          __nptl_initial_report_events, 0);
+      err = TD_OK;
     }
   else
     {
index f1aaa5aa9d543c8e78ef8c81548db2c4d7aeb6b8..1f7790297fe47c855745e8e3623714ebc5dca262 100644 (file)
@@ -27,6 +27,9 @@ bool __nptl_set_robust_list_avail __attribute__ ((nocommon));
 rtld_hidden_data_def (__nptl_set_robust_list_avail)
 #endif
 
+bool __nptl_initial_report_events __attribute__ ((nocommon));
+rtld_hidden_def (__nptl_initial_report_events)
+
 #ifdef SHARED
 /* Dummy implementation.  See __rtld_mutex_init.  */
 static int
@@ -63,6 +66,11 @@ __tls_init_tp (void)
    THREAD_SETMEM (pd, specific[0], &pd->specific_1stblock[0]);
    THREAD_SETMEM (pd, user_stack, true);
 
+  /* Before initializing GL (dl_stack_user), the debugger could not
+     find us and had to set __nptl_initial_report_events.  Propagate
+     its setting.  */
+  THREAD_SETMEM (pd, report_events, __nptl_initial_report_events);
+
   /* Initialize the robust mutex data.  */
   {
 #if __PTHREAD_MUTEX_HAVE_PREV
This page took 0.047601 seconds and 5 git commands to generate.