*** empty log message ***
[binutils-gdb.git] / gdb / corelow.c
index fa2431fd231742520fd6397468181ae649620ef9..9523f3273192ab60b467fe5807ab334c294d36e7 100644 (file)
@@ -1,7 +1,7 @@
 /* Core dump and executable file functions below target vector, for GDB.
 
    Copyright (C) 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -45,6 +45,8 @@
 #include "exceptions.h"
 #include "solib.h"
 #include "filenames.h"
+#include "progspace.h"
+#include "objfiles.h"
 
 
 #ifndef O_LARGEFILE
@@ -208,7 +210,7 @@ core_close (int quitting)
     {
       int pid = ptid_get_pid (inferior_ptid);
       inferior_ptid = null_ptid;       /* Avoid confusion from thread stuff */
-      delete_inferior_silent (pid);
+      exit_inferior_silent (pid);
 
       /* Clear out solib state while the bfd is still open. See
          comments in clear_solib in solib.c. */
@@ -220,9 +222,7 @@ core_close (int quitting)
       core_has_fake_pid = 0;
 
       name = bfd_get_filename (core_bfd);
-      if (!bfd_close (core_bfd))
-       warning (_("cannot close \"%s\": %s"),
-                name, bfd_errmsg (bfd_get_error ()));
+      gdb_bfd_close_or_warn (core_bfd);
       xfree (name);
       core_bfd = NULL;
     }
@@ -260,7 +260,7 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
       lwpid = merged_pid >> 16;
 
       /* This can happen on solaris core, for example, if we don't
-        find a NT_PRSTATUS note in the core, but do find NT_LWPSTATUS
+        find a NT_PSTATUS note in the core, but do find NT_LWPSTATUS
         notes.  */
       if (pid == 0)
        {
@@ -275,8 +275,8 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
       lwpid = core_tid;
     }
 
-  if (!in_inferior_list (pid))
-    add_inferior_silent (pid);
+  if (current_inferior ()->pid == 0)
+    inferior_appeared (current_inferior (), pid);
 
   ptid = ptid_build (pid, lwpid, 0);
 
@@ -301,7 +301,6 @@ core_open (char *filename, int from_tty)
   bfd *temp_bfd;
   int scratch_chan;
   int flags;
-  int corelow_pid = CORELOW_PID;
 
   target_preopen (from_tty);
   if (!filename)
@@ -419,9 +418,10 @@ core_open (char *filename, int from_tty)
         usually happen, but we're dealing with input here, which can
         always be broken in different ways.  */
       struct thread_info *thread = first_thread_of_process (-1);
+
       if (thread == NULL)
        {
-         add_inferior_silent (CORELOW_PID);
+         inferior_appeared (current_inferior (), CORELOW_PID);
          inferior_ptid = pid_to_ptid (CORELOW_PID);
          add_thread_silent (inferior_ptid);
        }
@@ -508,9 +508,9 @@ deprecated_core_resize_section_table (int num_added)
 
 static void
 get_core_register_section (struct regcache *regcache,
-                          char *name,
+                          const char *name,
                           int which,
-                          char *human_name,
+                          const char *human_name,
                           int required)
 {
   static char *section_name = NULL;
@@ -591,6 +591,7 @@ static void
 get_core_registers (struct target_ops *ops,
                    struct regcache *regcache, int regno)
 {
+  struct core_regset_section *sect_list;
   int i;
 
   if (!(core_gdbarch && gdbarch_regset_from_core_section_p (core_gdbarch))
@@ -601,16 +602,30 @@ get_core_registers (struct target_ops *ops,
       return;
     }
 
-  get_core_register_section (regcache,
-                            ".reg", 0, "general-purpose", 1);
-  get_core_register_section (regcache,
-                            ".reg2", 2, "floating-point", 0);
-  get_core_register_section (regcache,
-                            ".reg-xfp", 3, "extended floating-point", 0);
-  get_core_register_section (regcache,
-                            ".reg-ppc-vmx", 3, "ppc Altivec", 0);
-  get_core_register_section (regcache,
-                            ".reg-ppc-vsx", 4, "POWER7 VSX", 0);
+  sect_list = gdbarch_core_regset_sections (get_regcache_arch (regcache));
+  if (sect_list)
+    while (sect_list->sect_name != NULL)
+      {
+        if (strcmp (sect_list->sect_name, ".reg") == 0)
+         get_core_register_section (regcache, sect_list->sect_name,
+                                    0, sect_list->human_name, 1);
+        else if (strcmp (sect_list->sect_name, ".reg2") == 0)
+         get_core_register_section (regcache, sect_list->sect_name,
+                                    2, sect_list->human_name, 0);
+       else
+         get_core_register_section (regcache, sect_list->sect_name,
+                                    3, sect_list->human_name, 0);
+
+       sect_list++;
+      }
+
+  else
+    {
+      get_core_register_section (regcache,
+                                ".reg", 0, "general-purpose", 1);
+      get_core_register_section (regcache,
+                                ".reg2", 2, "floating-point", 0);
+    }
 
   /* Supply dummy value for all registers not found in the core.  */
   for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
@@ -676,7 +691,6 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
 
          struct bfd_section *section;
          bfd_size_type size;
-         char *contents;
 
          section = bfd_get_section_by_name (core_bfd, ".auxv");
          if (section == NULL)
@@ -708,7 +722,6 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
 
          struct bfd_section *section;
          bfd_size_type size;
-         char *contents;
 
          section = bfd_get_section_by_name (core_bfd, ".wcookie");
          if (section == NULL)
@@ -752,9 +765,8 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
 
          struct bfd_section *section;
          bfd_size_type size;
-         char *contents;
-
          char sectionstr[100];
+
          xsnprintf (sectionstr, sizeof sectionstr, "SPU/%s", annex);
 
          section = bfd_get_section_by_name (core_bfd, sectionstr);
@@ -781,6 +793,7 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
        {
          /* NULL annex requests list of all present spuids.  */
          struct spuid_list list;
+
          list.buf = readbuf;
          list.offset = offset;
          list.len = len;
@@ -845,6 +858,7 @@ core_pid_to_str (struct target_ops *ops, ptid_t ptid)
       && gdbarch_core_pid_to_str_p (core_gdbarch))
     {
       char *ret = gdbarch_core_pid_to_str (core_gdbarch, ptid);
+
       if (ret != NULL)
        return ret;
     }