From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: Guinevere Larsen <guinevere@redhat.com>
Cc: gdb-patches@sourceware.org, Guinevere Larsen <blarsen@redhat.com>
Subject: Re: [PATCH v5 4/5] gdb: introduce ability to disable frame unwinders
Date: Wed, 02 Oct 2024 23:45:16 -0300 [thread overview]
Message-ID: <87frpdaoqr.fsf@linaro.org> (raw)
In-Reply-To: <20241001184235.3710608-5-guinevere@redhat.com> (Guinevere Larsen's message of "Tue, 1 Oct 2024 15:42:34 -0300")
Guinevere Larsen <guinevere@redhat.com> 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.
> + 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 <http://www.gnu.org/licenses/>.
> +
> +# 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.
> + 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?
> + exp_continue
> + }
> + -re "${::gdb_prompt} $" {
With the changes above I can use -re -wrap "" here.
> + gdb_assert {${correct_state} == ${seen_arches}} "${gdb_test_name}"
> + }
> + }
> +}
--
Thiago
next prev parent reply other threads:[~2024-10-03 2:46 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 18:42 [PATCH v5 0/5] Modernize frame unwinders and add disable feature Guinevere Larsen
2024-10-01 18:42 ` [PATCH v5 1/5] gdb: make gdbarch store a vector of frame unwinders Guinevere Larsen
2024-10-02 21:49 ` Thiago Jung Bauermann
2024-10-08 17:01 ` Guinevere Larsen
2024-10-03 18:33 ` Simon Marchi
2024-10-04 18:37 ` Tom Tromey
2024-10-12 1:34 ` Thiago Jung Bauermann
2024-10-14 18:18 ` Guinevere Larsen
2024-10-17 22:53 ` Tom Tromey
2024-10-18 17:40 ` Guinevere Larsen
2024-10-17 23:41 ` Tom Tromey
2024-10-01 18:42 ` [PATCH v5 2/5] gdb: add "unwinder class" to " Guinevere Larsen
2024-10-02 22:08 ` Thiago Jung Bauermann
2024-10-03 18:46 ` Simon Marchi
2024-10-08 18:22 ` Guinevere Larsen
2024-10-08 18:37 ` Simon Marchi
2024-10-01 18:42 ` [PATCH v5 3/5] gdb: Migrate frame unwinders to use C++ classes Guinevere Larsen
2024-10-03 0:23 ` Thiago Jung Bauermann
2024-10-09 18:16 ` Guinevere Larsen
2024-10-03 20:06 ` Simon Marchi
2024-10-04 5:21 ` Simon Marchi
2024-10-10 14:10 ` Guinevere Larsen
2024-10-10 16:28 ` Simon Marchi
2024-10-09 20:00 ` Guinevere Larsen
2024-10-01 18:42 ` [PATCH v5 4/5] gdb: introduce ability to disable frame unwinders Guinevere Larsen
2024-10-02 6:10 ` Eli Zaretskii
2024-10-04 17:57 ` Guinevere Larsen
2024-10-03 2:45 ` Thiago Jung Bauermann [this message]
2024-10-08 19:23 ` Guinevere Larsen
2024-10-06 2:51 ` Simon Marchi
2024-10-09 13:32 ` Guinevere Larsen
2024-10-09 15:38 ` Simon Marchi
2024-10-01 18:42 ` [PATCH v5 5/5] gdb/testsuite: Test for a backtrace through object without debuginfo Guinevere Larsen
2024-10-03 2:47 ` Thiago Jung Bauermann
2024-10-03 6:58 ` Gerlicher, Klaus
2024-10-09 14:56 ` Guinevere Larsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87frpdaoqr.fsf@linaro.org \
--to=thiago.bauermann@linaro.org \
--cc=blarsen@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=guinevere@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox