* configure: Regenerate with proper autoconf 2.13.
[deliverable/binutils-gdb.git] / gdb / gcore.c
index 2e81d5bb7cd01acb15bdbbcaab8a15206c68ae21..155ebe09c8f5d1288cb98910692f89570a820c93 100644 (file)
@@ -23,7 +23,6 @@
 #include "inferior.h"
 #include "gdbcore.h"
 #include "elf-bfd.h"
-#include <sys/procfs.h>
 #include "symfile.h"
 #include "objfiles.h"
 
@@ -40,7 +39,7 @@ gcore_command (char *args, int from_tty)
 {
   struct cleanup *old_chain;
   char *corefilename, corefilename_buffer[40];
-  asection *note_sec;
+  asection *note_sec = NULL;
   bfd *obfd;
   void *note_data = NULL;
   int note_size = 0;
@@ -63,7 +62,7 @@ gcore_command (char *args, int from_tty)
                      "Opening corefile '%s' for output.\n", corefilename);
 
   /* Open the output file. */
-  if (!(obfd = bfd_openw (corefilename, NULL /*default_gcore_target ()*/)))
+  if (!(obfd = bfd_openw (corefilename, default_gcore_target ())))
     {
       error ("Failed to open '%s' for output.", corefilename);
     }
@@ -117,16 +116,20 @@ gcore_command (char *args, int from_tty)
 static unsigned long
 default_gcore_mach (void)
 {
+#if 1  /* See if this even matters... */
+  return 0;
+#else
 #ifdef TARGET_ARCHITECTURE
   const struct bfd_arch_info * bfdarch = TARGET_ARCHITECTURE;
 
   if (bfdarch != NULL)
     return bfdarch->mach;
-#endif
+#endif /* TARGET_ARCHITECTURE */
   if (exec_bfd == NULL)
     error ("Can't find default bfd machine type (need execfile).");
 
   return bfd_get_mach (exec_bfd);
+#endif /* 1 */
 }
 
 static enum bfd_architecture
@@ -149,30 +152,19 @@ default_gcore_target (void)
 {
   /* FIXME -- this may only work for ELF targets.  */
   if (exec_bfd == NULL)
-    error ("Can't find default bfd target for corefile (need execfile).");
-
-  return bfd_get_target (exec_bfd);
+    return NULL;
+  else
+    return bfd_get_target (exec_bfd);
 }
 
-/*
- * Default method for stack segment (preemptable by target).
- */
-
-static int (*override_derive_stack_segment) (bfd_vma *, bfd_vma *);
-
-extern void
-preempt_derive_stack_segment (int (*override_func) (bfd_vma *, bfd_vma *))
-{
-  override_derive_stack_segment = override_func;
-}
+/* Function: derive_stack_segment
 
-/* Function: default_derive_stack_segment
    Derive a reasonable stack segment by unwinding the target stack. 
    
    Returns 0 for failure, 1 for success.  */
 
 static int 
-default_derive_stack_segment (bfd_vma *bottom, bfd_vma *top)
+derive_stack_segment (bfd_vma *bottom, bfd_vma *top)
 {
   bfd_vma tmp_vma;
   struct frame_info *fi, *tmp_fi;
@@ -211,36 +203,15 @@ default_derive_stack_segment (bfd_vma *bottom, bfd_vma *top)
   return 1;    /* success */
 }
 
-static int
-derive_stack_segment (bfd_vma *bottom, bfd_vma *top)
-{
-  if (override_derive_stack_segment)
-    return override_derive_stack_segment (bottom, top);
-  else
-    return default_derive_stack_segment (bottom, top);
-}
-
-/*
- * Default method for heap segment (preemptable by target).
- */
-
-static int (*override_derive_heap_segment) (bfd *, bfd_vma *, bfd_vma *);
+/* Function: derive_heap_segment
 
-extern void
-preempt_derive_heap_segment (int (*override_func) (bfd *, 
-                                                  bfd_vma *, bfd_vma *))
-{
-  override_derive_heap_segment = override_func;
-}
-
-/* Function: default_derive_heap_segment
    Derive a reasonable heap segment by looking at sbrk and
    the static data sections.
    
    Returns 0 for failure, 1 for success.  */
 
 static int 
-default_derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
+derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
 {
   bfd_vma top_of_data_memory = 0;
   bfd_vma top_of_heap = 0;
@@ -265,7 +236,7 @@ default_derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
   for (sec = abfd->sections; sec; sec = sec->next)
     {
       if (bfd_get_section_flags (abfd, sec) & SEC_DATA ||
-         strcmp (".bss", bfd_get_section_name (abfd, sec)) == 0)
+         strcmp (".bss", bfd_section_name (abfd, sec)) == 0)
        {
          sec_vaddr = bfd_get_section_vma (abfd, sec);
          sec_size = bfd_get_section_size_before_reloc (sec);
@@ -274,8 +245,19 @@ default_derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
        }
     }
   /* Now get the top-of-heap by calling sbrk in the inferior.  */
-  if ((sbrk = find_function_in_inferior ("sbrk")) == NULL)
+  if (lookup_minimal_symbol ("sbrk", NULL, NULL) != NULL)
+    {
+      if ((sbrk = find_function_in_inferior ("sbrk")) == NULL)
+       return 0;
+    }
+  else if (lookup_minimal_symbol ("_sbrk", NULL, NULL) != NULL)
+    {
+      if ((sbrk = find_function_in_inferior ("_sbrk")) == NULL)
+       return 0;
+    }
+  else
     return 0;
+
   if ((zero = value_from_longest (builtin_type_int, (LONGEST) 0)) == NULL)
     return 0;
   if ((sbrk = call_function_by_hand (sbrk, 1, &zero)) == NULL)
@@ -293,15 +275,6 @@ default_derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
     return 0;  /* No additional heap space needs to be saved. */
 }
 
-static int
-derive_heap_segment (bfd *abfd, bfd_vma *bottom, bfd_vma *top)
-{
-  if (override_derive_heap_segment)
-    return override_derive_heap_segment (abfd, bottom, top);
-  else
-    return default_derive_heap_segment (abfd, bottom, top);
-}
-
 /* ARGSUSED */
 static void
 make_output_phdrs (bfd *obfd, asection *osec, void *ignored)
@@ -310,7 +283,7 @@ make_output_phdrs (bfd *obfd, asection *osec, void *ignored)
   int p_type;
 
   /* FIXME: these constants may only be applicable for ELF.  */
-  if (strncmp (osec->name, "load", 4) == 0)
+  if (strncmp (bfd_section_name (obfd, osec), "load", 4) == 0)
     p_type = PT_LOAD;
   else
     p_type = PT_NOTE;
@@ -344,8 +317,8 @@ make_mem_sec (bfd *obfd,
   if (info_verbose)
     {
       fprintf_filtered (gdb_stdout, 
-                       "Save segment, %ld bytes at 0x%s\n",
-                       size, paddr_nz (addr));
+                       "Save segment, %lld bytes at 0x%s\n",
+                       (long long) size, paddr_nz (addr));
     }
 
   bfd_set_section_size (obfd, osec, size);
@@ -448,7 +421,7 @@ gcore_copy_callback (bfd *obfd, asection *osec, void *ignored)
   if (size == 0)
     return;    /* Read-only sections are marked as zero-size.
                   We don't have to copy their contents. */
-  if (strncmp ("load", bfd_get_section_name (obfd, osec), 4) != 0)
+  if (strncmp ("load", bfd_section_name (obfd, osec), 4) != 0)
     return;    /* Only interested in "load" sections. */
 
   if ((memhunk = xmalloc (size)) == NULL)
This page took 0.026891 seconds and 4 git commands to generate.