From patchwork Tue Oct 15 22:33:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35028 Received: (qmail 49805 invoked by alias); 15 Oct 2019 22:34:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 49790 invoked by uid 89); 15 Oct 2019 22:34:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy=redeclaring X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 15 Oct 2019 22:34:03 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id AECDD208F0; Tue, 15 Oct 2019 18:34:01 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 6418D206FC; Tue, 15 Oct 2019 18:33:59 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 3EDE226976; Tue, 15 Oct 2019 18:33:59 -0400 (EDT) X-Gerrit-PatchSet: 2 Date: Tue, 15 Oct 2019 18:33:58 -0400 From: "Christian Biesinger (Code Review)" To: Christian Biesinger , gdb-patches@sourceware.org Cc: Tom Tromey , Simon Marchi Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review] Create xml-builtin.h to declare xml_builtins X-Gerrit-Change-Id: I806ef0851c43ead90b545a11794e41f5e5178436 X-Gerrit-Change-Number: 25 X-Gerrit-ChangeURL: X-Gerrit-Commit: 8d926e2b828614bfc7fa1886eacdc0be1714073b In-Reply-To: References: Reply-To: cbiesinger@google.com, simon.marchi@polymtl.ca, tromey@sourceware.org, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3 Message-Id: <20191015223359.3EDE226976@gnutoolchain-gerrit.osci.io> Christian Biesinger has uploaded a new patch set version (#2). Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/25 ...................................................................... Create xml-builtin.h to declare xml_builtins xml-builtin.c only has character arrays and no dependencies, so this creates a simple header file for that purpose so that gdbserver can include that instead of re-declaring xml_builtin. Despite the name, feature_to_c.sh is already specific to xml_builtins (it hardcodes the variable name), so making it always output the include for xml-builtin.h seems fine. gdb/ChangeLog: 2019-10-09 Christian Biesinger * Makefile.in: Add xml-builtin.h. * features/feature_to_c.sh: Add an include for xml-builtin.h to ensure that the compiler checks that the types match. * xml-builtin.h: New file. * xml-support.c (fetch_xml_builtin): Add missing const. * xml-support.h: Remove declaration of xml_builtins. gdb/gdbserver/ChangeLog: 2019-10-09 Christian Biesinger * server.c: Include xml-builtin.h. (get_xml_features): Don't declare xml_builtins here. Change-Id: I806ef0851c43ead90b545a11794e41f5e5178436 --- M gdb/Makefile.in M gdb/features/feature_to_c.sh M gdb/gdbserver/server.c A gdb/xml-builtin.h M gdb/xml-support.c M gdb/xml-support.h 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 36650ad..04a5cdb 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1426,6 +1426,7 @@ x86-linux-nat.h \ x86-nat.h \ xcoffread.h \ + xml-builtin.h \ xml-support.h \ xml-syscall.h \ xml-tdesc.h \ diff --git a/gdb/features/feature_to_c.sh b/gdb/features/feature_to_c.sh index 2e7e0c7..ae83774 100755 --- a/gdb/features/feature_to_c.sh +++ b/gdb/features/feature_to_c.sh @@ -32,6 +32,8 @@ exit 1 fi +echo '#include "xml-builtin.h"' >> $output + for input; do arrayname=xml_feature_`echo $input | sed 's,.*/,,; s/[-.]/_/g'` diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 0bfff04..25a2be8 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -41,6 +41,9 @@ #include "gdbsupport/environ.h" #include "filenames.h" #include "gdbsupport/pathstuff.h" +#ifdef USE_XML +#include "xml-builtin.h" +#endif #include "gdbsupport/selftest.h" #include "gdbsupport/scope-exit.h" @@ -920,7 +923,6 @@ #ifdef USE_XML { - extern const char *const xml_builtin[][2]; int i; /* Look for the annex. */ diff --git a/gdb/xml-builtin.h b/gdb/xml-builtin.h new file mode 100644 index 0000000..972417d --- /dev/null +++ b/gdb/xml-builtin.h @@ -0,0 +1,28 @@ +/* Header file for builtin XML files. + + Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef XML_BUILTIN_H +#define XML_BUILTIN_H + +/* The text of compiled-in XML documents, from xml-builtin.c + (generated). */ + +extern const char *const xml_builtin[][2]; + +#endif /* XML_BUILTIN_H */ diff --git a/gdb/xml-support.c b/gdb/xml-support.c index eaf99ef..915be76 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -19,6 +19,7 @@ #include "defs.h" #include "gdbcmd.h" +#include "xml-builtin.h" #include "xml-support.h" #include "gdbsupport/filestuff.h" #include "safe-ctype.h" @@ -919,7 +920,7 @@ const char * fetch_xml_builtin (const char *filename) { - const char *(*p)[2]; + const char *const (*p)[2]; for (p = xml_builtin; (*p)[0]; p++) if (strcmp ((*p)[0], filename) == 0) diff --git a/gdb/xml-support.h b/gdb/xml-support.h index 7ceb938..aaa829d 100644 --- a/gdb/xml-support.h +++ b/gdb/xml-support.h @@ -45,11 +45,6 @@ gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len); -/* The text of compiled-in XML documents, from xml-builtin.c - (generated). */ - -extern const char *xml_builtin[][2]; - /* Support for XInclude. */ /* Callback to fetch a new XML file, based on the provided HREF. */