]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Disable Z0 packet on aarch64 on multi-arch debugging
authorYao Qi <yao.qi@linaro.org>
Tue, 4 Aug 2015 13:34:14 +0000 (14:34 +0100)
committerYao Qi <yao.qi@linaro.org>
Tue, 4 Aug 2015 13:34:14 +0000 (14:34 +0100)
In multi-arch debugging, if GDB sends Z0 packet, GDBserver should be
able to do several things below:

 - choose the right breakpoint instruction to insert according to the
   information available, such as 'kind' in Z0 packet and address,

 - choose the right breakpoint instruction to check memory writes and
   validate inserted memory breakpoint

 - be aware of different breakpoint instructions in $ARCH_breakpoint_at.

unfortunately GDBserver can't do them now.  Although x86 GDBserver
supports multi-arch, it doesn't need to support them above because
breakpoint instruction on i686 and x86_64 is the same.  However,
breakpoint instructions on aarch64 and arm (arm mode, thumb1, and thumb2)
are different.

I tried to teach aarch64 GDBserver backend to be really
multi-arch-capable in the following ways,

 - linux_low_target return the right breakpoint instruction according to
   the 'kind' in Z0 packet, and insert_memory_breakpoint can do the right
   thing.
 - once breakpoint is inserted, the breakpoint data and length is recorded
   in each breakpoint object, so that validate_breakpoint and
   check_mem_write can get the right breakpoint instruction from each
   breakpoint object, rather than from global variable breakpoint_data.
 - linux_low_target needs another hook function for pc increment after
   hitting a breakpoint.
 - let set_breakpoint_at, which is widely used for tracepoint, use the
   'default' breakpoint instruction.  We can always use aarch64 breakpoint
   instruction since arm doesn't support tracepoint yet.

looks it is not a small piece of work, so I decide to disable Z0 packet
on multi-arch, which means aarch64 GDBserver only supports Z0 packet
if it is started to debug only one process (extended protocol is not
used) and process target description is 64-bit.

gdb/gdbserver:

2015-08-04  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_supports_z_point_type): Return
0 for Z_PACKET_SW_BP if it may be used in multi-arch debugging.
* server.c (extended_protocol): Remove "static".
* server.h (extended_protocol): Declare it.

gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-aarch64-low.c
gdb/gdbserver/server.c
gdb/gdbserver/server.h

index be13f9b29320756b1b6f598797913b7f7d5fa089..1227686426cc6756573cc8eeaa3c5b56e2478eaf 100644 (file)
@@ -1,3 +1,10 @@
+2015-08-04  Yao Qi  <yao.qi@linaro.org>
+
+       * linux-aarch64-low.c (aarch64_supports_z_point_type): Return
+       0 for Z_PACKET_SW_BP if it may be used in multi-arch debugging.
+       * server.c (extended_protocol): Remove "static".
+       * server.h (extended_protocol): Declare it.
+
 2015-08-04  Yao Qi  <yao.qi@linaro.org>
 
        * linux-aarch64-low.c (aarch64_get_pc): Get PC register on
index 3512ce949d73e86fb74cb8463660a4faa8e76cd8..90d2b438270363f4e1415c195391800cde822e36 100644 (file)
@@ -364,6 +364,22 @@ aarch64_supports_z_point_type (char z_type)
   switch (z_type)
     {
     case Z_PACKET_SW_BP:
+      {
+       if (!extended_protocol && is_64bit_tdesc ())
+         {
+           /* Only enable Z0 packet in non-multi-arch debugging.  If
+              extended protocol is used, don't enable Z0 packet because
+              GDBserver may attach to 32-bit process.  */
+           return 1;
+         }
+       else
+         {
+           /* Disable Z0 packet so that GDBserver doesn't have to handle
+              different breakpoint instructions (aarch64, arm, thumb etc)
+              in multi-arch debugging.  */
+           return 0;
+         }
+      }
     case Z_PACKET_HW_BP:
     case Z_PACKET_WRITE_WP:
     case Z_PACKET_READ_WP:
index 29187704c1972e021b1fceb77d01ee5b659c2ae1..f15b7bedefa53343b1d290c9083ba8d48dedfd76 100644 (file)
@@ -49,7 +49,7 @@ ptid_t general_thread;
 
 int server_waiting;
 
-static int extended_protocol;
+int extended_protocol;
 static int response_needed;
 static int exit_requested;
 
index 09a562455755ea8934539c732a88a17d4c302be6..9080151dd9d36b3e0dd34b27b4668678eb177b9e 100644 (file)
@@ -87,6 +87,7 @@ extern int multi_process;
 extern int report_fork_events;
 extern int report_vfork_events;
 extern int non_stop;
+extern int extended_protocol;
 
 /* True if the "swbreak+" feature is active.  In that case, GDB wants
    us to report whether a trap is explained by a software breakpoint