public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/7] Disable Z0 packet on aarch64 on multi-arch debugging
Date: Fri, 31 Jul 2015 15:17:00 -0000	[thread overview]
Message-ID: <1438355801-25798-6-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1438355801-25798-1-git-send-email-yao.qi@linaro.org>

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-07-28  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/linux-aarch64-low.c | 16 ++++++++++++++++
 gdb/gdbserver/server.c            |  2 +-
 gdb/gdbserver/server.h            |  1 +
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 3512ce9..90d2b43 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -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:
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 2918770..f15b7be 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -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;
 
diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h
index 09a5624..9080151 100644
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -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
-- 
1.9.1

  parent reply	other threads:[~2015-07-31 15:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 15:17 [PATCH 0/7] Aarch64 linux GDB remote " Yao Qi
2015-07-31 15:16 ` [PATCH 1/7] Move have_ptrace_getregset to linux-low.c Yao Qi
2015-07-31 15:17 ` [PATCH 6/7] Disable tracepoint support for aarch32 Yao Qi
2015-07-31 15:17 ` [PATCH 7/7] Mention multi-arch debugging support in NEWS Yao Qi
2015-08-19  8:26   ` Yao Qi
2015-09-04 14:30   ` Yao Qi
2015-07-31 15:17 ` Yao Qi [this message]
2015-07-31 15:17 ` [PATCH 2/7] New regs_info for aarch32 Yao Qi
2015-08-03 13:58   ` Pedro Alves
2015-08-03 16:34     ` Yao Qi
2015-08-03 17:11       ` Pedro Alves
2015-08-04  9:52         ` Yao Qi
2015-08-04 10:11           ` Pedro Alves
2015-08-11 19:40           ` Joel Brobecker
2015-08-18 15:21             ` Yao Qi
2015-08-18 22:42               ` Joel Brobecker
2015-07-31 15:17 ` [PATCH 3/7] Use arm target description and regs_info for 32-bit file on aarch64 GDBserver Yao Qi
2015-08-04 13:44   ` Yao Qi
2015-07-31 15:17 ` [PATCH 4/7] Get and set PC correctly on aarch64 in multi-arch Yao Qi
2015-08-03 14:00 ` [PATCH 0/7] Aarch64 linux GDB remote multi-arch debugging Pedro Alves
2015-08-04 13:41   ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438355801-25798-6-git-send-email-yao.qi@linaro.org \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).