Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0
Date: Sun, 11 Oct 2026 09:31:13 -0400	[thread overview]
Message-ID: <20261011133136.472634-1-simon.marchi@efficios.com> (raw)

When building against expat 2.9.0, I get:

      CXX    xml-support.o
    /home/smarchi/src/binutils-gdb/gdb/xml-support.c:182:39: error: 'XML_Size XML_GetCurrentLineNumber(XML_Parser)' is deprecated: please use XML_GetCurrentLineNumber64 instead [-Werror=deprecated-declarations]
      182 |   int line = XML_GetCurrentLineNumber (m_expat_parser);
          |              ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

The functions that return XML_Size were deprecated in favor of the new
functions, with suffix 64, that return uint64_t.

Add a gdb_xml_get_current_line_number wrapper in gdb_expat.h, which
calls XML_GetCurrentLineNumber64 with expat 2.9.0 and later, and
XML_GetCurrentLineNumber otherwise.  Use it in xml-support.c.

The uint64_t gets truncated when converted to int, but that was already
true before, as XML_Size is 64-bits when building on an arch where
unsigned long is 64-bits.

Change-Id: I31a0657702cf45d9d7572276d5c8cc37aed41f79
---
 gdb/gdb_expat.h   | 16 ++++++++++++++++
 gdb/xml-support.c |  4 ++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gdb/gdb_expat.h b/gdb/gdb_expat.h
index 1feac7f764c0..756cf81be95c 100644
--- a/gdb/gdb_expat.h
+++ b/gdb/gdb_expat.h
@@ -35,4 +35,20 @@
 #define XMLCALL
 #endif
 
+/* Return the line number of PARSER's current position.
+
+   Expat 2.9.0 deprecates XML_GetCurrentLineNumber in favor of
+   XML_GetCurrentLineNumber64.  */
+
+static inline std::uint64_t
+gdb_xml_get_current_line_number (XML_Parser parser)
+{
+#if (XML_MAJOR_VERSION > 2 \
+     || (XML_MAJOR_VERSION == 2 && XML_MINOR_VERSION >= 9))
+  return XML_GetCurrentLineNumber64 (parser);
+#else
+  return XML_GetCurrentLineNumber (parser);
+#endif
+}
+
 #endif /* GDB_GDB_EXPAT_H */
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index d806b53c9fa2..7d86dbb8c698 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -179,7 +179,7 @@ gdb_xml_body_text (void *data, const XML_Char *text, int length)
 void
 gdb_xml_parser::vdebug (const char *format, va_list ap)
 {
-  int line = XML_GetCurrentLineNumber (m_expat_parser);
+  int line = gdb_xml_get_current_line_number (m_expat_parser);
 
   std::string message = string_vprintf (format, ap);
   if (line)
@@ -208,7 +208,7 @@ gdb_xml_debug (struct gdb_xml_parser *parser, const char *format, ...)
 void
 gdb_xml_parser::verror (const char *format, va_list ap)
 {
-  int line = XML_GetCurrentLineNumber (m_expat_parser);
+  int line = gdb_xml_get_current_line_number (m_expat_parser);
 
   m_last_line = line;
   throw_verror (XML_PARSE_ERROR, format, ap);

base-commit: 0aeb555307247b71116fd063f436d9311aadfbe0
-- 
2.56.0


             reply	other threads:[~2026-10-11 13:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 13:31 Simon Marchi [this message]
2026-10-11 13:31 ` [PATCH 2/2] gdb: remove workarounds for old expat versions Simon Marchi
2026-10-13  9:23 ` [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0 Tom de Vries
2026-10-13 14:54   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261011133136.472634-1-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox