[ARM] Make thumb2_breakpoint static again
authorYao Qi <yao.qi@linaro.org>
Thu, 14 Jan 2016 09:36:43 +0000 (09:36 +0000)
committerYao Qi <yao.qi@linaro.org>
Thu, 14 Jan 2016 09:36:43 +0000 (09:36 +0000)
This patch makes thumb2_breakpoint static.  When writing this patch,
I find the only reason we keep thumb2_breakpoint extern is that it
is used as an argument passed to arm_gdbserver_get_next_pcs.  However,
field arm_thumb2_breakpoint is only used in a null check in
thumb_get_next_pcs_raw, so I wonder why do need to pass thumb2_breakpoint
to arm_gdbserver_get_next_pcs.

thumb2_breakpoint was added by Daniel Jacobowitz in order to support
single-step IT block
https://sourceware.org/ml/gdb-patches/2010-01/msg00624.html  the logic
there was if we have 32-bit thumb-2 breakpoint defined, we can safely
single-step IT block, otherwise, we can't.  Daniel didn't want to use
16-bit thumb BKPT instruction, because it triggers even on instruction
which should be executed.  Secondly, using 16-bit thumb illegal
instruction on top of 32-bit thumb instruction may break the meaning of
original IT blocks, because the other 16-bit can be regarded as an
instruction.  See more explanations from Daniel's kernel patch
http://www.spinics.net/lists/arm-kernel/msg80476.html

Let us back to this patch, GDB/GDBserver can safely single step
IT block if thumb2_breakpoint is defined, but the single step logic
doesn't have to know the thumb-2 breakpoint instruction.  Only
breakpoint insertion mechanism decides to use which breakpoint
instruction.  In the software single step code, instead of pass
thumb2_breakpoint, we can pass a boolean variable
has_thumb2_breakpoint indicate whether the target has thumb-2
breakpoint defined, which is equivalent to the original code.

Regression tested on arm-linux.  No regression.

gdb:

2016-01-14  Yao Qi  <yao.qi@linaro.org>

* arch/arm-get-next-pcs.c (arm_get_next_pcs_ctor): Change
argument arm_thumb2_breakpoint to has_thumb2_breakpoint.
(thumb_get_next_pcs_raw): Check has_thumb2_breakpoint
instead.
* arch/arm-get-next-pcs.h (struct arm_get_next_pcs)
<arm_thumb2_breakpoint>: Remove.
<has_thumb2_breakpoint>: New field.
(arm_get_next_pcs_ctor): Update declaration.
* arm-linux-tdep.c (arm_linux_software_single_step): Pass
1 to arm_get_next_pcs_ctor.
* arm-tdep.c (arm_software_single_step): Pass 0 to
arm_get_next_pcs_ctor.

gdb/gdbserver:

2016-01-14  Yao Qi  <yao.qi@linaro.org>

* linux-aarch32-low.c (thumb2_breakpoint): Make it static.
* linux-aarch32-low.h (thumb2_breakpoint): Remove declaration.
* linux-arm-low.c (arm_gdbserver_get_next_pcs): Pass 1 to
arm_get_next_pcs_ctor.

gdb/ChangeLog
gdb/arch/arm-get-next-pcs.c
gdb/arch/arm-get-next-pcs.h
gdb/arm-linux-tdep.c
gdb/arm-tdep.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-aarch32-low.c
gdb/gdbserver/linux-aarch32-low.h
gdb/gdbserver/linux-arm-low.c

index 8d35f5f1cd96b08eae086cd725049f56bdc72a16..048ac3ed13ae900c8235b07896c85da7a6aaebff 100644 (file)
@@ -1,3 +1,18 @@
+2016-01-14  Yao Qi  <yao.qi@linaro.org>
+
+       * arch/arm-get-next-pcs.c (arm_get_next_pcs_ctor): Change
+       argument arm_thumb2_breakpoint to has_thumb2_breakpoint.
+       (thumb_get_next_pcs_raw): Check has_thumb2_breakpoint
+       instead.
+       * arch/arm-get-next-pcs.h (struct arm_get_next_pcs)
+       <arm_thumb2_breakpoint>: Remove.
+       <has_thumb2_breakpoint>: New field.
+       (arm_get_next_pcs_ctor): Update declaration.
+       * arm-linux-tdep.c (arm_linux_software_single_step): Pass
+       1 to arm_get_next_pcs_ctor.
+       * arm-tdep.c (arm_software_single_step): Pass 0 to
+       arm_get_next_pcs_ctor.
+
 2016-01-13  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * MAINTAINERS: Add Andreas Arnez as s390 target maintainer.
index 137df1d30ec0f6f078bef7715a1d16f59f5f6cd3..6b8f38a0d511a41d8e6a81779efb1051784139fe 100644 (file)
@@ -30,13 +30,13 @@ arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
                       struct arm_get_next_pcs_ops *ops,
                       int byte_order,
                       int byte_order_for_code,
-                      const gdb_byte *arm_thumb2_breakpoint,
+                      int has_thumb2_breakpoint,
                       struct regcache *regcache)
 {
   self->ops = ops;
   self->byte_order = byte_order;
   self->byte_order_for_code = byte_order_for_code;
-  self->arm_thumb2_breakpoint = arm_thumb2_breakpoint;
+  self->has_thumb2_breakpoint = has_thumb2_breakpoint;
   self->regcache = regcache;
 }
 
@@ -297,7 +297,7 @@ thumb_get_next_pcs_raw (struct arm_get_next_pcs *self, CORE_ADDR pc)
      flags, affecting the execution of further instructions, we may
      need to set two breakpoints.  */
 
-  if (self->arm_thumb2_breakpoint != NULL)
+  if (self->has_thumb2_breakpoint)
     {
       if ((inst1 & 0xff00) == 0xbf00 && (inst1 & 0x000f) != 0)
        {
index 895e866644c3e3be562e30afc97a29ccfc915c40..4a0fc16814f6a59474a4e44e33797d0759ad8e33 100644 (file)
@@ -41,8 +41,9 @@ struct arm_get_next_pcs
   int byte_order;
   /* Byte order for code.  */
   int byte_order_for_code;
-  /* Thumb2 breakpoint instruction.  */
-  const gdb_byte *arm_thumb2_breakpoint;
+  /* Whether the target has 32-bit thumb-2 breakpoint defined or
+     not.  */
+  int has_thumb2_breakpoint;
   /* Registry cache.  */
   struct regcache *regcache;
 };
@@ -52,7 +53,7 @@ void arm_get_next_pcs_ctor (struct arm_get_next_pcs *self,
                            struct arm_get_next_pcs_ops *ops,
                            int byte_order,
                            int byte_order_for_code,
-                           const gdb_byte *arm_thumb2_breakpoint,
+                           int has_thumb2_breakpoint,
                            struct regcache *regcache);
 
 /* Find the next possible PCs after the current instruction executes.  */
index 2870bd15b3436893364eea78b2996877a357866d..6050bdf9531de502f776f7374fd6e651244351c4 100644 (file)
@@ -931,7 +931,7 @@ arm_linux_software_single_step (struct frame_info *frame)
                         &arm_linux_get_next_pcs_ops,
                         gdbarch_byte_order (gdbarch),
                         gdbarch_byte_order_for_code (gdbarch),
-                        gdbarch_tdep (gdbarch)->thumb2_breakpoint,
+                        1,
                         regcache);
 
   next_pcs = arm_get_next_pcs (&next_pcs_ctx, regcache_read_pc (regcache));
index 05d60bb447a05d8842a1081ed6965bb10c8002e6..8874ec85cbb38d52b014ee4d54b0a7da45fd82f3 100644 (file)
@@ -6183,7 +6183,7 @@ arm_software_single_step (struct frame_info *frame)
                         &arm_get_next_pcs_ops,
                         gdbarch_byte_order (gdbarch),
                         gdbarch_byte_order_for_code (gdbarch),
-                        gdbarch_tdep (gdbarch)->thumb2_breakpoint,
+                        0,
                         regcache);
 
   next_pcs = arm_get_next_pcs (&next_pcs_ctx, regcache_read_pc (regcache));
index 757424c4df78dab9a9fcd169bfc71104767f88a1..a76bb14797a647772e4bc9d97f158934e34fab1c 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-14  Yao Qi  <yao.qi@linaro.org>
+
+       * linux-aarch32-low.c (thumb2_breakpoint): Make it static.
+       * linux-aarch32-low.h (thumb2_breakpoint): Remove declaration.
+       * linux-arm-low.c (arm_gdbserver_get_next_pcs): Pass 1 to
+       arm_get_next_pcs_ctor.
+
 2016-01-12  Josh Stone  <jistone@redhat.com>
            Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
index ed66e085706f2e32572a8208433301d67699f24c..2bbbb2465795cce23d585bc6cbba13d8ce99b280 100644 (file)
@@ -45,7 +45,7 @@ static const unsigned long arm_breakpoint = arm_abi_breakpoint;
 #define arm_breakpoint_len 4
 static const unsigned short thumb_breakpoint = 0xde01;
 #define thumb_breakpoint_len 2
-const unsigned short thumb2_breakpoint[] = { 0xf7f0, 0xa000 };
+static const unsigned short thumb2_breakpoint[] = { 0xf7f0, 0xa000 };
 #define thumb2_breakpoint_len 4
 
 /* Some older versions of GNU/Linux and Android do not define
index 5c684541e84f043f9e6ae4670bab8873cd6e3603..434a523aded89ce5baf1b2504b60efb0803073f3 100644 (file)
@@ -15,8 +15,6 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-extern const unsigned short thumb2_breakpoint[];
-
 extern struct regs_info regs_info_aarch32;
 
 void arm_fill_gregset (struct regcache *regcache, void *buf);
index d967e5886b2739146791650446b95b71ec4de46b..927a6fabce564bf1ec1fb2b7440dd37e4845a605 100644 (file)
@@ -942,7 +942,7 @@ arm_gdbserver_get_next_pcs (CORE_ADDR pc, struct regcache *regcache)
                         /* Byte order is ignored assumed as host.  */
                         0,
                         0,
-                        (const gdb_byte *) &thumb2_breakpoint,
+                        1,
                         regcache);
 
   next_pcs = arm_get_next_pcs (&next_pcs_ctx, pc);
This page took 0.03376 seconds and 4 git commands to generate.