public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* MI to access value of $ prefixed variable name
@ 2021-05-25  4:35 Jonah Graham
  2021-05-25 14:03 ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Jonah Graham @ 2021-05-25  4:35 UTC (permalink / raw)
  To: GDB Development

Hello,

I have a user of Eclipse CDT who is having problems displaying a C variable
called $j (dollar sign prefixed variable) -
https://bugs.eclipse.org/bugs/show_bug.cgi?id=573703

I understand this is because $ prefixed variables are treated specially by
GDB.

47-stack-list-locals --thread 1 --frame 0 1
47^done,locals=[{name="$f",value="0"}]

52-var-create --thread 1 --frame 0 - * $f
52^done,name="var3",numchild="0",value="void",type="void",has_more="0"

Note type "void" above, $f is an int in the C code, but is indeed void (as
expected) in GDB. -stack-list-locals shows the correct value, but I can't
use the returned name back to -var-create because of the naming conflict.

There wasn't anything I saw in the help (
https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html)
on this topic.

Thanks for your help.
Jonah

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MI to access value of $ prefixed variable name
  2021-05-25  4:35 MI to access value of $ prefixed variable name Jonah Graham
@ 2021-05-25 14:03 ` Simon Marchi
  2021-05-25 17:11   ` Jonah Graham
  2021-06-01 18:57   ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Marchi @ 2021-05-25 14:03 UTC (permalink / raw)
  To: Jonah Graham, GDB Development

On 2021-05-25 12:35 a.m., Jonah Graham wrote:
> Hello,
> 
> I have a user of Eclipse CDT who is having problems displaying a C variable
> called $j (dollar sign prefixed variable) -
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=573703
> 
> I understand this is because $ prefixed variables are treated specially by
> GDB.
> 
> 47-stack-list-locals --thread 1 --frame 0 1
> 47^done,locals=[{name="$f",value="0"}]
> 
> 52-var-create --thread 1 --frame 0 - * $f
> 52^done,name="var3",numchild="0",value="void",type="void",has_more="0"
> 
> Note type "void" above, $f is an int in the C code, but is indeed void (as
> expected) in GDB. -stack-list-locals shows the correct value, but I can't
> use the returned name back to -var-create because of the naming conflict.
> 
> There wasn't anything I saw in the help (
> https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html)
> on this topic.

Huh, I didn't know this was possible:

https://gcc.gnu.org/onlinedocs/gcc/Dollar-Signs.html#Dollar-Signs

I didn't look in depth, but I don't think there's a way to make it work.
I don't remember seeing a way to escape that dollar sign.

I'd say that the simplest solution would be: don't use dollar sign in
identifiers.  But if somebody really wants GDB to support it, then they
can always send a patch for it (I don't think this is a priority for
anyone).

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MI to access value of $ prefixed variable name
  2021-05-25 14:03 ` Simon Marchi
@ 2021-05-25 17:11   ` Jonah Graham
  2021-06-01 18:57   ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Jonah Graham @ 2021-05-25 17:11 UTC (permalink / raw)
  To: Simon Marchi; +Cc: GDB Development

On Tue, 25 May 2021 at 10:04, Simon Marchi <simon.marchi@polymtl.ca> wrote:

> On 2021-05-25 12:35 a.m., Jonah Graham wrote:
> > Hello,
> >
> > I have a user of Eclipse CDT who is having problems displaying a C
> variable
> > called $j (dollar sign prefixed variable) -
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=573703
> >
> > I understand this is because $ prefixed variables are treated specially
> by
> > GDB.
> >
> > 47-stack-list-locals --thread 1 --frame 0 1
> > 47^done,locals=[{name="$f",value="0"}]
> >
> > 52-var-create --thread 1 --frame 0 - * $f
> > 52^done,name="var3",numchild="0",value="void",type="void",has_more="0"
> >
> > Note type "void" above, $f is an int in the C code, but is indeed void
> (as
> > expected) in GDB. -stack-list-locals shows the correct value, but I can't
> > use the returned name back to -var-create because of the naming conflict.
> >
> > There wasn't anything I saw in the help (
> >
> https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
> )
> > on this topic.
>
> Huh, I didn't know this was possible:
>
> https://gcc.gnu.org/onlinedocs/gcc/Dollar-Signs.html#Dollar-Signs


The main place I have seen this in practice is generated code.


> I didn't look in depth, but I don't think there's a way to make it work.
> I don't remember seeing a way to escape that dollar sign.
>

No problem - thanks for the answer.

I'd say that the simplest solution would be: don't use dollar sign in
> identifiers.  But if somebody really wants GDB to support it, then they
> can always send a patch for it (I don't think this is a priority for
> anyone).
>

OK. I will update the bugzilla in CDT with this information.

Jonah

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: MI to access value of $ prefixed variable name
  2021-05-25 14:03 ` Simon Marchi
  2021-05-25 17:11   ` Jonah Graham
@ 2021-06-01 18:57   ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2021-06-01 18:57 UTC (permalink / raw)
  To: Simon Marchi via Gdb

>>>>> "Simon" == Simon Marchi via Gdb <gdb@sourceware.org> writes:

Simon> I'd say that the simplest solution would be: don't use dollar sign in
Simon> identifiers.  But if somebody really wants GDB to support it, then they
Simon> can always send a patch for it (I don't think this is a priority for
Simon> anyone).

I think it would be fine if someone wanted to solve this.
Maybe one idea would be to defer to variables from the inferior, but
provide some additional way to refer to convenience variables.  Or maybe
vice versa.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-01 18:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25  4:35 MI to access value of $ prefixed variable name Jonah Graham
2021-05-25 14:03 ` Simon Marchi
2021-05-25 17:11   ` Jonah Graham
2021-06-01 18:57   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).