Blame SOURCES/gdb-rhbz1261564-aarch64-hw-watchpoint-2of5.patch

0b42f8
http://sourceware.org/ml/gdb-patches/2015-02/msg00733.html
0b42f8
Subject: [PATCH 4/8] remote+docs: software/hardware breakpoint traps
0b42f8
0b42f8
This adjusts target remote to tell the core whether a trap was caused
0b42f8
by a breakpoint.
0b42f8
0b42f8
To that end, the patch teaches GDB about new RSP stop reasons "T05
0b42f8
swbreak" and "T05 hwbreak", that remote targets report back to GDB,
0b42f8
similarly to how "T05 watch" indicates a stop caused by a watchpoint.
0b42f8
0b42f8
Because targets that can report these events are expected to
0b42f8
themselves adjust the PC after a software breakpoint, these new stop
0b42f8
reasons must only be reported if the stub is talking to a GDB that
0b42f8
understands them.  Because of that, the use of the new stop reasons
0b42f8
needs to be handshaked on initial connection, using the qSupported
0b42f8
mechanism.  GDB simply sends "swbreak+" in its qSupports query, and
0b42f8
the stub reports back "swbreak+" too.
0b42f8
0b42f8
Because these new stop reasons are required to fix a fundamental
0b42f8
non-stop mode problem, this commit extends the remote non-stop intro
0b42f8
section in the manual, documenting the events as required.
0b42f8
0b42f8
To be clear, GDB will still cope with remote targets that don't
0b42f8
support these new stop reasons; it will behave just like today.
0b42f8
0b42f8
Tested on x86-64 Fedora 20, native and gdbserver.
0b42f8
0b42f8
gdb/ChangeLog:
0b42f8
2015-02-25  Pedro Alves  <palves@redhat.com>
0b42f8
0b42f8
	* NEWS: Mention the new "swbreak" and "hwbreak" stop reasons.
0b42f8
	* remote.c (struct remote_state) <remote_stopped_by_watchpoint_p>:
0b42f8
	Delete field.
0b42f8
	<stop_reason>: New field.
0b42f8
	(PACKET_swbreak_feature, PACKET_hwbreak_feature): New enum values.
0b42f8
	(packet_set_cmd_state): New function.
0b42f8
	(remote_protocol_features): Register the "swbreak" and "hwbreak"
0b42f8
	features.
0b42f8
	(remote_query_supported): If not disabled with the corresponding
0b42f8
	"set remote foo-packet" command, report support for the swbreak
0b42f8
	and hwbreak features.
0b42f8
	(struct stop_reply) <remote_stopped_by_watchpoint_p>: Delete
0b42f8
	field.
0b42f8
	<stop_reason>: New field.
0b42f8
	(remote_parse_stop_reply): Handle "swbreak" and "hwbreak".
0b42f8
	(remote_wait_as): Adjust.
0b42f8
	(remote_stopped_by_sw_breakpoint)
0b42f8
	(remote_supports_stopped_by_sw_breakpoint)
0b42f8
	(remote_stopped_by_hw_breakpoint)
0b42f8
	(remote_supports_stopped_by_hw_breakpoint): New functions.
0b42f8
	(remote_stopped_by_watchpoint): New function.
0b42f8
	(init_remote_ops): Install them.
0b42f8
	(_initialize_remote): Register new "set/show remote
0b42f8
	swbreak-feature-packet" and "set/show remote
0b42f8
	swbreak-feature-packet" commands.
0b42f8
0b42f8
gdb/doc/ChangeLog:
0b42f8
2015-02-25  Pedro Alves  <palves@redhat.com>
0b42f8
0b42f8
	* gdb.texinfo (Remote Configuration): Document the "set/show
0b42f8
	remote swbreak-feature-packet" and "set/show remote
0b42f8
	hwbreak-feature-packet" commands.
0b42f8
	(Packets) <Z0>: Add cross link to the "swbreak" stop reason's
0b42f8
	decription.
0b42f8
	(Stop Reply Packets): Document the swbreak and hwbreak stop
0b42f8
	reasons.
0b42f8
	(General Query Packets): Document the swbreak and hwbreak
0b42f8
	qSupported features.
0b42f8
	(Remote Non-Stop): Explain that swbreak and hwbreak are required.
0b42f8
---
0b42f8
 gdb/NEWS            |  10 +++++
0b42f8
 gdb/doc/gdb.texinfo |  80 +++++++++++++++++++++++++++++++++++
0b42f8
 gdb/remote.c        | 119 ++++++++++++++++++++++++++++++++++++++++++++++++----
0b42f8
 3 files changed, 200 insertions(+), 9 deletions(-)
0b42f8
0b42f8
Index: gdb-7.6.1/gdb/remote.c
0b42f8
===================================================================
0b42f8
--- gdb-7.6.1.orig/gdb/remote.c	2016-03-13 19:41:32.258628611 +0100
0b42f8
+++ gdb-7.6.1/gdb/remote.c	2016-03-13 19:42:35.787094677 +0100
0b42f8
@@ -728,6 +728,9 @@
0b42f8
 /* This is non-zero if target stopped for a watchpoint.  */
0b42f8
 static int remote_stopped_by_watchpoint_p;
0b42f8
 
0b42f8
+/* RHEL: TARGET_STOPPED_BY_HW_BREAKPOINT */
0b42f8
+static int stopped_by_hw_breakpoint;
0b42f8
+
0b42f8
 static struct target_ops remote_ops;
0b42f8
 
0b42f8
 static struct target_ops extended_remote_ops;
0b42f8
@@ -1289,11 +1292,24 @@
0b42f8
   PACKET_Qbtrace_off,
0b42f8
   PACKET_Qbtrace_bts,
0b42f8
   PACKET_qXfer_btrace,
0b42f8
+
0b42f8
+  /* Support for hwbreak+ feature.  */
0b42f8
+  PACKET_hwbreak_feature,
0b42f8
+
0b42f8
   PACKET_MAX
0b42f8
 };
0b42f8
 
0b42f8
 static struct packet_config remote_protocol_packets[PACKET_MAX];
0b42f8
 
0b42f8
+/* Returns the packet's corresponding "set remote foo-packet" command
0b42f8
+   state.  See struct packet_config for more details.  */
0b42f8
+
0b42f8
+static enum auto_boolean
0b42f8
+packet_set_cmd_state (int packet)
0b42f8
+{
0b42f8
+  return remote_protocol_packets[packet].detect;
0b42f8
+}
0b42f8
+
0b42f8
 static void
0b42f8
 set_remote_protocol_packet_cmd (char *args, int from_tty,
0b42f8
 				struct cmd_list_element *c)
0b42f8
@@ -4017,7 +4033,8 @@
0b42f8
   { "Qbtrace:off", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_off },
0b42f8
   { "Qbtrace:bts", PACKET_DISABLE, remote_supported_packet, PACKET_Qbtrace_bts },
0b42f8
   { "qXfer:btrace:read", PACKET_DISABLE, remote_supported_packet,
0b42f8
-    PACKET_qXfer_btrace }
0b42f8
+    PACKET_qXfer_btrace },
0b42f8
+  { "hwbreak", PACKET_DISABLE, remote_supported_packet, PACKET_hwbreak_feature }
0b42f8
 };
0b42f8
 
0b42f8
 static char *remote_support_xml;
0b42f8
@@ -4086,6 +4103,9 @@
0b42f8
 
0b42f8
       q = remote_query_supported_append (q, "multiprocess+");
0b42f8
 
0b42f8
+      if (packet_set_cmd_state (PACKET_hwbreak_feature) != AUTO_BOOLEAN_FALSE)
0b42f8
+	q = remote_query_supported_append (q, "hwbreak+");
0b42f8
+
0b42f8
       if (remote_support_xml)
0b42f8
 	q = remote_query_supported_append (q, remote_support_xml);
0b42f8
 
0b42f8
@@ -5202,6 +5222,9 @@
0b42f8
   int stopped_by_watchpoint_p;
0b42f8
   CORE_ADDR watch_data_address;
0b42f8
 
0b42f8
+  /* RHEL: TARGET_STOPPED_BY_HW_BREAKPOINT */
0b42f8
+  int stopped_by_hw_breakpoint;
0b42f8
+
0b42f8
   int solibs_changed;
0b42f8
   int replay_event;
0b42f8
 
0b42f8
@@ -5467,6 +5490,7 @@
0b42f8
   event->solibs_changed = 0;
0b42f8
   event->replay_event = 0;
0b42f8
   event->stopped_by_watchpoint_p = 0;
0b42f8
+  event->stopped_by_hw_breakpoint = 0;
0b42f8
   event->regcache = NULL;
0b42f8
   event->core = -1;
0b42f8
 
0b42f8
@@ -5522,6 +5546,23 @@
0b42f8
 		  p = unpack_varlen_hex (++p1, &addr);
0b42f8
 		  event->watch_data_address = (CORE_ADDR) addr;
0b42f8
 		}
0b42f8
+	      else if (strncmp (p, "hwbreak", p1 - p) == 0)
0b42f8
+		{
0b42f8
+		  event->stopped_by_hw_breakpoint = 1;
0b42f8
+
0b42f8
+		  /* Make sure the stub doesn't forget to indicate support
0b42f8
+		     with qSupported.  */
0b42f8
+		  //if (packet_support (PACKET_hwbreak_feature) != PACKET_ENABLE)
0b42f8
+		  //  error (_("Unexpected hwbreak stop reason"));
0b42f8
+
0b42f8
+		  /* See above.  */
0b42f8
+		  //p = skip_to_semicolon (p1 + 1);
0b42f8
+		  p1++;
0b42f8
+		  p_temp = p1;
0b42f8
+		  while (*p_temp && *p_temp != ';')
0b42f8
+		    p_temp++;
0b42f8
+		  p = p_temp;
0b42f8
+		}
0b42f8
 	      else if (strncmp (p, "library", p1 - p) == 0)
0b42f8
 		{
0b42f8
 		  p1++;
0b42f8
@@ -5783,6 +5824,7 @@
0b42f8
 
0b42f8
       remote_stopped_by_watchpoint_p = stop_reply->stopped_by_watchpoint_p;
0b42f8
       remote_watch_data_address = stop_reply->watch_data_address;
0b42f8
+      stopped_by_hw_breakpoint = stop_reply->stopped_by_hw_breakpoint;
0b42f8
 
0b42f8
       remote_notice_new_inferior (ptid, 0);
0b42f8
       demand_private_info (ptid)->core = stop_reply->core;
0b42f8
@@ -8310,6 +8352,16 @@
0b42f8
   return -1;
0b42f8
 }
0b42f8
 
0b42f8
+/* The to_stopped_by_hw_breakpoint method of target remote.  */
0b42f8
+
0b42f8
+static int
0b42f8
+remote_stopped_by_hw_breakpoint (struct target_ops *ops)
0b42f8
+{
0b42f8
+  struct remote_state *rs = get_remote_state ();
0b42f8
+
0b42f8
+  return stopped_by_hw_breakpoint;
0b42f8
+}
0b42f8
+
0b42f8
 static int
0b42f8
 remote_stopped_by_watchpoint (void)
0b42f8
 {
0b42f8
@@ -11372,6 +11424,7 @@
0b42f8
   remote_ops.to_files_info = remote_files_info;
0b42f8
   remote_ops.to_insert_breakpoint = remote_insert_breakpoint;
0b42f8
   remote_ops.to_remove_breakpoint = remote_remove_breakpoint;
0b42f8
+  remote_ops.to_stopped_by_hw_breakpoint = remote_stopped_by_hw_breakpoint;
0b42f8
   remote_ops.to_stopped_by_watchpoint = remote_stopped_by_watchpoint;
0b42f8
   remote_ops.to_stopped_data_address = remote_stopped_data_address;
0b42f8
   remote_ops.to_watchpoint_addr_within_range =
0b42f8
@@ -12010,6 +12063,9 @@
0b42f8
   add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_btrace],
0b42f8
        "qXfer:btrace", "read-btrace", 0);
0b42f8
 
0b42f8
+  add_packet_config_cmd (&remote_protocol_packets[PACKET_hwbreak_feature],
0b42f8
+                         "hwbreak-feature", "hwbreak-feature", 0);
0b42f8
+
0b42f8
   /* Keep the old ``set remote Z-packet ...'' working.  Each individual
0b42f8
      Z sub-packet has its own set and show commands, but users may
0b42f8
      have sets to this variable in their .gdbinit files (or in their