Create xml-builtin.h to declare xml_builtins
authorChristian Biesinger <cbiesinger@google.com>
Thu, 10 Oct 2019 01:08:13 +0000 (20:08 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Wed, 16 Oct 2019 16:19:14 +0000 (18:19 +0200)
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-16  Christian Biesinger  <cbiesinger@google.com>

* 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-16  Christian Biesinger  <cbiesinger@google.com>

* server.c: Include xml-builtin.h.
(get_xml_features): Don't declare xml_builtins here.

Change-Id: I806ef0851c43ead90b545a11794e41f5e5178436

gdb/ChangeLog
gdb/Makefile.in
gdb/features/feature_to_c.sh
gdb/gdbserver/ChangeLog
gdb/gdbserver/server.c
gdb/xml-builtin.h [new file with mode: 0644]
gdb/xml-support.c
gdb/xml-support.h

index 8748257e015800b977713bacfe2396599a82be77..e79f4492310ce5525054cfca4bd80acdccf93dda 100644 (file)
@@ -1,3 +1,12 @@
+2019-10-16  Christian Biesinger  <cbiesinger@google.com>
+
+       * 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.
+
 2019-10-16  Tom de Vries  <tdevries@suse.de>
 
        PR tdep/25096
index af4b14d6e6ca228e1eac5906e56ba9a0d13e5fbb..8fec099a1b4257b996740d8cb6f723a780b45603 100644 (file)
@@ -1425,6 +1425,7 @@ HFILES_NO_SRCDIR = \
        x86-linux-nat.h \
        x86-nat.h \
        xcoffread.h \
+       xml-builtin.h \
        xml-support.h \
        xml-syscall.h \
        xml-tdesc.h \
index 2e7e0c72a8235edc1a14e893fb2ab23a12b81b53..ae83774fdf4fcdeb03cdf0ae59423031f6679ffb 100755 (executable)
@@ -32,6 +32,8 @@ if test -e "$output"; then
   exit 1
 fi
 
+echo '#include "xml-builtin.h"' >> $output
+
 for input; do
   arrayname=xml_feature_`echo $input | sed 's,.*/,,; s/[-.]/_/g'`
 
index 801a66c5635acf52a29ce89112e059d546cb4846..b2213cffcfb742241fb59cca9a979eefa9d90b4f 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-16  Christian Biesinger  <cbiesinger@google.com>
+
+       * server.c: Include xml-builtin.h.
+       (get_xml_features): Don't declare xml_builtins here.
+
 2019-10-15  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * Makefile.in: Remove references to vec-ipa.o.
index 0bfff04fd765bd505bfce30539b0d02bab7fbea9..25a2be86fb0bb5e273eae3495ab312cb27e200cf 100644 (file)
@@ -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 @@ get_features_xml (const char *annex)
 
 #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 (file)
index 0000000..972417d
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.  */
+
+#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 */
index eaf99efa6b972047231c36c2372d4231e4e7bb66..915be76066d9fce8003a6b3b4a60ea2354432515 100644 (file)
@@ -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 @@ xml_process_xincludes (std::string &result,
 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)
index 5012767568f4643f36bbf1b76767d744381af7bf..59b4467d082a9290151be86ad8417b3acc1c5049 100644 (file)
@@ -44,11 +44,6 @@ LONGEST xml_builtin_xfer_partial (const char *filename,
                                  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.  */