From: Daniel Jacobowitz <drow@mvista.com>
To: Keith Seitz <keiths@redhat.com>, gdb-patches@sources.redhat.com
Subject: Re: [RFA] varobj: call CHECK_TYPEDEF
Date: Thu, 19 Jun 2003 19:53:00 -0000 [thread overview]
Message-ID: <20030619194513.GA7225@nevyn.them.org> (raw)
In-Reply-To: <20030619192845.GA2379@nevyn.them.org>
On Thu, Jun 19, 2003 at 03:28:45PM -0400, Daniel Jacobowitz wrote:
> On Wed, Jun 11, 2003 at 09:28:10PM -0400, Daniel Jacobowitz wrote:
> > On Wed, Jun 11, 2003 at 05:36:02PM -0700, Keith Seitz wrote:
> > > On Wed, 2003-06-11 at 16:49, David Carlton wrote:
> > > > I've just gone and looked over the thread and at Keith's patch; I
> > > > think the idea is sound, but the implementation isn't. The comments
> > > > at the top of get_type say that it's supposed to skip past typedefs,
> > > > so calling CHECK_TYPEDEF certainly seems legitimate. But
> > > > CHECK_TYPEDEF calls check_typedef, which already goes through chains
> > > > of typedefs, so you can get rid of the loop in get_type.
> > >
> > > Yup, I think you are correct. I'm sure that I was just being laz^Whasty.
> > > :-)
> >
> > David's analysis sounds right to me. I'll look over the actual code
> > tomorrow, really I will...
>
> I don't think David's conversions are quite right; close though.
> However, something here is fishy.
>
> Compare:
> /* This returns the type of the variable. This skips past typedefs
> and returns the real type of the variable. It also dereferences
> pointers and references.
> vs.
> static struct type *
> get_type (struct varobj *var)
> {
> struct type *type;
> type = var->type;
>
> while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
> type = TYPE_TARGET_TYPE (type);
>
> return type;
> }
>
> That doesn't dereference pointers and references! It looks like
> get_type got inserted between get_type_deref and its comments? Can you
> confirm that it shouldn't dereference?
>
> Assuming get_type is not supposed to dereference pointers, then this
> would work:
>
> /* This returns the type of the variable. It also skips past typedefs
> to return the real type of the variable.
>
> NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
> except within get_target_type and get_type. */
> static struct type *
> get_type (struct varobj *var)
> {
> struct type *type;
> type = var->type;
>
> if (type != NULL)
> type = check_typedef (type);
>
> return type;
> }
>
> /* This returns the target type (or NULL) of TYPE, also skipping
> past typedefs, just like get_type ().
>
> NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
> except within get_target_type and get_type. */
> static struct type *
> get_target_type (struct type *type)
> {
> if (type != NULL)
> {
> type = TYPE_TARGET_TYPE (type);
> type = check_typedef (type);
> }
>
> return type;
> }
>
> Test results for that look OK but I don't have insight built at the
> moment, so I didn't test it.
I take that back. Test results are abominable; everything crashes
because I misunderstood the use of get_target_type. Try this patch.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-06-19 Daniel Jacobowitz <drow@mvista.com>
* varobj.c (get_type, get_target_type): Use check_typedef.
Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.38
diff -u -p -r1.38 varobj.c
--- varobj.c 4 Dec 2002 00:05:54 -0000 1.38
+++ varobj.c 19 Jun 2003 19:42:17 -0000
@@ -1379,9 +1379,8 @@ make_cleanup_free_variable (struct varob
return make_cleanup (do_free_variable_cleanup, var);
}
-/* This returns the type of the variable. This skips past typedefs
- and returns the real type of the variable. It also dereferences
- pointers and references.
+/* This returns the type of the variable. It also skips past typedefs
+ to return the real type of the variable.
NOTE: TYPE_TARGET_TYPE should NOT be used anywhere in this file
except within get_target_type and get_type. */
@@ -1391,8 +1390,8 @@ get_type (struct varobj *var)
struct type *type;
type = var->type;
- while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
- type = TYPE_TARGET_TYPE (type);
+ if (type != NULL)
+ type = check_typedef (type);
return type;
}
@@ -1423,8 +1422,8 @@ get_target_type (struct type *type)
if (type != NULL)
{
type = TYPE_TARGET_TYPE (type);
- while (type != NULL && TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
- type = TYPE_TARGET_TYPE (type);
+ if (type != NULL)
+ type = check_typedef (type);
}
return type;
next prev parent reply other threads:[~2003-06-19 19:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-24 20:47 Keith Seitz
2003-04-24 20:52 ` Daniel Jacobowitz
2003-04-24 21:51 ` Keith Seitz
2003-04-24 21:55 ` Daniel Jacobowitz
2003-04-24 22:18 ` Keith Seitz
[not found] ` <3EA84A9B.5020308@redhat.com>
2003-04-24 22:27 ` Keith Seitz
2003-04-24 22:31 ` Andrew Cagney
2003-04-25 0:18 ` Keith Seitz
2003-04-25 2:15 ` Daniel Jacobowitz
2003-04-25 3:47 ` Andrew Cagney
2003-04-25 5:32 ` Daniel Jacobowitz
2003-06-11 20:07 ` Keith Seitz
2003-06-11 21:01 ` Andrew Cagney
2003-06-11 23:51 ` David Carlton
2003-06-12 0:28 ` Keith Seitz
2003-06-12 1:28 ` Daniel Jacobowitz
2003-06-19 19:28 ` Daniel Jacobowitz
2003-06-19 19:53 ` Daniel Jacobowitz [this message]
2003-06-19 20:33 ` Keith Seitz
2003-06-19 20:43 ` Daniel Jacobowitz
2003-06-19 21:30 ` Keith Seitz
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=20030619194513.GA7225@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb-patches@sources.redhat.com \
--cc=keiths@redhat.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