This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] gdb: Workaround bad gdbserver qSupported:xmlRegisters=i386; UnknwnFeat+ handling
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 19 Nov 2015 18:36:03 -0000
- Subject: [binutils-gdb] gdb: Workaround bad gdbserver qSupported:xmlRegisters=i386; UnknwnFeat+ handling
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b35d5edb03798388d503d922d8f909a133bf93dd
commit b35d5edb03798388d503d922d8f909a133bf93dd
Author: Pedro Alves <palves@redhat.com>
Date: Thu Nov 19 18:31:49 2015 +0000
gdb: Workaround bad gdbserver qSupported:xmlRegisters=i386;UnknwnFeat+ handling
gdbserver's target_process_qsupported is called for each feature that
the gdbserver common code does not recognize. The only current
implementation, for x86 Linux, does this:
static void
x86_linux_process_qsupported (const char *query)
{
/* Return if gdb doesn't support XML. If gdb sends "xmlRegisters="
with "i386" in qSupported query, it supports x86 XML target
descriptions. */
use_xml = 0;
if (query != NULL && startswith (query, "xmlRegisters="))
{
char *copy = xstrdup (query + 13);
char *p;
for (p = strtok (copy, ","); p != NULL; p = strtok (NULL, ","))
{
if (strcmp (p, "i386") == 0)
{
use_xml = 1;
break;
}
}
free (copy);
}
x86_linux_update_xmltarget ();
}
Notice that this clears use_xml and calls x86_linux_update_xmltarget
each time target_process_qsupported is called. So if gdb sends in any
unknown feature after "xmlRegisters=i386", like e.g.,
"xmlRegisters=i386;UnknownFeature+" gdbserver ends up not reporting a
XML description...
Work around this by having GDB send the "xmlRegisters=" feature last.
gdb/ChangeLog:
2015-11-19 Pedro Alves <palves@redhat.com>
* remote.c (remote_query_supported): Send the "xmlRegisters="
feature last.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/remote.c | 8 +++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 94721a0..ee1b6ad 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-19 Pedro Alves <palves@redhat.com>
+
+ * remote.c (remote_query_supported): Send the "xmlRegisters="
+ feature last.
+
2015-11-19 Simon Marchi <simon.marchi@ericsson.com>
* nat/aarch64-linux-hw-point.c (aarch64_linux_set_debug_regs): Change
diff --git a/gdb/remote.c b/gdb/remote.c
index 6c86ab2..2bbab62 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4467,9 +4467,6 @@ remote_query_supported (void)
if (packet_set_cmd_state (PACKET_hwbreak_feature) != AUTO_BOOLEAN_FALSE)
q = remote_query_supported_append (q, "hwbreak+");
- if (remote_support_xml)
- q = remote_query_supported_append (q, remote_support_xml);
-
q = remote_query_supported_append (q, "qRelocInsn+");
if (rs->extended)
@@ -4488,6 +4485,11 @@ remote_query_supported (void)
if (packet_set_cmd_state (PACKET_vContSupported) != AUTO_BOOLEAN_FALSE)
q = remote_query_supported_append (q, "vContSupported+");
+ /* Keep this one last to work around a gdbserver <= 7.10 bug in
+ the qSupported:xmlRegisters=i386 handling. */
+ if (remote_support_xml != NULL)
+ q = remote_query_supported_append (q, remote_support_xml);
+
q = reconcat (q, "qSupported:", q, (char *) NULL);
putpkt (q);