aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>2024-01-26 02:19:52 -0600
committerTom Tromey <tom@tromey.com>2024-01-31 17:30:25 -0700
commit49346fa79442ba6f0be832c2c5af4360e52f070a (patch)
treef35762eeb12117683df413823fcba61da533b6fb /gdb
parent3d4b08fb895826ec5f0f6c36a3be98f955aa74ea (diff)
downloadgdb-49346fa79442ba6f0be832c2c5af4360e52f070a.zip
gdb-49346fa79442ba6f0be832c2c5af4360e52f070a.tar.gz
gdb-49346fa79442ba6f0be832c2c5af4360e52f070a.tar.bz2
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/complaints.c16
-rw-r--r--gdb/complaints.h8
-rw-r--r--gdb/defs.h2
-rw-r--r--gdb/interps.c1
-rw-r--r--gdb/top.c4
-rw-r--r--gdb/utils.c23
-rw-r--r--gdb/utils.h17
7 files changed, 50 insertions, 21 deletions
diff --git a/gdb/complaints.c b/gdb/complaints.c
index 0c46cd7..496736f 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 baf10fd..8ac4c50 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -89,11 +89,6 @@ private:
/* 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 @@ private:
/* 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 f466400..cf471bf 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 eddc7f3..391fea1 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 fb15c71..5114713 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 b326033..702c3f1 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 a9d0474..7487590 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,