[binutils-gdb] gdb: change gdbarch_vsyscall_range to return bool

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=84e279ce48d7ecd91d6c7e5e153ff960f215acad

commit 84e279ce48d7ecd91d6c7e5e153ff960f215acad
Author: Simon Marchi <[email protected]>
Date:   Fri Feb 27 15:05:27 2026 -0500

    gdb: change gdbarch_vsyscall_range to return bool
    
    Change-Id: I4faa4086e8dd43f99095c97b78390afe86601c67
    Approved-By: Tom Tromey <[email protected]>

Diff:
---
 gdb/arch-utils.c          |  4 ++--
 gdb/arch-utils.h          |  3 ++-
 gdb/fbsd-tdep.c           |  6 +++---
 gdb/gdbarch-gen.c         |  2 +-
 gdb/gdbarch-gen.h         |  4 ++--
 gdb/gdbarch_components.py |  2 +-
 gdb/linux-tdep.c          | 24 ++++++++++++------------
 7 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 4fcd82f0111..98732420fe2 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -340,10 +340,10 @@ default_remote_register_number (struct gdbarch *gdbarch,
 
 /* See arch-utils.h.  */
 
-int
+bool
 default_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
 {
-  return 0;
+  return false;
 }
 
 
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 4d1c76a69bf..a898a3b1ad2 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -334,7 +334,8 @@ extern bool default_program_breakpoint_here_p (struct gdbarch *gdbarch,
 
 /* Do-nothing version of vsyscall_range.  Returns false.  */
 
-extern int default_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range);
+extern bool default_vsyscall_range (struct gdbarch *gdbarch,
+				    struct mem_range *range);
 
 /* Symbols for gdbarch_infcall_mmap; their Linux PROT_* system
    definitions would be dependent on compilation host.  */
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 2e3e2c80210..458e9154272 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -2474,7 +2474,7 @@ fbsd_corefile_parse_exec_context (struct gdbarch *gdbarch, bfd *cbfd)
 
 /* Return the address range of the vDSO for the current inferior.  */
 
-static int
+static bool
 fbsd_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
 {
   struct fbsd_pspace_data *data = get_fbsd_pspace_data (current_program_space);
@@ -2488,10 +2488,10 @@ fbsd_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
     }
 
   if (data->vdso_range_p < 0)
-    return 0;
+    return false;
 
   *range = data->vdso_range;
-  return 1;
+  return true;
 }
 
 /* To be called from GDB_OSABI_FREEBSD handlers. */
diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c
index 2c6da958bdd..4f9cc637a5a 100644
--- a/gdb/gdbarch-gen.c
+++ b/gdb/gdbarch-gen.c
@@ -5008,7 +5008,7 @@ set_gdbarch_print_auxv_entry (struct gdbarch *gdbarch,
   gdbarch->print_auxv_entry = print_auxv_entry;
 }
 
-int
+bool
 gdbarch_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
 {
   gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
index db7cdb437fd..44e424e9420 100644
--- a/gdb/gdbarch-gen.h
+++ b/gdb/gdbarch-gen.h
@@ -1622,8 +1622,8 @@ extern void set_gdbarch_print_auxv_entry (struct gdbarch *gdbarch, gdbarch_print
    range with zero length is returned.  Returns true if the vsyscall is
    found, false otherwise. */
 
-typedef int (gdbarch_vsyscall_range_ftype) (struct gdbarch *gdbarch, struct mem_range *range);
-extern int gdbarch_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range);
+typedef bool (gdbarch_vsyscall_range_ftype) (struct gdbarch *gdbarch, struct mem_range *range);
+extern bool gdbarch_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range);
 extern void set_gdbarch_vsyscall_range (struct gdbarch *gdbarch, gdbarch_vsyscall_range_ftype *vsyscall_range);
 
 /* Allocate SIZE bytes of PROT protected page aligned memory in inferior.
diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
index 77c82c30044..f817bcb3c3f 100644
--- a/gdb/gdbarch_components.py
+++ b/gdb/gdbarch_components.py
@@ -2587,7 +2587,7 @@ write it to *RANGE.  If the vsyscall's length can't be determined, a
 range with zero length is returned.  Returns true if the vsyscall is
 found, false otherwise.
 """,
-    type="int",
+    type="bool",
     name="vsyscall_range",
     params=[("struct mem_range *", "range")],
     predefault="default_vsyscall_range",
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 5a2bd97df50..495dd068038 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -2720,14 +2720,14 @@ linux_gdb_signal_to_target (struct gdbarch *gdbarch,
 /* Helper for linux_vsyscall_range that does the real work of finding
    the vsyscall's address range.  */
 
-static int
+static bool
 linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
 {
   char filename[100];
   long pid;
 
   if (target_auxv_search (AT_SYSINFO_EHDR, &range->start) <= 0)
-    return 0;
+    return false;
 
   /* It doesn't make sense to access the host's /proc when debugging a
      core file.  Instead, look for the PT_LOAD segment that matches
@@ -2740,28 +2740,28 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
       bfd *cbfd = get_inferior_core_bfd (current_inferior ());
       phdrs_size = bfd_get_elf_phdr_upper_bound (cbfd);
       if (phdrs_size == -1)
-	return 0;
+	return false;
 
       gdb::unique_xmalloc_ptr<Elf_Internal_Phdr>
 	phdrs ((Elf_Internal_Phdr *) xmalloc (phdrs_size));
       num_phdrs = bfd_get_elf_phdrs (cbfd, phdrs.get ());
       if (num_phdrs == -1)
-	return 0;
+	return false;
 
       for (i = 0; i < num_phdrs; i++)
 	if (phdrs.get ()[i].p_type == PT_LOAD
 	    && phdrs.get ()[i].p_vaddr == range->start)
 	  {
 	    range->length = phdrs.get ()[i].p_memsz;
-	    return 1;
+	    return true;
 	  }
 
-      return 0;
+      return false;
     }
 
   /* We need to know the real target PID to access /proc.  */
   if (current_inferior ()->fake_pid_p)
-    return 0;
+    return false;
 
   pid = current_inferior ()->pid;
 
@@ -2795,20 +2795,20 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range)
 		p++;
 	      endaddr = strtoulst (p, &p, 16);
 	      range->length = endaddr - addr;
-	      return 1;
+	      return true;
 	    }
 	}
     }
   else
     warning (_("unable to open /proc file '%s'"), filename);
 
-  return 0;
+  return false;
 }
 
 /* Implementation of the "vsyscall_range" gdbarch hook.  Handles
    caching, and defers the real work to linux_vsyscall_range_raw.  */
 
-static int
+static bool
 linux_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
 {
   struct linux_info *info = get_linux_inferior_data (current_inferior ());
@@ -2822,10 +2822,10 @@ linux_vsyscall_range (struct gdbarch *gdbarch, struct mem_range *range)
     }
 
   if (info->vsyscall_range_p < 0)
-    return 0;
+    return false;
 
   *range = info->vsyscall_range;
-  return 1;
+  return true;
 }
 
 /* Symbols for linux_infcall_mmap's ARG_FLAGS; their Linux MAP_* system
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.