From 3780c3370815a315927580bcd22ce5e361cc9950 Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Wed, 21 May 1997 23:33:33 +0000 Subject: Wed May 21 16:03:25 1997 Michael Snyder * procfs.c (init_procinfo): new function, abstracts some code shared by create_procinfo and do_attach; (procfs_set_inferior_syscall_traps): new function, abstracts some code needed by procfs_init_inferior, do_attach, and procfs_lwp_creation_handler; (procfs_first_available): new function, find any LWP that's runnable; (procfs_thread_alive): replace stub function with real implementation; (procfs_lwp_creation_handler): fix bug starting new child threads; (info_proc): bug fixes and enhancements for the "INFO PROCESSES" command; (close_procinfo_file): call new function "delete_thread" to cleanup GDB's thread database; (proc_init_failed): add new argument "kill", to control whether process is killed (so this function can be shared by create_procinfo and do_attach); (procfs_exit_handler): handle exit from an attached process, and cleanup procinfo handles when the process exits; (procfs_resume, procfs_wait): cleanup after a thread when it exits; (do_attach, do_detach): handle attached processes with multiple threads; plus some general improvements in the diagnostic output. * sol-thread.c (sol_thread_alive): replace stub with real implementation; (thread_to_lwp, lwp_to_thread): enhance to handle threads that may have exited; (sol_thread_attach): add startup setup stuff; (sol_thread_detach): add unpush_target call; (sol_thread_mourn_inferior): add unpush_target call; (sol_thread_wait, sol_thread_resume): enhance to deal with thread exit cleanly; (sol_thread_new_objfile, sol_thread_pid_to_str): detect unsuccessful startup and don't crash; plus some general cleanup. * thread.c (delete_thread): new function, allows targets to notify gdb when a thread is no longer valid. * infrun.c (wait_for_inferior): don't try to detect a new thread on receiving a TARGET_EXITED event. --- gdb/thread.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'gdb/thread.c') diff --git a/gdb/thread.c b/gdb/thread.c index 7ffc65a..b8bf9e1 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -125,6 +125,31 @@ add_thread (pid) thread_list = tp; } +void +delete_thread (pid) + int pid; +{ + struct thread_info *tp, *tpprev; + + tpprev = NULL; + + for (tp = thread_list; tp; tpprev = tp, tp = tp->next) + if (tp->pid == pid) + break; + + if (!tp) + return; + + if (tpprev) + tpprev->next = tp->next; + else + thread_list = tp->next; + + free (tp); + + return; +} + static struct thread_info * find_thread_id (num) int num; @@ -332,7 +357,10 @@ info_threads_command (arg, from_tty) printf_filtered ("%d %s ", tp->num, target_pid_to_str (tp->pid)); switch_to_thread (tp->pid); - print_stack_frame (selected_frame, -1, 0); + if (selected_frame) + print_stack_frame (selected_frame, -1, 0); + else + printf_filtered ("[No stack.]\n"); } switch_to_thread (current_pid); -- cgit v1.1