Remove isize output argument from fast_tracepoint_valid_at
authorPierre Langlois <pierre.langlois@arm.com>
Thu, 30 Jul 2015 17:05:00 +0000 (18:05 +0100)
committerPierre Langlois <pierre.langlois@arm.com>
Thu, 30 Jul 2015 17:05:00 +0000 (18:05 +0100)
This patch removes the isize output argument from the
fast_tracepoint_valid_at gdbarch hook.  It was used to return the size
of the instruction that needs to be replaced when installing a fast
tracepoint.  Instead of getting this value from the
fast_tracepoint_valid_at hook, we can call the gdb_insn_length function.

If we do not do this, then architectures which do not have a restriction
on where to install the fast tracepoint will send uninitialized memory
off to GDBserver.  See remote_download_tracepoint:

~~~
int isize;

if (gdbarch_fast_tracepoint_valid_at (target_gdbarch (),
      tpaddr, &isize, NULL))
  xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x",
     isize);
~~~

The default implementation of fast_tracepoint_valid_at will not set
isize resulting in uninitialized memory being sent.  Later on, GDBserver
could use this information to compute a jump offset.

gdb/ChangeLog:

* arch-utils.c (default_fast_tracepoint_valid_at): Remove unused
isize argument.
* arch-utils.h (default_fast_tracepoint_valid_at): Likewise.
* breakpoint.c (check_fast_tracepoint_sals): Adjust call to
gdbarch_fast_tracepoint_valid_at.
* gdbarch.sh (fast_tracepoint_valid_at): Remove isize argument.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.
* i386-tdep.c (i386_fast_tracepoint_valid_at): Remove isize
argument.  Do not set it.
* remote.c (remote_download_tracepoint): Adjust call to
gdbarch_fast_tracepoint_valid_at.  Call gdb_insn_length to get
the instruction length.

gdb/ChangeLog
gdb/arch-utils.c
gdb/arch-utils.h
gdb/breakpoint.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/i386-tdep.c
gdb/remote.c

index 0e0f62c31037c5e01a93cca9c5c41399ce1d2b19..4d604de556a11c709cb70d658b9d3a8763d2c269 100644 (file)
@@ -1,3 +1,19 @@
+2015-07-30  Pierre Langlois  <pierre.langlois@arm.com>
+
+       * arch-utils.c (default_fast_tracepoint_valid_at): Remove unused
+       isize argument.
+       * arch-utils.h (default_fast_tracepoint_valid_at): Likewise.
+       * breakpoint.c (check_fast_tracepoint_sals): Adjust call to
+       gdbarch_fast_tracepoint_valid_at.
+       * gdbarch.sh (fast_tracepoint_valid_at): Remove isize argument.
+       * gdbarch.h: Regenerate.
+       * gdbarch.c: Regenerate.
+       * i386-tdep.c (i386_fast_tracepoint_valid_at): Remove isize
+       argument.  Do not set it.
+       * remote.c (remote_download_tracepoint): Adjust call to
+       gdbarch_fast_tracepoint_valid_at.  Call gdb_insn_length to get
+       the instruction length.
+
 2015-07-30  Yao Qi  <yao.qi@linaro.org>
 
        * arm-tdep.h (enum gdb_regnum): Move it to ...
index e9c622dd873d1fade576ce1d1eaf8e8c51caa4f3..46a6db0896f27c91a9e2dd3a0ea01f879a5b90e9 100644 (file)
@@ -795,8 +795,8 @@ default_has_shared_address_space (struct gdbarch *gdbarch)
 }
 
 int
-default_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
-                                 CORE_ADDR addr, int *isize, char **msg)
+default_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr,
+                                 char **msg)
 {
   /* We don't know if maybe the target has some way to do fast
      tracepoints that doesn't need gdbarch, so always say yes.  */
index 27f4787e842b70d5938293711f1622ab58bdc3c4..18e22907c355d48d40b33103da0bdca7f25959f6 100644 (file)
@@ -161,8 +161,7 @@ extern struct gdbarch *get_current_arch (void);
 extern int default_has_shared_address_space (struct gdbarch *);
 
 extern int default_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
-                                            CORE_ADDR addr,
-                                            int *isize, char **msg);
+                                            CORE_ADDR addr, char **msg);
 
 extern void default_remote_breakpoint_from_pc (struct gdbarch *,
                                               CORE_ADDR *pcptr, int *kindptr);
index af0d16730c3f2fea7716a29c8ac3652f9a150f87..2a55a6f731c306d8d782017cf3d60f67084bcbd7 100644 (file)
@@ -9406,8 +9406,7 @@ check_fast_tracepoint_sals (struct gdbarch *gdbarch,
         associated with SAL.  */
       if (sarch == NULL)
        sarch = gdbarch;
-      rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal->pc,
-                                              NULL, &msg);
+      rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal->pc, &msg);
       old_chain = make_cleanup (xfree, msg);
 
       if (!rslt)
index c2893341d4b2d28bfec1d55edd3ec2c2a7b97ccc..07b38a3b633d631423345a95bca24b39f6e7b6ca 100644 (file)
@@ -4394,13 +4394,13 @@ set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch,
 }
 
 int
-gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg)
+gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, char **msg)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->fast_tracepoint_valid_at != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_fast_tracepoint_valid_at called\n");
-  return gdbarch->fast_tracepoint_valid_at (gdbarch, addr, isize, msg);
+  return gdbarch->fast_tracepoint_valid_at (gdbarch, addr, msg);
 }
 
 void
index 7d6a0cfa79f24e1e7fddebcc0f427a65145a13fc..d714281b8372f78ff505dc36af935afd439ea662 100644 (file)
@@ -1310,8 +1310,8 @@ extern void set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch, gdbar
 
 /* True if a fast tracepoint can be set at an address. */
 
-typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg);
-extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg);
+typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, char **msg);
+extern int gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, char **msg);
 extern void set_gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at);
 
 /* Return the "auto" target charset. */
index 6c5d684b4d35600a410f32bf7f022505ffa45850..14a5f9c5ebed835d5219c1dcaadea32ff86693b9 100755 (executable)
@@ -1018,7 +1018,7 @@ v:int:has_global_breakpoints:::0:0::0
 m:int:has_shared_address_space:void:::default_has_shared_address_space::0
 
 # True if a fast tracepoint can be set at an address.
-m:int:fast_tracepoint_valid_at:CORE_ADDR addr, int *isize, char **msg:addr, isize, msg::default_fast_tracepoint_valid_at::0
+m:int:fast_tracepoint_valid_at:CORE_ADDR addr, char **msg:addr, msg::default_fast_tracepoint_valid_at::0
 
 # Return the "auto" target charset.
 f:const char *:auto_charset:void::default_auto_charset:default_auto_charset::0
index 371a2828df37cfea7a8e743bf37bc8c051c9cc9c..9d52d4ad5e175b3dd67fabf2638ae0a43d546023 100644 (file)
@@ -8045,8 +8045,8 @@ static const int i386_record_regmap[] =
    string.  */
 
 static int
-i386_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
-                              CORE_ADDR addr, int *isize, char **msg)
+i386_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr,
+                              char **msg)
 {
   int len, jumplen;
   static struct ui_file *gdb_null = NULL;
@@ -8078,8 +8078,6 @@ i386_fast_tracepoint_valid_at (struct gdbarch *gdbarch,
 
   /* Check for fit.  */
   len = gdb_print_insn (gdbarch, addr, gdb_null, NULL);
-  if (isize)
-    *isize = len;
 
   if (len < jumplen)
     {
index 69da5084add6c58bb592e8fb67125a8ba6e838a8..4ac393b28f86c848c2e6c35af45a208472669681 100644 (file)
@@ -44,6 +44,7 @@
 #include "gdb_bfd.h"
 #include "filestuff.h"
 #include "rsp-low.h"
+#include "disasm.h"
 
 #include <sys/time.h>
 
@@ -11106,12 +11107,10 @@ remote_download_tracepoint (struct target_ops *self, struct bp_location *loc)
         target capabilities at definition time.  */
       if (remote_supports_fast_tracepoints ())
        {
-         int isize;
-
-         if (gdbarch_fast_tracepoint_valid_at (target_gdbarch (),
-                                               tpaddr, &isize, NULL))
+         if (gdbarch_fast_tracepoint_valid_at (loc->gdbarch, tpaddr,
+                                               NULL))
            xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":F%x",
-                      isize);
+                      gdb_insn_length (loc->gdbarch, tpaddr));
          else
            /* If it passed validation at definition but fails now,
               something is very wrong.  */