This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to implement a new Python command that takes values from tty?
- From: Yifei Zheng <zheng432 at purdue dot edu>
- To: Tom Tromey <tom at tromey dot com>
- Cc: gdb at sourceware dot org
- Date: Wed, 4 Oct 2017 17:34:21 -0400
- Subject: Re: How to implement a new Python command that takes values from tty?
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=zheng432 at purdue dot edu;
- References: <42da207c-05cf-9648-bba7-650611a7bff4@purdue.edu> <87lgkqlig7.fsf@tromey.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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 <zheng432@purdue.edu> 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