From patchwork Thu Jan 5 20:02:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 62758 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 2C7CB385B516 for ; Thu, 5 Jan 2023 20:03:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C7CB385B516 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672949005; bh=y66i7Hz3zQ+F1dhbBT/8mRZPYbOxwfWcktfJwgrnFqA=; 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=GjSzj1pSFZ6VjAmbeTBi59tQsqESVvBKn8RENxDhK06bKd26B8RgQYpqeRU3jTgYJ crefc95V4jFSUqLErHo/74R+FhJddmie8Tz4tHniyQacxBz2qJxlGPQfO4UZGZYh4o GOggxJO1M8ws6uvPNe9w639Sb+iCxpq6YVyGkAX0= 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 0746E3858C62 for ; Thu, 5 Jan 2023 20:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0746E3858C62 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 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) 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 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 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 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,