From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id zTaGI8yGBWfVYwYAWB0awg (envelope-from ) for ; Tue, 08 Oct 2024 15:23:56 -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=ds8Eqlua; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7A7B91E355; Tue, 8 Oct 2024 15:23:56 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.8 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_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 769CC1E05C for ; Tue, 8 Oct 2024 15:23:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2443E385020F for ; Tue, 8 Oct 2024 19:23:55 +0000 (GMT) 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 DB10B385DC3C for ; Tue, 8 Oct 2024 19:23:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB10B385DC3C Authentication-Results: sourceware.org; dmarc=pass (p=none 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 DB10B385DC3C 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=1728415416; cv=none; b=B3Ywo7NvueKEsRZ6D3xDPDGxdGo9nO93fdXLsqAZgxpqCTOdKsXn795WhYaPywnmHRtVIzxsu6f70FObR/ALKO6OPrUz1o5pjpHzM3bmS6IvG7jIZrvNKW8o+FkZNxvTLM+kfAEwuwbKSEIGRbAiUdbJusUtcWJucBNRN8mPzow= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728415416; c=relaxed/simple; bh=smiyVTIz7uOkjXxsYW5WVqr8YQvjr4k1DMg/4Hy34x0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=gbbbIA5oUvpdRIrZydzOkQajozd9IrRNbqoQELra4TonfMxSuDH1PeixaeFVFah3QJebKZDC7zFYajh67K2Ge7zA6Gtidzl0UpBaPgVbZvDGWrCQi7DNxwfHzJailuRiUDllljMQ7yEKNMIShGt6+qVcGSO5bLoLELx4ujZCKnc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728415412; 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=5tRwGVIHbIrJU4rOc/eI29WwJaelyTrnyNWYr+naisQ=; b=ds8EqluaowRCenClUgx4SNMCp+6nlqPU7WkMsJ7YWxp1oXHzw2SfSXy/Cdp4efs+WP/aUJ X9RWPmgdBbL0xGE3ZHLqzHbpDq4AijSGfn/N9fPdyp22K/436pMXFdeBgllz8gIaRNycfi /5vM2MPJaPYVP11544MKoX68CAaiEVw= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-vXbjXGnWO9SfLhZnUtltHg-1; Tue, 08 Oct 2024 15:23:31 -0400 X-MC-Unique: vXbjXGnWO9SfLhZnUtltHg-1 Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-3a3479460f4so49062955ab.2 for ; Tue, 08 Oct 2024 12:23:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728415411; x=1729020211; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5tRwGVIHbIrJU4rOc/eI29WwJaelyTrnyNWYr+naisQ=; b=nNKretDoCdNFfgs4bUjETSoBFXJEyAUFyxuFYYl40l9mmOrB9wzQ+gLEUueoAoiwmU QPzv1BX0FUWPRZCRYJWBc+CQ+3F2Ne/hQOQUK+I9xWF/N5Q+9wf9yl/UF321/WRdhAJW cSCC9Y+tav438FvusOWDe5cSTtmgAfD3nXqrU5cZb5wvai1+VaSlqZ7la5yiLvVd0WUd T7Ihhx8ppZkF44OFIq+HUQDNIBi+mlzc+YHOBSQAa6CJoPQTt96JktJZK7Mh0ugQYTtF YDJJl6t6ombk53PainoIubsP75pXdQGDvSLUaZMjNJRxkc8qBCmiz/JO7Kd+CWMDV/Es Vzyg== X-Gm-Message-State: AOJu0Yxu15+roXp7qGWzGARHZQeSPG3MP+W832dx1reWDigUWYIpVRfV C9rBfIImpqZSGsY6cNObGYFordDt4VRUpfS2jIdMI5jG+yArAB4wvcj7cNj9+Dpa/K4QwQkrM34 Q5glYhRL68fb8yNI6cvT8QqVScR4m59PYcLvUGiRYMIx0YPeaWdYLNVAHAK0= X-Received: by 2002:a05:6e02:1889:b0:3a0:a385:911d with SMTP id e9e14a558f8ab-3a397b7b262mr18085ab.0.1728415410897; Tue, 08 Oct 2024 12:23:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFA85sxDCv22pW02EIzWa/IlwlYvYaupL1oNJqQsfwGf/udmu/fXn3jgjOa69YuXaVcMmuqyA== X-Received: by 2002:a05:6e02:1889:b0:3a0:a385:911d with SMTP id e9e14a558f8ab-3a397b7b262mr18015ab.0.1728415410464; Tue, 08 Oct 2024 12:23:30 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:92c5::1000? ([2804:14d:8084:92c5::1000]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a37a7e7c2esm20079795ab.16.2024.10.08.12.23.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Oct 2024 12:23:29 -0700 (PDT) Message-ID: <34153c2f-ec41-4a3c-98eb-a19e8c89ebd1@redhat.com> Date: Tue, 8 Oct 2024 16:23:27 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 4/5] gdb: introduce ability to disable frame unwinders To: Thiago Jung Bauermann Cc: gdb-patches@sourceware.org References: <20241001184235.3710608-1-guinevere@redhat.com> <20241001184235.3710608-5-guinevere@redhat.com> <87frpdaoqr.fsf@linaro.org> From: Guinevere Larsen In-Reply-To: <87frpdaoqr.fsf@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 10/2/24 11:45 PM, Thiago Jung Bauermann wrote: > Guinevere Larsen writes: > >> +/* Helper function to both enable and disable frame unwinders. >> + if ENABLE is true, this call will be enabling unwinders, >> + otherwise the unwinders will be disabled. */ >> +static void >> +enable_disable_frame_unwinders (const char *args, int from_tty, bool enable) >> +{ >> + reinit_frame_cache (); >> + if (args == nullptr) >> + { >> + if (enable) >> + error (_("specify which frame unwinder(s) should be enabled")); >> + else > git complains about this line: > > /home/bauermann/src/binutils-gdb/.git/worktrees/binutils-gdb-wt-2/rebase-apply/patch:327: trailing whitespace. > else > warning: 1 line adds whitespace errors. oops, fixed. > >> + error (_("specify which frame unwinder(s) should be disabled")); >> + } >> diff --git a/gdb/testsuite/gdb.base/frame-unwind-disable.exp b/gdb/testsuite/gdb.base/frame-unwind-disable.exp >> new file mode 100644 >> index 00000000000..972d6b70351 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/frame-unwind-disable.exp >> @@ -0,0 +1,140 @@ >> +# Copyright 2024 Free Software Foundation, Inc. >> + >> +# This program is free software; you can redistribute it and/or modify >> +# it under the terms of the GNU General Public License as published by >> +# the Free Software Foundation; either version 3 of the License, or >> +# (at your option) any later version. >> +# >> +# This program is distributed in the hope that it will be useful, >> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> +# GNU General Public License for more details. >> +# >> +# You should have received a copy of the GNU General Public License >> +# along with this program. If not, see . >> + >> +# Test multiple situations in which we may use the maintenance command to >> +# disable and enable frame unwinders, and check that they really are >> +# disabled when they say the are. >> + >> +standard_testfile .c >> + >> +# Proc to check if the unwinder of the given name is in the desired state. >> +# STATE can be either Y or N. >> +proc check_unwinder_state { unwinder_name state {testname ""} } { >> + set should_pass false >> + set command "maint info frame-unwinders" >> + if {${testname} == ""} { >> + set testname "checking state ${state} for ${unwinder_name}" >> + } >> + gdb_test_multiple "${command}" "${testname}" -lbl { >> + -re "^${unwinder_name}\\s+\\w+\\s+\\w+\\s+${state}\\s+" { > With 'make check-read1', this test only passes if I remove the '^' from > the beginning of the pattern. > >> + set should_pass true >> + exp_continue >> + } >> + -re "${command}" { >> + exp_continue >> + } >> + -re "\\w+\\s+\\w+\\s+\\w+\\s+\\w+\\s+" { >> + exp_continue >> + } >> + -re "${::gdb_prompt} $" { >> + # We can't use -wrap here because it expects the line with start >> + # with \r\n, but the previous commands eat that > If I use -re -wrap "" here things still work (with or without read1), so > this comment probably applied only to a previous version of this test. > > It does apply to the prompt pattern in check_unwinder_class, but there's > a way around that. See below. Thanks for all the TCL and regexp help, it's all too arcane to me at this point. I applied all of your suggestions. > >> + gdb_assert {${should_pass} == true} "${gdb_test_name}" >> + } >> + } >> +} >> + >> +proc check_unwinder_class { unwinder_class state {testname ""} } { >> + set command "maint info frame-unwinders" >> + set seen_arches 0 >> + set correct_state 0 >> + if {$testname == ""} { >> + set testname "checking if ${unwinder_class} state is ${state}" >> + } >> + gdb_test_multiple "${command}" "${testname}" -lbl { >> + -re "^\[^\r\n\]+\\s+\\w+\\s+${unwinder_class}\\s+\(\[YN\]\)\\s+\r\n" { > You can change the last "\r\n" in the pattern to "(?=\r\n)", which tests > for the presence of the characters without taking them out of the buffer. > >> + # The unwinder name may have multiple words, so we need to use the >> + # more generic [^\r\n] pattern to match the unwinders. >> + set should_pass true >> + incr seen_arches >> + set cur_state $expect_out(1,string) >> + if {$cur_state == $state} { >> + incr correct_state >> + } >> + exp_continue >> + } >> + -re "${command}" { >> + exp_continue >> + } >> + -re "\[^\r\n\]+\r\n" { > Same here, though this pattern is very similar to what the -lbl option > adds: > > if {$line_by_line} { > append code { > -re "\r\n\[^\r\n\]*(?=\r\n)" { > exp_continue > } > } > } > > So is it necessary? it isn't, you're correct! removed. > >> + exp_continue >> + } >> + -re "${::gdb_prompt} $" { > With the changes above I can use -re -wrap "" here. > >> + gdb_assert {${correct_state} == ${seen_arches}} "${gdb_test_name}" >> + } >> + } >> +} -- Cheers, Guinevere Larsen She/Her/Hers