From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29671 invoked by alias); 30 Mar 2010 14:58:55 -0000 Received: (qmail 29662 invoked by uid 22791); 30 Mar 2010 14:58:54 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM,SARE_SUB_OBFU_Q1,TW_QS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Mar 2010 14:58:49 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 30 Mar 2010 07:55:50 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.107]) by orsmga002.jf.intel.com with ESMTP; 30 Mar 2010 07:57:48 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 4ACFF812387; Tue, 30 Mar 2010 07:58:47 -0700 (PDT) Date: Tue, 30 Mar 2010 14:58:00 -0000 From: "H.J. Lu" To: GDB Subject: Re: PATCH: Add xmlRegisters= to qsupported query Message-ID: <20100330145847.GA29553@intel.com> Reply-To: "H.J. Lu" References: <20100328204807.GA10649@intel.com> <20100328205207.GA11401@intel.com> <20100328234643.GA25607@intel.com> <20100329145549.GA7015@intel.com> <20100329161910.GA10204@intel.com> <20100329180136.GA14704@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100329180136.GA14704@intel.com> User-Agent: Mutt/1.5.20 (2009-08-17) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg01046.txt.bz2 On Mon, Mar 29, 2010 at 11:01:36AM -0700, H.J. Lu wrote: > On Mon, Mar 29, 2010 at 09:19:10AM -0700, H.J. Lu wrote: > > On Mon, Mar 29, 2010 at 07:55:49AM -0700, H.J. Lu wrote: > > > 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. > > > > > > > We should check if libexpat is available. Any comments/suggestions? > > > > Updated patch to pass "i386" instead of "x86" to > register_remote_support_xml. OK to install? > Here is the updated patch. OK to install? Thanks. H.J. --- gdb/ 2010-03-30 H.J. Lu * NEWS: Mention xmlRegisters= in qSupported packet. * i386-tdep.c: Include "remote.h". (_initialize_i386_tdep): 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-30 H.J. Lu * gdb.texinfo (General Query Packets): Add xmlRegisters. diff --git a/gdb/NEWS b/gdb/NEWS index f01b55e..0d27faa 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,9 @@ *** Changes since GDB 7.1 +* GDB now sends xmlRegisters= in qSupported packet to indicate that + it understands register description. + * The --batch flag now disables pagination and queries. * X86 general purpose registers diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ef51ed1..fab06a8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30633,6 +30633,12 @@ 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 report register +description. @end table Stubs should ignore any unknown values for diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 83275ac..9b4c93e 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" @@ -6000,4 +6001,7 @@ is \"default\"."), /* Initialize the standard target descriptions. */ initialize_tdesc_i386 (); + + /* Tell remote stub that we support XML target description. */ + register_remote_support_xml ("i386"); } diff --git a/gdb/remote.c b/gdb/remote.c index dcae72c..03644d1 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -3467,6 +3467,53 @@ static struct protocol_feature remote_protocol_features[] = { PACKET_TracepointSource }, }; +static char *remote_support_xml; + +/* Register string appended to "xmlRegisters=" in qSupported query. */ + +void +register_remote_support_xml (const char *xml ATTRIBUTE_UNUSED) +{ +#if defined(HAVE_LIBEXPAT) + if (remote_support_xml == NULL) + remote_support_xml = concat ("xmlRegisters=", xml, NULL); + else + { + char *copy = xstrdup (remote_support_xml + 13); + char *p = strtok (copy, ","); + + do + { + if (strcmp (p, xml) == 0) + { + /* already there */ + xfree (copy); + return; + } + } + while ((p = strtok (NULL, ",")) != NULL); + xfree (copy); + + p = concat (remote_support_xml, ",", xml, NULL); + xfree (remote_support_xml); + remote_support_xml = p; + } +#endif +} + +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) { @@ -3485,24 +3532,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);