Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0
@ 2026-10-11 13:31 Simon Marchi
  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
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Marchi @ 2026-10-11 13:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] gdb: remove workarounds for old expat versions
  2026-10-11 13:31 [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0 Simon Marchi
@ 2026-10-11 13:31 ` Simon Marchi
  2026-10-13  9:23 ` [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0 Tom de Vries
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2026-10-11 13:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb_expat.h provides fallback definitions of XML_STATUS_OK,
XML_STATUS_ERROR and XMLCALL for versions that lack them.  xml-support.c
only calls XML_StopParser if configure found it.  These workarounds were
relevant for the Expat 1.95.x versions, which is not relevant anymore
(Expat 2 was released 20 years ago).

Remove AC_CHECK_FUNCS(XML_StopParser) and the conditional in
xml-support.c.

Remove the fallback definitions from gdb_expat.h.

Change-Id: Ia0d0dd692518c190dfb97644be3bb2f3b4082b05
---
 gdb/config.in     |  3 ---
 gdb/configure     | 15 ---------------
 gdb/configure.ac  |  5 -----
 gdb/gdb_expat.h   | 13 -------------
 gdb/xml-support.c |  2 --
 5 files changed, 38 deletions(-)

diff --git a/gdb/config.in b/gdb/config.in
index 0e5a6637c2b1..8afa32f83e7f 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -628,9 +628,6 @@
 /* Define to 1 if you have the <ws2tcpip.h> header file. */
 #undef HAVE_WS2TCPIP_H
 
-/* Define to 1 if you have the `XML_StopParser' function. */
-#undef HAVE_XML_STOPPARSER
-
 /* Define to 1 if zstd is enabled. */
 #undef HAVE_ZSTD
 
diff --git a/gdb/configure b/gdb/configure
index 810e9ed7a378..9487c2c55001 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -28249,21 +28249,6 @@ $as_echo "$LIBEXPAT" >&6; }
       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: expat is missing or unusable; some features may be unavailable." >&5
 $as_echo "$as_me: WARNING: expat is missing or unusable; some features may be unavailable." >&2;}
     fi
-  else
-    save_LIBS=$LIBS
-    LIBS="$LIBS $LIBEXPAT"
-    for ac_func in XML_StopParser
-do :
-  ac_fn_c_check_func "$LINENO" "XML_StopParser" "ac_cv_func_XML_StopParser"
-if test "x$ac_cv_func_XML_StopParser" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_XML_STOPPARSER 1
-_ACEOF
-
-fi
-done
-
-    LIBS=$save_LIBS
   fi
 fi
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 0d88a280b163..b1f19cb80ee0 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -796,11 +796,6 @@ else
     else
       AC_MSG_WARN([expat is missing or unusable; some features may be unavailable.])
     fi
-  else
-    save_LIBS=$LIBS
-    LIBS="$LIBS $LIBEXPAT"
-    AC_CHECK_FUNCS(XML_StopParser)
-    LIBS=$save_LIBS
   fi
 fi
 
diff --git a/gdb/gdb_expat.h b/gdb/gdb_expat.h
index 756cf81be95c..4b9ed1ac1381 100644
--- a/gdb/gdb_expat.h
+++ b/gdb/gdb_expat.h
@@ -22,19 +22,6 @@
 
 #include <expat.h>
 
-/* Expat 1.95.x does not define these; this is the definition
-   recommended by the expat 2.0 headers.  */
-#ifndef XML_STATUS_OK
-# define XML_STATUS_OK    1
-# define XML_STATUS_ERROR 0
-#endif
-
-/* Old versions of expat do not define this macro, so define it
-   as void.  */
-#ifndef XMLCALL
-#define XMLCALL
-#endif
-
 /* Return the line number of PARSER's current position.
 
    Expat 2.9.0 deprecates XML_GetCurrentLineNumber in favor of
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 7d86dbb8c698..0e33ce54d12e 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -117,9 +117,7 @@ struct gdb_xml_parser
   void set_error (gdb_exception &&error)
   {
     m_error = std::move (error);
-#ifdef HAVE_XML_STOPPARSER
     XML_StopParser (m_expat_parser, XML_FALSE);
-#endif
   }
 
   /* Return the underlying expat parser.  */
-- 
2.56.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0
  2026-10-11 13:31 [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0 Simon Marchi
  2026-10-11 13:31 ` [PATCH 2/2] gdb: remove workarounds for old expat versions Simon Marchi
@ 2026-10-13  9:23 ` Tom de Vries
  2026-10-13 14:54   ` Simon Marchi
  1 sibling, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2026-10-13  9:23 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 10/11/26 3:31 PM, Simon Marchi wrote:
> 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.
> 

Hi Simon.

I ran into the same issue on Tumbleweed.

I applied this series, and I managed to complete the build.

Both patches LGTM.

Reviewed-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0
  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
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2026-10-13 14:54 UTC (permalink / raw)
  To: Tom de Vries, Simon Marchi, gdb-patches

On 10/13/26 5:23 AM, Tom de Vries wrote:
> On 10/11/26 3:31 PM, Simon Marchi wrote:
>> 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.
>>
> 
> Hi Simon.
> 
> I ran into the same issue on Tumbleweed.
> 
> I applied this series, and I managed to complete the build.
> 
> Both patches LGTM.
> 
> Reviewed-By: Tom de Vries <tdevries@suse.de>

Thanks, pushed both.

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-13 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-11 13:31 [PATCH 1/2] gdb: use XML_GetCurrentLineNumber64 with expat >= 2.9.0 Simon Marchi
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox