]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove complaint_interceptor::g_complaint_interceptor
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 21 May 2026 04:00:49 +0000 (00:00 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 21 May 2026 17:48:59 +0000 (13:48 -0400)
The thread_local g_complaint_interceptor pointer is unnecessary.  The
complaint_interceptor constructor registers itself as the warning hook
via m_saved_warning_hook (this), so when complaint_internal dispatches
through the warning hook, it lands in complaint_interceptor::warn with
'this' already pointing at the registered interceptor.  Inside warn,
g_complaint_interceptor and 'this' always refer to the same object.

Replace g_complaint_interceptor->m_complaints with m_complaints in
complaint_interceptor::warn and remove g_complaint_interceptor.

Change-Id: I75565a5f2c0e51363f36be0e3544210c10bb5491
Approved-By: Tom Tromey <tom@tromey.com>
gdb/complaints.c
gdb/complaints.h

index ab6e2049685c25e26da6842fb4ec45eae6765dc3..e3d68a869c991e40d4b8fa0c25e6f70e6cdc696a 100644 (file)
@@ -77,13 +77,8 @@ clear_complaints ()
 
 /* See complaints.h.  */
 
-thread_local complaint_interceptor *complaint_interceptor::g_complaint_interceptor;
-
-/* See complaints.h.  */
-
 complaint_interceptor::complaint_interceptor ()
-  : m_saved_complaint_interceptor (&g_complaint_interceptor, this),
-    m_saved_warning_hook (this)
+  : m_saved_warning_hook (this)
 {
 }
 
@@ -122,7 +117,7 @@ void
 complaint_interceptor::warn (const char *fmt, va_list args)
 {
   gdb::lock_guard<gdb::mutex> guard (complaint_mutex);
-  g_complaint_interceptor->m_complaints.insert (string_vprintf (fmt, args));
+  m_complaints.insert (string_vprintf (fmt, args));
 }
 
 static void
index c607194e265e9d4f115dd45f3e13807d7573cd6a..8f5cf24c1c9b8895d07f8224fb0b93c11c0c228d 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef GDB_COMPLAINTS_H
 #define GDB_COMPLAINTS_H
 
-#include "gdbsupport/scoped_restore.h"
 #include "gdbsupport/unordered_set.h"
 
 /* Helper for complaint.  */
@@ -89,17 +88,11 @@ private:
   /* The issued complaints.  */
   complaint_collection m_complaints;
 
-  /* The saved value of g_complaint_interceptor.  */
-  scoped_restore_tmpl<complaint_interceptor *> m_saved_complaint_interceptor;
-
   /* A helper function that is used by the 'complaint' implementation
      to issue a complaint.  */
   void warn (const char *, va_list) override
     ATTRIBUTE_PRINTF (2, 0);
 
-  /* 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;
 };