How to implement a new Python command that takes values from tty?

Yifei Zheng <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Hi there,

I have written a few gdb pretty-printers using Python but this time I'm 
trying to write a new command in Python. I want it to take arguments 
from gdb and somewhat works like gdb's print. (It's a special printer 
for some kind of std::vector).

I know I should start by inheriting `gdb.Command` and call `__init__`, 
but I'm definitely stuck on `invoke`. The arguments passed in are in 
string, which, I would like to convert them to gdb.Value, by looking 
them up somehow. I have a partially working version that uses 
"gdb.lookup_symbol", but it does not work for expressions (of course, 
expected).

For example, say the command was called `ppack` which accepts an 
argument just as native `print` do. Desired syntax would be like "pprint 
some_var" or "pprint some_other_var.field1" or "pprint *some_ptr".

How can I let gdb evaluates the expression for me so that I don't have 
to parse it, and then give me the value instead of the name?

Thanks,
Yifei
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.