summaryrefslogtreecommitdiff
path: root/libpthread/nptl_db/td_thr_get_info.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2015-04-28 11:07:24 +0800
committerWaldemar Brodkorb <wbx@openadk.org>2015-06-10 10:17:53 -0500
commit8d92e32a73655a0820ce5085f017911abaad28b3 (patch)
tree0cb314484a17a76b3255a795f3103e41b877b8b2 /libpthread/nptl_db/td_thr_get_info.c
parent8484e59e6b1dfe424d13f736c146aafbeac5cabf (diff)
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 <roland@gnu.org> Signed-off-by: Sheng Yong <shengyong1@huawei.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libpthread/nptl_db/td_thr_get_info.c')
-rw-r--r--libpthread/nptl_db/td_thr_get_info.c81
1 files changed, 48 insertions, 33 deletions
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 <drepper@redhat.com>, 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)