aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.h
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2020-03-04 17:42:41 -0700
committerKevin Buettner <kevinb@redhat.com>2020-07-22 12:36:42 -0700
commite56cb451c9ca63bdafc11cc3d3ee14b74e409fa9 (patch)
treeeaa40a076254f68d56636fd2da805926ce92ccc2 /gdb/exec.h
parent678c7a56ced1828d37a554ec97f672496f135054 (diff)
downloadbinutils-e56cb451c9ca63bdafc11cc3d3ee14b74e409fa9.zip
binutils-e56cb451c9ca63bdafc11cc3d3ee14b74e409fa9.tar.gz
binutils-e56cb451c9ca63bdafc11cc3d3ee14b74e409fa9.tar.bz2
section_table_xfer_memory: Replace section name with callback predicate
This patch is motivated by the need to be able to select sections that section_table_xfer_memory_partial should consider for memory transfers. I'll use this facility in the next patch in this series. section_table_xfer_memory_partial() can currently be passed a section name which may be used to make name-based selections. This is similar to what I want to do, except that I want to be able to consider section flags instead of the name. I'm replacing the section name parameter with a predicate that, when passed a pointer to a target_section struct, will return true if that section should be further considered, or false which indicates that it shouldn't. I've converted the one existing use where a non-NULL section name is passed to section_table_xfer_memory_partial(). Instead of passing the section name, it now looks like this: 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, match_cb); The other callers all passed NULL; they've been simplified somewhat in that they no longer need to pass NULL. gdb/ChangeLog: * 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.
Diffstat (limited to 'gdb/exec.h')
-rw-r--r--gdb/exec.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/gdb/exec.h b/gdb/exec.h
index 54e6ff4..82eb39c 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -65,8 +65,13 @@ extern enum target_xfer_status
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.
@@ -83,7 +88,9 @@ extern enum target_xfer_status
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