gdb: change gdbarch_has_shared_address_space to return bool

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>
This commit is contained in:
Simon Marchi 2026-02-27 15:05:23 -05:00
parent 4cdad01ef4
commit dffaef4457
9 changed files with 16 additions and 19 deletions

View 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

View 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);

View 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);

View 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. */

View 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",

View 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 ();

View 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.

View 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;

View 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;