From 6fbc7cd8d32a55630316a8089ad6838d63f000ed Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 20 Apr 2010 23:14:12 +0000 Subject: [PATCH] Implement thread support with core files on alpha-tru64 Thread support currently does not work with core files. Note that, in order to thread support to work on tru64, one need to allow GDB to write in the core file (this is because the thread debug library needs to write). An obvious visible symptom of the problem is that "info threads" does not list the various threads: (gdb) info threads * 1
0x000003ff805c0918 in __nxm_thread_kill () from /usr/shlib/libpthread.so One other noticeable consequence is that GDB generates some warnings when using "info tasks": (gdb) info tasks warning: Could not find thread id from THREAD = 0x3ffc01b6000 warning: Could not find thread id from THREAD = 0x20000e2b4c0 ID TID P-ID Pri State Name * 1 140051000 0 30 Runnable main_task * 2 14005c000 1 30 Accept or Select Term my_t (notice also how both tasks are marked as being the active task, which cannot be true). The problem is that the dec-thread module has not updated its thread list after the core file got loaded. In fact, the list only gets resync'ed at the end of each target-wait. The solution was to implement the find_new_threads target_ops method. gdb/ChangeLog: Implement thread support with core files on alpha-tru64. * dec-thread.c (dec_thread_find_new_threads): New function, extracted from resync_thread_list. (resync_thread_list): Add OPS parameter. Replace extracted-out code by call to dec_thread_find_new_threads. (dec_thread_wait): Update call to resync_thread_list. (init_dec_thread_ops): Set dec_thread_ops.to_find_new_threads. --- gdb/ChangeLog | 10 ++++++++++ gdb/dec-thread.c | 29 +++++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f220340250f..a939f74ec1b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2010-04-20 Joel Brobecker + + Implement thread support with core files on alpha-tru64. + * dec-thread.c (dec_thread_find_new_threads): New function, + extracted from resync_thread_list. + (resync_thread_list): Add OPS parameter. Replace extracted-out + code by call to dec_thread_find_new_threads. + (dec_thread_wait): Update call to resync_thread_list. + (init_dec_thread_ops): Set dec_thread_ops.to_find_new_threads. + 2010-04-20 Joel Brobecker * ada-lang.c (value_pointer): New function. diff --git a/gdb/dec-thread.c b/gdb/dec-thread.c index 01191ea101c..4aba7796a54 100644 --- a/gdb/dec-thread.c +++ b/gdb/dec-thread.c @@ -394,22 +394,15 @@ dec_thread_add_gdb_thread (struct thread_info *info, void *context) return 0; } -/* Resynchronize the list of threads known by GDB with the actual - list of threads reported by libpthread_debug. */ +/* Implement the find_new_thread target_ops method. */ static void -resync_thread_list (void) +dec_thread_find_new_threads (struct target_ops *ops) { int i; struct dec_thread_info *info; - int num_gdb_threads = 0; - struct thread_info **gdb_thread_list; - struct thread_info **next_thread_info; update_dec_thread_list (); - - /* Add new threads. */ - for (i = 0; VEC_iterate (dec_thread_info_s, dec_thread_list, i, info); i++) { ptid_t ptid = ptid_build_from_info (*info); @@ -417,6 +410,21 @@ resync_thread_list (void) if (!in_thread_list (ptid)) add_thread (ptid); } +} + +/* Resynchronize the list of threads known by GDB with the actual + list of threads reported by libpthread_debug. */ + +static void +resync_thread_list (struct target_ops *ops) +{ + int i; + int num_gdb_threads = 0; + struct thread_info **gdb_thread_list; + struct thread_info **next_thread_info; + + /* Add new threads. */ + dec_thread_find_new_threads (ops); /* Remove threads that no longer exist. To help with the search, we build an array of GDB threads, and then iterate over this @@ -479,7 +487,7 @@ dec_thread_wait (struct target_ops *ops, /* The ptid returned by the target beneath us is the ptid of the process. We need to find which thread is currently active and return its ptid. */ - resync_thread_list (); + resync_thread_list (ops); active_ptid = get_active_ptid (); if (ptid_equal (active_ptid, null_ptid)) return ptid; @@ -708,6 +716,7 @@ init_dec_thread_ops (void) dec_thread_ops.to_store_registers = dec_thread_store_registers; dec_thread_ops.to_mourn_inferior = dec_thread_mourn_inferior; dec_thread_ops.to_thread_alive = dec_thread_thread_alive; + dec_thread_ops.to_find_new_threads = dec_thread_find_new_threads; dec_thread_ops.to_pid_to_str = dec_thread_pid_to_str; dec_thread_ops.to_stratum = thread_stratum; dec_thread_ops.to_get_ada_task_ptid = dec_thread_get_ada_task_ptid; -- 2.30.2