Move gdbserver tdesc header funcs to c file
[deliverable/binutils-gdb.git] / gdb / ravenscar-thread.c
index e7922277ce84bb717515b0cb5cb32762a6e6d21a..46e454a6a80d0a24ac58521375dff43873f2b8e6 100644 (file)
@@ -1,6 +1,6 @@
 /* Ada Ravenscar thread support.
 
-   Copyright (C) 2004-2017 Free Software Foundation, Inc.
+   Copyright (C) 2004-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -25,7 +25,7 @@
 #include "inferior.h"
 #include "command.h"
 #include "ravenscar-thread.h"
-#include "observer.h"
+#include "observable.h"
 #include "gdbcmd.h"
 #include "top.h"
 #include "regcache.h"
@@ -101,8 +101,14 @@ static void ravenscar_inferior_created (struct target_ops *target,
 static int
 is_ravenscar_task (ptid_t ptid)
 {
-  /* By construction, ravenscar tasks have their LWP set to zero.  */
-  return ptid_get_lwp (ptid) == 0;
+  /* By construction, ravenscar tasks have their LWP set to zero.
+     Also make sure that the TID is nonzero, as some remotes, when
+     asked for the list of threads, will return the first thread
+     as having its TID set to zero.  For instance, TSIM version
+     2.0.48 for LEON3 sends 'm0' as a reply to the 'qfThreadInfo'
+     query, which the remote protocol layer then treats as a thread
+     whose TID is 0.  This is obviously not a ravenscar task.  */
+  return ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) != 0;
 }
 
 /* Given PTID, which can be either a ravenscar task or a CPU thread,
@@ -291,9 +297,10 @@ ravenscar_wait (struct target_ops *ops, ptid_t ptid,
                 int options)
 {
   struct target_ops *beneath = find_target_beneath (ops);
+  ptid_t event_ptid;
 
   inferior_ptid = base_ptid;
-  beneath->to_wait (beneath, base_ptid, status, 0);
+  event_ptid = beneath->to_wait (beneath, base_ptid, status, 0);
   /* Find any new threads that might have been created, and update
      inferior_ptid to the active thread.
 
@@ -304,6 +311,7 @@ ravenscar_wait (struct target_ops *ops, ptid_t ptid,
   if (status->kind != TARGET_WAITKIND_EXITED
       && status->kind != TARGET_WAITKIND_SIGNALLED)
     {
+      inferior_ptid = event_ptid;
       ravenscar_update_thread_list (ops);
       ravenscar_update_inferior_ptid ();
     }
@@ -529,7 +537,7 @@ ravenscar_inferior_created (struct target_ops *target, int from_tty)
   err_msg = ada_get_tcb_types_info ();
   if (err_msg != NULL)
     {
-      warning (_("%s. Task/thread support disabled.\n"), err_msg);
+      warning (_("%s. Task/thread support disabled."), err_msg);
       return;
     }
 
@@ -624,7 +632,7 @@ _initialize_ravenscar (void)
 
   /* Notice when the inferior is created in order to push the
      ravenscar ops if needed.  */
-  observer_attach_inferior_created (ravenscar_inferior_created);
+  gdb::observers::inferior_created.attach (ravenscar_inferior_created);
 
   complete_target_initialization (&ravenscar_ops);
 
This page took 0.024703 seconds and 4 git commands to generate.