From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11928 invoked by alias); 29 Feb 2008 03:58:12 -0000 Received: (qmail 11920 invoked by uid 22791); 29 Feb 2008 03:58:11 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 29 Feb 2008 03:57:49 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A20B62A9EB9 for ; Thu, 28 Feb 2008 22:57:47 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id QvI1pPwZAqgN for ; Thu, 28 Feb 2008 22:57:47 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 1F50E2A9EAD for ; Thu, 28 Feb 2008 22:57:47 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id A7887E7ACB; Thu, 28 Feb 2008 19:57:44 -0800 (PST) Date: Fri, 29 Feb 2008 04:45:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFC] Make version attribute of really optional Message-ID: <20080229035744.GK19729@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i 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: 2008-02/txt/msg00491.txt.bz2 --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2959 Hello, I'm trying to fix the type of the "lr" register in the XML features files for rs6000, but I have hit a strange problem: The XML parser is complaining that the version number in the element is missing. On the other hand, the documentation says that it is optional (but recommended). Looking back at the discussion, it seems that the attribute was meant to be optional for now. But on the other hand, the implementation was such that the attribute is NOT optional. I thought it'd quickly give it a go at making the attribute optional, and the following seems to be working, but now I'm having other issues when trying to read the XML file from GDB: (gdb) set tdesc filename rs6000/powerpc-32.xml warning: while parsing target description: unbound prefix warning: Could not load XML target description; ignoring This error seems independent of the change I made, as I can reproduce the same error without my change. It looks like the problem is happening during the processing of the xi:include tag, but I can't figure out better what is going on for lack of familiarity with the XML parser. Just for the record, I'm using expat-2.0.1. "set debug xml" reveals: (gdb) set debug xml 1 (gdb) set tdesc filename rs6000/powerpc-32.xml target description (line 1): Starting: [snip] powerpc:common target description (line 12): Entering element target description (line 13): Entering element target description (line 13): Leaving element warning: while parsing target description: unbound prefix warning: Could not load XML target description; ignoring We raised the failure because we weren't able to find element "target" in the list of elements passed to us by the parser: /* Find this element in the list of the current scope's allowed children. Record that we've seen it. */ seen = 1; for (element = scope->elements; element && element->name; element++, seen <<= 1) if (strcmp (element->name, name) == 0) break; It feels like I'm missing something, here... Does it work for someone else? Daniel, or Ulrich, maybe? You regenerated the files not long ago, so perhaps it works for you... The following is the untested patch that I wrote in an attempt to make the version optional for now: 2008-02-28 Joel Brobecker * xml-tdesc.c (tdesc_start_target): Handle the "version" attribute as optional. (target_attributes): Make the "version" attribute optional. Note that another approach would be to keep this attribute mandatory, update the XML files, and update the documentation as well. -- Joel --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="xml-tdesc.c.diff" Content-length: 1046 Index: xml-tdesc.c =================================================================== RCS file: /cvs/src/src/gdb/xml-tdesc.c,v retrieving revision 1.10 diff -u -p -r1.10 xml-tdesc.c --- xml-tdesc.c 1 Jan 2008 22:53:13 -0000 1.10 +++ xml-tdesc.c 29 Feb 2008 03:36:06 -0000 @@ -114,7 +114,14 @@ tdesc_start_target (struct gdb_xml_parse void *user_data, VEC(gdb_xml_value_s) *attributes) { struct tdesc_parsing_data *data = user_data; - char *version = VEC_index (gdb_xml_value_s, attributes, 0)->value; + int length; + char *version; + + length = VEC_length (gdb_xml_value_s, attributes); + if (length == 0) + return; + + version = VEC_index (gdb_xml_value_s, attributes, 0)->value; if (strcmp (version, "1.0") != 0) gdb_xml_error (parser, @@ -338,7 +345,7 @@ static const struct gdb_xml_element feat }; static const struct gdb_xml_attribute target_attributes[] = { - { "version", GDB_XML_AF_NONE, NULL, NULL }, + { "version", GDB_XML_AF_OPTIONAL, NULL, NULL }, { NULL, GDB_XML_AF_NONE, NULL, NULL } }; --mYCpIKhGyMATD0i+--