From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 0746E3858C62 for ; Thu, 5 Jan 2023 20:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0746E3858C62 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca 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 305K2eLn009516 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Jan 2023 15:02:44 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 305K2eLn009516 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1672948965; bh=y66i7Hz3zQ+F1dhbBT/8mRZPYbOxwfWcktfJwgrnFqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Artmc831WDoFs+kx5AYJ8KfzSu/vxLz6+Ag0QygCg9IfNmcg7M5K3exbrue26/JsX YEyyIUv2pA1rwtPXbFv/QxfhrOhm5PaFQrqaLCMQdB9D6uLgPnzQUHgj9DEKgka5W5 nzNG8Gz2nbg9OvPCRSFFqZm2IqTjauC39LOP11io= Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id A2F821E222; Thu, 5 Jan 2023 15:02:39 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Pedro Alves , Simon Marchi , Andrew Burgess Subject: [PATCH v2 2/8] gdb: make install_breakpoint return a non-owning reference Date: Thu, 5 Jan 2023 15:02:31 -0500 Message-Id: <20230105200237.987771-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105200237.987771-1-simon.marchi@polymtl.ca> References: <20230105200237.987771-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 5 Jan 2023 20:02:40 +0000 X-Spam-Status: No, score=-3189.4 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_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Pedro Alves A following patch will want to install a breakpoint and then keep a non-owning reference to it. Make install_breakpoint return a non-owning reference, to make that easy. Co-Authored-By: Simon Marchi Change-Id: I2e8106a784021ff276ce251e24708cbdccc2d479 Approved-By: Andrew Burgess --- gdb/breakpoint.c | 4 +++- gdb/breakpoint.h | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8cfc46e0bed4..5778a5c64dfb 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7956,7 +7956,7 @@ catchpoint::catchpoint (struct gdbarch *gdbarch, bool temp, pspace = current_program_space; } -void +breakpoint * install_breakpoint (int internal, std::unique_ptr &&arg, int update_gll) { breakpoint *b = add_to_breakpoint_chain (std::move (arg)); @@ -7969,6 +7969,8 @@ install_breakpoint (int internal, std::unique_ptr &&arg, int update_ if (update_gll) update_global_location_list (UGLL_MAY_INSERT); + + return b; } static int diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 7289a09e95c5..93267a1d177f 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1480,10 +1480,12 @@ extern void target and breakpoint_created observers of its existence. If INTERNAL is non-zero, the breakpoint number will be allocated from the internal breakpoint count. If UPDATE_GLL is non-zero, - update_global_location_list will be called. */ + update_global_location_list will be called. -extern void install_breakpoint (int internal, std::unique_ptr &&b, - int update_gll); + Takes ownership of B, and returns a non-owning reference to it. */ + +extern breakpoint *install_breakpoint + (int internal, std::unique_ptr &&b, int update_gll); /* Returns the breakpoint ops appropriate for use with with LOCSPEC and according to IS_TRACEPOINT. Use this to ensure, for example, -- 2.39.0