*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / cli / cli-dump.c
index 295e2eb84ca26a8a5333fe4a8bba6d74ba272b16..bce42f393e77191fdaf1e7ffb8f4c1832037fd70 100644 (file)
@@ -1,6 +1,7 @@
 /* Dump-to-file commands, for GDB, the GNU debugger.
 
-   Copyright 2002, 2005 Free Software Foundation, Inc.
+   Copyright (c) 2002, 2005, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
    Contributed by Red Hat.
 
@@ -8,7 +9,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -17,9 +18,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "gdb_string.h"
@@ -32,6 +31,7 @@
 #include <ctype.h>
 #include "target.h"
 #include "readline/readline.h"
+#include "gdbcore.h"
 
 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
 
@@ -69,19 +69,6 @@ scan_expression_with_cleanup (char **cmd, const char *def)
 }
 
 
-static void
-do_fclose_cleanup (void *arg)
-{
-  FILE *file = arg;
-  fclose (arg);
-}
-
-static struct cleanup *
-make_cleanup_fclose (FILE *file)
-{
-  return make_cleanup (do_fclose_cleanup, file);
-}
-
 char *
 scan_filename_with_cleanup (char **cmd, const char *defname)
 {
@@ -218,7 +205,9 @@ dump_bfd_file (const char *filename, const char *mode,
   bfd_set_section_size (obfd, osection, len);
   bfd_set_section_vma (obfd, osection, vaddr);
   bfd_set_section_alignment (obfd, osection, 0);
-  bfd_set_section_flags (obfd, osection, 0x203);
+  bfd_set_section_flags (obfd, osection, (SEC_HAS_CONTENTS
+                                         | SEC_ALLOC
+                                         | SEC_LOAD));
   osection->entsize = 0;
   bfd_set_section_contents (obfd, osection, buf, 0, len);
 }
@@ -259,7 +248,7 @@ dump_memory_to_file (char *cmd, char *mode, char *file_format)
      value.  */
   buf = xmalloc (count);
   make_cleanup (xfree, buf);
-  target_read_memory (lo, buf, count);
+  read_memory (lo, buf, count);
   
   /* Have everything.  Open/write the data.  */
   if (file_format == NULL || strcmp (file_format, "binary") == 0)
@@ -309,7 +298,7 @@ dump_value_to_file (char *cmd, char *mode, char *file_format)
 
       if (VALUE_LVAL (val))
        {
-         vaddr = VALUE_ADDRESS (val);
+         vaddr = value_address (val);
        }
       else
        {
@@ -436,12 +425,12 @@ add_dump_command (char *name, void (*func) (char *args, char *mode),
       && c->doc[3] == 't' 
       && c->doc[4] == 'e'
       && c->doc[5] == ' ')
-    c->doc = concat ("Append ", c->doc + 6, NULL);
+    c->doc = concat ("Append ", c->doc + 6, (char *)NULL);
 }
 
 /* Opaque data for restore_section_callback. */
 struct callback_data {
-  unsigned long load_offset;
+  CORE_ADDR load_offset;
   CORE_ADDR load_start;
   CORE_ADDR load_end;
 };
@@ -461,7 +450,7 @@ restore_section_callback (bfd *ibfd, asection *isec, void *args)
   bfd_size_type sec_offset = 0;
   bfd_size_type sec_load_count = size;
   struct cleanup *old_chain;
-  char *buf;
+  gdb_byte *buf;
   int ret;
 
   /* Ignore non-loadable sections, eg. from elf files. */
@@ -501,11 +490,13 @@ restore_section_callback (bfd *ibfd, asection *isec, void *args)
                   (unsigned long) sec_end);
 
   if (data->load_offset != 0 || data->load_start != 0 || data->load_end != 0)
-    printf_filtered (" into memory (0x%s to 0x%s)\n", 
-                    paddr_nz ((unsigned long) sec_start 
+    printf_filtered (" into memory (%s to %s)\n",
+                    paddress (target_gdbarch,
+                              (unsigned long) sec_start
                               + sec_offset + data->load_offset), 
-                    paddr_nz ((unsigned long) sec_start + sec_offset 
-                      + data->load_offset + sec_load_count));
+                    paddress (target_gdbarch,
+                              (unsigned long) sec_start + sec_offset
+                               + data->load_offset + sec_load_count));
   else
     puts_filtered ("\n");
 
@@ -523,7 +514,7 @@ restore_binary_file (char *filename, struct callback_data *data)
 {
   FILE *file = fopen_with_cleanup (filename, FOPEN_RB);
   int status;
-  char *buf;
+  gdb_byte *buf;
   long len;
 
   /* Get the file size for reading.  */
@@ -546,8 +537,8 @@ restore_binary_file (char *filename, struct callback_data *data)
   printf_filtered 
     ("Restoring binary file %s into memory (0x%lx to 0x%lx)\n", 
      filename, 
-     (unsigned long) data->load_start + data->load_offset, 
-     (unsigned long) data->load_start + data->load_offset + len);
+     (unsigned long) (data->load_start + data->load_offset),
+     (unsigned long) (data->load_start + data->load_offset + len));
 
   /* Now set the file pos to the requested load start pos.  */
   if (fseek (file, data->load_start, SEEK_SET) != 0)
@@ -597,7 +588,7 @@ restore_command (char *args, int from_tty)
       /* Parse offset (optional). */
       if (args != NULL && *args != '\0')
       data.load_offset = 
-       parse_and_eval_long (scan_expression_with_cleanup (&args, NULL));
+       parse_and_eval_address (scan_expression_with_cleanup (&args, NULL));
       if (args != NULL && *args != '\0')
        {
          /* Parse start address (optional). */
This page took 0.027828 seconds and 4 git commands to generate.