This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit/Ada] make sure thread list is up to date before switching to different Ada task


Hello,

I thought for a while about whether to submit this little patch or not,
because I don't think the issue it fixes occurs on any of the targets
currently support by FSF GDB.  But in the end, I still decided to push
it, because others might also have a yet-to-be-contributed port that
might need this little fix.  For AdaCore, this happened on VxWorks...

The issue is explained in the comment just before the line that I added.
So hopefully that's enough.  Otherwise, I'll expand further the comment.

PS: It used to work before we introduced the notion of inferior. Now,
    everytime we switch thread, we try to find the associated inferior,
    and if we don't know about the thread, we fail to find the inferior,
    and end up tripping an assertion (that the inferior is not NULL).

2009-04-23  Joel Brobecker  <brobecker@adacore.com>

        * ada-tasks (task_command_1): Call target_find_new_threads.

Tested on x86_64-linux. Checked in.

-- 
Joel
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index f7bbf2d..14f2503 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -865,6 +865,15 @@ task_command_1 (char *taskno_str, int from_tty)
   if (!ada_task_is_alive (task_info))
     error (_("Cannot switch to task %d: Task is no longer running"), taskno);
    
+  /* On some platforms, the thread list is not updated until the user
+     performs a thread-related operation (by using the "info threads"
+     command, for instance).  So this thread list may not be up to date
+     when the user attempts this task switch.  Since we cannot switch
+     to the thread associated to our task if GDB does not know about
+     that thread, we need to make sure that any new threads gets added
+     to the thread list.  */
+  target_find_new_threads ();
+
   switch_to_thread (task_info->ptid);
   ada_find_printable_frame (get_selected_frame (NULL));
   printf_filtered (_("[Switching to task %d]\n"), taskno);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]