gdbarch: Remove displaced_step_free_closure
authorSimon Marchi <simon.marchi@polymtl.ca>
Fri, 9 Jun 2017 22:24:05 +0000 (00:24 +0200)
committerSimon Marchi <simon.marchi@ericsson.com>
Fri, 9 Jun 2017 22:24:50 +0000 (00:24 +0200)
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.

14 files changed:
gdb/ChangeLog
gdb/aarch64-linux-tdep.c
gdb/amd64-linux-tdep.c
gdb/arch-utils.c
gdb/arch-utils.h
gdb/arm-linux-tdep.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/i386-linux-tdep.c
gdb/infrun.c
gdb/rs6000-aix-tdep.c
gdb/rs6000-tdep.c
gdb/s390-linux-tdep.c

index 5ebc7f805f65ae16a31c04366da064ac193f9cbb..c48fb92e9e002388448aa6fa8942a3a0abfb966c 100644 (file)
@@ -1,3 +1,20 @@
+2017-06-10  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * 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  <sergiodj@redhat.com>
 
        * common/common-utils.c (stringify_argv): Check for "arg[0] !=
index b94ccb2c6dcda7342206c3bfa3658270d07c1a2c..d2ca70a99b1d8ca88729d55c1bb30c0047bc53b0 100644 (file)
@@ -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);
index 0e2f285d2fdd21a6467f3325085ea19108d3c42c..4ef0f783ab5c5ab149bd3b2ee38ee90db6717f8a 100644 (file)
@@ -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);
 
index c011b0f55c4777df1bf81958c22926921c1c57ce..2ae34130874bff3ef3a568d262dd20ea75c2dac8 100644 (file)
@@ -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)
index 040afcaabd3234a76a6e34f9ce18c5e1e7045c4c..2aa9159fdcaf6ac0d6a061985a998450a75e946a 100644 (file)
@@ -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 *,
index 094ed72757d66f639afb4a820c03bce6b088d08b..95c52608adbb1ff92a9ddb203835d5a1102339bd 100644 (file)
@@ -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.  */
index 257c39fd1e720216b323f84e1e035dfc9ce3737e..e5efdfbb265f83cf3766e1c6e289c4134aa3840d 100644 (file)
@@ -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)
 {
index 15a81418b0aee7fd856b6f90839867bf7f4ef5a2..ab7561f8516ff4fd94ebab325a05bfcec21c2ab5 100644 (file)
@@ -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
index 7992cbe355c84b03169da8dd0b082e43dd02febd..22f5715037bd2860168a02e439a6f6f1c23438aa 100755 (executable)
@@ -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
index 1909d6122b4d7b01ce99d716ca3d3d4a4f187d6e..d381e41c14ad8ba54771086b5f84fd4906ec0db7 100644 (file)
@@ -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);
 
index d0504decb405fcdaaeb1da6c15fe3015b2c795e8..5e4cd51facf328720d3adb2882c590c025d4e01b 100644 (file)
@@ -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
index 6cbfdbe9909d4eb00e22d8417650b9537758b5d6..e9b3f10686bf178c26c6bda6ba6e7d0385923808 100644 (file)
@@ -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);
index 57faa673b89aab7071128113d1105084fe3d7cc2..97a975ec23c2a839996d64a110d9d429c1f1a04c 100644 (file)
@@ -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);
 
index 6d682608d41e408e2bac59f997691f3b281eb330..8840c2f633eaaef112b76a3452739a935560729b 100644 (file)
@@ -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);