From: Andrew Burgess Date: Wed, 17 Sep 2025 12:07:09 +0000 (+0100) Subject: gdb: int to bool conversion in find_memory_regions API X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dcfde4f8c731afc672cf658cd63f6743f4030027;p=thirdparty%2Fbinutils-gdb.git gdb: int to bool conversion in find_memory_regions API Perform int to bool conversion for find_memory_region_ftype function type. This function type is used in the find_memory_regions API, both target_find_memory_regions and target_find_memory_regions. There should be no user visible changes after this commit. Approved-By: Tom Tromey --- diff --git a/gdb/defs.h b/gdb/defs.h index bb1e11925da..147a8d2822f 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -225,8 +225,8 @@ extern const char *pc_prefix (CORE_ADDR); DATA is passed without changes from a caller. */ typedef int (*find_memory_region_ftype) (CORE_ADDR addr, unsigned long size, - int read, int write, int exec, - int modified, bool memory_tagged, + bool read, bool write, bool exec, + bool modified, bool memory_tagged, void *data); /* * Possible lvalue types. Like enum language, this should be in diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 81bd6d98469..d5e7a017235 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -188,7 +188,7 @@ fbsd_nat_target::find_memory_regions (find_memory_region_ftype func, Pass MODIFIED as true, we do not know the real modification state. */ func (kve->kve_start, size, kve->kve_protection & KVME_PROT_READ, kve->kve_protection & KVME_PROT_WRITE, - kve->kve_protection & KVME_PROT_EXEC, 1, false, data); + kve->kve_protection & KVME_PROT_EXEC, true, false, data); } return 0; } diff --git a/gdb/gcore.c b/gdb/gcore.c index ce5f570aa46..e5ecd9a44bc 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -398,8 +398,8 @@ make_output_phdrs (bfd *obfd, asection *osec) DATA is 'bfd *' for the core file GDB is creating. */ static int -gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, - int write, int exec, int modified, bool memory_tagged, +gcore_create_callback (CORE_ADDR vaddr, unsigned long size, bool read, + bool write, bool exec, bool modified, bool memory_tagged, void *data) { bfd *obfd = (bfd *) data; @@ -409,7 +409,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, /* If the memory segment has no permissions set, ignore it, otherwise when we later try to access it for read/write, we'll get an error or jam the kernel. */ - if (read == 0 && write == 0 && exec == 0 && modified == 0) + if (!read && !write && !exec && !modified) { if (info_verbose) gdb_printf ("Ignore segment, %s bytes at %s\n", @@ -419,7 +419,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, return 0; } - if (write == 0 && modified == 0 && !solib_keep_data_in_core (vaddr, size)) + if (!write && !modified && !solib_keep_data_in_core (vaddr, size)) { /* See if this region of memory lies inside a known file on disk. If so, we can avoid copying its contents by clearing SEC_LOAD. */ @@ -453,7 +453,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, keep:; } - if (write == 0) + if (!write) flags |= SEC_READONLY; if (exec) @@ -489,8 +489,8 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read, static int gcore_create_memtag_section_callback (CORE_ADDR vaddr, unsigned long size, - int read, int write, int exec, - int modified, bool memory_tagged, + bool read, bool write, bool exec, + bool modified, bool memory_tagged, void *data) { /* Are there memory tags in this particular memory map entry? */ @@ -548,10 +548,10 @@ objfile_find_memory_regions (struct target_ops *self, int ret; ret = (*func) (objsec.addr (), size, - 1, /* All sections will be readable. */ + true, /* All sections will be readable. */ (flags & SEC_READONLY) == 0, /* Writable. */ (flags & SEC_CODE) != 0, /* Executable. */ - 1, /* MODIFIED is unknown, pass it as true. */ + true, /* MODIFIED is unknown, pass it as true. */ false, /* No memory tags in the object file. */ obfd); if (ret != 0) @@ -562,10 +562,10 @@ objfile_find_memory_regions (struct target_ops *self, /* Make a stack segment. */ if (derive_stack_segment (&temp_bottom, &temp_top)) (*func) (temp_bottom, temp_top - temp_bottom, - 1, /* Stack section will be readable. */ - 1, /* Stack section will be writable. */ - 0, /* Stack section will not be executable. */ - 1, /* Stack section will be modified. */ + true, /* Stack section will be readable. */ + true, /* Stack section will be writable. */ + false, /* Stack section will not be executable. */ + true, /* Stack section will be modified. */ false, /* No memory tags in the object file. */ obfd); @@ -573,10 +573,10 @@ objfile_find_memory_regions (struct target_ops *self, if (derive_heap_segment (current_program_space->exec_bfd (), &temp_bottom, &temp_top)) (*func) (temp_bottom, temp_top - temp_bottom, - 1, /* Heap section will be readable. */ - 1, /* Heap section will be writable. */ - 0, /* Heap section will not be executable. */ - 1, /* Heap section will be modified. */ + true, /* Heap section will be readable. */ + true, /* Heap section will be writable. */ + false, /* Heap section will not be executable. */ + true, /* Heap section will be modified. */ false, /* No memory tags in the object file. */ obfd); diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 33391ba35f2..41cbebfc96e 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2623,7 +2623,7 @@ gnu_nat_target::find_memory_regions (find_memory_region_ftype func, last_protection & VM_PROT_READ, last_protection & VM_PROT_WRITE, last_protection & VM_PROT_EXECUTE, - 1, /* MODIFIED is unknown, pass it as true. */ + true, /* MODIFIED is unknown, pass it as true. */ false, /* No memory tags in the object file. */ data); last_region_address = region_address; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 4b679c8759e..5be0648e287 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1322,8 +1322,8 @@ linux_core_xfer_siginfo (struct gdbarch *gdbarch, struct bfd &cbfd, typedef int linux_find_memory_region_ftype (ULONGEST vaddr, ULONGEST size, ULONGEST offset, - int read, int write, - int exec, int modified, + bool read, bool write, + bool exec, bool modified, bool memory_tagged, const std::string &filename, void *data); @@ -1596,7 +1596,7 @@ linux_find_memory_regions_full (struct gdbarch *gdbarch, { func (map.start_address, map.end_address - map.start_address, map.offset, map.read, map.write, map.exec, - 1, /* MODIFIED is true because we want to dump + true, /* MODIFIED is true because we want to dump the mapping. */ map.vmflags.memory_tagging != 0, map.filename, obfd); @@ -1626,8 +1626,8 @@ struct linux_find_memory_regions_data static int linux_find_memory_regions_thunk (ULONGEST vaddr, ULONGEST size, ULONGEST offset, - int read, int write, int exec, int modified, - bool memory_tagged, + bool read, bool write, bool exec, + bool modified, bool memory_tagged, const std::string &filename, void *arg) { struct linux_find_memory_regions_data *data @@ -1683,7 +1683,7 @@ struct linux_make_mappings_data static int linux_make_mappings_callback (ULONGEST vaddr, ULONGEST size, ULONGEST offset, - int read, int write, int exec, int modified, + bool read, bool write, bool exec, bool modified, bool memory_tagged, const std::string &filename, void *data) { diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c index 207e69cfdc5..2e38fb38246 100644 --- a/gdb/netbsd-nat.c +++ b/gdb/netbsd-nat.c @@ -260,7 +260,7 @@ nbsd_nat_target::find_memory_regions (find_memory_region_ftype func, Pass MODIFIED as true, we do not know the real modification state. */ func (kve->kve_start, size, kve->kve_protection & KVME_PROT_READ, kve->kve_protection & KVME_PROT_WRITE, - kve->kve_protection & KVME_PROT_EXEC, 1, false, data); + kve->kve_protection & KVME_PROT_EXEC, true, false, data); } return 0; } diff --git a/gdb/procfs.c b/gdb/procfs.c index ca7ecbbe190..49a0ff58b31 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -3168,7 +3168,7 @@ find_memory_regions_callback (struct prmap *map, (map->pr_mflags & MA_READ) != 0, (map->pr_mflags & MA_WRITE) != 0, (map->pr_mflags & MA_EXEC) != 0, - 1, /* MODIFIED is unknown, pass it as true. */ + true, /* MODIFIED is unknown, pass it as true. */ false, data); }