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_ta_thr_iter.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'libpthread/nptl_db/td_ta_thr_iter.c') diff --git a/libpthread/nptl_db/td_ta_thr_iter.c b/libpthread/nptl_db/td_ta_thr_iter.c index 1fd02ef87..0f1b2bfd2 100644 --- a/libpthread/nptl_db/td_ta_thr_iter.c +++ b/libpthread/nptl_db/td_ta_thr_iter.c @@ -1,5 +1,6 @@ /* Iterate over a process's threads. - Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. + Copyright (C) 1999,2000,2001,2002,2003,2004,2007 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -23,7 +24,7 @@ static td_err_e iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback, void *cbdata_p, td_thr_state_e state, int ti_pri, - psaddr_t head, int fake_empty) + psaddr_t head, bool fake_empty) { td_err_e err; psaddr_t next, ofs; @@ -40,13 +41,13 @@ iterate_thread_list (td_thragent_t *ta, td_thr_iter_f *callback, if (next == 0 && fake_empty) { - /* __pthread_initialize_minimal has not run. - There is just the main thread to return. */ - td_thrhandle_t th; - err = td_ta_map_lwp2thr (ta, ps_getpid (ta->ph), &th); - if (err == TD_OK) - err = callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK; - return err; + /* __pthread_initialize_minimal has not run. There is just the main + thread to return. We cannot rely on its thread register. They + sometimes contain garbage that would confuse us, left by the + kernel at exec. So if it looks like initialization is incomplete, + we only fake a special descriptor for the initial thread. */ + td_thrhandle_t th = { ta, 0 }; + return callback (&th, cbdata_p) != 0 ? TD_DBERR : TD_OK; } /* Cache the offset from struct pthread to its list_t member. */ @@ -135,13 +136,15 @@ td_ta_thr_iter (const td_thragent_t *ta_arg, td_thr_iter_f *callback, err = DB_GET_SYMBOL (list, ta, __stack_user); if (err == TD_OK) - err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, list, 1); + err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, + list, true); /* And the threads with stacks allocated by the implementation. */ if (err == TD_OK) err = DB_GET_SYMBOL (list, ta, stack_used); if (err == TD_OK) - err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, list, 0); + err = iterate_thread_list (ta, callback, cbdata_p, state, ti_pri, + list, false); return err; } -- cgit v1.2.3