From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id 7BEC73858C2F for ; Sun, 16 Apr 2023 16:28:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BEC73858C2F 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 cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 1234E10047E2C for ; Sun, 16 Apr 2023 16:28:30 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id o5EspEjOwb9i8o5EspLlVR; Sun, 16 Apr 2023 16:28:30 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Wd7J12tX c=1 sm=1 tr=0 ts=643c222e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=dKHAf1wccvYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=FY_HHhEQSXUS_0aUBsMA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=T5BqGIHpCN7C6zQ2hcQZqh9vkljDwSRlWwVkRjNaLOo=; b=uGhE1RfcV7TwScLX0INcQ0/ZVW ZolaWiTDxiWLAn7BSLIQV8zXLjOYbBzpxs7zBtNBvPjWPkANPon53TaxoOXf7HpHdyBd3VYU52odD 9F/N9XR6mNaKisSyDqbH6JXtn; Received: from 71-211-191-82.hlrn.qwest.net ([71.211.191.82]:48248 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1po5Er-002aa3-SZ for gdb-patches@sourceware.org; Sun, 16 Apr 2023 10:28:29 -0600 From: Tom Tromey Date: Sun, 16 Apr 2023 10:28:30 -0600 Subject: [PATCH 4/4] Remove ALL_BREAKPOINTS_SAFE MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230416-remove-all-macros-v1-4-f118956faafe@tromey.com> References: <20230416-remove-all-macros-v1-0-f118956faafe@tromey.com> In-Reply-To: <20230416-remove-all-macros-v1-0-f118956faafe@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 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.191.82 X-Source-L: No X-Exim-ID: 1po5Er-002aa3-SZ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-191-82.hlrn.qwest.net ([192.168.0.21]) [71.211.191.82]:48248 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.0 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 List-Id: There's just a single remaining use of the ALL_BREAKPOINTS_SAFE macro; this patch replaces it with a for-each and an explicit temporary variable. --- gdb/breakpoint.c | 134 ++++++++++++++++++++++++++----------------------------- 1 file changed, 63 insertions(+), 71 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 46287da5f87..b1460b51b0c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -610,15 +610,6 @@ static int overlay_events_enabled; /* See description in breakpoint.h. */ bool target_exact_watchpoints = false; -/* Walk the following statement or block through all breakpoints. - ALL_BREAKPOINTS_SAFE does so even if the statement deletes the - current breakpoint. */ - -#define ALL_BREAKPOINTS_SAFE(B,TMP) \ - for (B = breakpoint_chain; \ - B ? (TMP=B->next, 1): 0; \ - B = TMP) - /* Chains of all breakpoints defined. */ static struct breakpoint *breakpoint_chain; @@ -7616,72 +7607,73 @@ set_longjmp_breakpoint_for_call_dummy (void) void check_longjmp_breakpoint_for_call_dummy (struct thread_info *tp) { - struct breakpoint *b, *b_tmp; + for (struct breakpoint *b : all_breakpoints_safe ()) + { + struct breakpoint *b_tmp = b->next; + if (b->type == bp_longjmp_call_dummy && b->thread == tp->global_num) + { + struct breakpoint *dummy_b = b->related_breakpoint; - ALL_BREAKPOINTS_SAFE (b, b_tmp) - if (b->type == bp_longjmp_call_dummy && b->thread == tp->global_num) - { - struct breakpoint *dummy_b = b->related_breakpoint; - - /* Find the bp_call_dummy breakpoint in the list of breakpoints - chained off b->related_breakpoint. */ - while (dummy_b != b && dummy_b->type != bp_call_dummy) - dummy_b = dummy_b->related_breakpoint; - - /* If there was no bp_call_dummy breakpoint then there's nothing - more to do. Or, if the dummy frame associated with the - bp_call_dummy is still on the stack then we need to leave this - bp_call_dummy in place. */ - if (dummy_b->type != bp_call_dummy - || frame_find_by_id (dummy_b->frame_id) != NULL) - continue; + /* Find the bp_call_dummy breakpoint in the list of breakpoints + chained off b->related_breakpoint. */ + while (dummy_b != b && dummy_b->type != bp_call_dummy) + dummy_b = dummy_b->related_breakpoint; - /* We didn't find the dummy frame on the stack, this could be - because we have longjmp'd to a stack frame that is previous to - the dummy frame, or it could be because the stack unwind is - broken at some point between the longjmp frame and the dummy - frame. - - Next we figure out why the stack unwind stopped. If it looks - like the unwind is complete then we assume the dummy frame has - been jumped over, however, if the unwind stopped for an - unexpected reason then we assume the stack unwind is currently - broken, and that we will (eventually) return to the dummy - frame. - - It might be tempting to consider using frame_id_inner here, but - that is not safe. There is no guarantee that the stack frames - we are looking at here are even on the same stack as the - original dummy frame, hence frame_id_inner can't be used. See - the comments on frame_id_inner for more details. */ - bool unwind_finished_unexpectedly = false; - for (frame_info_ptr fi = get_current_frame (); fi != nullptr; ) - { - frame_info_ptr prev = get_prev_frame (fi); - if (prev == nullptr) - { - /* FI is the last stack frame. Why did this frame not - unwind further? */ - auto stop_reason = get_frame_unwind_stop_reason (fi); - if (stop_reason != UNWIND_NO_REASON - && stop_reason != UNWIND_OUTERMOST) - unwind_finished_unexpectedly = true; - } - fi = prev; - } - if (unwind_finished_unexpectedly) - continue; + /* If there was no bp_call_dummy breakpoint then there's nothing + more to do. Or, if the dummy frame associated with the + bp_call_dummy is still on the stack then we need to leave this + bp_call_dummy in place. */ + if (dummy_b->type != bp_call_dummy + || frame_find_by_id (dummy_b->frame_id) != NULL) + continue; - dummy_frame_discard (dummy_b->frame_id, tp); + /* We didn't find the dummy frame on the stack, this could be + because we have longjmp'd to a stack frame that is previous to + the dummy frame, or it could be because the stack unwind is + broken at some point between the longjmp frame and the dummy + frame. + + Next we figure out why the stack unwind stopped. If it looks + like the unwind is complete then we assume the dummy frame has + been jumped over, however, if the unwind stopped for an + unexpected reason then we assume the stack unwind is currently + broken, and that we will (eventually) return to the dummy + frame. + + It might be tempting to consider using frame_id_inner here, but + that is not safe. There is no guarantee that the stack frames + we are looking at here are even on the same stack as the + original dummy frame, hence frame_id_inner can't be used. See + the comments on frame_id_inner for more details. */ + bool unwind_finished_unexpectedly = false; + for (frame_info_ptr fi = get_current_frame (); fi != nullptr; ) + { + frame_info_ptr prev = get_prev_frame (fi); + if (prev == nullptr) + { + /* FI is the last stack frame. Why did this frame not + unwind further? */ + auto stop_reason = get_frame_unwind_stop_reason (fi); + if (stop_reason != UNWIND_NO_REASON + && stop_reason != UNWIND_OUTERMOST) + unwind_finished_unexpectedly = true; + } + fi = prev; + } + if (unwind_finished_unexpectedly) + continue; - while (b->related_breakpoint != b) - { - if (b_tmp == b->related_breakpoint) - b_tmp = b->related_breakpoint->next; - delete_breakpoint (b->related_breakpoint); - } - delete_breakpoint (b); - } + dummy_frame_discard (dummy_b->frame_id, tp); + + while (b->related_breakpoint != b) + { + if (b_tmp == b->related_breakpoint) + b_tmp = b->related_breakpoint->next; + delete_breakpoint (b->related_breakpoint); + } + delete_breakpoint (b); + } + } } void -- 2.39.2