From 022278948f2034198be6cdc95cb4bc9b71122698 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 24 Oct 1997 21:04:39 +0000 Subject: [PATCH] fix for PR 13618 -- gdb incorrectly reports thread information. If other systems besides nm-sun4sol2 exhibit the problem, they may need definitions of FIND_NEW_THREADS and a corresponding support function. --- gdb/ChangeLog | 9 +++++++++ gdb/config/sparc/nm-sun4sol2.h | 3 +++ gdb/sol-thread.c | 37 +++++++++++++++++++++++++++++++++++++ gdb/thread.c | 4 ++++ 4 files changed, 53 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fdfffcd..0e42ed3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +Fri Oct 24 16:48:21 1997 David Taylor + + * sol-thread.c (sol_find_new_threads_callback, + sol_find_new_threads): New functions. + * config/sparc/nm-sun4sol2.h (FIND_NEW_THREADS): New macro, invoke + sol_find_new_threads. + * thread.c (info_threads_command): invoke FIND_NEW_THREADS if it + is defined. + Thu Oct 23 16:16:04 1997 Jeff Law (law@fast.cs.utah.edu) * dbxread.c (process_one_symbol): Put back initialization diff --git a/gdb/config/sparc/nm-sun4sol2.h b/gdb/config/sparc/nm-sun4sol2.h index c83e44d..f6833f4 100644 --- a/gdb/config/sparc/nm-sun4sol2.h +++ b/gdb/config/sparc/nm-sun4sol2.h @@ -39,4 +39,7 @@ struct objfile; void sol_thread_new_objfile PARAMS ((struct objfile *objfile)); +#define FIND_NEW_THREADS sol_find_new_threads +void sol_find_new_threads PARAMS ((void)); + #endif diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index cc61c6a..aa69c0d 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -1239,6 +1239,43 @@ solaris_pid_to_str (pid) } +/* Worker bee for find_new_threads + Callback function that gets called once per USER thread (i.e., not + kernel) thread. */ + +static int +sol_find_new_threads_callback(th, ignored) + const td_thrhandle_t *th; + void *ignored; +{ + td_err_e retval; + td_thrinfo_t ti; + int pid; + + if ((retval = p_td_thr_get_info(th, &ti)) != TD_OK) + { + return -1; + } + pid = BUILD_THREAD(ti.ti_tid, PIDGET(inferior_pid)); + if (!in_thread_list(pid)) + add_thread(pid); + + return 0; +} + +void +sol_find_new_threads() +{ + if (inferior_pid == -1) + { + printf_filtered("No process.\n"); + return; + } + p_td_ta_thr_iter (main_ta, sol_find_new_threads_callback, (void *)0, + TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, + TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); +} + #ifdef MAINTENANCE_CMDS /* Worker bee for info sol-thread command. This is a callback function that gets called once for each Solaris thread (ie. not kernel thread) in the diff --git a/gdb/thread.c b/gdb/thread.c index b8bf9e1..4c158ff 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -347,6 +347,10 @@ info_threads_command (arg, from_tty) if (!target_has_stack) error ("No stack."); prune_threads (); +#if defined(FIND_NEW_THREADS) + FIND_NEW_THREADS (); +#endif + for (tp = thread_list; tp; tp = tp->next) { if (tp->pid == current_pid) -- 2.7.4