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

2c2fa1
http://sourceware.org/ml/gdb-patches/2015-02/msg00727.html
2c2fa1
Subject: [PATCH 6/8] gdbserver: Support the "swbreak"/"hwbreak" stop reasons
2c2fa1
2c2fa1
This patch teaches the core of gdbserver about the new "swbreak" and
2c2fa1
"hwbreak" stop reasons, and adds the necessary hooks a backend needs
2c2fa1
to implement to support the feature.
2c2fa1
2c2fa1
gdb/gdbserver/ChangeLog:
2c2fa1
2015-02-25  Pedro Alves  <palves@redhat.com>
2c2fa1
2c2fa1
	* remote-utils.c (prepare_resume_reply): Report swbreak/hbreak.
2c2fa1
	* server.c (swbreak_feature, hwbreak_feature): New globals.
2c2fa1
	(handle_query) <qSupported>: Handle "swbreak+" and "hwbreak+".
2c2fa1
	(captured_main): Clear swbreak_feature and hwbreak_feature.
2c2fa1
	* server.h (swbreak_feature, hwbreak_feature): Declare.
2c2fa1
	* target.h (struct target_ops) 
2c2fa1
	supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint,
2c2fa1
	supports_stopped_by_hw_breakpoint>: New fields.
2c2fa1
	(target_supports_stopped_by_sw_breakpoint)
2c2fa1
	(target_stopped_by_sw_breakpoint)
2c2fa1
	(target_supports_stopped_by_hw_breakpoint)
2c2fa1
	(target_stopped_by_hw_breakpoint): Declare.
2c2fa1
---
2c2fa1
 gdb/gdbserver/remote-utils.c | 10 ++++++++++
2c2fa1
 gdb/gdbserver/server.c       | 25 +++++++++++++++++++++++++
2c2fa1
 gdb/gdbserver/server.h       | 11 +++++++++++
2c2fa1
 gdb/gdbserver/target.h       | 31 +++++++++++++++++++++++++++++++
2c2fa1
 4 files changed, 77 insertions(+)
2c2fa1
2c2fa1
Index: gdb-7.6.1/gdb/gdbserver/remote-utils.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbserver/remote-utils.c	2016-03-13 19:45:54.182550173 +0100
2c2fa1
+++ gdb-7.6.1/gdb/gdbserver/remote-utils.c	2016-03-13 19:45:59.518589318 +0100
2c2fa1
@@ -1355,6 +1355,11 @@
2c2fa1
 	      *buf++ = tohex ((addr >> (i - 1) * 4) & 0xf);
2c2fa1
 	    *buf++ = ';';
2c2fa1
 	  }
2c2fa1
+	else if (hwbreak_feature && target_stopped_by_hw_breakpoint ())
2c2fa1
+	  {
2c2fa1
+	    sprintf (buf, "hwbreak:;");
2c2fa1
+	    buf += strlen (buf);
2c2fa1
+	  }
2c2fa1
 
2c2fa1
 	while (*regp)
2c2fa1
 	  {
2c2fa1
Index: gdb-7.6.1/gdb/gdbserver/server.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbserver/server.c	2016-03-13 19:45:54.184550187 +0100
2c2fa1
+++ gdb-7.6.1/gdb/gdbserver/server.c	2016-03-13 19:46:24.182770265 +0100
2c2fa1
@@ -56,6 +56,7 @@
2c2fa1
 
2c2fa1
 int multi_process;
2c2fa1
 int non_stop;
2c2fa1
+int hwbreak_feature;
2c2fa1
 
2c2fa1
 /* Whether we should attempt to disable the operating system's address
2c2fa1
    space randomization feature before starting an inferior.  */
2c2fa1
@@ -1728,6 +1729,13 @@
2c2fa1
 		  /* GDB supports relocate instruction requests.  */
2c2fa1
 		  gdb_supports_qRelocInsn = 1;
2c2fa1
 		}
2c2fa1
+	      else if (strcmp (p, "hwbreak+") == 0)
2c2fa1
+		{
2c2fa1
+		  /* GDB wants us to report whether a trap is caused
2c2fa1
+		     by a hardware breakpoint.  */
2c2fa1
+		  if (target_supports_stopped_by_hw_breakpoint ())
2c2fa1
+		    hwbreak_feature = 1;
2c2fa1
+		}
2c2fa1
 	      else
2c2fa1
 		target_process_qsupported (p);
2c2fa1
 
2c2fa1
@@ -1817,6 +1825,9 @@
2c2fa1
 	  strcat (own_buf, ";qXfer:btrace:read+");
2c2fa1
 	}
2c2fa1
 
2c2fa1
+      if (target_supports_stopped_by_hw_breakpoint ())
2c2fa1
+	strcat (own_buf, ";hwbreak+");
2c2fa1
+
2c2fa1
       return;
2c2fa1
     }
2c2fa1
 
2c2fa1
@@ -2933,6 +2944,7 @@
2c2fa1
       multi_process = 0;
2c2fa1
       /* Be sure we're out of tfind mode.  */
2c2fa1
       current_traceframe = -1;
2c2fa1
+      hwbreak_feature = 0;
2c2fa1
 
2c2fa1
       remote_open (port);
2c2fa1
 
2c2fa1
Index: gdb-7.6.1/gdb/gdbserver/server.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbserver/server.h	2016-03-13 19:45:54.184550187 +0100
2c2fa1
+++ gdb-7.6.1/gdb/gdbserver/server.h	2016-03-13 19:45:59.520589333 +0100
2c2fa1
@@ -237,6 +237,11 @@
2c2fa1
 extern int multi_process;
2c2fa1
 extern int non_stop;
2c2fa1
 
2c2fa1
+/* True if the "hwbreak+" feature is active.  In that case, GDB wants
2c2fa1
+   us to report whether a trap is explained by a hardware breakpoint.
2c2fa1
+   Only enabled if the target supports it.  */
2c2fa1
+extern int hwbreak_feature;
2c2fa1
+
2c2fa1
 extern int disable_randomization;
2c2fa1
 
2c2fa1
 #if USE_WIN32API
2c2fa1
Index: gdb-7.6.1/gdb/gdbserver/target.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/gdbserver/target.h	2016-03-13 19:45:54.185550195 +0100
2c2fa1
+++ gdb-7.6.1/gdb/gdbserver/target.h	2016-03-13 19:45:59.520589333 +0100
2c2fa1
@@ -250,6 +250,13 @@
2c2fa1
   int (*insert_point) (char type, CORE_ADDR addr, int len);
2c2fa1
   int (*remove_point) (char type, CORE_ADDR addr, int len);
2c2fa1
 
2c2fa1
+  /* Returns 1 if the target stopped for a hardware breakpoint.  */
2c2fa1
+  int (*stopped_by_hw_breakpoint) (void);
2c2fa1
+
2c2fa1
+  /* Returns true if the target knows whether a trap was caused by a
2c2fa1
+     HW breakpoint triggering.  */
2c2fa1
+  int (*supports_stopped_by_hw_breakpoint) (void);
2c2fa1
+
2c2fa1
   /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise.  */
2c2fa1
 
2c2fa1
   int (*stopped_by_watchpoint) (void);
2c2fa1
@@ -549,6 +556,14 @@
2c2fa1
 #define target_read_btrace(tinfo, buffer, type)	\
2c2fa1
   (*the_target->read_btrace) (tinfo, buffer, type)
2c2fa1
 
2c2fa1
+#define target_supports_stopped_by_hw_breakpoint() \
2c2fa1
+  (the_target->supports_stopped_by_hw_breakpoint ? \
2c2fa1
+   (*the_target->supports_stopped_by_hw_breakpoint) () : 0)
2c2fa1
+
2c2fa1
+#define target_stopped_by_hw_breakpoint() \
2c2fa1
+  (the_target->stopped_by_hw_breakpoint ? \
2c2fa1
+   (*the_target->stopped_by_hw_breakpoint) () : 0)
2c2fa1
+
2c2fa1
 /* Start non-stop mode, returns 0 on success, -1 on failure.   */
2c2fa1
 
2c2fa1
 int start_non_stop (int nonstop);