2004-02-17 David Mosberger <davidm@hpl.hp.com>
[deliverable/binutils-gdb.git] / gdb / corelow.c
index 8fc3e669849924e474d94aa5248f767e36e0fd38..5f6e26db3b5ed77b037bc3815830ba1ebf0e7954 100644 (file)
@@ -1,7 +1,8 @@
 /* Core dump and executable file functions below target vector, for GDB.
 
    Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+   1997, 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation,
+   Inc.
 
    This file is part of GDB.
 
@@ -477,7 +478,7 @@ get_core_register_section (char *name,
     }
 
   gdb_assert (core_vec);
-  core_vec->core_read_registers (contents, size, which, 
+  core_vec->core_read_registers (contents, size, which,
                                 ((CORE_ADDR)
                                  bfd_section_vma (core_bfd, section)));
 }
@@ -514,6 +515,63 @@ core_files_info (struct target_ops *t)
 {
   print_section_info (t, core_bfd);
 }
+\f
+static LONGEST
+core_xfer_partial (struct target_ops *ops, enum target_object object,
+                  const char *annex, void *readbuf,
+                  const void *writebuf, ULONGEST offset, LONGEST len)
+{
+  switch (object)
+    {
+    case TARGET_OBJECT_MEMORY:
+      if (readbuf)
+       return (*ops->to_xfer_memory) (offset, readbuf, len, 0/*write*/,
+                                      NULL, ops);
+      if (writebuf)
+       return (*ops->to_xfer_memory) (offset, readbuf, len, 1/*write*/,
+                                      NULL, ops);
+      return -1;
+
+    case TARGET_OBJECT_AUXV:
+      if (readbuf)
+       {
+         /* When the aux vector is stored in core file, BFD
+            represents this with a fake section called ".auxv".  */
+
+         struct bfd_section *section;
+         bfd_size_type size;
+         char *contents;
+
+         section = bfd_get_section_by_name (core_bfd, ".auxv");
+         if (section == NULL)
+           return -1;
+
+         size = bfd_section_size (core_bfd, section);
+         if (offset >= size)
+           return 0;
+         size -= offset;
+         if (size > len)
+           size = len;
+         if (size > 0 &&
+             ! bfd_get_section_contents (core_bfd, section, readbuf,
+                                         (file_ptr) offset, size))
+           {
+             warning ("Couldn't read NT_AUXV note in core file.");
+             return -1;
+           }
+
+         return size;
+       }
+      return -1;
+
+    default:
+      if (ops->beneath != NULL)
+       return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
+                                             readbuf, writebuf, offset, len);
+      return -1;
+    }
+}
+
 \f
 /* If mourn is being called in all the right places, this could be say
    `gdb internal error' (since generic_mourn calls breakpoint_init_inferior).  */
@@ -551,6 +609,7 @@ init_core_ops (void)
   core_ops.to_attach = find_default_attach;
   core_ops.to_detach = core_detach;
   core_ops.to_fetch_registers = get_core_registers;
+  core_ops.to_xfer_partial = core_xfer_partial;
   core_ops.to_xfer_memory = xfer_memory;
   core_ops.to_files_info = core_files_info;
   core_ops.to_insert_breakpoint = ignore;
This page took 0.024311 seconds and 4 git commands to generate.