Re: 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 Tom, Thank you for pointing me out "parse_and_eval". I didn't write an pretty printer because it'll be a little ambiguous on type matching. Say the type I wanted to print is "std::vector<Var*>" (which I call a pack) where Var is a class and has its own printer. What I wanted to do is to dereference all pointers in the vector and pretty-print each one. However, some of the "std::vector<Var*>"s are packs while some are not. It's at debugger users' discretion. I don't know if that's generally a good practice or not. Any better idea? Yifei On 04/10/2017 5:19 PM, Tom Tromey wrote: >>>>>> "Yifei" == Yifei Zheng <[email protected]> writes: > > Yifei> I have written a few gdb pretty-printers using Python but this time > Yifei> I'm trying to write a new command in Python. I want it to take > Yifei> arguments from gdb and somewhat works like gdb's print. (It's a > Yifei> special printer for some kind of std::vector). > > I'm curious why not write a pretty-printer for this case as well? > > Yifei> How can I let gdb evaluates the expression for me so that I don't have > Yifei> to parse it, and then give me the value instead of the name? > > You want gdb.parse_and_eval. > > Tom >