From patchwork Thu May 21 04:00:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 135377 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B6CF34BB8F45 for ; Thu, 21 May 2026 05:09:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6CF34BB8F45 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=P0UH6fmb X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 544CC4BA7985 for ; Thu, 21 May 2026 04:01:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 544CC4BA7985 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 544CC4BA7985 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779336081; cv=none; b=ZtqGYGoNrVFXuBk4Ggpxr+bMAaTaFMjI/yJhciD3t3yYitCKGsssTLF+mSvkVqHbwZNaC9Zr6tQSggYJlvIB5I+WnZG87vauGoMzzGEVyvuio2J/vgANb4SgZR5/yfgf/0ImYlsnFsR54O1PAvguSKd38J4cuui/0N/qrhVlsWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779336081; c=relaxed/simple; bh=CfycKwylq+ZlYmlp5b4sbezhQZ57NVKyU38MFSFnwsM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EClMu5H+ymzOPmjqaREfZt3zkgWbuS7xHuR+e5OPRJrrvzlsmO/80GZA/FXtR1ygwFPZb7A4nek4P0Rs3B7xUK+Bzb/owlIyXF5/spMGDXv0h5T7eB8Zg1Q8ubyywHQUybVWSSRoS2Qd41mlh613R6fMTnpiyU6f8Z0F7/jP1fI= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=P0UH6fmb DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 544CC4BA7985 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 64L41ECd093779 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 May 2026 00:01:18 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 64L41ECd093779 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1779336079; bh=x+D/T7xozOfnlKlgyzp8YUS9p4owYgVL6mLwBJF73j4=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=P0UH6fmbwRMYyukqr9joCiG7UOKioOaedOezBr2TQwbSxIh+Gwk3pTKvTpI4j157/ aprbBw+YKw/kyuiChGAVJu72y545WRcNF98ckrjCk/qyvLLhWfQlMb1WYyX9TaLBd6 /v7E+0R3AJXJiatTs6AnPBNM8J6u/ibiayUGTQ2Ccy3pcLofJMIkW1no0QARb5DFaB 7s6QICKrybIYsLDGZ9yvTawYYZWG6N8QJMl6cN9ooUELl8y+zgZ/oo403igbIHyR8c aO9pYV+ySYi9uEAdX6sdFBTVkrifE48H74DIyEAUhYYsxTt0Q8TLPK8p2Gj1jT6ZmM 96ehaSuHZSdsA== Received: by simark.ca (Postfix) id 2703A1E08D; Thu, 21 May 2026 00:01:13 -0400 (EDT) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] gdb: remove complaint_interceptor::g_complaint_interceptor Date: Thu, 21 May 2026 00:00:49 -0400 Message-ID: <20260521040112.1618748-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260521040112.1618748-1-simon.marchi@polymtl.ca> References: <20260521040112.1618748-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 21 May 2026 04:01:14 +0000 X-Spam-Status: No, score=-3034.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org From: Simon Marchi 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 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 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; };