From patchwork Tue Dec 6 13:57:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 61550 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7303384C905 for ; Tue, 6 Dec 2022 13:57:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7303384C905 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670335079; bh=6N5VpZlw249QIlNyllyhQUf9Z4aRRsS5AR0MeP6jR0Q=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=YoHSZxTqKC7imAbYu0N3WtFwvRcS75M8Dp8vox49qkSSwq2R7e0Fj8p1PzXBp88E1 ebF/u2Oz0vNuKOpND6O5SgEpXESX6B6X7yiYDYKF9NKxBRRVEVrnmZZmtV2sO6OaA/ Ob25cJeqaOutYhXpUoaHA5SK4LeHlEzIPc4ZSH+M= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 9FBA93864A30 for ; Tue, 6 Dec 2022 13:57:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9FBA93864A30 X-ASG-Debug-ID: 1670335052-0c856e762b1baf0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id CfZ0J6cD5ZIsQUo8 (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 06 Dec 2022 08:57:32 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 2190C441D64; Tue, 6 Dec 2022 08:57:32 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Pedro Alves , Simon Marchi Subject: [PATCH 02/12] gdb: make install_breakpoint return a non-owning reference Date: Tue, 6 Dec 2022 08:57:19 -0500 X-ASG-Orig-Subj: [PATCH 02/12] gdb: make install_breakpoint return a non-owning reference Message-Id: <20221206135729.3937767-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221206135729.3937767-1-simon.marchi@efficios.com> References: <20221206135729.3937767-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1670335052 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2032 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102644 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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 --- 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 f0276a963c0..f974808b4b4 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7954,7 +7954,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)); @@ -7967,6 +7967,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 f7633d29cbf..eafe694f367 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1479,10 +1479,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,