From: Simon Marchi Date: Fri, 9 Jun 2017 22:24:05 +0000 (+0200) Subject: gdbarch: Remove displaced_step_free_closure X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d45d4b42b5b360c0b80259e101c01d650d0be23;p=binutils-gdb.git gdbarch: Remove displaced_step_free_closure The displaced_step_free_closure gdbarch hook allows architectures to free data they might have allocated to complete a displaced step. However, all architectures using that hook use the simple_displaced_step_free_closure provided in arch-utils.{c,h}, which does a simple xfree. We can remove it and do an xfree directly instead of calling the hook. gdb/ChangeLog: * gdbarch.sh (displaced_step_free_closure): Remove. * gdbarch.h, gdbarch.c: Re-generate. * aarch64-linux-tdep.c (aarch64_linux_init_abi): Don't set displaced_step_free_closure. * amd64-linux-tdep.c (amd64_linux_init_abi_common): Likewise. * arm-linux-tdep.c (arm_linux_init_abi): Likewise. * i386-linux-tdep.c (i386_linux_init_abi): Likewise. * rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise. * rs6000-tdep.c (rs6000_gdbarch_init): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * arch-utils.h (simple_displaced_step_free_closure): Remove. * arch-utils.c (simple_displaced_step_free_closure): Remove. * infrun.c (displaced_step_clear): Call xfree instead of gdbarch_displaced_step_free_closure. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5ebc7f805f6..c48fb92e9e0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2017-06-10 Simon Marchi + + * gdbarch.sh (displaced_step_free_closure): Remove. + * gdbarch.h, gdbarch.c: Re-generate. + * aarch64-linux-tdep.c (aarch64_linux_init_abi): Don't set + displaced_step_free_closure. + * amd64-linux-tdep.c (amd64_linux_init_abi_common): Likewise. + * arm-linux-tdep.c (arm_linux_init_abi): Likewise. + * i386-linux-tdep.c (i386_linux_init_abi): Likewise. + * rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise. + * rs6000-tdep.c (rs6000_gdbarch_init): Likewise. + * s390-linux-tdep.c (s390_gdbarch_init): Likewise. + * arch-utils.h (simple_displaced_step_free_closure): Remove. + * arch-utils.c (simple_displaced_step_free_closure): Remove. + * infrun.c (displaced_step_clear): Call xfree instead of + gdbarch_displaced_step_free_closure. + 2017-06-08 Sergio Durigan Junior * common/common-utils.c (stringify_argv): Check for "arg[0] != diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index b94ccb2c6dc..d2ca70a99b1 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -1204,8 +1204,6 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_displaced_step_copy_insn (gdbarch, aarch64_displaced_step_copy_insn); set_gdbarch_displaced_step_fixup (gdbarch, aarch64_displaced_step_fixup); - set_gdbarch_displaced_step_free_closure (gdbarch, - simple_displaced_step_free_closure); set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location); set_gdbarch_displaced_step_hw_singlestep (gdbarch, aarch64_displaced_step_hw_singlestep); diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 0e2f285d2fd..4ef0f783ab5 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1848,8 +1848,6 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_displaced_step_copy_insn (gdbarch, amd64_displaced_step_copy_insn); set_gdbarch_displaced_step_fixup (gdbarch, amd64_displaced_step_fixup); - set_gdbarch_displaced_step_free_closure (gdbarch, - simple_displaced_step_free_closure); set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location); diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index c011b0f55c4..2ae34130874 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -60,14 +60,6 @@ simple_displaced_step_copy_insn (struct gdbarch *gdbarch, return (struct displaced_step_closure *) buf; } - -void -simple_displaced_step_free_closure (struct gdbarch *gdbarch, - struct displaced_step_closure *closure) -{ - xfree (closure); -} - int default_displaced_step_hw_singlestep (struct gdbarch *gdbarch, struct displaced_step_closure *closure) diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 040afcaabd3..2aa9159fdca 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -85,13 +85,6 @@ extern struct displaced_step_closure * CORE_ADDR from, CORE_ADDR to, struct regcache *regs); -/* Simple implementation of gdbarch_displaced_step_free_closure: Call - xfree. - This is appropriate for use with simple_displaced_step_copy_insn. */ -extern void - simple_displaced_step_free_closure (struct gdbarch *gdbarch, - struct displaced_step_closure *closure); - /* Default implementation of gdbarch_displaced_hw_singlestep. */ extern int default_displaced_step_hw_singlestep (struct gdbarch *, diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 094ed72757d..95c52608adb 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -1812,8 +1812,6 @@ arm_linux_init_abi (struct gdbarch_info info, set_gdbarch_displaced_step_copy_insn (gdbarch, arm_linux_displaced_step_copy_insn); set_gdbarch_displaced_step_fixup (gdbarch, arm_displaced_step_fixup); - set_gdbarch_displaced_step_free_closure (gdbarch, - simple_displaced_step_free_closure); set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location); /* Reversible debugging, process record. */ diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 257c39fd1e7..e5efdfbb265 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -295,7 +295,6 @@ struct gdbarch gdbarch_displaced_step_copy_insn_ftype *displaced_step_copy_insn; gdbarch_displaced_step_hw_singlestep_ftype *displaced_step_hw_singlestep; gdbarch_displaced_step_fixup_ftype *displaced_step_fixup; - gdbarch_displaced_step_free_closure_ftype *displaced_step_free_closure; gdbarch_displaced_step_location_ftype *displaced_step_location; gdbarch_relocate_instruction_ftype *relocate_instruction; gdbarch_overlay_update_ftype *overlay_update; @@ -443,7 +442,6 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->skip_permanent_breakpoint = default_skip_permanent_breakpoint; gdbarch->displaced_step_hw_singlestep = default_displaced_step_hw_singlestep; gdbarch->displaced_step_fixup = NULL; - gdbarch->displaced_step_free_closure = NULL; gdbarch->displaced_step_location = NULL; gdbarch->relocate_instruction = NULL; gdbarch->has_shared_address_space = default_has_shared_address_space; @@ -656,8 +654,6 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of displaced_step_copy_insn, has predicate. */ /* Skip verify of displaced_step_hw_singlestep, invalid_p == 0 */ /* Skip verify of displaced_step_fixup, has predicate. */ - if ((! gdbarch->displaced_step_free_closure) != (! gdbarch->displaced_step_copy_insn)) - log.puts ("\n\tdisplaced_step_free_closure"); if ((! gdbarch->displaced_step_location) != (! gdbarch->displaced_step_copy_insn)) log.puts ("\n\tdisplaced_step_location"); /* Skip verify of relocate_instruction, has predicate. */ @@ -911,9 +907,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: displaced_step_fixup = <%s>\n", host_address_to_string (gdbarch->displaced_step_fixup)); - fprintf_unfiltered (file, - "gdbarch_dump: displaced_step_free_closure = <%s>\n", - host_address_to_string (gdbarch->displaced_step_free_closure)); fprintf_unfiltered (file, "gdbarch_dump: displaced_step_hw_singlestep = <%s>\n", host_address_to_string (gdbarch->displaced_step_hw_singlestep)); @@ -3970,23 +3963,6 @@ set_gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, gdbarch->displaced_step_fixup = displaced_step_fixup; } -void -gdbarch_displaced_step_free_closure (struct gdbarch *gdbarch, struct displaced_step_closure *closure) -{ - gdb_assert (gdbarch != NULL); - gdb_assert (gdbarch->displaced_step_free_closure != NULL); - if (gdbarch_debug >= 2) - fprintf_unfiltered (gdb_stdlog, "gdbarch_displaced_step_free_closure called\n"); - gdbarch->displaced_step_free_closure (gdbarch, closure); -} - -void -set_gdbarch_displaced_step_free_closure (struct gdbarch *gdbarch, - gdbarch_displaced_step_free_closure_ftype displaced_step_free_closure) -{ - gdbarch->displaced_step_free_closure = displaced_step_free_closure; -} - CORE_ADDR gdbarch_displaced_step_location (struct gdbarch *gdbarch) { diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 15a81418b0a..ab7561f8516 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -1039,21 +1039,6 @@ typedef void (gdbarch_displaced_step_fixup_ftype) (struct gdbarch *gdbarch, stru extern void gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, struct displaced_step_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); extern void set_gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, gdbarch_displaced_step_fixup_ftype *displaced_step_fixup); -/* Free a closure returned by gdbarch_displaced_step_copy_insn. - - If you provide gdbarch_displaced_step_copy_insn, you must provide - this function as well. - - If your architecture uses closures that don't need to be freed, then - you can use simple_displaced_step_free_closure here. - - For a general explanation of displaced stepping and how GDB uses it, - see the comments in infrun.c. */ - -typedef void (gdbarch_displaced_step_free_closure_ftype) (struct gdbarch *gdbarch, struct displaced_step_closure *closure); -extern void gdbarch_displaced_step_free_closure (struct gdbarch *gdbarch, struct displaced_step_closure *closure); -extern void set_gdbarch_displaced_step_free_closure (struct gdbarch *gdbarch, gdbarch_displaced_step_free_closure_ftype *displaced_step_free_closure); - /* Return the address of an appropriate place to put displaced instructions while we step over them. There need only be one such place, since we're only stepping one thread over a breakpoint at a diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 7992cbe355c..22f5715037b 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -833,18 +833,6 @@ m;int;displaced_step_hw_singlestep;struct displaced_step_closure *closure;closur # see the comments in infrun.c. M;void;displaced_step_fixup;struct displaced_step_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs;closure, from, to, regs;;NULL -# Free a closure returned by gdbarch_displaced_step_copy_insn. -# -# If you provide gdbarch_displaced_step_copy_insn, you must provide -# this function as well. -# -# If your architecture uses closures that don't need to be freed, then -# you can use simple_displaced_step_free_closure here. -# -# For a general explanation of displaced stepping and how GDB uses it, -# see the comments in infrun.c. -m;void;displaced_step_free_closure;struct displaced_step_closure *closure;closure;;NULL;;(! gdbarch->displaced_step_free_closure) != (! gdbarch->displaced_step_copy_insn) - # Return the address of an appropriate place to put displaced # instructions while we step over them. There need only be one such # place, since we're only stepping one thread over a breakpoint at a diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 1909d6122b4..d381e41c14a 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -1059,8 +1059,6 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_displaced_step_copy_insn (gdbarch, i386_linux_displaced_step_copy_insn); set_gdbarch_displaced_step_fixup (gdbarch, i386_displaced_step_fixup); - set_gdbarch_displaced_step_free_closure (gdbarch, - simple_displaced_step_free_closure); set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location); diff --git a/gdb/infrun.c b/gdb/infrun.c index d0504decb40..5e4cd51facf 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1710,12 +1710,8 @@ displaced_step_clear (struct displaced_step_inferior_state *displaced) /* Indicate that there is no cleanup pending. */ displaced->step_ptid = null_ptid; - if (displaced->step_closure) - { - gdbarch_displaced_step_free_closure (displaced->step_gdbarch, - displaced->step_closure); - displaced->step_closure = NULL; - } + xfree (displaced->step_closure); + displaced->step_closure = NULL; } static void diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 6cbfdbe9909..e9b3f10686b 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -1048,7 +1048,6 @@ rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) software single-stepping. */ set_gdbarch_displaced_step_copy_insn (gdbarch, NULL); set_gdbarch_displaced_step_fixup (gdbarch, NULL); - set_gdbarch_displaced_step_free_closure (gdbarch, NULL); set_gdbarch_displaced_step_location (gdbarch, NULL); set_gdbarch_push_dummy_call (gdbarch, rs6000_push_dummy_call); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 57faa673b89..97a975ec23c 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -6522,8 +6522,6 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_displaced_step_hw_singlestep (gdbarch, ppc_displaced_step_hw_singlestep); set_gdbarch_displaced_step_fixup (gdbarch, ppc_displaced_step_fixup); - set_gdbarch_displaced_step_free_closure (gdbarch, - simple_displaced_step_free_closure); set_gdbarch_displaced_step_location (gdbarch, displaced_step_at_entry_point); diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 6d682608d41..8840c2f633e 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -8005,8 +8005,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_displaced_step_copy_insn (gdbarch, s390_displaced_step_copy_insn); set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup); - set_gdbarch_displaced_step_free_closure (gdbarch, - simple_displaced_step_free_closure); set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location); set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);