This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Allow remote stub to indicate number of hardware breakpoints


Hi,

The attached patch adds 3 additional stub features to the remote protocol,
returned in response to a qSupported packet, to allow a stub to indicate how
many breakpoints and watchpoints are supported by the target:

HWBreakpoints=breakpoints
HWWatchpoints=watchpoints
HWWatchpointLengthLimit=length

This means a user will not need to manually type the 'set remote
hardware-breakpoint-limit', 'set remote hardware-watchpoint-limit' or 'set
remote hardware-watchpoint-length-limit'  commands. This results in better
diagnostics and interaction with the Eclipse front-end, compared to simply
returning an error to a Z1 packet when all h/w breakpoints are used.

Cheers,
Jon


2016-07-14  Jon Beniston  <jon@beniston.com>

	* remote.c (remote_hw_breakpoints): New function.
	(remote_hw_watchpoints): New function.
	(remote_hw_watchpoint_length): New function.
	(remote_protocol_features): Add HWBreakpoints,
	HWWatchpoints and HWWatchpointLengthLimit features.
	* gdb.texinfo (Remote protocol): Add new stub features.


diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a068622..144a33b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -36977,6 +36977,21 @@ These are the currently defined stub features and
their properties:
 @tab @samp{-}
 @tab No
 
+@item @samp{HWBreakpoints}
+@tab Yes
+@tab @samp{-}
+@tab No
+
+@item @samp{HWWatchpoints}
+@tab Yes
+@tab @samp{-}
+@tab No
+
+@item @samp{HWWatchpointLengthLimit}
+@tab Yes
+@tab @samp{-}
+@tab No
+
 @end multitable
 
 These are the currently defined stub features, in more detail:
@@ -37199,6 +37214,21 @@ The remote stub understands the
@samp{QThreadEvents} packet.
 @item no-resumed
 The remote stub reports the @samp{N} stop reply.
 
+@item HWBreakpoints=@var{breakpoints}
+The remote target supports @var{breakpoints} hardware breakpoints. This
+allows the value of @ref{set remote hardware-breakpoint-limit} to be set
+by the stub.
+
+@item HWWatchpoints=@var{watchpoints}
+The remote target supports @var{watchpoints} hardware watchpoints. This
+allows the value of @ref{set remote hardware-watchpoint-limit} to be set
+by the stub.
+
+@item HWWatchpointLengthLimit=@var{length}
+The remote target supports watchpoints of length @var{length}. This
+allows the value of @ref{set remote hardware-watchpoint-length-limit} to be
set
+by the stub.
+
 @end table
 
 @item qSymbol::
diff --git a/gdb/remote.c b/gdb/remote.c
index 5568346..941438b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4549,6 +4549,79 @@ remote_packet_size (const struct protocol_feature
*feature,
   rs->explicit_packet_size = packet_size;
 }
 
+int remote_hw_watchpoint_limit = -1;
+int remote_hw_watchpoint_length_limit = -1;
+int remote_hw_breakpoint_limit = -1;
+
+static void
+remote_hw_breakpoints (const struct protocol_feature *feature,
+		       enum packet_support support, const char *value)
+{
+  char *value_end;
+
+  if (value == NULL || *value == '\0')
+    {
+      warning (_("Remote target reported \"%s\" without a value."),
+	       feature->name);
+      return;
+    }
+
+  errno = 0;
+  remote_hw_breakpoint_limit = strtol (value, &value_end, 16);
+  if (errno != 0 || *value_end != '\0')
+    {
+      warning (_("Remote target reported \"%s\" with a bad value:
\"%s\"."),
+	       feature->name, value);
+      return;
+    }
+}
+
+static void
+remote_hw_watchpoints (const struct protocol_feature *feature,
+		       enum packet_support support, const char *value)
+{
+  char *value_end;
+
+  if (value == NULL || *value == '\0')
+    {
+      warning (_("Remote target reported \"%s\" without a value."),
+	       feature->name);
+      return;
+    }
+
+  errno = 0;
+  remote_hw_watchpoint_limit = strtol (value, &value_end, 16);
+  if (errno != 0 || *value_end != '\0')
+    {
+      warning (_("Remote target reported \"%s\" with a bad value:
\"%s\"."),
+	       feature->name, value);
+      return;
+    }
+}
+
+static void
+remote_hw_watchpoint_length (const struct protocol_feature *feature,
+		             enum packet_support support, const char *value)
+{
+  char *value_end;
+
+  if (value == NULL || *value == '\0')
+    {
+      warning (_("Remote target reported \"%s\" without a value."),
+	       feature->name);
+      return;
+    }
+
+  errno = 0;
+  remote_hw_watchpoint_length_limit = strtol (value, &value_end, 16);
+  if (errno != 0 || *value_end != '\0')
+    {
+      warning (_("Remote target reported \"%s\" with a bad value:
\"%s\"."),
+	       feature->name, value);
+      return;
+    }
+}
+
 static const struct protocol_feature remote_protocol_features[] = {
   { "PacketSize", PACKET_DISABLE, remote_packet_size, -1 },
   { "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet,
@@ -4646,6 +4719,9 @@ static const struct protocol_feature
remote_protocol_features[] = {
   { "vContSupported", PACKET_DISABLE, remote_supported_packet,
PACKET_vContSupported },
   { "QThreadEvents", PACKET_DISABLE, remote_supported_packet,
PACKET_QThreadEvents },
   { "no-resumed", PACKET_DISABLE, remote_supported_packet,
PACKET_no_resumed },
+  { "HWBreakpoints", PACKET_DISABLE, remote_hw_breakpoints, -1 },
+  { "HWWatchpoints", PACKET_DISABLE, remote_hw_watchpoints, -1 },
+  { "HWWatchpointLengthLimit", PACKET_DISABLE, remote_hw_watchpoint_length,
-1 },
 };
 
 static char *remote_support_xml;
@@ -9467,10 +9543,6 @@ remote_remove_watchpoint (struct target_ops *self,
CORE_ADDR addr, int len,
 }
 
 
-int remote_hw_watchpoint_limit = -1;
-int remote_hw_watchpoint_length_limit = -1;
-int remote_hw_breakpoint_limit = -1;
-
 static int
 remote_region_ok_for_hw_watchpoint (struct target_ops *self,
 				    CORE_ADDR addr, int len)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]