Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Elmenthaler, Jens" <jens.elmenthaler@verigy.com>
To: <gdb@sourceware.org>
Subject: RE: MI Interface and Pretty Print to_string() result
Date: Sun, 07 Mar 2010 10:16:00 -0000	[thread overview]
Message-ID: <58596C4646708B4BB990C4483997333001E4F2C5@usplmvpbe001.ent.rt.verigy.net> (raw)
In-Reply-To: <m3zl2mqqgy.fsf@fleche.redhat.com>

Jens> The current issue is that if I have a pointer as a direct or
Jens> indirect child of a dynamic variable object, how do I dereference
Jens> it? The way it is done without pretty printers is to take the
Jens> result of -var-info-path-expression, and than create a variable
Jens> object for *(resulting-expression).

Tom> If that is the only problem, what about adding a new command to
Tom> dereference the pointer and add a child to the varobj?

I noticed that the Eclipse CDT requires the result of -var-info-path-expression, but it is not used to dereference it and determine the children. The gdb already behaves nicely, as it returns a single child for references and pointers, which is the dereferenced value. This is independent of whether it is a actually a child of a pretty printer or not. So, the most important use case is handled perfectly.

I found it is used for the following purposes:

- display label: well, I can construct something meaningful easily

- determine address and size of the value, most notably, to create a watchpoint from it. Well, here a new MI command would indeed help. In order to determine address and size, the CDT builds new expressions from the value (i.e. "&(value-expression)" and "sizeof(value-expression)"), and calls -data-evaluate-expression. This is what is no longer possible with children of dynamic variable objects.

Tom> The only way I can think of to truly implement -var-info-path-
Tom> expression
Tom> would be to let the printers return path expressions.  That is going to
Tom> yield some crazy expressions, though, for many typical containers.

Well, from what I saw in the Eclipse CDT, the main purpose of -var-info-path-expression is to be later able to use them in other expressions. The Eclipse CDT has an expressions view. As a user I would expect, that if a vector "v" displays a child with the name [0], that I also could create an expression v.[0] (well actually v[0], but this is not a real problem) in the expression view. However, that is not possible, since the gdb will not be able to evaluate this expression.

For this, it would be sufficient, if gdb would map "v.[0]" to the child named "[0]". The pretty printers children() method provides all information that is need. The relative expression of a child to it's parent simple is the name of the child. The expressions resulting from it don't look like real C/C++ anymore, but this is something a user could possibly deal with. In the worst case, a gdb frontend could polish that up by using the disply hint information.

Jens Elmenthaler
Platform & Components Lab
SW Designer R&D


Verigy Germany GmbH, Herrenberger Str. 130, 71034 Böblingen
Sitz der Gesellschaft: Böblingen - Amtsgericht Böblingen HRB 6167
WEEE-Reg.-Nr. DE 16968742
Geschäftsführer: Hans-Jürgen Wagner, Dietmar Höller

Tel: +49 7031 4357-119
jens.elmenthaler@verigy.com
 

-----Original Message-----
From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On Behalf Of Tom Tromey
Sent: Samstag, 6. März 2010 00:49
To: Elmenthaler, Jens
Cc: gdb@sourceware.org
Subject: Re: MI Interface and Pretty Print to_string() result

>>>>> "Jens" == Elmenthaler, Jens <jens.elmenthaler@verigy.com> writes:

Jens> The current issue is that if I have a pointer as a direct or
Jens> indirect child of a dynamic variable object, how do I dereference
Jens> it? The way it is done without pretty printers is to take the
Jens> result of -var-info-path-expression, and than create a variable
Jens> object for *(resulting-expression).

If that is the only problem, what about adding a new command to
dereference the pointer and add a child to the varobj?

The only way I can think of to truly implement -var-info-path-expression
would be to let the printers return path expressions.  That is going to
yield some crazy expressions, though, for many typical containers.

Tom


  reply	other threads:[~2010-03-07 10:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-23  7:08 How to set default value of yquery and nquery Hui Zhu
2010-02-23  7:53 ` MI Interface and Pretty Print to_string() result Elmenthaler, Jens
2010-03-03 22:14   ` Tom Tromey
2010-03-04  8:14     ` Elmenthaler, Jens
2010-03-05 23:49       ` Tom Tromey
2010-03-07 10:16         ` Elmenthaler, Jens [this message]
2010-03-08 20:17           ` Tom Tromey
2010-02-23 17:13 ` How to set default value of yquery and nquery Tom Tromey
2010-02-24  6:08   ` Marc Khouzam
2010-02-24  9:53     ` Hui Zhu
2010-02-24 16:41       ` Marc Khouzam
2010-02-25 16:26         ` Hui Zhu
2010-02-26  0:23           ` Marc Khouzam
2010-02-26 17:31             ` Hui Zhu
2010-02-24  6:19   ` Hui Zhu

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=58596C4646708B4BB990C4483997333001E4F2C5@usplmvpbe001.ent.rt.verigy.net \
    --to=jens.elmenthaler@verigy.com \
    --cc=gdb@sourceware.org \
    /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