From 8d92e32a73655a0820ce5085f017911abaad28b3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 28 Apr 2015 11:07:24 +0800 Subject: init.c (__nptl_initial_report_events): New variable. (__pthread_initialize_minimal_internal): Initialize pd->report_events to that. This patch helps NPTL report TD_CREATE event, so that GDB could catch the event and update its thread_list. Link: http://lists.uclibc.org/pipermail/uclibc/2015-April/048921.html [shengyong: - original patch from glibc: commit 7d9d8bd18906fdd17364f372b160d7ab896ce909 - context adjust - update nptl_db/ChangeLog] Signed-off-by: Roland McGrath Signed-off-by: Sheng Yong Signed-off-by: Bernhard Reutner-Fischer --- libpthread/nptl_db/td_thr_get_info.c | 81 +++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 33 deletions(-) (limited to 'libpthread/nptl_db/td_thr_get_info.c') diff --git a/libpthread/nptl_db/td_thr_get_info.c b/libpthread/nptl_db/td_thr_get_info.c index 09d0d1a13..27d5d706b 100644 --- a/libpthread/nptl_db/td_thr_get_info.c +++ b/libpthread/nptl_db/td_thr_get_info.c @@ -1,5 +1,5 @@ /* Get thread information. - Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999,2000,2001,2002,2003,2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -31,35 +31,49 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop) LOG ("td_thr_get_info"); - /* Copy the whole descriptor in once so we can access the several - fields locally. Excess copying in one go is much better than - multiple ps_pdread calls. */ - err = DB_GET_STRUCT (copy, th->th_ta_p, th->th_unique, pthread); - if (err != TD_OK) - return err; - - err = DB_GET_FIELD_ADDRESS (tls, th->th_ta_p, th->th_unique, - pthread, specific, 0); - if (err != TD_OK) - return err; - - err = DB_GET_FIELD_LOCAL (schedpolicy, th->th_ta_p, copy, pthread, - schedpolicy, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (schedprio, th->th_ta_p, copy, pthread, - schedparam_sched_priority, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (tid, th->th_ta_p, copy, pthread, tid, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (cancelhandling, th->th_ta_p, copy, pthread, - cancelhandling, 0); - if (err != TD_OK) - return err; - err = DB_GET_FIELD_LOCAL (report_events, th->th_ta_p, copy, pthread, - report_events, 0); + if (th->th_unique == 0) + { + /* Special case for the main thread before initialization. */ + copy = NULL; + tls = 0; + cancelhandling = 0; + schedprio = 0; + tid = 0; + err = DB_GET_VALUE (report_events, th->th_ta_p, + __nptl_initial_report_events, 0); + } + else + { + /* Copy the whole descriptor in once so we can access the several + fields locally. Excess copying in one go is much better than + multiple ps_pdread calls. */ + err = DB_GET_STRUCT (copy, th->th_ta_p, th->th_unique, pthread); + if (err != TD_OK) + return err; + + err = DB_GET_FIELD_ADDRESS (tls, th->th_ta_p, th->th_unique, + pthread, specific, 0); + if (err != TD_OK) + return err; + + err = DB_GET_FIELD_LOCAL (schedpolicy, th->th_ta_p, copy, pthread, + schedpolicy, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (schedprio, th->th_ta_p, copy, pthread, + schedparam_sched_priority, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (tid, th->th_ta_p, copy, pthread, tid, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (cancelhandling, th->th_ta_p, copy, pthread, + cancelhandling, 0); + if (err != TD_OK) + return err; + err = DB_GET_FIELD_LOCAL (report_events, th->th_ta_p, copy, pthread, + report_events, 0); + } if (err != TD_OK) return err; @@ -86,9 +100,10 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop) infop->ti_lid = tid == 0 ? ps_getpid (th->th_ta_p->ph) : (uintptr_t) tid; infop->ti_traceme = report_events != 0; - err = DB_GET_FIELD_LOCAL (infop->ti_startfunc, th->th_ta_p, copy, pthread, - start_routine, 0); - if (err == TD_OK) + if (copy != NULL) + err = DB_GET_FIELD_LOCAL (infop->ti_startfunc, th->th_ta_p, copy, pthread, + start_routine, 0); + if (copy != NULL && err == TD_OK) { uint32_t idx; for (idx = 0; idx < TD_EVENTSIZE; ++idx) -- cgit v1.2.3