Add '#define HAVE_PROCFS', move '#include "fopen-same.h" to end of file
[deliverable/binutils-gdb.git] / gdb / core.c
index b4f812a7173f35e4c6a341d835bf2496ee7205a2..c59fc55c0031a5cc1f0f0d2dd92b31b38503dd3c 100644 (file)
@@ -1,5 +1,5 @@
 /* Work with core dump and executable files, for GDB.
-   Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -22,7 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <signal.h>
 #include <fcntl.h>
 #include "defs.h"
-#include "param.h"
 #include "frame.h"  /* required by inferior.h */
 #include "inferior.h"
 #include "symtab.h"
@@ -112,7 +111,7 @@ core_open (filename, from_tty)
 
   filename = tilde_expand (filename);
   if (filename[0] != '/') {
-    temp = concat (current_directory, "/", filename);
+    temp = concat (current_directory, "/", filename, NULL);
     free (filename);
     filename = temp;
   }
@@ -131,8 +130,8 @@ core_open (filename, from_tty)
 
   if (!bfd_check_format (temp_bfd, bfd_core))
     {
-      bfd_close (temp_bfd);
-      error ("\"%s\" does not appear to be a core dump", filename);
+      make_cleanup (bfd_close, temp_bfd);      /* Do it after the err msg */
+      error ("\"%s\" is not a core dump: %s", filename, bfd_errmsg(bfd_error));
     }
 
   /* Looks semi-reasonable.  Toss the old core file and work on the new.  */
@@ -155,7 +154,7 @@ core_open (filename, from_tty)
 
   p = bfd_core_file_failing_command (core_bfd);
   if (p)
-    printf ("Core file invoked as `%s'.\n", p);
+    printf ("Core was generated by `%s'.\n", p);
 
   siggy = bfd_core_file_failing_signal (core_bfd);
   if (siggy > 0)
@@ -279,18 +278,19 @@ core_files_info (t)
 {
   struct section_table *p;
 
-  printf ("\tCore file `%s'.\n", bfd_get_filename(core_bfd));
+  printf_filtered ("\t`%s', ", bfd_get_filename(core_bfd));
+  wrap_here ("        ");
+  printf_filtered ("file type %s.\n", bfd_get_target(core_bfd));
 
   for (p = t->sections; p < t->sections_end; p++) {
-    printf(p->bfd == core_bfd? "\tcore file  ": "\tshared lib ");
-    printf("from %s", local_hex_string_custom (p->addr, "08"));
-    printf(" to %s", local_hex_string_custom (p->endaddr, "08"));
+    printf_filtered ("\t%s", local_hex_string_custom (p->addr, "08"));
+    printf_filtered (" - %s is %s",
+       local_hex_string_custom (p->endaddr, "08"),
+       bfd_section_name (p->bfd, p->sec_ptr));
     if (p->bfd != core_bfd) {
-      printf(" is %s in %s",
-            bfd_section_name (p->bfd, p->sec_ptr),
-            bfd_get_filename (p->bfd));
+      printf_filtered (" in %s", bfd_get_filename (p->bfd));
     }
-    printf ("\n");
+    printf_filtered ("\n");
   }
 }
 \f
@@ -398,15 +398,17 @@ get_core_registers (regno)
   char *the_regs;
 
   reg_sec = bfd_get_section_by_name (core_bfd, ".reg");
+  if (!reg_sec) goto cant;
   size = bfd_section_size (core_bfd, reg_sec);
   the_regs = alloca (size);
-  if (bfd_get_section_contents (core_bfd, reg_sec, the_regs,
-                               (unsigned)0, size))
+  if (bfd_get_section_contents (core_bfd, reg_sec, the_regs, (file_ptr)0, size))
     {
-      fetch_core_registers (the_regs, size, 0);
+      fetch_core_registers (the_regs, size, 0,
+                           (unsigned) bfd_section_vma (abfd,reg_sec));
     }
   else
     {
+cant:
       fprintf (stderr, "Couldn't fetch registers from core file: %s\n",
               bfd_errmsg (bfd_error));
     }
@@ -416,10 +418,11 @@ get_core_registers (regno)
   if (reg_sec) {
     size = bfd_section_size (core_bfd, reg_sec);
     the_regs = alloca (size);
-    if (bfd_get_section_contents (core_bfd, reg_sec, the_regs,
-                                 (unsigned)0, size))
+    if (bfd_get_section_contents (core_bfd, reg_sec, the_regs, (file_ptr)0,
+                                 size))
       {
-       fetch_core_registers (the_regs, size, 2);
+       fetch_core_registers (the_regs, size, 2,
+                             (unsigned) bfd_section_vma (abfd,reg_sec));
       }
     else
       {
This page took 0.036076 seconds and 4 git commands to generate.