/* 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.
#include "gdbcore.h"
#include <ctype.h>
-#include "gdb_stat.h"
+#include <sys/stat.h>
void (*deprecated_file_changed_hook) (char *);
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;
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;
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)
ULONGEST memaddr = offset;
ULONGEST memend = memaddr + len;
- if (len <= 0)
+ if (len == 0)
internal_error (__FILE__, __LINE__,
_("failed internal consistency check"));
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)
{
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 *
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
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;
}
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. */
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;
}
}
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"));
}