Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Yifei Zheng <zheng432@purdue.edu>
To: Tom Tromey <tom@tromey.com>
Cc: gdb@sourceware.org
Subject: Re: How to implement a new Python command that takes values from tty?
Date: Wed, 04 Oct 2017 21:34:00 -0000	[thread overview]
Message-ID: <8bc7860c-aeeb-59a2-451c-aa087bcf98bb@purdue.edu> (raw)
In-Reply-To: <87lgkqlig7.fsf@tromey.com>

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
> 


      reply	other threads:[~2017-10-04 21:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03 22:42 Yifei Zheng
2017-10-04 21:19 ` Tom Tromey
2017-10-04 21:34   ` Yifei Zheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8bc7860c-aeeb-59a2-451c-aa087bcf98bb@purdue.edu \
    --to=zheng432@purdue.edu \
    --cc=gdb@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox