From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CdxNGV2qOWoa6RMAWB0awg (envelope-from ) for ; Mon, 22 Jun 2026 17:34:21 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QgosDHJw; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 628DD1E098; Mon, 22 Jun 2026 17:34:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E076D1E070 for ; Mon, 22 Jun 2026 17:34:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E7804BA2E10 for ; Mon, 22 Jun 2026 21:34:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E7804BA2E10 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QgosDHJw Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id E84914BA2E10 for ; Mon, 22 Jun 2026 21:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E84914BA2E10 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E84914BA2E10 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782163994; cv=none; b=X6l2frxwmnxgPsQo7LU9+RKq0OjFCoFEPxyAHPi6AgiUvvr8brC7jnSfQ0OafY+0HL83GcLH2fqNeAxaHyPWGIuGn30SssM/shx6k+//hDLs6thScO53o0ejTyJ2KeaYBUq6wqyeAaYvKyn4qeEfy0NcfjagUTlxbuHLx0EI3MM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782163994; c=relaxed/simple; bh=99l/T0t/jZBJ7jnagjgrR0HCHBQPM7vfOOD5iz/IFWM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=SwT2D0NXagSygYb6f90MTJoSUOoIpKrFlPWih9hayKkCFgwFw3dVS9oQ/ZnvmamEeYQ77p+7NJRA972Iz6pxIcmf/WUyDW/XSH8RDR3M4GGx9vxIRcTyMwp9KB7+MrYoYC1kDv3gAP6sFmeu1emY7BQ2MVnAkqGzPdISRnwb1E8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QgosDHJw DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E84914BA2E10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782163993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PNyVS1LCu/D6PgYdjQsoevAGEw6mCB1xGfjZEa/8VKI=; b=QgosDHJw4drEOgyxYfHqjh8Fr54LkBQepdrIjEoZ/0wuElQe5piZWq9oErjAOwyMHn3ySJ fyYKjd+qFPZ0lgmcR0SYMgc9EMzQGZaPPQcVMv92tRjUxgYWnCQoQ9BVCJK7G7gDZMoqaN G3KJCyJHHE37Q09YNmcC7k26kA5+Oxc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-367-QEeC56CaNGqph9qppiuCLg-1; Mon, 22 Jun 2026 17:33:12 -0400 X-MC-Unique: QEeC56CaNGqph9qppiuCLg-1 X-Mimecast-MFC-AGG-ID: QEeC56CaNGqph9qppiuCLg_1782163991 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49243626f15so34751245e9.1 for ; Mon, 22 Jun 2026 14:33:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782163991; x=1782768791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PNyVS1LCu/D6PgYdjQsoevAGEw6mCB1xGfjZEa/8VKI=; b=JM6Bp3wwXAojGPmqNu4PozJpcNpWkXAd5B61zhbP3/N98L1GJ14ZgS5Sx9z4BcvRVI OodBSzQ8PsPLwzbe14e5txFsOoN41L40A01kbrXzL5Ij5dXY/vqhuL2lQ4C429VWWRr/ Hr+gaNGlz2a1eYzzk1KTAKTPjHAZ1bw2UOXpf+Qqia+hWHBLroO+pHbknI4DcSct8f6i sXXL0tYIKiAeYbduPJDTL8kAjM+of0OltVs9s+1a0g3LI6GFj/G6hlhpKPpDx/IXqf+z /9I3+DgbeVrgzk7TMsoeJXw5LhK0mV5TsZogBEg6oufxivRLMWTUkpPYxpAXgSf36VPV kZvg== X-Gm-Message-State: AOJu0YyfYEcJ2/jUOEgYF9sgw/2q6JrkL4j1VainBP9TJxWuVRMJ9/xF bNS9qjK+Z4ZPHRy15+1JsDshcTYB2Io+Sb67rm0pfS09LWjCk0xmyKndVIvawwK3+i1WyEdjzIu 81Dhwas3m6MRKYwuhKiCi5ibgp0q1k82YvckFpG6JZV7rbmq2ktMss6qvT5nKvoGOzJNLUrzuyH T5ZGAl0MbQcgWAtYUKluHLF6JEenTZ+HLJLC5V/XMarM6Fu7I= X-Gm-Gg: AfdE7ck0tKGNEnDE//RdKryoPbWdgm9Z7d3MuVF33nA4ERX2m7/XvcMRW0ulw9udp8m bLjv/mmiyDxWtI1KjmD5QV/HFqNa7XwxSfPYeXI2HVG1Y1Dh/NBL8nHyJkjMUmeBUZnmyhqXD1Y YKh4Lis0EJFsnRnFwF5hOUDGonhxenwgVTSUzRvDGDz7xmeEIlbkmkb5hg3ChN2EmGWnRtZGyOy 1dzvf0CB5PFn60yKHDAurs8s/y5cgtAhezmZTsYK0IKz/z7v1zUB4lw/zWrHcFV9CV+ZDHdbbBB BNrsXipHK2LrzMBl7ZeBxWjVl+DLSsyps2FGlB5fGeVGigjkiWf4P5nJZcg4P7UTEJaNaPJ8Xqn 7VVO0C9zTcBklsv5g79NPSTcZ2CIxjA== X-Received: by 2002:a05:600c:19d4:b0:492:5068:61fc with SMTP id 5b1f17b1804b1-49250686272mr143662255e9.19.1782163991152; Mon, 22 Jun 2026 14:33:11 -0700 (PDT) X-Received: by 2002:a05:600c:19d4:b0:492:5068:61fc with SMTP id 5b1f17b1804b1-49250686272mr143661875e9.19.1782163990650; Mon, 22 Jun 2026 14:33:10 -0700 (PDT) Received: from localhost (19.81.93.209.dyn.plus.net. [209.93.81.19]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4923fd15535sm357275035e9.3.2026.06.22.14.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2026 14:33:10 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , Simon Marchi Subject: [PATCHv2 1/2] gdb: remove sentinel frame check in frame_find_by_id Date: Mon, 22 Jun 2026 22:33:05 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: swqs-Gu8tC7OT_VnshXjB9oVzVso1DetRLpN3UL5B8U_1782163991 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org While reviewing another patch Simon pointed out that the code in frame_find_by_id for looking up the sentinel frame is no longer needed since commit: commit 19f988359a62889b00d67fb59ef8c7d6d759fc98 Date: Mon Jan 30 15:02:49 2023 -0500 gdb: give sentinel for user frames distinct IDs, register sentinel frames to the frame cache Prior to this commit the sentinel_frame was not added to the frame stash, so we needed a manual check to lookup the sentinel frame. After this commit the sentinel frame is added to the stash so the manual check, though perfectly valid, is just unnecessary complexity, and can be removed. A frame stash lookup is just a hash lookup, and is relatively cheap, so switching to this isn't much extra cost. While I was working in frame_find_by_id I made a couple of additional changes: 1. I moved the declarations of frame and prev_frame locals into the function body, closer to where they are first defined. 2. Instead of treating a frame_info_ptr as a bool, I made use of the frame_info_ptr::is_null method. There should be no user visible changes after this commit. --- gdb/frame.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index f64f5554f8c..c1a7c41dc4a 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -959,17 +959,11 @@ frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r) frame_info_ptr frame_find_by_id (struct frame_id id) { - frame_info_ptr frame, prev_frame; - /* ZERO denotes the null frame, let the caller decide what to do about it. Should it instead return get_current_frame()? */ if (!frame_id_p (id)) return NULL; - /* Check for the sentinel frame. */ - if (id == frame_id_build_sentinel (0, 0)) - return frame_info_ptr (sentinel_frame); - /* Try using the frame stash first. Finding it there removes the need to perform the search by looping over all frames, which can be very CPU-intensive if the number of frames is very high (the loop is O(n) @@ -978,10 +972,11 @@ frame_find_by_id (struct frame_id id) is called from another function (such as value_fetch_lazy, case val->lval () == lval_register) which already loops over all frames, making the overall behavior O(n^2). */ - frame = frame_stash_find (id); - if (frame) + frame_info_ptr frame = frame_stash_find (id); + if (!frame.is_null ()) return frame; + frame_info_ptr prev_frame; for (frame = get_current_frame (); ; frame = prev_frame) { struct frame_id self = get_frame_id (frame); @@ -991,7 +986,7 @@ frame_find_by_id (struct frame_id id) return frame; prev_frame = get_prev_frame (frame); - if (!prev_frame) + if (prev_frame.is_null ()) return NULL; /* As a safety net to avoid unnecessary backtracing while trying -- 2.25.4