From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/2] gdb: remove complaint_interceptor::g_complaint_interceptor
Date: Thu, 21 May 2026 00:00:49 -0400 [thread overview]
Message-ID: <20260521040112.1618748-2-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20260521040112.1618748-1-simon.marchi@polymtl.ca>
From: Simon Marchi <simon.marchi@polymtl.ca>
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
---
gdb/complaints.c | 9 ++-------
gdb/complaints.h | 7 -------
2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/gdb/complaints.c b/gdb/complaints.c
index ab6e2049685c..e3d68a869c99 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -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
diff --git a/gdb/complaints.h b/gdb/complaints.h
index c607194e265e..8f5cf24c1c9b 100644
--- a/gdb/complaints.h
+++ b/gdb/complaints.h
@@ -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 @@ class complaint_interceptor final : public warning_hook_handler_type
/* 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;
};
--
2.54.0
next prev parent reply other threads:[~2026-05-21 5:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 4:00 [PATCH 1/2] gdb: lock complaint_mutex in clear_complaints simon.marchi
2026-05-21 4:00 ` simon.marchi [this message]
2026-05-21 14:34 ` [PATCH 2/2] gdb: remove complaint_interceptor::g_complaint_interceptor Tom Tromey
2026-05-21 17:51 ` Simon Marchi
2026-05-21 14:25 ` [PATCH 1/2] gdb: lock complaint_mutex in clear_complaints Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260521040112.1618748-2-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox