convert to_has_exited
[deliverable/binutils-gdb.git] / gdb / exec.c
index afd32245de09404174906a366b16307ed99751a8..61dea49e2d9a9838d0c1d5042a00c26950c0b007 100644 (file)
@@ -1,6 +1,6 @@
 /* Work with executable files, for GDB. 
 
-   Copyright (C) 1988-2013 Free Software Foundation, Inc.
+   Copyright (C) 1988-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -42,7 +42,7 @@
 #include "gdbcore.h"
 
 #include <ctype.h>
-#include "gdb_stat.h"
+#include <sys/stat.h>
 
 void (*deprecated_file_changed_hook) (char *);
 
@@ -62,6 +62,10 @@ void _initialize_exec (void);
 
 struct target_ops exec_ops;
 
+/* Function used to implement to_find_memory_regions.  */
+
+static int (*exec_do_find_memory_regions) (find_memory_region_ftype, void *);
+
 /* True if the exec target is pushed on the stack.  */
 static int using_exec_ops;
 
@@ -112,7 +116,7 @@ exec_close (void)
    sections and closes all executable bfds from all program spaces.  */
 
 static void
-exec_close_1 (void)
+exec_close_1 (struct target_ops *self)
 {
   using_exec_ops = 0;
 
@@ -566,9 +570,10 @@ section_table_available_memory (VEC(mem_range_s) *memory,
   return memory;
 }
 
-int
+enum target_xfer_status
 section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
-                                  ULONGEST offset, LONGEST len,
+                                  ULONGEST offset, ULONGEST len,
+                                  ULONGEST *xfered_len,
                                   struct target_section *sections,
                                   struct target_section *sections_end,
                                   const char *section_name)
@@ -578,7 +583,7 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
   ULONGEST memaddr = offset;
   ULONGEST memend = memaddr + len;
 
-  if (len <= 0)
+  if (len == 0)
     internal_error (__FILE__, __LINE__,
                    _("failed internal consistency check"));
 
@@ -602,7 +607,14 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
                res = bfd_get_section_contents (abfd, asect,
                                                readbuf, memaddr - p->addr,
                                                len);
-             return (res != 0) ? len : 0;
+
+             if (res != 0)
+               {
+                 *xfered_len = len;
+                 return TARGET_XFER_OK;
+               }
+             else
+               return TARGET_XFER_EOF;
            }
          else if (memaddr >= p->endaddr)
            {
@@ -621,12 +633,18 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
                res = bfd_get_section_contents (abfd, asect,
                                                readbuf, memaddr - p->addr,
                                                len);
-             return (res != 0) ? len : 0;
+             if (res != 0)
+               {
+                 *xfered_len = len;
+                 return TARGET_XFER_OK;
+               }
+             else
+               return TARGET_XFER_EOF;
            }
         }
     }
 
-  return 0;                    /* We can't help.  */
+  return TARGET_XFER_EOF;              /* We can't help.  */
 }
 
 static struct target_section_table *
@@ -635,22 +653,22 @@ exec_get_section_table (struct target_ops *ops)
   return current_target_sections;
 }
 
-static LONGEST
+static enum target_xfer_status
 exec_xfer_partial (struct target_ops *ops, enum target_object object,
                   const char *annex, gdb_byte *readbuf,
                   const gdb_byte *writebuf,
-                  ULONGEST offset, LONGEST len)
+                  ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
 {
   struct target_section_table *table = target_get_section_table (ops);
 
   if (object == TARGET_OBJECT_MEMORY)
     return section_table_xfer_memory_partial (readbuf, writebuf,
-                                             offset, len,
+                                             offset, len, xfered_len,
                                              table->sections,
                                              table->sections_end,
                                              NULL);
   else
-    return -1;
+    return TARGET_XFER_E_IO;
 }
 \f
 
@@ -801,7 +819,8 @@ exec_set_section_address (const char *filename, int index, CORE_ADDR address)
    breakpoint_init_inferior).  */
 
 static int
-ignore (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
+ignore (struct target_ops *ops, struct gdbarch *gdbarch,
+       struct bp_target_info *bp_tgt)
 {
   return 0;
 }
@@ -820,10 +839,17 @@ exec_has_memory (struct target_ops *ops)
 extern void
 exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *))
 {
-  exec_ops.to_find_memory_regions = func;
+  exec_do_find_memory_regions = func;
+}
+
+static int
+exec_find_memory_regions (struct target_ops *self,
+                         find_memory_region_ftype func, void *data)
+{
+  return exec_do_find_memory_regions (func, data);
 }
 
-static char *exec_make_note_section (bfd *, int *);
+static char *exec_make_note_section (struct target_ops *self, bfd *, int *);
 
 /* Fill in the exec file target vector.  Very few entries need to be
    defined.  */
@@ -847,6 +873,7 @@ Specify the filename of the executable file.";
   exec_ops.to_stratum = file_stratum;
   exec_ops.to_has_memory = exec_has_memory;
   exec_ops.to_make_corefile_notes = exec_make_note_section;
+  exec_ops.to_find_memory_regions = exec_find_memory_regions;
   exec_ops.to_magic = OPS_MAGIC;
 }
 
@@ -894,7 +921,7 @@ Show writing into executable and core files."), NULL,
 }
 
 static char *
-exec_make_note_section (bfd *obfd, int *note_size)
+exec_make_note_section (struct target_ops *self, bfd *obfd, int *note_size)
 {
   error (_("Can't create a corefile"));
 }
This page took 0.029229 seconds and 4 git commands to generate.