gas/
[deliverable/binutils-gdb.git] / gdb / corelow.c
index 485e2c2eb0b55109f86dbafdc355a0e4be2d496e..ffaf04c93ae313f020740fa60221e50f53030709 100644 (file)
@@ -81,12 +81,8 @@ static void core_close (int);
 
 static void core_close_cleanup (void *ignore);
 
-static void get_core_registers (struct regcache *, int);
-
 static void add_to_thread_list (bfd *, asection *, void *);
 
-static int core_file_thread_alive (ptid_t tid);
-
 static void init_core_ops (void);
 
 void _initialize_corelow (void);
@@ -383,6 +379,14 @@ core_open (char *filename, int from_tty)
      from ST to MT.  */
   add_thread_silent (inferior_ptid);
 
+  /* Need to flush the register cache (and the frame cache) from a
+     previous debug session.  If inferior_ptid ends up the same as the
+     last debug session --- e.g., b foo; run; gcore core1; step; gcore
+     core2; core core1; core core2 --- then there's potential for
+     get_current_regcache to return the cached regcache of the
+     previous session, and the frame cache being stale.  */
+  registers_changed ();
+
   /* Build up thread list from BFD sections, and possibly set the
      current thread to the .reg/NN section matching the .reg
      section. */
@@ -525,7 +529,8 @@ get_core_register_section (struct regcache *regcache,
 /* We just get all the registers, so we don't use regno.  */
 
 static void
-get_core_registers (struct regcache *regcache, int regno)
+get_core_registers (struct target_ops *ops,
+                   struct regcache *regcache, int regno)
 {
   int i;
 
@@ -678,7 +683,7 @@ ignore (struct bp_target_info *bp_tgt)
    behaviour.
  */
 static int
-core_file_thread_alive (ptid_t tid)
+core_thread_alive (struct target_ops *ops, ptid_t ptid)
 {
   return 1;
 }
@@ -702,6 +707,14 @@ core_pid_to_str (struct target_ops *ops, ptid_t ptid)
 {
   static char buf[64];
 
+  if (core_gdbarch
+      && gdbarch_core_pid_to_str_p (core_gdbarch))
+    {
+      char *ret = gdbarch_core_pid_to_str (core_gdbarch, ptid);
+      if (ret != NULL)
+       return ret;
+    }
+
   if (ptid_get_lwp (ptid) == 0)
     xsnprintf (buf, sizeof buf, "<main task>");
   else
@@ -730,7 +743,7 @@ init_core_ops (void)
   core_ops.to_insert_breakpoint = ignore;
   core_ops.to_remove_breakpoint = ignore;
   core_ops.to_create_inferior = find_default_create_inferior;
-  core_ops.to_thread_alive = core_file_thread_alive;
+  core_ops.to_thread_alive = core_thread_alive;
   core_ops.to_read_description = core_read_description;
   core_ops.to_pid_to_str = core_pid_to_str;
   core_ops.to_stratum = core_stratum;
@@ -740,19 +753,10 @@ init_core_ops (void)
   core_ops.to_magic = OPS_MAGIC;
 }
 
-/* non-zero if we should not do the add_target call in
-   _initialize_corelow; not initialized (i.e., bss) so that
-   the target can initialize it (i.e., data) if appropriate.
-   This needs to be set at compile time because we don't know
-   for sure whether the target's initialize routine is called
-   before us or after us. */
-int coreops_suppress_target;
-
 void
 _initialize_corelow (void)
 {
   init_core_ops ();
 
-  if (!coreops_suppress_target)
-    add_target (&core_ops);
+  add_target (&core_ops);
 }
This page took 0.025139 seconds and 4 git commands to generate.