+2020-07-22 Kevin Buettner <kevinb@redhat.com>
+
+ * exec.h (section_table_xfer_memory): Revise declaration,
+ replacing section name parameter with an optional callback
+ predicate.
+ * exec.c (section_table_xfer_memory): Likewise.
+ * bfd-target.c, exec.c, target.c, corelow.c: Adjust all callers
+ of section_table_xfer_memory.
+
2020-07-22 Tom Tromey <tromey@adacore.com>
* mi/mi-cmd-stack.c (list_args_or_locals): Use
return section_table_xfer_memory_partial (readbuf, writebuf,
offset, len, xfered_len,
m_table.sections,
- m_table.sections_end,
- NULL);
+ m_table.sections_end);
}
default:
return TARGET_XFER_E_IO;
(readbuf, writebuf,
offset, len, xfered_len,
m_core_section_table.sections,
- m_core_section_table.sections_end,
- NULL));
+ m_core_section_table.sections_end));
case TARGET_OBJECT_AUXV:
if (readbuf)
ULONGEST *xfered_len,
struct target_section *sections,
struct target_section *sections_end,
- const char *section_name)
+ gdb::function_view<bool
+ (const struct target_section *)> match_cb)
{
int res;
struct target_section *p;
struct bfd_section *asect = p->the_bfd_section;
bfd *abfd = asect->owner;
- if (section_name && strcmp (section_name, asect->name) != 0)
+ if (match_cb != nullptr && !match_cb (p))
continue; /* not the section we need. */
if (memaddr >= p->addr)
{
return section_table_xfer_memory_partial (readbuf, writebuf,
offset, len, xfered_len,
table->sections,
- table->sections_end,
- NULL);
+ table->sections_end);
else
return TARGET_XFER_E_IO;
}
Request to transfer up to LEN 8-bit bytes of the target sections
defined by SECTIONS and SECTIONS_END. The OFFSET specifies the
starting address.
- If SECTION_NAME is not NULL, only access sections with that same
- name.
+
+ The MATCH_CB predicate is optional; when provided it will be called
+ for each section under consideration. When MATCH_CB evaluates as
+ true, the section remains under consideration; a false result
+ removes it from consideration for performing the memory transfers
+ noted above. See memory_xfer_partial_1() in target.c for an
+ example.
Return the number of bytes actually transfered, or zero when no
data is available for the requested range.
ULONGEST, ULONGEST, ULONGEST *,
struct target_section *,
struct target_section *,
- const char *);
+ gdb::function_view<bool
+ (const struct target_section *)> match_cb
+ = nullptr);
/* Read from mappable read-only sections of BFD executable files.
Similar to exec_read_partial_read_only, but return
const char *section_name = section->the_bfd_section->name;
memaddr = overlay_mapped_address (memaddr, section);
+
+ auto match_cb = [=] (const struct target_section *s)
+ {
+ return (strcmp (section_name, s->the_bfd_section->name) == 0);
+ };
+
return section_table_xfer_memory_partial (readbuf, writebuf,
memaddr, len, xfered_len,
table->sections,
table->sections_end,
- section_name);
+ match_cb);
}
}
return section_table_xfer_memory_partial (readbuf, writebuf,
memaddr, len, xfered_len,
table->sections,
- table->sections_end,
- NULL);
+ table->sections_end);
}
}