#include "target.h"
#include "gdbcmd.h"
#include "language.h"
+#include "filenames.h"
#include "symfile.h"
#include "objfiles.h"
#include "completer.h"
nxt = vp->nxt;
/* if there is an objfile associated with this bfd,
- free_objfile() will do proper cleanup of objfile *and* bfd. */
+ free_objfile() will do proper cleanup of objfile *and* bfd. */
if (vp->objfile)
{
/* At this point, scratch_pathname and exec_bfd->name both point to the
same malloc'd string. However exec_close() will attempt to free it
via the exec_bfd->name pointer, so we need to make another copy and
- leave exec_bfd as the new owner of the original copy. */
+ leave exec_bfd as the new owner of the original copy. */
scratch_pathname = xstrdup (scratch_pathname);
cleanups = make_cleanup (xfree, scratch_pathname);
/* FIXME - This should only be run for RS6000, but the ifdef is a poor
way to accomplish. */
#ifdef DEPRECATED_IBM6000_TARGET
- /* Setup initial vmap. */
+ /* Setup initial vmap. */
map_vmap (exec_bfd, 0);
if (vmap == NULL)
be called from file_command(), which also calls symbol_file_command()
which can take multiple args.
- If ARGS is NULL, we just want to close the exec file. */
+ If ARGS is NULL, we just want to close the exec file. */
static void
exec_file_command (char *args, int from_tty)
exec_file_attach (NULL, from_tty);
}
-/* Set both the exec file and the symbol file, in one command.
+/* Set both the exec file and the symbol file, in one command.
What a novelty. Why did GDB go through four major releases before this
command was added? */
}
\f
-/* Locate all mappable sections of a BFD file.
+/* Locate all mappable sections of a BFD file.
table_pp_char is a char * to get it through bfd_map_over_sections;
we cast it back to its proper type. */
vp->dend = vp->dstart + bfd_section_size (abfd, sect);
vp->dvma = bfd_section_vma (abfd, sect);
}
- /* Silently ignore other types of sections. (FIXME?) */
+ /* Silently ignore other types of sections. (FIXME?) */
}
/* Make a vmap for ABFD which might be a member of the archive ARCH.
vmap_bfd.pvmap = vp;
bfd_map_over_sections (abfd, bfdsec_to_vmap, &vmap_bfd);
- /* Find the end of the list and append. */
+ /* Find the end of the list and append. */
for (vpp = &vmap; *vpp; vpp = &(*vpp)->nxt)
;
*vpp = vp;
}
\f
+VEC(mem_range_s) *
+section_table_available_memory (VEC(mem_range_s) *memory,
+ CORE_ADDR memaddr, ULONGEST len,
+ struct target_section *sections,
+ struct target_section *sections_end)
+{
+ struct target_section *p;
+
+ for (p = sections; p < sections_end; p++)
+ {
+ if ((bfd_get_section_flags (p->bfd, p->the_bfd_section)
+ & SEC_READONLY) == 0)
+ continue;
+
+ /* Copy the meta-data, adjusted. */
+ if (mem_ranges_overlap (p->addr, p->endaddr - p->addr, memaddr, len))
+ {
+ ULONGEST lo1, hi1, lo2, hi2;
+ struct mem_range *r;
+
+ lo1 = memaddr;
+ hi1 = memaddr + len;
+
+ lo2 = p->addr;
+ hi2 = p->endaddr;
+
+ r = VEC_safe_push (mem_range_s, memory, NULL);
+
+ r->start = max (lo1, lo2);
+ r->length = min (hi1, hi2) - r->start;
+ }
+ }
+
+ return memory;
+}
+
int
section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
ULONGEST offset, LONGEST len,
for (p = sections; p < sections_end; p++)
{
if (section_name && strcmp (section_name, p->the_bfd_section->name) != 0)
- continue; /* not the section we need */
+ continue; /* not the section we need. */
if (memaddr >= p->addr)
{
if (memend <= p->endaddr)
}
}
- return 0; /* We can't help */
+ return 0; /* We can't help. */
}
struct target_section_table *
}
}
if (p == t->sections_end)
- warning (_("Cannot find section for the entry point of %s.\n"),
+ warning (_("Cannot find section for the entry point of %s."),
bfd_get_filename (abfd));
entry_point = gdbarch_addr_bits_remove (gdbarch,
if (args == 0)
error (_("Must specify section name and its virtual address"));
- /* Parse out section name */
+ /* Parse out section name. */
for (secname = args; !isspace (*args); args++);
seclen = args - secname;
- /* Parse out new virtual address */
+ /* Parse out new virtual address. */
secaddr = parse_and_eval_address (args);
table = current_target_sections;
table = current_target_sections;
for (p = table->sections; p < table->sections_end; p++)
{
- if (strcmp (filename, p->bfd->filename) == 0
+ if (filename_cmp (filename, p->bfd->filename) == 0
&& index == p->the_bfd_section->index)
{
p->endaddr += address - p->addr;
!= current_target_sections->sections_end);
}
-/* Find mapped memory. */
+/* Find mapped memory. */
extern void
exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *))