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

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