]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: int to bool conversion in find_memory_regions API
authorAndrew Burgess <aburgess@redhat.com>
Wed, 17 Sep 2025 12:07:09 +0000 (13:07 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Thu, 2 Oct 2025 16:41:56 +0000 (17:41 +0100)
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 <tom@tromey.com>
gdb/defs.h
gdb/fbsd-nat.c
gdb/gcore.c
gdb/gnu-nat.c
gdb/linux-tdep.c
gdb/netbsd-nat.c
gdb/procfs.c

index bb1e11925da848696378aebc888b7420819d2221..147a8d2822f3e44b2bb159a2e18544782f1516c1 100644 (file)
@@ -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
index 81bd6d98469b69e43ffd8bff8e10e62234008320..d5e7a017235e91ce310f3111a80b4e475a5f9a7e 100644 (file)
@@ -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;
 }
index ce5f570aa464e5f04f58a6a658e21d24b841e703..e5ecd9a44bc6b5e8ddde96fc6cd81fb09e5503fb 100644 (file)
@@ -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);
 
index 33391ba35f2bc85629817002303884ac4fda2088..41cbebfc96e8534497ea2cba49ccb53109255875 100644 (file)
@@ -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;
index 4b679c8759ed62a320d9223d9f77072f8b6d4ea3..5be0648e2871178bcf54870f9f28b4cfcc6e8020 100644 (file)
@@ -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)
 {
index 207e69cfdc55186f36ad7b00a9084238c5d1b21b..2e38fb38246f5dfc800fec0cd32624a41d5d9f42 100644 (file)
@@ -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;
 }
index ca7ecbbe190d5231e1ff761ffdbae3ac3c43ad26..49a0ff58b314e9e9a5ff1495999afd5b39e4e596 100644 (file)
@@ -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);
 }