Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Jim Blandy" <jimb@red-bean.com>
To: "Vladimir Prus" <ghost@cs.msu.su>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Variable objects: references formatting
Date: Thu, 04 May 2006 06:08:00 -0000	[thread overview]
Message-ID: <8f2776cb0605032308r7645469di45fda7e57ae5718c@mail.gmail.com> (raw)
In-Reply-To: <200605040918.33856.ghost@cs.msu.su>

On 5/3/06, Vladimir Prus <ghost@cs.msu.su> wrote:
> > - In GDB, when traversing types, remember to call check_typedef to
> > avoid having your traversal stopped by typedef nodes.
>
> Thanks, noted. So, in this case I should have called check_typedef before
> checking if type is reference, right?

Well, the get_type function is taking care of that one for you.  So
it's enough to check the new types you uncover with TYPE_TARGET_TYPE.

> Would you like me to resend the patch adjusted per your comments, or you've
> already done those changes locally?

I've already done them.  Here's the patch I actually committed (which
I should have posted when I did so):

gdb/ChangeLog:
2006-05-03  Vladimir Prus  <ghost@cs.msu.su>

       * varobj.c (c_value_of_variable): Ignore top-level references.
       (Committed by Jim Blandy.)

Index: gdb/varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.59
diff -u -p -r1.59 varobj.c
--- gdb/varobj.c	27 Mar 2006 00:15:22 -0000	1.59
+++ gdb/varobj.c	3 May 2006 18:07:43 -0000
@@ -2054,10 +2054,16 @@ c_variable_editable (struct varobj *var)
 static char *
 c_value_of_variable (struct varobj *var)
 {
-  /* BOGUS: if val_print sees a struct/class, it will print out its
-     children instead of "{...}" */
+  /* BOGUS: if val_print sees a struct/class, or a reference to one,
+     it will print out its children instead of "{...}".  So we need to
+     catch that case explicitly.  */
+  struct type *type = get_type (var);
+
+  /* Strip top-level references. */
+  while (TYPE_CODE (type) == TYPE_CODE_REF)
+    type = check_typedef (TYPE_TARGET_TYPE (type));

-  switch (TYPE_CODE (get_type (var)))
+  switch (TYPE_CODE (type))
     {
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:


  reply	other threads:[~2006-05-04  6:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-03  9:22 Vladimir Prus
2006-05-03 17:50 ` Jim Blandy
2006-05-03 18:08   ` Jim Blandy
2006-05-04  5:19     ` Vladimir Prus
2006-05-04  6:08       ` Jim Blandy [this message]
2006-05-04  6:10         ` Vladimir Prus
2006-05-03 23:05 Nick Roberts
2006-05-03 23:50 ` Jim Blandy
2006-05-04  1:53   ` Nick Roberts
2006-05-04 17:32     ` Jim Blandy
2006-05-04 22:30       ` Nick Roberts
2006-05-05  8:08         ` Jim Blandy
2006-05-04  5:30 ` Vladimir Prus
2006-05-04  6:21   ` Nick Roberts
2006-05-04  7:00     ` Vladimir Prus
2006-05-04  7:20       ` Nick Roberts
2006-05-04 12:10         ` Vladimir Prus

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=8f2776cb0605032308r7645469di45fda7e57ae5718c@mail.gmail.com \
    --to=jimb@red-bean.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=ghost@cs.msu.su \
    /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