]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: change gdbarch_has_shared_address_space to return bool
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 27 Feb 2026 20:05:23 +0000 (15:05 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Mar 2026 17:15:47 +0000 (13:15 -0400)
Change the target_is_uclinux global in m68k-linux-tdep.c to be an
std::optional, for clarity.

Change-Id: Ifb401865bac15dbb9803aeeb9f3d61ed965d6541
Approved-By: Tom Tromey <tom@tromey.com>
gdb/arch-utils.c
gdb/arch-utils.h
gdb/gdbarch-gen.c
gdb/gdbarch-gen.h
gdb/gdbarch_components.py
gdb/linux-tdep.c
gdb/linux-tdep.h
gdb/m68k-linux-tdep.c
gdb/progspace.c

index 6065315870cabd8806077a1b718fc1ae880000e1..886f9431fea87824fd555f0a9b87e759626ef67b 100644 (file)
@@ -849,12 +849,12 @@ get_current_arch (void)
     return current_inferior ()->arch ();
 }
 
-int
+bool
 default_has_shared_address_space (struct gdbarch *gdbarch)
 {
   /* Simply say no.  In most unix-like targets each inferior/process
      has its own address space.  */
-  return 0;
+  return false;
 }
 
 int
index cc7d6fd84593a2530bc51d27e1fd350a0b44a872..5ff262179f8155f30846b4fdb731ad002b3db8f1 100644 (file)
@@ -300,7 +300,7 @@ extern struct gdbarch *gdbarch_from_bfd (bfd *abfd);
    routines to determine the architecture to execute a command in.  */
 extern struct gdbarch *get_current_arch (void);
 
-extern int default_has_shared_address_space (struct gdbarch *);
+extern bool default_has_shared_address_space (struct gdbarch *);
 
 extern int default_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
                                             CORE_ADDR addr, std::string *msg);
index 3ba67a79fbf6fa255121043fb5a9fb70eb938e8d..332849c162e67af1f9f98817b1c8571e05c6c6b9 100644 (file)
@@ -4732,7 +4732,7 @@ set_gdbarch_has_global_breakpoints (struct gdbarch *gdbarch,
   gdbarch->has_global_breakpoints = has_global_breakpoints;
 }
 
-int
+bool
 gdbarch_has_shared_address_space (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch != NULL);
index 4949d92d69e37da57cf8290dceac9581eec04209..b4f73e308db36f442ced12e1aac88b158e950731 100644 (file)
@@ -1509,8 +1509,8 @@ extern void set_gdbarch_has_global_breakpoints (struct gdbarch *gdbarch, bool ha
 
 /* True if inferiors share an address space (e.g., uClinux). */
 
-typedef int (gdbarch_has_shared_address_space_ftype) (struct gdbarch *gdbarch);
-extern int gdbarch_has_shared_address_space (struct gdbarch *gdbarch);
+typedef bool (gdbarch_has_shared_address_space_ftype) (struct gdbarch *gdbarch);
+extern bool gdbarch_has_shared_address_space (struct gdbarch *gdbarch);
 extern void set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch, gdbarch_has_shared_address_space_ftype *has_shared_address_space);
 
 /* True if a fast tracepoint can be set at an address. */
index cb88a15872a01df1ac5d66560c5c894a24c9f0a3..c719c27279107c34d8d36cd947ed69afecd4fab3 100644 (file)
@@ -2394,7 +2394,7 @@ Method(
     comment="""
 True if inferiors share an address space (e.g., uClinux).
 """,
-    type="int",
+    type="bool",
     name="has_shared_address_space",
     params=[],
     predefault="default_has_shared_address_space",
index 47007ca841c3e5108b7e27d1535e51dd83638bd2..5a2bd97df50546fd982716deee2d0bfca3b0b1f9 100644 (file)
@@ -422,8 +422,8 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
 /* Return true if the target is running on uClinux instead of normal
    Linux kernel.  */
 
-int
-linux_is_uclinux (void)
+bool
+linux_is_uclinux ()
 {
   CORE_ADDR dummy;
 
@@ -431,7 +431,7 @@ linux_is_uclinux (void)
          && target_auxv_search (AT_PAGESZ, &dummy) == 0);
 }
 
-static int
+static bool
 linux_has_shared_address_space (struct gdbarch *gdbarch)
 {
   return linux_is_uclinux ();
index 73d4832069f446dbb1c8e1067fa901bf41510e61..4f74d40075da15b3b8bba4b552ce0cf27ad2e14a 100644 (file)
@@ -100,7 +100,7 @@ extern void linux_displaced_step_restore_all_in_ptid (inferior *parent_inf,
 extern void linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
                            int num_disp_step_buffers);
 
-extern int linux_is_uclinux (void);
+extern bool linux_is_uclinux ();
 
 /* Fetch the AT_HWCAP entry from auxv data AUXV.  Use TARGET and GDBARCH to
    parse auxv entries.
index 1d147eb482b5117b5e50cd9f90d88b59a8daf86e..ceb15cb1a20b2c41e39bc006a8216051666e700b 100644 (file)
@@ -209,14 +209,14 @@ struct m68k_linux_sigtramp_info
 };
 
 /* Nonzero if running on uClinux.  */
-static int target_is_uclinux;
+static std::optional<bool> target_is_uclinux;
 
 static void
 m68k_linux_inferior_created (inferior *inf)
 {
   /* Record that we will need to re-evaluate whether we are running on a
      uClinux or normal GNU/Linux target (see m68k_linux_get_sigtramp_info).  */
-  target_is_uclinux = -1;
+  target_is_uclinux = std::nullopt;
 }
 
 static struct m68k_linux_sigtramp_info
@@ -229,7 +229,7 @@ m68k_linux_get_sigtramp_info (const frame_info_ptr &this_frame)
 
   /* Determine whether we are running on a uClinux or normal GNU/Linux
      target so we can use the correct sigcontext layouts.  */
-  if (target_is_uclinux == -1)
+  if (!target_is_uclinux.has_value ())
     target_is_uclinux = linux_is_uclinux ();
 
   sp = get_frame_register_unsigned (this_frame, M68K_SP_REGNUM);
@@ -240,7 +240,7 @@ m68k_linux_get_sigtramp_info (const frame_info_ptr &this_frame)
   if (m68k_linux_pc_in_sigtramp (this_frame) == 2)
     info.sc_reg_offset = m68k_linux_ucontext_reg_offset;
   else
-    info.sc_reg_offset = (target_is_uclinux
+    info.sc_reg_offset = (target_is_uclinux.value ()
                          ? m68k_uclinux_sigcontext_reg_offset
                          : m68k_linux_sigcontext_reg_offset);
   return info;
index 484fd085b1f44babc5aac2698d155b8cdab3cf39..1407b058dfdf2b828d98c98c1a6b693c7e60d887 100644 (file)
@@ -43,10 +43,7 @@ struct program_space *current_program_space;
 address_space_ref_ptr
 maybe_new_address_space ()
 {
-  int shared_aspace
-    = gdbarch_has_shared_address_space (current_inferior ()->arch ());
-
-  if (shared_aspace)
+  if (gdbarch_has_shared_address_space (current_inferior ()->arch ()))
     {
       /* Just return the first in the list.  */
       return program_spaces[0]->aspace;