[binutils-gdb] gdb/linux-tdep: check return value of linux_find_memory_region_ftype callback
Simon Marchi via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b916472f0930f253a57275128b7c036615830eeb commit b916472f0930f253a57275128b7c036615830eeb Author: Simon Marchi <[email protected]> Date: Tue Mar 10 13:30:32 2026 -0400 gdb/linux-tdep: check return value of linux_find_memory_region_ftype callback I noticed that linux_find_memory_regions_full did not check the return value of the linux_find_memory_region_ftype callback. I think this is a mistake. When called from linux_find_memory_regions, the find_memory_region_ftype callback could return false, in which case we should stop iterating. This probably didn't matter in practice, as these callbacks generally don't return false (only in error cases that never happen). Change-Id: Iafc5a9aae3d955454420d700a23f18de6f0bc267 Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/linux-tdep.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 495dd068038..53ee6d9579c 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1637,15 +1637,12 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, for (const struct smaps_data &map : smaps) { /* Invoke the callback function to create the corefile segment. */ - if (should_dump_mapping_p (filterflags, map)) - { - func (map.start_address, map.end_address - map.start_address, - map.offset, map.read, map.write, map.exec, - true, /* MODIFIED is true because we want to dump - the mapping. */ - map.vmflags.memory_tagging != 0, - map.filename, obfd); - } + if (should_dump_mapping_p (filterflags, map) + && !func (map.start_address, map.end_address - map.start_address, + map.offset, map.read, map.write, map.exec, + /* MODIFIED is true because we want to dump the mapping. */ + true, map.vmflags.memory_tagging != 0, map.filename, obfd)) + return false; } return true;