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