* symmisc.c: Whitespace fixes.
[deliverable/binutils-gdb.git] / gdb / ravenscar-thread.c
index ec5c77340721c7ea0bedc66435a37f1050fad38c..0f9380bcaf2a48b8552213b464d039646e4a96a4 100644 (file)
@@ -1,6 +1,6 @@
 /* Ada Ravenscar thread support.
 
-   Copyright 2004, 2009, 2010 Free Software Foundation, Inc.
+   Copyright 2004, 2009-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -51,8 +51,10 @@ static ptid_t base_ptid;
 static const char running_thread_name[] = "__gnat_running_thread_table";
 
 static const char known_tasks_name[] = "system__tasking__debug__known_tasks";
+static const char first_task_name[] = "system__tasking__debug__first_task";
 
-static const char ravenscar_runtime_initializer[] = "system__bb__threads__initialize";
+static const char ravenscar_runtime_initializer[] =
+  "system__bb__threads__initialize";
 
 static struct observer *update_target_observer = NULL;
 
@@ -70,7 +72,7 @@ static void ravenscar_store_registers (struct target_ops *ops,
 static void ravenscar_prepare_to_store (struct regcache *regcache);
 static void ravenscar_initialize  (char *name, int from_tty);
 static void ravenscar_resume (struct target_ops *ops, ptid_t ptid, int step,
-                             enum target_signal siggnal);
+                             enum gdb_signal siggnal);
 static void ravenscar_mourn_inferior (struct target_ops *ops);
 static void ravenscar_update_inferior_ptid (void);
 static int has_ravenscar_runtime (void);
@@ -134,10 +136,12 @@ has_ravenscar_runtime (void)
     lookup_minimal_symbol (ravenscar_runtime_initializer, NULL, NULL);
   struct minimal_symbol *msym_known_tasks =
     lookup_minimal_symbol (known_tasks_name, NULL, NULL);
+  struct minimal_symbol *msym_first_task =
+    lookup_minimal_symbol (first_task_name, NULL, NULL);
   struct minimal_symbol *msym_running_thread = get_running_thread_msymbol ();
 
   return (msym_ravenscar_runtime_initializer
-         && msym_known_tasks
+         && (msym_known_tasks || msym_first_task)
          && msym_running_thread);
 }
 
@@ -162,7 +166,7 @@ get_running_thread_id (void)
   char *buf;
   CORE_ADDR object_addr;
   struct type *builtin_type_void_data_ptr =
-    builtin_type (target_gdbarch)->builtin_data_ptr;
+    builtin_type (target_gdbarch ())->builtin_data_ptr;
 
   if (!object_msym)
     return 0;
@@ -183,7 +187,7 @@ ravenscar_close (int quitting)
 
 static void
 ravenscar_resume (struct target_ops *ops, ptid_t ptid, int step,
-                 enum target_signal siggnal)
+                 enum gdb_signal siggnal)
 {
   struct target_ops *beneath = find_target_beneath (ops);
 
@@ -200,8 +204,19 @@ ravenscar_wait (struct target_ops *ops, ptid_t ptid,
 
   inferior_ptid = base_ptid;
   beneath->to_wait (beneath, base_ptid, status, 0);
-  ravenscar_find_new_threads (ops);
-  ravenscar_update_inferior_ptid ();
+  /* Find any new threads that might have been created, and update
+     inferior_ptid to the active thread.
+
+     Only do it if the program is still alive, though.  Otherwise,
+     this causes problems when debugging through the remote protocol,
+     because we might try switching threads (and thus sending packets)
+     after the remote has disconnected.  */
+  if (status->kind != TARGET_WAITKIND_EXITED
+      && status->kind != TARGET_WAITKIND_SIGNALLED)
+    {
+      ravenscar_find_new_threads (ops);
+      ravenscar_update_inferior_ptid ();
+    }
   return inferior_ptid;
 }
 
@@ -218,7 +233,7 @@ ravenscar_add_thread (struct ada_task_info *task)
 static void
 ravenscar_find_new_threads (struct target_ops *ops)
 {
-  ada_build_task_list (0);
+  ada_build_task_list ();
 
   /* Do not clear the thread list before adding the Ada task, to keep
      the thread that the process stratum has included into it
@@ -329,7 +344,7 @@ ravenscar_register_arch_ops (struct ravenscar_arch_ops *ops)
      architectures, just like in remote-wtx-hw.c.  However, for now the
      only Ravenscar run-time for bare board that is implemented in
      GNAT is for only one architecture: erc32-elf.  So no need to care about
-     that for now...*/
+     that for now...  */
   current_arch_ops = ops;
 }
 
@@ -417,6 +432,9 @@ Support for Ravenscar task/thread switching is enabled\n"));
 Support for Ravenscar task/thread switching is disabled\n"));
 }
 
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern void _initialize_ravenscar (void);
+
 /* Module startup initialization function, automagically called by
    init.c.  */
 
This page took 0.026039 seconds and 4 git commands to generate.