[PATCH] Fix AIX build break.

Aditya Kamath1 Aditya.Kamath1@ibm.com
Tue Feb 6 15:54:00 GMT 2024


Hi Ciaran and respected community members,

Thank you for reaching out.

>I did have success with the following (pasted) patch, so I can submit that
>properly if it isn't going to break anything for the AIX build, but also
>open to other suggestions.

GDB in AIX builds successfully with the patch you pasted in the previous email. We are okay with the fix.

Kindly let us know if you want to check anything else in AIX operating system.

Have a nice day ahead.

Thanks and regards,
Aditya.

From: Ciaran Woodward <ciaranwoodward@xmos.com>
Date: Tuesday, 6 February 2024 at 6:07 PM
To: Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Tom Tromey <tom@tromey.com>
Cc: Tom Tromey <tom@tromey.com>, Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>, Aditya Kamath1 via Gdb-patches <gdb-patches@sourceware.org>
Subject: [EXTERNAL] RE: [PATCH] Fix AIX build break.
> +/* A function that can be used to intercept warnings.  */
> +typedef void (*warning_hook_handler) (const char *, va_list);
> +
> +/* Set the thread-local warning hook, and restore the old value when
> +   finished.  */
> +class scoped_restore_warning_hook
> +{
> +public:
> +  explicit scoped_restore_warning_hook (warning_hook_handler new_handler);
> +
> +private:
> +  scoped_restore_tmpl<warning_hook_handler> m_save;
> +};

This part of the patch seems to have broken the build on mingw-64 gcc 13.2.0.

I think it is because va_list on that platform has some attributes.

Example (Werror) warning:

In file included from ../../gdb/defs.h:620,
                 from ../../gdb/x86-tdep.c:20:
../../gdb/utils.h:387:43: error: ignoring attributes on template argument 'warning_hook_handler' {aka 'void (*)(const char*, char*)'} [-Werror=ignored-attributes]
  387 |   scoped_restore_tmpl<warning_hook_handler> m_save;
      |                                           ^

I'm not sure what the 'best' solution is, as we don't really care about the
type attributes in this context, as we're just saving and restoring it.

I did have success with the following (pasted) patch, so I can submit that
properly if it isn't going to break anything for the AIX build, but also
open to other suggestions.

""""""
diff --git a/gdb/utils.c b/gdb/utils.c
index 702c3f15826..9d8a6443b37 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -145,7 +145,8 @@ get_warning_hook_handler ()

 scoped_restore_warning_hook::scoped_restore_warning_hook
      (warning_hook_handler new_handler)
-       : m_save (make_scoped_restore (&warning_hook, new_handler))
+       : m_save (make_scoped_restore (reinterpret_cast<void(**)()>(&warning_hook),
+                                      reinterpret_cast<void(*)()>(new_handler)))
 {
 }

diff --git a/gdb/utils.h b/gdb/utils.h
index 7487590902a..bea19369b9b 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -384,7 +384,7 @@ class scoped_restore_warning_hook
   explicit scoped_restore_warning_hook (warning_hook_handler new_handler);

 private:
-  scoped_restore_tmpl<warning_hook_handler> m_save;
+  scoped_restore_tmpl<void(*)()> m_save;
 };

 /* Return the current warning handler.  */
""""""

Cheers,
Ciaran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20240206/bdad9fc0/attachment-0001.htm>


More information about the Gdb-patches mailing list