From fdb61c6c395292a39e594981023b903bc21c6c36 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 14 Feb 2020 16:45:40 -0500 Subject: [PATCH] gdb: introduce displaced_step_closure_up type alias To help with readability, add the type displaced_step_closure_up, an alias for std::unique_ptr, and use it throughout the code base. gdb/ChangeLog: * aarch64-tdep.c (aarch64_displaced_step_copy_insn): Use displaced_step_closure_up. * aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise. (struct displaced_step_closure_up): * amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise. * amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * gdbarch.sh (displaced_step_copy_insn): Likewise. * gdbarch.c, gdbarch.h: Re-generate. * i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Use displaced_step_closure_up. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. * i386-tdep.h (i386_displaced_step_copy_insn): Likewise. * infrun.h (displaced_step_closure_up): New type alias. (struct displaced_step_inferior_state) : Change type to displaced_step_closure_up. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Use displaced_step_closure_up. * s390-tdep.c (s390_displaced_step_copy_insn): Likewise. --- gdb/ChangeLog | 23 +++++++++++++++++++++++ gdb/aarch64-tdep.c | 2 +- gdb/aarch64-tdep.h | 3 ++- gdb/amd64-tdep.c | 2 +- gdb/amd64-tdep.h | 3 ++- gdb/arm-linux-tdep.c | 2 +- gdb/gdbarch.c | 2 +- gdb/gdbarch.h | 6 +++--- gdb/gdbarch.sh | 4 ++-- gdb/i386-linux-tdep.c | 5 +++-- gdb/i386-tdep.c | 2 +- gdb/i386-tdep.h | 2 +- gdb/infrun.h | 4 +++- gdb/rs6000-tdep.c | 2 +- gdb/s390-tdep.c | 2 +- 15 files changed, 46 insertions(+), 18 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fd9b6a85ea1..dafd90ec373 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,26 @@ +2020-02-14 Simon Marchi + + * aarch64-tdep.c (aarch64_displaced_step_copy_insn): Use + displaced_step_closure_up. + * aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise. + (struct displaced_step_closure_up): + * amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise. + * amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise. + * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): + Likewise. + * gdbarch.sh (displaced_step_copy_insn): Likewise. + * gdbarch.c, gdbarch.h: Re-generate. + * i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Use + displaced_step_closure_up. + * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. + * i386-tdep.h (i386_displaced_step_copy_insn): Likewise. + * infrun.h (displaced_step_closure_up): New type alias. + (struct displaced_step_inferior_state) : Change + type to displaced_step_closure_up. + * rs6000-tdep.c (ppc_displaced_step_copy_insn): Use + displaced_step_closure_up. + * s390-tdep.c (s390_displaced_step_copy_insn): Likewise. + 2020-02-14 Tom Tromey * minidebug.c (gnu_debug_key): New global. diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 1bf6bfdf92c..bfacfb05b21 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2999,7 +2999,7 @@ static const struct aarch64_insn_visitor visitor = /* Implement the "displaced_step_copy_insn" gdbarch method. */ -std::unique_ptr +displaced_step_closure_up aarch64_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index fc397967cd8..f6ebabeaeb9 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -23,6 +23,7 @@ #define AARCH64_TDEP_H #include "arch/aarch64.h" +#include "infrun.h" /* Forward declarations. */ struct gdbarch; @@ -106,7 +107,7 @@ const target_desc *aarch64_read_description (uint64_t vq, bool pauth_p); extern int aarch64_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr); -struct std::unique_ptr +displaced_step_closure_up aarch64_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 35ddfbaa32d..9264fe4026d 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -1465,7 +1465,7 @@ fixup_displaced_copy (struct gdbarch *gdbarch, } } -std::unique_ptr +displaced_step_closure_up amd64_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h index 33ef0c3cea7..44c1250cb91 100644 --- a/gdb/amd64-tdep.h +++ b/gdb/amd64-tdep.h @@ -26,6 +26,7 @@ struct frame_info; struct regcache; #include "i386-tdep.h" +#include "infrun.h" /* Register numbers of various important registers. */ @@ -87,7 +88,7 @@ enum amd64_regnum #define AMD64_NUM_REGS (AMD64_GSBASE_REGNUM + 1) -extern std::unique_ptr amd64_displaced_step_copy_insn +extern displaced_step_closure_up amd64_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); extern void amd64_displaced_step_fixup (struct gdbarch *gdbarch, diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index b3ae04fb431..ccb556babb0 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -1103,7 +1103,7 @@ arm_catch_kernel_helper_return (struct gdbarch *gdbarch, CORE_ADDR from, the program has stepped into a Linux kernel helper routine (which must be handled as a special case). */ -static std::unique_ptr +static displaced_step_closure_up arm_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 4e59b375f78..e7d4ccca9e7 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -3936,7 +3936,7 @@ gdbarch_displaced_step_copy_insn_p (struct gdbarch *gdbarch) return gdbarch->displaced_step_copy_insn != NULL; } -std::unique_ptr +displaced_step_closure_up gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) { gdb_assert (gdbarch != NULL); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 8a3a07181c5..0259fcdbfd2 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -39,6 +39,7 @@ #include "frame.h" #include "dis-asm.h" #include "gdb_obstack.h" +#include "infrun.h" struct floatformat; struct ui_file; @@ -55,7 +56,6 @@ struct obstack; struct bp_target_info; struct target_desc; struct symbol; -struct displaced_step_closure; struct syscall; struct agent_expr; struct axs_value; @@ -1036,8 +1036,8 @@ extern void set_gdbarch_max_insn_length (struct gdbarch *gdbarch, ULONGEST max_i extern int gdbarch_displaced_step_copy_insn_p (struct gdbarch *gdbarch); -typedef std::unique_ptr (gdbarch_displaced_step_copy_insn_ftype) (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); -extern std::unique_ptr gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); +typedef displaced_step_closure_up (gdbarch_displaced_step_copy_insn_ftype) (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); +extern displaced_step_closure_up gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); extern void set_gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, gdbarch_displaced_step_copy_insn_ftype *displaced_step_copy_insn); /* Return true if GDB should use hardware single-stepping to execute diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index d4170c98223..4a4b1bc66cf 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -816,7 +816,7 @@ V;ULONGEST;max_insn_length;;;0;0 # If the instruction cannot execute out of line, return NULL. The # core falls back to stepping past the instruction in-line instead in # that case. -M;std::unique_ptr;displaced_step_copy_insn;CORE_ADDR from, CORE_ADDR to, struct regcache *regs;from, to, regs +M;displaced_step_closure_up;displaced_step_copy_insn;CORE_ADDR from, CORE_ADDR to, struct regcache *regs;from, to, regs # Return true if GDB should use hardware single-stepping to execute # the displaced instruction identified by CLOSURE. If false, @@ -1312,6 +1312,7 @@ cat < +static displaced_step_closure_up i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) { - std::unique_ptr closure_ + displaced_step_closure_up closure_ = i386_displaced_step_copy_insn (gdbarch, from, to, regs); if (i386_linux_get_syscall_number_from_regcache (regs) != -1) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 4b6f3d0ecdc..9771421c86b 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -798,7 +798,7 @@ i386_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr) /* Some kernels may run one past a syscall insn, so we have to cope. */ -std::unique_ptr +displaced_step_closure_up i386_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index 41faf515868..fa29e316a19 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -428,7 +428,7 @@ extern void typedef buf_displaced_step_closure i386_displaced_step_closure; -extern std::unique_ptr i386_displaced_step_copy_insn +extern displaced_step_closure_up i386_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); extern void i386_displaced_step_fixup (struct gdbarch *gdbarch, diff --git a/gdb/infrun.h b/gdb/infrun.h index c6329c844d9..625c53a94a0 100644 --- a/gdb/infrun.h +++ b/gdb/infrun.h @@ -265,6 +265,8 @@ struct displaced_step_closure virtual ~displaced_step_closure () = 0; }; +using displaced_step_closure_up = std::unique_ptr; + /* A simple displaced step closure that contains only a byte buffer. */ struct buf_displaced_step_closure : displaced_step_closure @@ -310,7 +312,7 @@ struct displaced_step_inferior_state /* The closure provided gdbarch_displaced_step_copy_insn, to be used for post-step cleanup. */ - std::unique_ptr step_closure; + displaced_step_closure_up step_closure; /* The address of the original instruction, and the copy we made. */ diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 010bbc9e01a..513ce6a34fc 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -855,7 +855,7 @@ typedef buf_displaced_step_closure ppc_displaced_step_closure; /* We can't displaced step atomic sequences. */ -static std::unique_ptr +static displaced_step_closure_up ppc_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 313d459cb3a..51d0203231f 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -425,7 +425,7 @@ typedef buf_displaced_step_closure s390_displaced_step_closure; /* Implementation of gdbarch_displaced_step_copy_insn. */ -static std::unique_ptr +static displaced_step_closure_up s390_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) -- 2.30.2