gdb: rename gdbarch_software_single_step -> gdbarch_get_next_pcs

I spotted this while reviewing a patch adding a new
gdbarch_software_single_step implementation.  I find the name
"software_single_step" a bit misleading or unclear.  It makes it sounds
as if the function executed a single step.  In reality, this function
returns the possible next PCs for current instructions.

We have a similar concept in GDBserver:
linux_process_target::low_get_next_pcs.  I like that name, it's clear
and straight to the point.

Rename gdbarch_software_single_step to gdbarch_get_next_pcs.  I find
this name more indicative of what happens.

There is some code for ARM shared between GDB and GDBserver to implement
both sides, also called "get next pcs", so I think it all fits well
together.

Tested by rebuilding.

Change-Id: Ide74011a5034ba11117b7e7c865a093ef0b1dece
Approved-by: Kevin Buettner <kevinb@redhat.com>
Acked-by: Luis Machado <luis.machado.foss@gmail.com>
This commit is contained in:
Simon Marchi
2025-08-14 16:14:17 -04:00
committed by Simon Marchi
parent 1bf1357c68
commit 1d5f884e50
36 changed files with 57 additions and 59 deletions

View File

@@ -4638,7 +4638,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_sw_breakpoint_from_kind (gdbarch,
aarch64_breakpoint::bp_from_kind);
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
set_gdbarch_software_single_step (gdbarch, aarch64_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, aarch64_software_single_step);
/* Information about registers, etc. */
set_gdbarch_sp_regnum (gdbarch, AARCH64_SP_REGNUM);

View File

@@ -261,7 +261,7 @@ alphanbsd_init_abi (struct gdbarch_info info,
/* NetBSD/alpha does not provide single step support via ptrace(2); we
must use software single-stepping. */
set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, alpha_software_single_step);
/* NetBSD/alpha has SVR4-style shared libraries. */
set_solib_svr4_ops (gdbarch, make_svr4_lp64_solib_ops);

View File

@@ -106,7 +106,7 @@ alphaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
/* OpenBSD/alpha 3.0 and earlier does not provide single step
support via ptrace(2); use software single-stepping for now. */
set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, alpha_software_single_step);
/* OpenBSD/alpha has SVR4-style shared libraries. */
set_solib_svr4_ops (gdbarch, make_svr4_lp64_solib_ops);

View File

@@ -1797,7 +1797,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
/* Handles single stepping of atomic sequences. */
set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, alpha_software_single_step);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);

View File

@@ -728,7 +728,7 @@ arc_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
arc_linux_sw_breakpoint_from_kind);
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
set_gdbarch_software_single_step (gdbarch, arc_linux_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, arc_linux_software_single_step);
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_gdbarch_skip_solib_resolver (gdbarch, arc_linux_skip_solib_resolver);
set_gdbarch_iterate_over_regset_sections

View File

@@ -48,7 +48,7 @@
bool
default_displaced_step_hw_singlestep (struct gdbarch *gdbarch)
{
return !gdbarch_software_single_step_p (gdbarch);
return !gdbarch_get_next_pcs_p (gdbarch);
}
CORE_ADDR

View File

@@ -318,7 +318,7 @@ arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
}
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
}
INIT_GDB_FILE (arm_fbsd_tdep)

View File

@@ -1805,7 +1805,7 @@ arm_linux_init_abi (struct gdbarch_info info,
set_solib_svr4_ops (gdbarch, make_linux_ilp32_svr4_solib_ops);
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, arm_linux_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, arm_linux_software_single_step);
/* Shared library handling. */
set_gdbarch_skip_trampoline_code (gdbarch, arm_linux_skip_trampoline_code);

View File

@@ -139,7 +139,7 @@ arm_netbsd_init_abi_common (struct gdbarch_info info,
set_gdbarch_iterate_over_regset_sections
(gdbarch, arm_nbsd_iterate_over_regset_sections);
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
}
static void

View File

@@ -96,7 +96,7 @@ armobsd_init_abi (struct gdbarch_info info,
tdep->struct_return = pcc_struct_return;
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
/* Breakpoints. */
switch (info.byte_order)

View File

@@ -26,7 +26,7 @@ static void
arm_pikeos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
}
/* The ARM PikeOS OSABI sniffer (see gdbarch_register_osabi_sniffer).

View File

@@ -135,7 +135,7 @@ arm_wince_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_skip_trampoline_code (gdbarch, arm_pe_skip_trampoline_code);
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
/* Skip call to __gccmain that gcc places in main. */
set_gdbarch_skip_main_prologue (gdbarch, arm_wince_skip_main_prologue);

View File

@@ -14004,9 +14004,7 @@ int
insert_single_step_breakpoints (struct gdbarch *gdbarch)
{
regcache *regcache = get_thread_regcache (inferior_thread ());
std::vector<CORE_ADDR> next_pcs;
next_pcs = gdbarch_software_single_step (gdbarch, regcache);
std::vector<CORE_ADDR> next_pcs = gdbarch_get_next_pcs (gdbarch, regcache);
if (!next_pcs.empty ())
{

View File

@@ -3993,7 +3993,7 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_cannot_store_register (gdbarch, cris_cannot_store_register);
set_gdbarch_cannot_fetch_register (gdbarch, cris_cannot_fetch_register);
set_gdbarch_software_single_step (gdbarch, cris_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, cris_software_single_step);
break;
case 32:

View File

@@ -153,7 +153,7 @@ struct gdbarch
gdbarch_set_memtags_ftype *set_memtags = default_set_memtags;
gdbarch_get_memtag_ftype *get_memtag = default_get_memtag;
CORE_ADDR memtag_granule_size = 0;
gdbarch_software_single_step_ftype *software_single_step = nullptr;
gdbarch_get_next_pcs_ftype *get_next_pcs = nullptr;
gdbarch_single_step_through_delay_ftype *single_step_through_delay = nullptr;
gdbarch_print_insn_ftype *print_insn = default_print_insn;
gdbarch_skip_trampoline_code_ftype *skip_trampoline_code = generic_skip_trampoline_code;
@@ -421,7 +421,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of set_memtags, invalid_p == 0. */
/* Skip verify of get_memtag, invalid_p == 0. */
/* Skip verify of memtag_granule_size, invalid_p == 0. */
/* Skip verify of software_single_step, has predicate. */
/* Skip verify of get_next_pcs, has predicate. */
/* Skip verify of single_step_through_delay, has predicate. */
/* Skip verify of print_insn, invalid_p == 0. */
/* Skip verify of skip_trampoline_code, invalid_p == 0. */
@@ -948,11 +948,11 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: memtag_granule_size = %s\n",
core_addr_to_string_nz (gdbarch->memtag_granule_size));
gdb_printf (file,
"gdbarch_dump: gdbarch_software_single_step_p() = %d\n",
gdbarch_software_single_step_p (gdbarch));
"gdbarch_dump: gdbarch_get_next_pcs_p() = %d\n",
gdbarch_get_next_pcs_p (gdbarch));
gdb_printf (file,
"gdbarch_dump: software_single_step = <%s>\n",
host_address_to_string (gdbarch->software_single_step));
"gdbarch_dump: get_next_pcs = <%s>\n",
host_address_to_string (gdbarch->get_next_pcs));
gdb_printf (file,
"gdbarch_dump: gdbarch_single_step_through_delay_p() = %d\n",
gdbarch_single_step_through_delay_p (gdbarch));
@@ -3388,27 +3388,27 @@ set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch,
}
bool
gdbarch_software_single_step_p (struct gdbarch *gdbarch)
gdbarch_get_next_pcs_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
return gdbarch->software_single_step != NULL;
return gdbarch->get_next_pcs != NULL;
}
std::vector<CORE_ADDR>
gdbarch_software_single_step (struct gdbarch *gdbarch, struct regcache *regcache)
gdbarch_get_next_pcs (struct gdbarch *gdbarch, struct regcache *regcache)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->software_single_step != NULL);
gdb_assert (gdbarch->get_next_pcs != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_software_single_step called\n");
return gdbarch->software_single_step (regcache);
gdb_printf (gdb_stdlog, "gdbarch_get_next_pcs called\n");
return gdbarch->get_next_pcs (regcache);
}
void
set_gdbarch_software_single_step (struct gdbarch *gdbarch,
gdbarch_software_single_step_ftype software_single_step)
set_gdbarch_get_next_pcs (struct gdbarch *gdbarch,
gdbarch_get_next_pcs_ftype get_next_pcs)
{
gdbarch->software_single_step = software_single_step;
gdbarch->get_next_pcs = get_next_pcs;
}
bool

View File

@@ -792,11 +792,11 @@ extern void set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch, CORE_ADDR
the condition is true, so that we ensure forward progress when stepping
past a conditional branch to self. */
extern bool gdbarch_software_single_step_p (struct gdbarch *gdbarch);
extern bool gdbarch_get_next_pcs_p (struct gdbarch *gdbarch);
typedef std::vector<CORE_ADDR> (gdbarch_software_single_step_ftype) (struct regcache *regcache);
extern std::vector<CORE_ADDR> gdbarch_software_single_step (struct gdbarch *gdbarch, struct regcache *regcache);
extern void set_gdbarch_software_single_step (struct gdbarch *gdbarch, gdbarch_software_single_step_ftype *software_single_step);
typedef std::vector<CORE_ADDR> (gdbarch_get_next_pcs_ftype) (struct regcache *regcache);
extern std::vector<CORE_ADDR> gdbarch_get_next_pcs (struct gdbarch *gdbarch, struct regcache *regcache);
extern void set_gdbarch_get_next_pcs (struct gdbarch *gdbarch, gdbarch_get_next_pcs_ftype *get_next_pcs);
/* Return non-zero if the processor is executing a delay slot and a
further single-step is needed before the instruction finishes. */
@@ -1148,7 +1148,7 @@ extern void set_gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, gdbar
the displaced instruction buffer).
The default implementation returns false on all targets that provide a
gdbarch_software_single_step routine, and true otherwise. */
gdbarch_get_next_pcs routine, and true otherwise. */
typedef bool (gdbarch_displaced_step_hw_singlestep_ftype) (struct gdbarch *gdbarch);
extern bool gdbarch_displaced_step_hw_singlestep (struct gdbarch *gdbarch);

View File

@@ -1395,7 +1395,7 @@ the condition is true, so that we ensure forward progress when stepping
past a conditional branch to self.
""",
type="std::vector<CORE_ADDR>",
name="software_single_step",
name="get_next_pcs",
params=[("struct regcache *", "regcache")],
predicate=True,
)
@@ -1891,7 +1891,7 @@ receive control again (e.g. by placing a software breakpoint instruction into
the displaced instruction buffer).
The default implementation returns false on all targets that provide a
gdbarch_software_single_step routine, and true otherwise.
gdbarch_get_next_pcs routine, and true otherwise.
""",
type="bool",
name="displaced_step_hw_singlestep",

View File

@@ -2370,7 +2370,7 @@ maybe_software_singlestep (struct gdbarch *gdbarch)
bool hw_step = true;
if (execution_direction == EXEC_FORWARD
&& gdbarch_software_single_step_p (gdbarch))
&& gdbarch_get_next_pcs_p (gdbarch))
hw_step = !insert_single_step_breakpoints (gdbarch);
return hw_step;

View File

@@ -549,8 +549,8 @@ linux_nat_target::follow_fork (inferior *child_inf, ptid_t child_ptid,
/* Note that we consult the parent's architecture instead of
the child's because there's no inferior for the child at
this point. */
if (!gdbarch_software_single_step_p (target_thread_architecture
(parent_ptid)))
if (!gdbarch_get_next_pcs_p (target_thread_architecture
(parent_ptid)))
{
int status;

View File

@@ -1895,7 +1895,7 @@ loongarch_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_align (gdbarch, loongarch_frame_align);
/* Breakpoint manipulation. */
set_gdbarch_software_single_step (gdbarch, loongarch_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, loongarch_software_single_step);
set_gdbarch_breakpoint_kind_from_pc (gdbarch, loongarch_breakpoint::kind_from_pc);
set_gdbarch_sw_breakpoint_from_kind (gdbarch, loongarch_breakpoint::bp_from_kind);
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);

View File

@@ -580,7 +580,7 @@ mips_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Generic FreeBSD support. */
fbsd_init_abi (info, gdbarch);
set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, mips_software_single_step);
switch (abi)
{

View File

@@ -1605,7 +1605,7 @@ mips_linux_init_abi (struct gdbarch_info info,
set_gdbarch_skip_solib_resolver (gdbarch, mips_linux_skip_resolver);
set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, mips_software_single_step);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,

View File

@@ -399,7 +399,7 @@ mipsnbsd_init_abi (struct gdbarch_info info,
set_gdbarch_cannot_fetch_register (gdbarch, mipsnbsd_cannot_fetch_register);
set_gdbarch_cannot_store_register (gdbarch, mipsnbsd_cannot_store_register);
set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, mips_software_single_step);
/* NetBSD/mips has SVR4-style shared libraries. */
set_solib_svr4_ops (gdbarch, (gdbarch_ptr_bit (gdbarch) == 32

View File

@@ -1088,7 +1088,7 @@ moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
frame_unwind_append_unwinder (gdbarch, &moxie_frame_unwind);
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, moxie_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, moxie_software_single_step);
/* Support simple overlay manager. */
set_gdbarch_overlay_update (gdbarch, simple_overlay_update);

View File

@@ -153,7 +153,7 @@ or1k_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* GNU/Linux uses the dynamic linker included in the GNU C Library. */
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
set_gdbarch_software_single_step (gdbarch, or1k_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, or1k_software_single_step);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,

View File

@@ -1091,7 +1091,7 @@ record_full_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
if (!step)
{
/* This is not hard single step. */
if (!gdbarch_software_single_step_p (gdbarch))
if (!gdbarch_get_next_pcs_p (gdbarch))
{
/* This is a normal continue. */
step = 1;
@@ -1266,7 +1266,7 @@ record_full_wait_1 (struct target_ops *ops,
process_stratum_target *proc_target
= current_inferior ()->process_target ();
if (gdbarch_software_single_step_p (gdbarch))
if (gdbarch_get_next_pcs_p (gdbarch))
{
/* Try to insert the software single step breakpoint.
If insert success, set step to 0. */

View File

@@ -189,7 +189,7 @@ riscv_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Generic FreeBSD support. */
fbsd_init_abi (info, gdbarch);
set_gdbarch_software_single_step (gdbarch, riscv_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, riscv_software_single_step);
set_solib_svr4_ops (gdbarch, (riscv_isa_xlen (gdbarch) == 4
? make_svr4_ilp32_solib_ops

View File

@@ -511,7 +511,7 @@ riscv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
linux_init_abi (info, gdbarch, 0);
set_gdbarch_software_single_step (gdbarch, riscv_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, riscv_software_single_step);
set_solib_svr4_ops (gdbarch, (riscv_isa_xlen (gdbarch) == 4
? make_linux_ilp32_svr4_solib_ops

View File

@@ -1362,7 +1362,7 @@ rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
/* RS6000/AIX does not support PT_STEP. Has to be simulated. */
set_gdbarch_software_single_step (gdbarch, rs6000_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, rs6000_software_single_step);
/* Displaced stepping is currently not supported in combination with
software single-stepping. These override the values set by

View File

@@ -8458,7 +8458,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
/* Handles single stepping of atomic sequences. */
set_gdbarch_software_single_step (gdbarch, ppc_deal_with_atomic_sequence);
set_gdbarch_get_next_pcs (gdbarch, ppc_deal_with_atomic_sequence);
/* Not sure on this. FIXMEmgo */
set_gdbarch_frame_args_skip (gdbarch, 8);

View File

@@ -7300,7 +7300,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
s390_displaced_step_copy_insn);
set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, s390_software_single_step);
set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);
/* Prologue analysis. */

View File

@@ -214,7 +214,7 @@ sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->plt_entry_size = 12;
/* Solaris has kernel-assisted single-stepping support. */
set_gdbarch_software_single_step (gdbarch, NULL);
set_gdbarch_get_next_pcs (gdbarch, NULL);
frame_unwind_append_unwinder (gdbarch, &sparc32_sol2_sigtramp_frame_unwind);
}

View File

@@ -1874,7 +1874,7 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_args_skip (gdbarch, 8);
set_gdbarch_software_single_step (gdbarch, sparc_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, sparc_software_single_step);
set_gdbarch_write_pc (gdbarch, sparc_write_pc);
set_gdbarch_dummy_id (gdbarch, sparc_dummy_id);

View File

@@ -221,7 +221,7 @@ sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->plt_entry_size = 16;
/* Solaris has kernel-assisted single-stepping support. */
set_gdbarch_software_single_step (gdbarch, NULL);
set_gdbarch_get_next_pcs (gdbarch, NULL);
}
INIT_GDB_FILE (sparc64_sol2_tdep)

View File

@@ -1267,7 +1267,7 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
dwarf2_frame_set_init_reg (gdbarch, tic6x_dwarf2_frame_init_reg);
/* Single stepping. */
set_gdbarch_software_single_step (gdbarch, tic6x_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, tic6x_software_single_step);
/* Call dummy code. */
set_gdbarch_frame_align (gdbarch, tic6x_frame_align);

View File

@@ -1173,7 +1173,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_skip_prologue (gdbarch, z80_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan); // falling stack
set_gdbarch_software_single_step (gdbarch, z80_software_single_step);
set_gdbarch_get_next_pcs (gdbarch, z80_software_single_step);
set_gdbarch_breakpoint_kind_from_pc (gdbarch, z80_breakpoint_kind_from_pc);
set_gdbarch_sw_breakpoint_from_kind (gdbarch, z80_sw_breakpoint_from_kind);
set_gdbarch_insn_is_call (gdbarch, z80_insn_is_call);