Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Make gdb_caching_proc support namespaces
Date: Mon, 15 Sep 2025 23:55:18 -0400	[thread overview]
Message-ID: <e2ea45af-2974-4685-9fff-ac98e547c339@simark.ca> (raw)
In-Reply-To: <f187f2d1-f9d3-4862-ac51-5864da35c7ae@palves.net>



On 2025-09-15 19:57, Pedro Alves wrote:
> On 2025-09-15 22:54, Pedro Alves wrote:
>> I should have mentioned something here:
>>
>> On 2025-09-15 22:28, Pedro Alves wrote:
>>
>>> --- a/gdb/testsuite/lib/cache.exp
>>> +++ b/gdb/testsuite/lib/cache.exp
>>> @@ -24,26 +24,9 @@ proc ignore_pass { msg } {
>>>  
>>>  # Call proc real_name and return the result, while ignoring calls to pass.
>>>  proc gdb_do_cache_wrap {real_name args} {
>>> -    if { [info procs save_pass] != "" } {
>>> -	return [uplevel 2 $real_name]
>>> +    with_override pass ignore_pass {
>>> +	return [$real_name {*}$args]
>>>      }
>>
>> The previous code was using "uplevel 2" here.  But I'm struggling to see why that is the
>> right level.
>>
>> When gdb_do_cache_wrap is called via gdb_caching_proc => gdb_do_cache, that takes us to the scope of
>> the caller of the gdb_caching_proc, which off hand would seem right.
>>
>> However, when gdb_do_cache_wrap is called directly by gdb.testsuite/gdb-caching-proc-consistency.exp, it
>> takes us to ... the caller of test_proc?
>>
>> So I'm wondering, what could we possibly want to reference from a higher level in gdb_do_cache_wrap
>> that not having the uplevel in gdb_do_cache_wrap would get wrong?  A caching proc IMO shouldn't be doing
>> something like taking the name of a variable as argument instead of a value, as then the procedure wouldn't
>> be guaranteed to be idempotent?  So I dropped the uplevel, and found that that doesn't cause any
>> testsuite regression.  But maybe I'm missing something.  If I am, it'd be nice to add a testcase for it.
> 
> Trying to find a testcase for the above, I thought to try a gdb_caching_proc defined in a namespace,
> and have that proc access a namespace variable, in its own namespace.
> 
> That ran into the fact that gdb_caching_proc doesn't support namespaces today.  So I fixed that, with
> the patch below (on top of the previous one), which includes tests.  That still didn't require any
> uplevel in gdb_do_cache_wrap.
> 
> I don't have a current use for this, but I figure that eventually we will find a use, and since
> I wrote it...

I haven't looked at the code, but it fixes the problem for me.

Tested-By: Simon Marchi <simon.marchi@efficios.com>

Simon

  reply	other threads:[~2025-09-16  3:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15 21:28 [PATCH] Fix nested gdb_caching_proc with args; Fix gdb.rocm/ tests Pedro Alves
2025-09-15 21:54 ` Pedro Alves
2025-09-15 23:57   ` [PATCH] Make gdb_caching_proc support namespaces Pedro Alves
2025-09-16  3:55     ` Simon Marchi [this message]
2025-09-16  9:31   ` [PATCH v2] Fix nested gdb_caching_proc with args; Fix gdb.rocm/ tests Pedro Alves
2025-09-16 10:56     ` Pedro Alves

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=e2ea45af-2974-4685-9fff-ac98e547c339@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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