Re: MI to access value of $ prefixed variable name

Simon Marchi via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.