[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gdb-patches
Subject:    RE: [PATCH] Fix AIX build break.
From:       Aditya Kamath1 <Aditya.Kamath1 () ibm ! com>
Date:       2024-01-31 9:15:05
Message-ID: CH2PR15MB3544BD28782FA7B1C6CFAD8ED67C2 () CH2PR15MB3544 ! namprd15 ! prod ! outlook ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

Respected Tom and community members,

Hi,

> This looks basically reasonable, but rather than subject you to another
> round of review, I just went ahead and made a few changes.  Could you
> try this out?

This patch builds AIX GDB successfully. I am okay with this.

> Basically there were some formatting issues and I thought the code ought
> to be in utils.c.
> +private:
> +  scoped_restore_tmpl<warning_hook_handler> m_save;

This is nice.

Thank you so much for your guidance. Kindly commit the patch version you pasted in \
the previous email.

> You may wish to send an email to the Insight list, warning them that
> this is going to break their build.

Sure. Will send an email to the insight list.

Have a nice day ahead.

Thanks and regards,
Aditya.


From: Tom Tromey <tom@tromey.com>
Date: Wednesday, 31 January 2024 at 6:11 AM
To: Aditya Kamath1 <Aditya.Kamath1@ibm.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.
> > > > > "Aditya" == Aditya Kamath1 <Aditya.Kamath1@ibm.com> writes:

Aditya> Please find attached a patch. (See: 0001-Fix-AIX-build-break.patch)

Aditya> Thank you for your feedback.

Thanks.

This looks basically reasonable, but rather than subject you to another
round of review, I just went ahead and made a few changes.  Could you
try this out?

Basically there were some formatting issues and I thought the code ought
to be in utils.c.

You may wish to send an email to the Insight list, warning them that
this is going to break their build.

Tom

From c67ddecdef06043a916a07ad34b3f4db090d377f Mon Sep 17 00:00:00 2001
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Date: Fri, 26 Jan 2024 02:19:52 -0600
Subject: [PATCH] Fix AIX build break.

A recent commit broke AIX build. The thread_local type defined functions
were being considered a weak symbol and hence while creating the binary these
symbols were not visible.

This patch is a fix for the same.
---
 gdb/complaints.c | 16 +++++++++-------
 gdb/complaints.h |  8 +++-----
 gdb/defs.h       |  2 --
 gdb/interps.c    |  1 -
 gdb/top.c        |  4 ----
 gdb/utils.c      | 23 +++++++++++++++++++++--
 gdb/utils.h      | 17 +++++++++++++++++
 7 files changed, 50 insertions(+), 21 deletions(-)

diff --git a/gdb/complaints.c b/gdb/complaints.c
index 0c46cd7c84f..496736fe95f 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -57,8 +57,9 @@ complaint_internal (const char *fmt, ...)

   va_start (args, fmt);

-  if (deprecated_warning_hook)
-    (*deprecated_warning_hook) (fmt, args);
+  warning_hook_handler handler = get_warning_hook_handler ();
+  if (handler != nullptr)
+    handler (fmt, args);
   else
     {
       gdb_puts (_("During symbol reading: "), gdb_stderr);
@@ -84,15 +85,15 @@ thread_local complaint_interceptor \
*complaint_interceptor::g_complaint_intercept  /* See complaints.h.  */

 complaint_interceptor::complaint_interceptor ()
-  : m_saved_warning_hook (&deprecated_warning_hook, issue_complaint),
-    m_saved_complaint_interceptor (&g_complaint_interceptor, this)
+  : m_saved_complaint_interceptor (&g_complaint_interceptor, this),
+    m_saved_warning_hook (issue_complaint)
 {
 }

 /* A helper that wraps a warning hook.  */

 static void
-wrap_warning_hook (void (*hook) (const char *, va_list), ...)
+wrap_warning_hook (warning_hook_handler hook, ...)
 {
   va_list args;
   va_start (args, hook);
@@ -109,8 +110,9 @@ re_emit_complaints (const complaint_collection &complaints)

   for (const std::string &str : complaints)
     {
-      if (deprecated_warning_hook)
-       wrap_warning_hook (deprecated_warning_hook, str.c_str ());
+      warning_hook_handler handler = get_warning_hook_handler ();
+      if (handler != nullptr)
+       wrap_warning_hook (handler, str.c_str ());
       else
         gdb_printf (gdb_stderr, _("During symbol reading: %s\n"),
                     str.c_str ());
diff --git a/gdb/complaints.h b/gdb/complaints.h
index baf10fd7dd7..8ac4c5034ee 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -89,11 +89,6 @@ class complaint_interceptor
   /* The issued complaints.  */
   complaint_collection m_complaints;

-  typedef void (*saved_warning_hook_ftype) (const char *, va_list);
-
-  /* The saved value of deprecated_warning_hook.  */
-  scoped_restore_tmpl<saved_warning_hook_ftype> m_saved_warning_hook;
-
   /* The saved value of g_complaint_interceptor.  */
   scoped_restore_tmpl<complaint_interceptor *> m_saved_complaint_interceptor;

@@ -104,6 +99,9 @@ class complaint_interceptor

   /* This object.  Used by the static callback function.  */
   static thread_local complaint_interceptor *g_complaint_interceptor;
+
+  /* Object to initialise the warning hook.  */
+  scoped_restore_warning_hook m_saved_warning_hook;
 };

 /* Re-emit complaints that were collected by complaint_interceptor.
diff --git a/gdb/defs.h b/gdb/defs.h
index f4664000641..cf471bf5d66 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -562,8 +562,6 @@ extern void (*deprecated_print_frame_info_listing_hook) (struct \
symtab * s,  int noerror);
 extern int (*deprecated_query_hook) (const char *, va_list)
      ATTRIBUTE_FPTR_PRINTF(1,0);
-extern thread_local void (*deprecated_warning_hook) (const char *, va_list)
-     ATTRIBUTE_FPTR_PRINTF(1,0);
 extern void (*deprecated_readline_begin_hook) (const char *, ...)
      ATTRIBUTE_FPTR_PRINTF_1;
 extern char *(*deprecated_readline_hook) (const char *);
diff --git a/gdb/interps.c b/gdb/interps.c
index eddc7f3c871..391fea1da03 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -273,7 +273,6 @@ clear_interpreter_hooks (void)
   deprecated_print_frame_info_listing_hook = 0;
   /*print_frame_more_info_hook = 0; */
   deprecated_query_hook = 0;
-  deprecated_warning_hook = 0;
   deprecated_readline_begin_hook = 0;
   deprecated_readline_hook = 0;
   deprecated_readline_end_hook = 0;
diff --git a/gdb/top.c b/gdb/top.c
index fb15c719564..5114713baa4 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -219,10 +219,6 @@ void (*deprecated_print_frame_info_listing_hook) (struct symtab \
* s,

 int (*deprecated_query_hook) (const char *, va_list);

-/* Replaces most of warning.  */
-
-thread_local void (*deprecated_warning_hook) (const char *, va_list);
-
 /* These three functions support getting lines of text from the user.
    They are used in sequence.  First deprecated_readline_begin_hook is
    called with a text string that might be (for example) a message for
diff --git a/gdb/utils.c b/gdb/utils.c
index b326033e9ff..702c3f15826 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -128,7 +128,26 @@ show_pagination_enabled (struct ui_file *file, int from_tty,
 }


+/* Warning hook pointer.  This has to be 'static' to avoid link
+   problems with thread-locals on AIX.  */

+static thread_local void (*warning_hook) (const char *, va_list);
+
+/* See utils.h.  */
+
+warning_hook_handler
+get_warning_hook_handler ()
+{
+  return warning_hook;
+}
+
+/* See utils.h.  */
+
+scoped_restore_warning_hook::scoped_restore_warning_hook
+     (warning_hook_handler new_handler)
+       : m_save (make_scoped_restore (&warning_hook, new_handler))
+{
+}

 /* Print a warning message.  The first argument STRING is the warning
    message, used as an fprintf format string, the second is the
@@ -139,8 +158,8 @@ show_pagination_enabled (struct ui_file *file, int from_tty,
 void
 vwarning (const char *string, va_list args)
 {
-  if (deprecated_warning_hook)
-    (*deprecated_warning_hook) (string, args);
+  if (warning_hook != nullptr)
+    warning_hook (string, args);
   else
     {
       std::optional<target_terminal::scoped_restore_terminal_state> term_state;
diff --git a/gdb/utils.h b/gdb/utils.h
index a9d04746b21..7487590902a 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -373,6 +373,23 @@ assign_return_if_changed (T &lval, const T &val)
   return true;
 }

+/* 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;
+};
+
+/* Return the current warning handler.  */
+extern warning_hook_handler get_warning_hook_handler ();
+
 /* In some cases GDB needs to try several different solutions to a problem,
    if any of the solutions work then as far as the user is concerned the
    problem is solved, and GDB should continue without warnings.  However,
--
2.43.0


[Attachment #3 (text/html)]

<html xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Aptos;
	panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:10.0pt;
	font-family:"Calibri",sans-serif;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;
	mso-ligatures:none;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style>
</head>
<body lang="EN-IN" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span \
style="font-size:11.0pt;mso-fareast-language:EN-US">Respected Tom and community \
members,<br> <br>
Hi,<br>
<br>
</span><span style="font-size:11.0pt;color:#212121">&gt;This looks basically \
reasonable, but rather than subject you to another<br> &gt;round of review, I just \
went ahead and made a few changes.&nbsp; Could you<br> &gt;try this out?</span><span \
style="font-family:&quot;Aptos&quot;,sans-serif;color:#212121"><o:p></o:p></span></p> \
<p class="MsoNormal"><span \
style="font-family:&quot;Aptos&quot;,sans-serif;color:#212121"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span style="font-size:11.0pt;color:#212121">This patch builds \
AIX GDB successfully. I am okay with this. <o:p></o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;color:#212121"><o:p>&nbsp;</o:p></span></p> <p \
class="MsoNormal"><span style="font-size:11.0pt">&gt;Basically there were some \
formatting issues and I thought the code ought<br> &gt;to be in \
utils.c.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt">&gt;+private:<br> &gt;+&nbsp; \
scoped_restore_tmpl&lt;warning_hook_handler&gt; m_save;<br> <br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">This is nice. \
<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt">Thank you so much for your guidance. Kindly commit the patch \
version you pasted in the previous email. <o:p></o:p></span></p>
<p class="MsoNormal"><span \
style="font-size:11.0pt;color:#212121"><o:p>&nbsp;</o:p></span></p> <p \
class="MsoNormal"><span style="font-size:11.0pt">&gt;You may wish to send an email to \
the Insight list, warning them that<br> &gt;this is going to break their \
build.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt">Sure. Will send an email to the insight \
list.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt">Have a nice day ahead.<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="font-size:11.0pt"><o:p>&nbsp;</o:p></span></p> <p \
class="MsoNormal"><span style="font-size:11.0pt">Thanks and regards,<br> \
Aditya.</span><span style="font-size:11.0pt;color:#212121"><o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p> <div \
id="mail-editor-reference-message-container"> <div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span \
style="font-size:12.0pt;font-family:&quot;Aptos&quot;,sans-serif;color:black">From: \
</span></b><span style="font-size:12.0pt;font-family:&quot;Aptos&quot;,sans-serif;color:black">Tom \
Tromey &lt;tom@tromey.com&gt;<br> <b>Date: </b>Wednesday, 31 January 2024 at \
6:11</span><span style="font-size:12.0pt;font-family:&quot;Arial&quot;,sans-serif;color:black"> </span><span \
style="font-size:12.0pt;font-family:&quot;Aptos&quot;,sans-serif;color:black">AM<br> \
<b>To: </b>Aditya Kamath1 &lt;Aditya.Kamath1@ibm.com&gt;<br> <b>Cc: </b>Tom Tromey \
&lt;tom@tromey.com&gt;, Ulrich Weigand &lt;Ulrich.Weigand@de.ibm.com&gt;, Sangamesh \
Mallayya &lt;sangamesh.swamy@in.ibm.com&gt;, Aditya Kamath1 via Gdb-patches \
&lt;gdb-patches@sourceware.org&gt;<br> <b>Subject: </b>[EXTERNAL] Re: [PATCH] Fix AIX \
build break.<o:p></o:p></span></p> </div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span \
style="font-size:11.0pt">&gt;&gt;&gt;&gt;&gt; &quot;Aditya&quot; == Aditya Kamath1 \
&lt;Aditya.Kamath1@ibm.com&gt; writes:<br> <br>
Aditya&gt; Please find attached a patch. (See: 0001-Fix-AIX-build-break.patch)<br>
<br>
Aditya&gt; Thank you for your feedback. <br>
<br>
Thanks.<br>
<br>
This looks basically reasonable, but rather than subject you to another<br>
round of review, I just went ahead and made a few changes.&nbsp; Could you<br>
try this out?<br>
<br>
Basically there were some formatting issues and I thought the code ought<br>
to be in utils.c.<br>
<br>
You may wish to send an email to the Insight list, warning them that<br>
this is going to break their build.<br>
<br>
Tom<br>
<br>
From c67ddecdef06043a916a07ad34b3f4db090d377f Mon Sep 17 00:00:00 2001<br>
From: Aditya Vidyadhar Kamath &lt;Aditya.Kamath1@ibm.com&gt;<br>
Date: Fri, 26 Jan 2024 02:19:52 -0600<br>
Subject: [PATCH] Fix AIX build break.<br>
<br>
A recent commit broke AIX build. The thread_local type defined functions<br>
were being considered a weak symbol and hence while creating the binary these<br>
symbols were not visible.<br>
<br>
This patch is a fix for the same.<br>
---<br>
&nbsp;gdb/complaints.c | 16 +++++++++-------<br>
&nbsp;gdb/complaints.h |&nbsp; 8 +++-----<br>
&nbsp;gdb/defs.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; 2 --<br>
&nbsp;gdb/interps.c&nbsp;&nbsp;&nbsp; |&nbsp; 1 -<br>
&nbsp;gdb/top.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; 4 ----<br>
&nbsp;gdb/utils.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 23 +++++++++++++++++++++--<br>
&nbsp;gdb/utils.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 17 +++++++++++++++++<br>
&nbsp;7 files changed, 50 insertions(+), 21 deletions(-)<br>
<br>
diff --git a/gdb/complaints.c b/gdb/complaints.c<br>
index 0c46cd7c84f..496736fe95f 100644<br>
--- a/gdb/complaints.c<br>
+++ b/gdb/complaints.c<br>
@@ -57,8 +57,9 @@ complaint_internal (const char *fmt, ...)<br>
&nbsp;<br>
&nbsp;&nbsp; va_start (args, fmt);<br>
&nbsp;<br>
-&nbsp; if (deprecated_warning_hook)<br>
-&nbsp;&nbsp;&nbsp; (*deprecated_warning_hook) (fmt, args);<br>
+&nbsp; warning_hook_handler handler = get_warning_hook_handler ();<br>
+&nbsp; if (handler != nullptr)<br>
+&nbsp;&nbsp;&nbsp; handler (fmt, args);<br>
&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gdb_puts (_(&quot;During symbol reading: \
&quot;), gdb_stderr);<br> @@ -84,15 +85,15 @@ thread_local complaint_interceptor \
*complaint_interceptor::g_complaint_intercept<br> &nbsp;/* See complaints.h.&nbsp; \
*/<br> &nbsp;<br>
&nbsp;complaint_interceptor::complaint_interceptor ()<br>
-&nbsp; : m_saved_warning_hook (&amp;deprecated_warning_hook, issue_complaint),<br>
-&nbsp;&nbsp;&nbsp; m_saved_complaint_interceptor (&amp;g_complaint_interceptor, \
this)<br> +&nbsp; : m_saved_complaint_interceptor (&amp;g_complaint_interceptor, \
this),<br> +&nbsp;&nbsp;&nbsp; m_saved_warning_hook (issue_complaint)<br>
&nbsp;{<br>
&nbsp;}<br>
&nbsp;<br>
&nbsp;/* A helper that wraps a warning hook.&nbsp; */<br>
&nbsp;<br>
&nbsp;static void<br>
-wrap_warning_hook (void (*hook) (const char *, va_list), ...)<br>
+wrap_warning_hook (warning_hook_handler hook, ...)<br>
&nbsp;{<br>
&nbsp;&nbsp; va_list args;<br>
&nbsp;&nbsp; va_start (args, hook);<br>
@@ -109,8 +110,9 @@ re_emit_complaints (const complaint_collection \
&amp;complaints)<br> &nbsp;<br>
&nbsp;&nbsp; for (const std::string &amp;str : complaints)<br>
&nbsp;&nbsp;&nbsp;&nbsp; {<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (deprecated_warning_hook)<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wrap_warning_hook (deprecated_warning_hook, \
str.c_str ());<br> +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; warning_hook_handler handler = \
get_warning_hook_handler ();<br> +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (handler != \
nullptr)<br> +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wrap_warning_hook (handler, \
str.c_str ());<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gdb_printf (gdb_stderr, \
_(&quot;During symbol reading: %s\n&quot;),<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                str.c_str ());<br>
diff --git a/gdb/complaints.h b/gdb/complaints.h<br>
index baf10fd7dd7..8ac4c5034ee 100644<br>
--- a/gdb/complaints.h<br>
+++ b/gdb/complaints.h<br>
@@ -89,11 +89,6 @@ class complaint_interceptor<br>
&nbsp;&nbsp; /* The issued complaints.&nbsp; */<br>
&nbsp;&nbsp; complaint_collection m_complaints;<br>
&nbsp;<br>
-&nbsp; typedef void (*saved_warning_hook_ftype) (const char *, va_list);<br>
-<br>
-&nbsp; /* The saved value of deprecated_warning_hook.&nbsp; */<br>
-&nbsp; scoped_restore_tmpl&lt;saved_warning_hook_ftype&gt; m_saved_warning_hook;<br>
-<br>
&nbsp;&nbsp; /* The saved value of g_complaint_interceptor.&nbsp; */<br>
&nbsp;&nbsp; scoped_restore_tmpl&lt;complaint_interceptor *&gt; \
m_saved_complaint_interceptor;<br> &nbsp;<br>
@@ -104,6 +99,9 @@ class complaint_interceptor<br>
&nbsp;<br>
&nbsp;&nbsp; /* This object.&nbsp; Used by the static callback function.&nbsp; */<br>
&nbsp;&nbsp; static thread_local complaint_interceptor *g_complaint_interceptor;<br>
+<br>
+&nbsp; /* Object to initialise the warning hook.&nbsp; */<br>
+&nbsp; scoped_restore_warning_hook m_saved_warning_hook;<br>
&nbsp;};<br>
&nbsp;<br>
&nbsp;/* Re-emit complaints that were collected by complaint_interceptor.<br>
diff --git a/gdb/defs.h b/gdb/defs.h<br>
index f4664000641..cf471bf5d66 100644<br>
--- a/gdb/defs.h<br>
+++ b/gdb/defs.h<br>
@@ -562,8 +562,6 @@ extern void (*deprecated_print_frame_info_listing_hook) (struct \
symtab * s,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n \
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
int noerror);<br> &nbsp;extern int (*deprecated_query_hook) (const char *, \
va_list)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ATTRIBUTE_FPTR_PRINTF(1,0);<br>
-extern thread_local void (*deprecated_warning_hook) (const char *, va_list)<br>
-&nbsp;&nbsp;&nbsp;&nbsp; ATTRIBUTE_FPTR_PRINTF(1,0);<br>
&nbsp;extern void (*deprecated_readline_begin_hook) (const char *, ...)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ATTRIBUTE_FPTR_PRINTF_1;<br>
&nbsp;extern char *(*deprecated_readline_hook) (const char *);<br>
diff --git a/gdb/interps.c b/gdb/interps.c<br>
index eddc7f3c871..391fea1da03 100644<br>
--- a/gdb/interps.c<br>
+++ b/gdb/interps.c<br>
@@ -273,7 +273,6 @@ clear_interpreter_hooks (void)<br>
&nbsp;&nbsp; deprecated_print_frame_info_listing_hook = 0;<br>
&nbsp;&nbsp; /*print_frame_more_info_hook = 0; */<br>
&nbsp;&nbsp; deprecated_query_hook = 0;<br>
-&nbsp; deprecated_warning_hook = 0;<br>
&nbsp;&nbsp; deprecated_readline_begin_hook = 0;<br>
&nbsp;&nbsp; deprecated_readline_hook = 0;<br>
&nbsp;&nbsp; deprecated_readline_end_hook = 0;<br>
diff --git a/gdb/top.c b/gdb/top.c<br>
index fb15c719564..5114713baa4 100644<br>
--- a/gdb/top.c<br>
+++ b/gdb/top.c<br>
@@ -219,10 +219,6 @@ void (*deprecated_print_frame_info_listing_hook) (struct symtab \
* s,<br> &nbsp;<br>
&nbsp;int (*deprecated_query_hook) (const char *, va_list);<br>
&nbsp;<br>
-/* Replaces most of warning.&nbsp; */<br>
-<br>
-thread_local void (*deprecated_warning_hook) (const char *, va_list);<br>
-<br>
&nbsp;/* These three functions support getting lines of text from the user.<br>
&nbsp;&nbsp;&nbsp; They are used in sequence.&nbsp; First \
deprecated_readline_begin_hook is<br> &nbsp;&nbsp;&nbsp; called with a text string \
                that might be (for example) a message for<br>
diff --git a/gdb/utils.c b/gdb/utils.c<br>
index b326033e9ff..702c3f15826 100644<br>
--- a/gdb/utils.c<br>
+++ b/gdb/utils.c<br>
@@ -128,7 +128,26 @@ show_pagination_enabled (struct ui_file *file, int from_tty,<br>
&nbsp;}<br>
&nbsp;<br>
&nbsp; <br>
+/* Warning hook pointer.&nbsp; This has to be 'static' to avoid link<br>
+&nbsp;&nbsp; problems with thread-locals on AIX.&nbsp; */<br>
&nbsp;<br>
+static thread_local void (*warning_hook) (const char *, va_list);<br>
+<br>
+/* See utils.h.&nbsp; */<br>
+<br>
+warning_hook_handler<br>
+get_warning_hook_handler ()<br>
+{<br>
+&nbsp; return warning_hook;<br>
+}<br>
+<br>
+/* See utils.h.&nbsp; */<br>
+<br>
+scoped_restore_warning_hook::scoped_restore_warning_hook<br>
+&nbsp;&nbsp;&nbsp;&nbsp; (warning_hook_handler new_handler)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : m_save (make_scoped_restore \
(&amp;warning_hook, new_handler))<br> +{<br>
+}<br>
&nbsp;<br>
&nbsp;/* Print a warning message.&nbsp; The first argument STRING is the warning<br>
&nbsp;&nbsp;&nbsp; message, used as an fprintf format string, the second is the<br>
@@ -139,8 +158,8 @@ show_pagination_enabled (struct ui_file *file, int from_tty,<br>
&nbsp;void<br>
&nbsp;vwarning (const char *string, va_list args)<br>
&nbsp;{<br>
-&nbsp; if (deprecated_warning_hook)<br>
-&nbsp;&nbsp;&nbsp; (*deprecated_warning_hook) (string, args);<br>
+&nbsp; if (warning_hook != nullptr)<br>
+&nbsp;&nbsp;&nbsp; warning_hook (string, args);<br>
&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                std::optional&lt;target_terminal::scoped_restore_terminal_state&gt; \
                term_state;<br>
diff --git a/gdb/utils.h b/gdb/utils.h<br>
index a9d04746b21..7487590902a 100644<br>
--- a/gdb/utils.h<br>
+++ b/gdb/utils.h<br>
@@ -373,6 +373,23 @@ assign_return_if_changed (T &amp;lval, const T &amp;val)<br>
&nbsp;&nbsp; return true;<br>
&nbsp;}<br>
&nbsp;<br>
+/* A function that can be used to intercept warnings.&nbsp; */<br>
+typedef void (*warning_hook_handler) (const char *, va_list);<br>
+<br>
+/* Set the thread-local warning hook, and restore the old value when<br>
+&nbsp;&nbsp; finished.&nbsp; */<br>
+class scoped_restore_warning_hook<br>
+{<br>
+public:<br>
+&nbsp; explicit scoped_restore_warning_hook (warning_hook_handler new_handler);<br>
+<br>
+private:<br>
+&nbsp; scoped_restore_tmpl&lt;warning_hook_handler&gt; m_save;<br>
+};<br>
+<br>
+/* Return the current warning handler.&nbsp; */<br>
+extern warning_hook_handler get_warning_hook_handler ();<br>
+<br>
&nbsp;/* In some cases GDB needs to try several different solutions to a problem,<br>
&nbsp;&nbsp;&nbsp; if any of the solutions work then as far as the user is concerned \
the<br> &nbsp;&nbsp;&nbsp; problem is solved, and GDB should continue without \
                warnings.&nbsp; However,<br>
-- <br>
2.43.0<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic