Move gdbserver tdesc header funcs to c file
[deliverable/binutils-gdb.git] / gdb / ravenscar-thread.c
index 83dfd9d4adfdd383f35c39c8972e32055e05e69d..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 ();
     }
@@ -519,12 +527,20 @@ ravenscar_core_of_thread (struct target_ops *ops, ptid_t ptid)
 static void
 ravenscar_inferior_created (struct target_ops *target, int from_tty)
 {
+  const char *err_msg;
 
   if (!ravenscar_task_support
       || gdbarch_ravenscar_ops (target_gdbarch ()) == NULL
       || !has_ravenscar_runtime ())
     return;
 
+  err_msg = ada_get_tcb_types_info ();
+  if (err_msg != NULL)
+    {
+      warning (_("%s. Task/thread support disabled."), err_msg);
+      return;
+    }
+
   ravenscar_update_inferior_ptid ();
   push_target (&ravenscar_ops);
 }
@@ -616,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.025738 seconds and 4 git commands to generate.