From: Keith Seitz <keiths@redhat.com>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH 05/11] [gdb/testsuite] Add transparent_uplevel
Date: Tue, 1 Sep 2026 09:16:50 -0700 [thread overview]
Message-ID: <ba86a1a0-5a2e-41f8-99f0-70df46b505e8@redhat.com> (raw)
In-Reply-To: <20260824135855.1195963-6-tdevries@suse.de>
Hi,
On 8/24/26 6:58 AM, Tom de Vries wrote:
> Having learned the trick of increasing -level, factor out a new proc
> transparent_uplevel:
> ...
> proc transparent_uplevel { body } {
> catch {uplevel 2 $body} result opts
> return -options [dict incr opts -level 2] $result
> ...
> to be used in conjunction with try/finally to apply this pattern:
> ...
> proc foo { body } {
> <do something>
> try {
> transparent_uplevel $body
> } finally {
> <do something else>
> }
> }
> ...
> such that "foo body" has the same effect as "body", apart from the
> <do something>/<do something else> parts.
>
> This proc has the fix for PR34553 designed into it, so (correctly) applying it
> in a proc will fix the PR there.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34553
> ---
> gdb/testsuite/lib/gdb.exp | 47 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 88a42aff4ac..853b45f4a53 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -3218,6 +3218,53 @@ gdb_caching_proc allow_tui_tests {} {
> return [expr {[string first "--enable-tui" $output] != -1}]
> }
>
> +# Run BODY in the context of the callers caller.
Typo: "caller's caller".
> +#
> +# To be used in a proc foo:
> +# proc foo {body} {
> +# transparent_uplevel body
> +# }
I think "body" here is missing a '$'?
Keith
> +# to make "foo body" have the same effect as "body".
> +#
> +# It ensures this by doing two things:
> +# - evaluating the body in the context of the caller of foo
> +# - propagating any return, exceptional or not to the caller of foo.
> +#
> +# Typically used in conjunction with try/finally, to ensure something
> +# happens before and after body. For instance, this:
> +# proc foo {body} {
> +# try {
> +# puts "foo: enter"
> +# transparent_uplevel $body
> +# } finally {
> +# puts "foo: exit"
> +# }
> +# }
> +#
> +# for {set i 0} {$i < 5} {incr i} {
> +# puts $i
> +# foo {
> +# if {$i == 2} {
> +# break
> +# }
> +# }
> +# }
> +# produces:
> +# 0
> +# foo: enter
> +# foo: exit
> +# 1
> +# foo: enter
> +# foo: exit
> +# 2
> +# foo: enter
> +# foo: exit
> +
> +proc transparent_uplevel { body } {
> + catch {uplevel 2 $body} result opts
> + return -options [dict incr opts -level 2] $result
> +}
> +
> # Test files shall make sure all the test result lines in gdb.sum are
> # unique in a test run, so that comparing the gdb.sum files of two
> # test runs gives correct results. Test files that exercise
next prev parent reply other threads:[~2026-09-01 16:17 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 13:58 [PATCH 00/11] [gdb/testsuite] Refactor exception handling Tom de Vries
2026-08-24 13:58 ` [PATCH 01/11] [gdb/testsuite] Normalize indentation in with_test_prefix Tom de Vries
2026-09-02 19:41 ` Tom Tromey
2026-09-04 9:48 ` Tom de Vries
2026-08-24 13:58 ` [PATCH 02/11] [gdb/testsuite] Fix return -level 2 bug " Tom de Vries
2026-09-02 19:46 ` Tom Tromey
2026-08-24 13:58 ` [PATCH 03/11] [gdb/testsuite] Simplify foreach_with_prefix Tom de Vries
2026-08-24 13:58 ` [PATCH 04/11] [gdb/testsuite] Refactor exception handling in foreach_with_prefix Tom de Vries
2026-08-24 13:58 ` [PATCH 05/11] [gdb/testsuite] Add transparent_uplevel Tom de Vries
2026-09-01 16:16 ` Keith Seitz [this message]
2026-08-24 13:58 ` [PATCH 06/11] [gdb/testsuite] Refactor exception handling Tom de Vries
2026-08-24 13:58 ` [PATCH 07/11] [gdb/testsuite] Refactor exception handling in gdb_expect Tom de Vries
2026-08-24 13:58 ` [PATCH 08/11] [gdb/testsuite] Refactor exception handling in gdb_test_multiple Tom de Vries
2026-08-25 7:29 ` Tom de Vries
2026-09-01 16:13 ` Keith Seitz
2026-08-24 13:58 ` [PATCH 09/11] [gdb/testsuite] Refactor exception handling in lock_file_acquire/release Tom de Vries
2026-08-24 13:58 ` [PATCH 10/11] [gdb/testsuite] Refactor exception handling in tentative_rename Tom de Vries
2026-08-24 13:58 ` [PATCH 11/11] [gdb/testsuite] Refactor exception handling in with_stub_devices Tom de Vries
2026-09-01 16:10 ` Keith Seitz
2026-09-01 17:07 ` [PATCH 00/11] [gdb/testsuite] Refactor exception handling Keith Seitz
2026-09-02 19:57 ` Tom Tromey
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=ba86a1a0-5a2e-41f8-99f0-70df46b505e8@redhat.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/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