/* 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 <fcntl.h>
#include "readline/readline.h"
-#include "gdb_string.h"
+#include <string.h>
#include "gdbcore.h"
#include <ctype.h>
-#include "gdb_stat.h"
+#include <sys/stat.h>
void (*deprecated_file_changed_hook) (char *);
struct target_section *sections = NULL, *sections_end = NULL;
char **matching;
- scratch_chan = openp (getenv ("PATH"),
- OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH, filename,
+ scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname);
#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
char *exename = alloca (strlen (filename) + 5);
strcat (strcpy (exename, filename), ".exe");
- scratch_chan = openp (getenv ("PATH"),
- OPF_TRY_CWD_FIRST | OPF_DISABLE_REALPATH,
- exename,
+ scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename,
write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
&scratch_pathname);
}
}
gdb_assert (exec_filename == NULL);
- exec_filename = xstrdup (scratch_pathname);
+ exec_filename = gdb_realpath_keepfile (scratch_pathname);
if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching))
{
}
}
+/* Add the sections of OBJFILE to the current set of target sections. */
+
+void
+add_target_sections_of_objfile (struct objfile *objfile)
+{
+ struct target_section_table *table = current_target_sections;
+ struct obj_section *osect;
+ int space;
+ unsigned count = 0;
+ struct target_section *ts;
+
+ if (objfile == NULL)
+ return;
+
+ /* Compute the number of sections to add. */
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
+ {
+ if (bfd_get_section_size (osect->the_bfd_section) == 0)
+ continue;
+ count++;
+ }
+
+ if (count == 0)
+ return;
+
+ space = resize_section_table (table, count);
+
+ ts = table->sections + space;
+
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
+ {
+ if (bfd_get_section_size (osect->the_bfd_section) == 0)
+ continue;
+
+ gdb_assert (ts < table->sections + space + count);
+
+ ts->addr = obj_section_addr (osect);
+ ts->endaddr = obj_section_endaddr (osect);
+ ts->the_bfd_section = osect->the_bfd_section;
+ ts->owner = (void *) objfile;
+
+ ts++;
+ }
+}
+
/* Remove all target sections owned by OWNER.
OWNER must be the same value passed to add_target_sections. */
int
section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
- ULONGEST offset, LONGEST len,
+ ULONGEST offset, ULONGEST 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"));
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)
{
struct target_section_table *table = target_get_section_table (ops);
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;
}