* [PATCH] Include xml-support.h to get a variable declaration
@ 2019-10-07 19:06 Christian Biesinger via gdb-patches
2019-10-09 17:47 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-10-07 19:06 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
Instead of declaring xml_builtin as an extern variable
in the .c file.
gdb/gdbserver/ChangeLog:
2019-10-07 Christian Biesinger <cbiesinger@google.com>
* server.c (get_features_xml): Remove declaration of xml_builtin
in favor of including xml-support.h.
---
gdb/gdbserver/server.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 0bfff04fd7..da20340b7a 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -45,6 +45,10 @@
#include "gdbsupport/selftest.h"
#include "gdbsupport/scope-exit.h"
+#ifdef USE_XML
+#include "xml-support.h"
+#endif
+
#define require_running_or_return(BUF) \
if (!target_running ()) \
{ \
@@ -920,7 +924,6 @@ get_features_xml (const char *annex)
#ifdef USE_XML
{
- extern const char *const xml_builtin[][2];
int i;
/* Look for the annex. */
--
2.23.0.581.g78d2f28ef7-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Include xml-support.h to get a variable declaration
2019-10-07 19:06 [PATCH] Include xml-support.h to get a variable declaration Christian Biesinger via gdb-patches
@ 2019-10-09 17:47 ` Tom Tromey
2019-10-10 2:44 ` [PATCH v2] Create xml-builtin.h to declare xml_builtins cbiesinger
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2019-10-09 17:47 UTC (permalink / raw)
To: Christian Biesinger via gdb-patches; +Cc: Christian Biesinger
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
Christian> Instead of declaring xml_builtin as an extern variable
Christian> in the .c file.
Christian> gdb/gdbserver/ChangeLog:
Christian> 2019-10-07 Christian Biesinger <cbiesinger@google.com>
Christian> * server.c (get_features_xml): Remove declaration of xml_builtin
Christian> in favor of including xml-support.h.
I don't think we want to include xml-support.h in gdbserver.
Maybe the xml_builtin can be declared somewhere else instead.
It's only defined in generated files according to the comment.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] Create xml-builtin.h to declare xml_builtins
2019-10-09 17:47 ` Tom Tromey
@ 2019-10-10 2:44 ` cbiesinger
0 siblings, 0 replies; 3+ messages in thread
From: cbiesinger @ 2019-10-10 2:44 UTC (permalink / raw)
To: gdb-patches; +Cc: Christian Biesinger
From: Christian Biesinger <cbiesinger@google.com>
[Now updated to create a new header file xml-builtin.h]
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 <cbiesinger@google.com>
* Makefile.in: Add xml-builtin.h.
* features/feature_to_c.sh: Add an include for xml-buoltin.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 <cbiesinger@google.com>
* server.c: Include xml-builtin.h.
(get_xml_features): Don't declare xml_builtins here.
---
gdb/Makefile.in | 1 +
gdb/features/feature_to_c.sh | 2 ++
gdb/gdbserver/server.c | 4 +++-
gdb/xml-builtin.h | 28 ++++++++++++++++++++++++++++
gdb/xml-support.c | 3 ++-
gdb/xml-support.h | 5 -----
6 files changed, 36 insertions(+), 7 deletions(-)
create mode 100644 gdb/xml-builtin.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 36650ad555f..04a5cdbb3da 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1426,6 +1426,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 \
diff --git a/gdb/features/feature_to_c.sh b/gdb/features/feature_to_c.sh
index 2e7e0c72a82..ae83774fdf4 100755
--- a/gdb/features/feature_to_c.sh
+++ b/gdb/features/feature_to_c.sh
@@ -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'`
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 0bfff04fd76..25a2be86fb0 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 @@ 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
index 00000000000..972417df32e
--- /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 <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 */
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index eaf99efa6b9..915be76066d 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 @@ 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)
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index 7ceb9385454..aaa829d5195 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -45,11 +45,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. */
--
2.23.0.581.g78d2f28ef7-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-10 2:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 19:06 [PATCH] Include xml-support.h to get a variable declaration Christian Biesinger via gdb-patches
2019-10-09 17:47 ` Tom Tromey
2019-10-10 2:44 ` [PATCH v2] Create xml-builtin.h to declare xml_builtins cbiesinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).