* same-name vars from different scopes
@ 2010-03-18 23:15 Michael Snyder
2010-03-19 1:54 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2010-03-18 23:15 UTC (permalink / raw)
To: gdb
Is there a syntax for printing/using a static variable from a different
module, even though it's eclipsed by a more-local variable of the
same name?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: same-name vars from different scopes
2010-03-18 23:15 same-name vars from different scopes Michael Snyder
@ 2010-03-19 1:54 ` Tom Tromey
2010-03-19 5:28 ` Joel Brobecker
2010-03-19 17:41 ` Michael Snyder
0 siblings, 2 replies; 5+ messages in thread
From: Tom Tromey @ 2010-03-19 1:54 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb
>>>>> "Michael" == Michael Snyder <msnyder@vmware.com> writes:
Michael> Is there a syntax for printing/using a static variable from a
Michael> different module, even though it's eclipsed by a more-local
Michael> variable of the same name?
According the node Variables in the manual, this should work:
print 'file.c'::global
Surprisingly, I don't think I have ever actually done this.
There's no syntax for printing a local variable which is hidden by a
more inner definition.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: same-name vars from different scopes
2010-03-19 1:54 ` Tom Tromey
@ 2010-03-19 5:28 ` Joel Brobecker
2010-03-19 17:54 ` Tom Tromey
2010-03-19 17:41 ` Michael Snyder
1 sibling, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2010-03-19 5:28 UTC (permalink / raw)
To: Tom Tromey; +Cc: Michael Snyder, gdb
> There's no syntax for printing a local variable which is hidden by a
> more inner definition.
In that case, I think you have to switch frames (there might be
a known bug with Ada on that subject).
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: same-name vars from different scopes
2010-03-19 1:54 ` Tom Tromey
2010-03-19 5:28 ` Joel Brobecker
@ 2010-03-19 17:41 ` Michael Snyder
1 sibling, 0 replies; 5+ messages in thread
From: Michael Snyder @ 2010-03-19 17:41 UTC (permalink / raw)
To: tromey; +Cc: gdb
Tom Tromey wrote:
>>>>>> "Michael" == Michael Snyder <msnyder@vmware.com> writes:
>
> Michael> Is there a syntax for printing/using a static variable from a
> Michael> different module, even though it's eclipsed by a more-local
> Michael> variable of the same name?
>
> According the node Variables in the manual, this should work:
>
> print 'file.c'::global
>
> Surprisingly, I don't think I have ever actually done this.
>
> There's no syntax for printing a local variable which is hidden by a
> more inner definition.
Thanks Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: same-name vars from different scopes
2010-03-19 5:28 ` Joel Brobecker
@ 2010-03-19 17:54 ` Tom Tromey
0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2010-03-19 17:54 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Michael Snyder, gdb
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
>> There's no syntax for printing a local variable which is hidden by a
>> more inner definition.
Joel> In that case, I think you have to switch frames (there might be
Joel> a known bug with Ada on that subject).
Actually, I meant nested lexical scopes:
void f () {
int x = something;
{
int x = something_else;
}
}
If you in the inner scope, you can't refer directly to the outer 'x'.
You can see it with "info locals", but you can't use it in an expression.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-19 17:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-18 23:15 same-name vars from different scopes Michael Snyder
2010-03-19 1:54 ` Tom Tromey
2010-03-19 5:28 ` Joel Brobecker
2010-03-19 17:54 ` Tom Tromey
2010-03-19 17:41 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox