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