From: "H.J. Lu" <hongjiu.lu@intel.com>
To: GDB <gdb-patches@sourceware.org>
Subject: Re: PATCH: Add xmlRegisters= to qsupported query
Date: Mon, 29 Mar 2010 14:55:00 -0000 [thread overview]
Message-ID: <20100329145549.GA7015@intel.com> (raw)
In-Reply-To: <20100328234643.GA25607@intel.com>
On Sun, Mar 28, 2010 at 04:46:43PM -0700, H.J. Lu wrote:
> On Sun, Mar 28, 2010 at 01:52:07PM -0700, H.J. Lu wrote:
> > On Sun, Mar 28, 2010 at 01:48:07PM -0700, H.J. Lu wrote:
> > > Hi,
> > >
> > > This patch adds xmlRegisters= to qsupported query. Any comments?
> > >
> > > Thanks.
> > >
> > >
> >
> > An updated patch.
> >
> >
>
> Here is a new patch to simplify extending qsupported query and fix a
> memory leak. Any comments?
>
This patch updated documentation based on Eli's feedbacks. OK to
install?
Thanks.
H.J.
---
gdb/
2010-03-29 H.J. Lu <hongjiu.lu@intel.com>
* i386-tdep.c: Include "remote.h".
(i386_gdbarch_init): Call register_remote_support_xml.
* remote.c (remote_support_xml): New.
(register_remote_support_xml): Likewise.
(remote_query_supported_append): Likewise.
(remote_query_supported): Support remote_support_xml.
* remote.h (register_remote_support_xml): New.
gdb/doc/
2010-03-29 H.J. Lu <hongjiu.lu@intel.com>
* gdb.texinfo (General Query Packets): Add xmlRegisters.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 56dbe5d..15da725 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -30603,6 +30603,13 @@ extensions to the remote protocol. @value{GDBN} does not use such
extensions unless the stub also reports that it supports them by
including @samp{multiprocess+} in its @samp{qSupported} reply.
@xref{multiprocess extensions}, for details.
+
+@item xmlRegisters
+This feature indicates that @value{GDBN} supports the XML target
+description. If the stub sees @samp{xmlRegisters=} with target
+specific strings separated by a comma, it will send either an XML
+target description or an XML stub that states only the architecture
+and the OSABI.
@end table
Stubs should ignore any unknown values for
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 83275ac..d7af84a 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -44,6 +44,7 @@
#include "value.h"
#include "dis-asm.h"
#include "disasm.h"
+#include "remote.h"
#include "gdb_assert.h"
#include "gdb_string.h"
@@ -5943,6 +5944,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_fast_tracepoint_valid_at (gdbarch,
i386_fast_tracepoint_valid_at);
+ /* Tell remote stub that we support XML target description. */
+ register_remote_support_xml ("x86");
+
return gdbarch;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 0c791aa..2dcf079 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3464,6 +3464,55 @@ static struct protocol_feature remote_protocol_features[] = {
PACKET_bs },
};
+static char *remote_support_xml;
+
+/* Register string appended to "xmlRegisters=" in qSupported query. */
+
+void
+register_remote_support_xml (const char *xml)
+{
+ if (remote_support_xml == NULL)
+ remote_support_xml = concat ("xmlRegisters=", xml, NULL);
+ else
+ {
+ const char *str = strstr (remote_support_xml, xml);
+ int append;
+
+ if (str)
+ {
+ if (str != remote_support_xml && *(str - 1) != ',')
+ append = 0;
+ else
+ {
+ size_t len = strlen (xml);
+ append = xml[len] != ',' && xml[len] != '\0';
+ }
+ }
+ else
+ append = 1;
+
+ if (append)
+ {
+ char *p = concat (remote_support_xml, ",", xml, NULL);
+ xfree (remote_support_xml);
+ remote_support_xml = p;
+ }
+ }
+}
+
+static char *
+remote_query_supported_append (char *msg, const char *append)
+{
+ if (msg)
+ {
+ char *p = concat (msg, ";", append, NULL);
+ xfree (msg);
+ return p;
+ }
+ else
+ return xstrdup (append);
+}
+
static void
remote_query_supported (void)
{
@@ -3482,24 +3531,27 @@ remote_query_supported (void)
rs->buf[0] = 0;
if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE)
{
+ char *q = NULL;
const char *qsupported = gdbarch_qsupported (target_gdbarch);
+
+ if (rs->extended)
+ q = remote_query_supported_append (q, "multiprocess+;");
+
if (qsupported)
+ q = remote_query_supported_append (q, qsupported);
+
+ if (remote_support_xml)
+ q = remote_query_supported_append (q, remote_support_xml);
+
+ if (q)
{
- char *q;
- if (rs->extended)
- q = concat ("qSupported:multiprocess+;", qsupported, NULL);
- else
- q = concat ("qSupported:", qsupported, NULL);
- putpkt (q);
+ char *p = concat ("qSupported:", q, NULL);
xfree (q);
+ putpkt (p);
+ xfree (p);
}
else
- {
- if (rs->extended)
- putpkt ("qSupported:multiprocess+");
- else
- putpkt ("qSupported");
- }
+ putpkt ("qSupported");
getpkt (&rs->buf, &rs->buf_size, 0);
diff --git a/gdb/remote.h b/gdb/remote.h
index a82d0d7..d480e26 100644
--- a/gdb/remote.h
+++ b/gdb/remote.h
@@ -66,6 +66,7 @@ extern void (*deprecated_target_wait_loop_hook) (void);
void register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes,
const struct target_desc *tdesc);
+void register_remote_support_xml (const char *);
void remote_file_put (const char *local_file, const char *remote_file,
int from_tty);
next prev parent reply other threads:[~2010-03-29 14:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-28 20:48 H.J. Lu
2010-03-28 20:52 ` H.J. Lu
2010-03-28 21:27 ` Pedro Alves
2010-03-28 22:56 ` H.J. Lu
2010-03-28 23:48 ` H.J. Lu
2010-03-28 23:46 ` H.J. Lu
2010-03-29 6:40 ` Eli Zaretskii
2010-03-29 14:13 ` H.J. Lu
2010-03-29 14:32 ` Eli Zaretskii
2010-03-29 14:47 ` H.J. Lu
2010-03-29 14:55 ` H.J. Lu [this message]
2010-03-29 16:19 ` H.J. Lu
2010-03-29 17:49 ` Mark Kettenis
2010-03-29 18:02 ` H.J. Lu
2010-03-30 13:55 ` Pedro Alves
2010-03-30 14:58 ` H.J. Lu
2010-03-30 15:09 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100329145549.GA7015@intel.com \
--to=hongjiu.lu@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox