vuvova / gdb-tools

Various tools to improve the gdb experience
BSD 3-Clause "New" or "Revised" License
123 stars 17 forks source link

Support assigned variables #7

Closed spectrec closed 7 years ago

spectrec commented 7 years ago
(gdb) set variable $i = 0
(gdb) p $i
$1 = 0
(gdb) dl $i
Expected 'if' or ident or '&&/' or '||/' or '#/' or '+/' or '-' or '*' or '&' or '!' or '~' or '(cast)' or real or hexadecimal or decimal or octal or char or string or underscores or ident or '(' or '{' or '..' at position (1, 1) => '*$i'

is it possible to fix this?)

vuvova commented 7 years ago

Yes, it's even in TODO.

gdb convenience variables are not true symbols, so one would need to use gdb.parse_and_eval() to get them. But Ident class already does, so I suspect the fix would simply be to extend the syntax to allow identifiers to start with a dollar sign.

Note that it won't let gdb convenience functions (like $_streq) to work, the error is

Python Exception <type 'exceptions.RuntimeError'> Value is not callable (not TYPE_CODE_FUNC).: 

the type is "internal function" and it's not callable. I consider it a bug in gdb, pretty much like "object method" values are not callable either.