Browse Source

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.
master
Aditya Vidyadhar Kamath 3 years ago
committed by Tom Tromey
parent
commit
49346fa794
  1. 16
      gdb/complaints.c
  2. 8
      gdb/complaints.h
  3. 2
      gdb/defs.h
  4. 1
      gdb/interps.c
  5. 4
      gdb/top.c
  6. 23
      gdb/utils.c
  7. 17
      gdb/utils.h

16
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 ());

8
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.

2
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 *);

1
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;

4
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

23
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;

17
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,

Loading…
Cancel
Save