From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WeYDJ2dp12kZqw4AWB0awg (envelope-from ) for ; Thu, 09 Apr 2026 04:55:03 -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=ftFZPZIO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9A0A21E0BC; Thu, 09 Apr 2026 04:55:03 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham 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 1E0211E08C for ; Thu, 09 Apr 2026 04:55:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 7CF3E4BA2E3C for ; Thu, 9 Apr 2026 08:55:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CF3E4BA2E3C 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=ftFZPZIO 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 1CF484BA2E1E for ; Thu, 9 Apr 2026 08:54:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1CF484BA2E1E 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 1CF484BA2E1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775724876; cv=none; b=mYUK543626W6UYPN7ss8yVpQrlrZu/zGgOd4+eX8aNcDx1LcQEOVPE8uZW0KDIq/AlZ0PKg86oaRSwEDJQhxOT/oNPC6d+4hgr2ifKzKCloLczqZRAMYpx+Mlr/mKq3pcrb31jn2tGvPoArMG4EL5aY6oyRlOIkSmVEuLU7A0sI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775724876; c=relaxed/simple; bh=JT8RfaFzS96pRPsXMNkTGKTNInyv91w8nwre4JT0lJ4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lwJeb9taYetXIUil9IpZ3/0DA/zKxfQz0prf55ut4EHNpSbQHnpbbVAnzi89ma5D3xQQAI5NY9uAqlmTAOY42mvEpWZxsRkmcIZ5E8Tj8DUYUScCCIaSQlDpBzg+YTzjHSilcWsdexmPLpYXuY5FC0S7GwPzDZ7LOSNzDeDcM4M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1CF484BA2E1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775724875; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=a3GaGDZpGAttYTNB2KHO9Vk1HuBDjPJoYD3hmoPyyYY=; b=ftFZPZIOuzcO/PGebzJl9wUoZFfgN29RVfZCspUg5D0JNd0FLmvtatQ/Rlx7NRhS6izJuj uZ+sq4xGoguh4VSvUtgWQcI3cHdOYv98fvUMufxFKXNBejZfbzzUn9t+fMra7smooCT61O 1xx1cEnpmCO6amPHSPySFC9UzAykHEg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-_8_cnwtsMXWfl_V-iHPhKA-1; Thu, 09 Apr 2026 04:54:34 -0400 X-MC-Unique: _8_cnwtsMXWfl_V-iHPhKA-1 X-Mimecast-MFC-AGG-ID: _8_cnwtsMXWfl_V-iHPhKA_1775724873 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43d03db814eso665145f8f.2 for ; Thu, 09 Apr 2026 01:54:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775724873; x=1776329673; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a3GaGDZpGAttYTNB2KHO9Vk1HuBDjPJoYD3hmoPyyYY=; b=r8AVblwf9JzQh6FfhxnkX9sbEfld3AQ0buy1uO1AaRJcyplWL+lKTjePJ+t37QjPGK AH56os2/abzc7Q3uBJ3+s1HVLYyaq0N6ABlT+AIFygjQVjYW0joM6ysxBfXLSHsAf3ib O0Y+Gj5GTHMBMlKjkT6vEz06z8G4vwMsAiv5AZb/xab0JpHEjpjwj3XQ+3qTbbtuhZBy gJ0u2yThHX+urEf716MGINOVTcIWpQnUZQD/GOVss39rtQM5DiTXSu1MYPuz8KPmVgKh 4npcgxeotSQkmUzo29p2rVTjwHxnrtSHPM79xSPe5iFMQZ2w/aX/r9K7N5F4iiITSO7s T4zQ== X-Forwarded-Encrypted: i=1; AJvYcCWQ/tiMfIOUmnv7g5OmlgPM3CHchJLRNlKE9aPqz8KwXOHfMqbePIXVuy4kLGa/1jRowc/pMQNVkv46GQ==@sourceware.org X-Gm-Message-State: AOJu0Yxojl2whT9UH4lFvVIPyewEDEda7g3eRvxBVBw97qQ3QyCX6x2+ G3mXVZfuryOQHX2GkDzava5vPwOpYB21u9OtDpMHHaJ2sX3kRy8cDV1g3z2BKeNNeWUN8tVMt/L QVKnj25kZi8yROhEtKAPFxhWQT1jh3ghm0+LqNGEsrVX2DOZOpEU659B/er5Kvfc= X-Gm-Gg: AeBDiesT+MwElmotm0vH2+MySOfEla7h+Zi/YAq+MFTviqm/YPaQNmpFFta8a7N13eF E+Kfplhq3rmjmEZ3SJe1RPtL3F75sc2Cbi0YgVnVosCYq5tQjjcQCOHTLqP3VzMXyVL47QcF/BN fqToKGRpx/Xu/JLm5OG5SnIbgtLkqT4UngpncNPTnkBxZ94hXRnZDjoqG4id2gWqbe1GgktCxAD UyRTU2a5ewms3mYivB6O7FoR+x4xLST7TY13yf0fwDLhBNzTm2Kw5w//Aq6bEIDa5dW037FEwC5 8CdGpXBzojW9glT+RFN7UkWH9NgMeFQEQDliBalcBmWHZHiiJnVK1cLnJGSvuqgFCUiAvqfUwx7 T54/WLhV5ymeVwfqY X-Received: by 2002:a05:6000:4313:b0:43d:6e0:9447 with SMTP id ffacd0b85a97d-43d292dabfdmr36832269f8f.28.1775724871961; Thu, 09 Apr 2026 01:54:31 -0700 (PDT) X-Received: by 2002:a05:6000:4313:b0:43d:6e0:9447 with SMTP id ffacd0b85a97d-43d292dabfdmr36832175f8f.28.1775724870683; Thu, 09 Apr 2026 01:54:30 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e2c5253sm59249506f8f.9.2026.04.09.01.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2026 01:54:29 -0700 (PDT) From: Andrew Burgess To: Tom de Vries , gdb-patches@sourceware.org Subject: Re: [PATCH 1/2] gdb: use get_current_frame consistently in print_stop_location In-Reply-To: <337213ec-dce2-47d2-b04a-21aaf3d849dc@suse.de> References: <20260331132342.1050954-1-tdevries@suse.de> <640943dbfd2e2d6555be950b04a4c50288e3334a.1775383137.git.aburgess@redhat.com> <337213ec-dce2-47d2-b04a-21aaf3d849dc@suse.de> Date: Thu, 09 Apr 2026 09:54:28 +0100 Message-ID: <87o6js4ipn.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HqwDt9zzeYSTQaAbUl9icnV-774p69pB5QJ6Wce7is4_1775724873 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Tom de Vries writes: > On 4/5/26 12:12 PM, Andrew Burgess wrote: >> In print_stop_location, in the PRINT_UNKNOWN case we currently use a >> strange mix of get_current_frame and get_selected_frame. This works >> fine because at the point print_stop_location is called the selected >> frame will always be the current frame, but calling these two >> different functions is confusing, at least for me. >> >> As we are stopping, and deciding whether to print information about >> the frame, it makes sense, I think, to make the choice based on the >> current frame, and so let's call get_current_frame once, and then use >> that result throughout the decision making process. >> >> There should be no user visible changes after this commit. > > Hi Andrew, > > thanks for looking into this, for me using these two different functions > is also confusing. > > While reviewing this patch I wondered why this line at the end of the > function still uses get_selected_frame: > ... > print_stack_frame (get_selected_frame (nullptr), 0, source_flag, 1); > ... > so I tried to use get_current_frame () there as well, and ran into > trouble in these ada test-cases: > ... > 1 gdb.ada/catch_assert_if.exp: > 6 gdb.ada/catch_ex.exp: > 6 gdb.ada/excep_handle.exp: > 1 gdb.ada/mi_catch_assert.exp: > 6 gdb.ada/mi_catch_ex.exp: > 3 gdb.ada/mi_catch_ex_hand.exp: > 1 gdb.ada/mi_ex_cond.exp: > ... > > I investigated this, and found that bpstat_print may change the selected > frame, specifically ada_catchpoint::print_it which calls > ada_find_printable_frame. As it happens, ada_catchpoint::print_it > returns PRINT_SRC_AND_LOC, so it doesn't interact with the PRINT_UNKNOWN > case. > > But if I consider the scenario where ada_catchpoint::print_it would > return PRINT_UNKNOWN, it seems more logical to me to use the selected > frame there as well. > > That is, if we're stepping in some function foo, and run into an ada > catchpoint, and ada_catchpoint::print_it selects the frame in foo, and > ada_catchpoint::print_it returns PRINT_UNKNOWN, you want to use the > selected frame in the PRINT_UNKNOWN case to select SRC_LINE, which is > appropriate because as far as the user can see, we haven't left foo. > > So I'm proposing a change to this patch (attached below, doesn't apply > to the first but to the second patch) that: > - introduces a variable print_frame > - assigns get_selected_frame (nullptr) to print_frame > - adds a comment explaining how print_frame relates to the stop frame > - uses print_frame everywhere in the function > > I tested the series in combination with the attached patch on > x86_64-linux, and found no regressions. Thanks for the great analysis, and explanation, I wasn't aware of this aspect of bpstat_print. Given this new information, I think your patch is the right solution. Approved-By: Andrew Burgess Thanks, Andrew > > Thanks, > - Tom > diff --git a/gdb/infrun.c b/gdb/infrun.c > index 344f13df4fa..687390f24dd 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -9349,18 +9349,22 @@ print_stop_location (const target_waitstatus &ws) > struct thread_info *tp = inferior_thread (); > > bpstat_ret = bpstat_print (tp->control.stop_bpstat, ws.kind ()); > + /* Function bpstat_print selects the frame to print. Typically, that is the > + stop frame, in other words get_current_frame (). But bpstat_print may > + select a different frame, see for instance ada_catchpoint::print_it. */ > + frame_info_ptr print_frame = get_selected_frame (nullptr); > + > switch (bpstat_ret) > { > case PRINT_UNKNOWN: > /* FIXME: cagney/2002-12-01: Given that a frame ID does (or > should) carry around the function and does (or should) use > that when doing a frame comparison. */ > - if (frame_info_ptr frame = get_current_frame (); > - tp->control.stop_step > - && (tp->control.step_frame_id == get_frame_id (frame)) > - && tp->control.in_step_start_function (frame)) > + if (tp->control.stop_step > + && (tp->control.step_frame_id == get_frame_id (print_frame)) > + && tp->control.in_step_start_function (print_frame)) > { > - symtab_and_line sal = find_frame_sal (frame); > + symtab_and_line sal = find_frame_sal (print_frame); > if (sal.symtab != tp->current_symtab) > { > /* Finished step in same frame but into different file, print > @@ -9403,7 +9407,7 @@ print_stop_location (const target_waitstatus &ws) > LOCATION: Print only location > SRC_AND_LOC: Print location and source line. */ > if (do_frame_printing) > - print_stack_frame (get_selected_frame (nullptr), 0, source_flag, 1); > + print_stack_frame (print_frame, 0, source_flag, 1); > } > > /* See `print_stop_event` in infrun.h. */