* gdb.cp/cplusfuncs.exp (do_tests): Add check for proper error message
[deliverable/binutils-gdb.git] / gdb / gcore.c
index 754fb2c8822b343973c975835fdee126dab1209f..5bc38e2ab5fecf0ff682519303ec745a73faec94 100644 (file)
@@ -35,7 +35,7 @@
    generate-core-file for programs with large resident data.  */
 #define MAX_COPY_BYTES (1024 * 1024)
 
-static char *default_gcore_target (void);
+static const char *default_gcore_target (void);
 static enum bfd_architecture default_gcore_arch (void);
 static unsigned long default_gcore_mach (void);
 static int gcore_memory_sections (bfd *);
@@ -125,7 +125,7 @@ default_gcore_mach (void)
   return 0;
 #else
 
-  const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (current_gdbarch);
+  const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (target_gdbarch);
 
   if (bfdarch != NULL)
     return bfdarch->mach;
@@ -139,8 +139,7 @@ default_gcore_mach (void)
 static enum bfd_architecture
 default_gcore_arch (void)
 {
-  const struct bfd_arch_info * bfdarch = gdbarch_bfd_arch_info
-                                        (current_gdbarch);
+  const struct bfd_arch_info *bfdarch = gdbarch_bfd_arch_info (target_gdbarch);
 
   if (bfdarch != NULL)
     return bfdarch->arch;
@@ -150,10 +149,15 @@ default_gcore_arch (void)
   return bfd_get_arch (exec_bfd);
 }
 
-static char *
+static const char *
 default_gcore_target (void)
 {
-  /* FIXME: This may only work for ELF targets.  */
+  /* The gdbarch may define a target to use for core files.  */
+  if (gdbarch_gcore_bfd_target_p (target_gdbarch))
+    return gdbarch_gcore_bfd_target (target_gdbarch);
+
+  /* Otherwise, try to fall back to the exec_bfd target.  This will probably
+     not work for non-ELF targets.  */
   if (exec_bfd == NULL)
     return NULL;
   else
@@ -327,8 +331,8 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size,
     {
       if (info_verbose)
         {
-          fprintf_filtered (gdb_stdout, "Ignore segment, %s bytes at 0x%s\n",
-                            plongest (size), paddr_nz (vaddr));
+          fprintf_filtered (gdb_stdout, "Ignore segment, %s bytes at %s\n",
+                            plongest (size), paddress (target_gdbarch, vaddr));
         }
 
       return 0;
@@ -385,8 +389,8 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size,
 
   if (info_verbose)
     {
-      fprintf_filtered (gdb_stdout, "Save segment, %s bytes at 0x%s\n",
-                       plongest (size), paddr_nz (vaddr));
+      fprintf_filtered (gdb_stdout, "Save segment, %s bytes at %s\n",
+                       plongest (size), paddress (target_gdbarch, vaddr));
     }
 
   bfd_set_section_size (obfd, osec, size);
@@ -478,8 +482,9 @@ gcore_copy_callback (bfd *obfd, asection *osec, void *ignored)
       if (target_read_memory (bfd_section_vma (obfd, osec) + offset,
                              memhunk, size) != 0)
        {
-         warning (_("Memory read failed for corefile section, %s bytes at 0x%s."),
-                  plongest (size), paddr (bfd_section_vma (obfd, osec)));
+         warning (_("Memory read failed for corefile section, %s bytes at %s."),
+                  plongest (size),
+                  paddress (target_gdbarch, bfd_section_vma (obfd, osec)));
          break;
        }
       if (!bfd_set_section_contents (obfd, osec, memhunk, offset, size))
@@ -511,6 +516,9 @@ gcore_memory_sections (bfd *obfd)
   return 1;
 }
 
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_gcore;
+
 void
 _initialize_gcore (void)
 {
This page took 0.025319 seconds and 4 git commands to generate.