From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id AABC63857BBC for ; Sat, 28 May 2022 02:42:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AABC63857BBC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id E6F5710050360 for ; Sat, 28 May 2022 02:42:33 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id umPRn4xr6Qs3CumPRn72Iz; Sat, 28 May 2022 02:42:33 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=A+Opg4aG c=1 sm=1 tr=0 ts=62918c19 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=oZkIemNP1mAA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=QHJ-6iwTcbNy_oBpVS8A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Or9Eh4BSvh7w9GUL08jqTki7mqrp4XKf25kR9xbQbH8=; b=HbQjjcS4YtvvnHsJfnIGUxWi4C rwOgvgCiMezRncJp0dHNQeGKEyxd5q0wtI1jPcO1HvoR9T1ZnJl9nAHSa/dxuKRrSQ1rzDkcibFcO /xzO9zCmHQc0WlyhPedyoJcA9; Received: from 71-211-158-194.hlrn.qwest.net ([71.211.158.194]:45628 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1numPR-003NVE-5c; Fri, 27 May 2022 20:42:33 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/3] Change location_to_sals to a method Date: Fri, 27 May 2022 20:42:30 -0600 Message-Id: <20220528024231.474534-3-tom@tromey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220528024231.474534-1-tom@tromey.com> References: <20220528024231.474534-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.158.194 X-Source-L: No X-Exim-ID: 1numPR-003NVE-5c X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-158-194.hlrn.qwest.net (prentzel.Home) [71.211.158.194]:45628 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3029.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Sat, 28 May 2022 02:42:36 -0000 location_to_sals is only ever called for code breakpoints, so make it a protected method there. --- gdb/breakpoint.c | 58 ++++++++++++++++++++++++------------------------ gdb/breakpoint.h | 8 +++++++ 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index cc0d527fd30..ee34733e6cd 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -12621,9 +12621,10 @@ update_breakpoint_locations (code_breakpoint *b, /* Find the SaL locations corresponding to the given LOCATION. On return, FOUND will be 1 if any SaL was found, zero otherwise. */ -static std::vector -location_to_sals (struct breakpoint *b, struct event_location *location, - struct program_space *search_pspace, int *found) +std::vector +code_breakpoint::location_to_sals (struct event_location *location, + struct program_space *search_pspace, + int *found) { struct gdb_exception exception; @@ -12631,7 +12632,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location, try { - sals = b->decode_location (location, search_pspace); + sals = decode_location (location, search_pspace); } catch (gdb_exception_error &e) { @@ -12645,13 +12646,13 @@ location_to_sals (struct breakpoint *b, struct event_location *location, breakpoint being disabled, and don't want to see more errors. */ if (e.error == NOT_FOUND_ERROR - && (b->condition_not_parsed - || (b->loc != NULL + && (condition_not_parsed + || (loc != NULL && search_pspace != NULL - && b->loc->pspace != search_pspace) - || (b->loc && b->loc->shlib_disabled) - || (b->loc && b->loc->pspace->executing_startup) - || b->enable_state == bp_disabled)) + && loc->pspace != search_pspace) + || (loc && loc->shlib_disabled) + || (loc && loc->pspace->executing_startup) + || enable_state == bp_disabled)) not_found_and_ok = 1; if (!not_found_and_ok) @@ -12662,7 +12663,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location, have separate 'warning emitted' flag. Since this happens only when a binary has changed, I don't know which approach is better. */ - b->enable_state = bp_disabled; + enable_state = bp_disabled; throw; } @@ -12673,26 +12674,26 @@ location_to_sals (struct breakpoint *b, struct event_location *location, { for (auto &sal : sals) resolve_sal_pc (&sal); - if (b->condition_not_parsed && b->extra_string != NULL) + if (condition_not_parsed && extra_string != NULL) { - gdb::unique_xmalloc_ptr cond_string, extra_string; + gdb::unique_xmalloc_ptr local_cond, local_extra; int thread, task; - find_condition_and_thread_for_sals (sals, b->extra_string.get (), - &cond_string, &thread, - &task, &extra_string); - gdb_assert (b->cond_string == NULL); - if (cond_string) - b->cond_string = std::move (cond_string); - b->thread = thread; - b->task = task; - if (extra_string) - b->extra_string = std::move (extra_string); - b->condition_not_parsed = 0; + find_condition_and_thread_for_sals (sals, extra_string.get (), + &local_cond, &thread, + &task, &local_extra); + gdb_assert (cond_string == nullptr); + if (local_cond != nullptr) + cond_string = std::move (local_cond); + thread = thread; + task = task; + if (local_extra != nullptr) + extra_string = std::move (local_extra); + condition_not_parsed = 0; } - if (b->type == bp_static_tracepoint) - sals[0] = update_static_tracepoint (b, sals[0]); + if (type == bp_static_tracepoint) + sals[0] = update_static_tracepoint (this, sals[0]); *found = 1; } @@ -12713,7 +12714,7 @@ code_breakpoint::re_set_default () std::vector expanded, expanded_end; int found; - std::vector sals = location_to_sals (this, location.get (), + std::vector sals = location_to_sals (location.get (), filter_pspace, &found); if (found) expanded = std::move (sals); @@ -12721,8 +12722,7 @@ code_breakpoint::re_set_default () if (location_range_end != NULL) { std::vector sals_end - = location_to_sals (this, location_range_end.get (), - filter_pspace, &found); + = location_to_sals (location_range_end.get (), filter_pspace, &found); if (found) expanded_end = std::move (sals_end); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 4fdd50324e3..5ce6edf6efc 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -890,6 +890,14 @@ struct code_breakpoint : public breakpoint /* Helper method that does the basic work of re_set. */ void re_set_default (); + + /* Find the SaL locations corresponding to the given LOCATION. + On return, FOUND will be 1 if any SaL was found, zero otherwise. */ + + std::vector location_to_sals + (struct event_location *location, + struct program_space *search_pspace, + int *found); }; /* An instance of this type is used to represent a watchpoint, -- 2.34.1