From: Daniel Jacobowitz <drow@mvista.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFA/c++] Fix printing classes with virtual base classes
Date: Mon, 26 Nov 2001 18:02:00 -0000 [thread overview]
Message-ID: <20011126210231.A32203@nevyn.them.org> (raw)
Message-ID: <20011126180200.mcfeE8BjODpHjUxgT5GKMGN4J9oQbGwblWWC9fdHOs0@z> (raw)
In-Reply-To: <20011126201945.A27754@nevyn.them.org>
On Mon, Nov 26, 2001 at 08:19:45PM -0500, Daniel Jacobowitz wrote:
> Whew. Finally tracked this down.
[snip correct explanation]
[snip incorrect patch]
I find the use of VALUE_OFFSET and VALUE_EMBEDDED_OFFSET exceedingly
unintuitive. Go figure. This one works a little bit better yet.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2001-11-26 Daniel Jacobowitz <drow@mvista.com>
* gnu-v3-abi.c (gnuv3_rtti_type): Explicitly cast
the vtable pointer to a pointer before loading it.
(gnuv3_virtual_fn_field): Likewise.
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.4
diff -u -p -r1.4 gnu-v3-abi.c
--- gnu-v3-abi.c 2001/10/16 01:58:07 1.4
+++ gnu-v3-abi.c 2001/11/27 02:00:22
@@ -188,7 +188,7 @@ gnuv3_rtti_type (struct value *value,
struct type *vtable_type = gdbarch_data (vtable_type_gdbarch_data);
struct type *value_type = check_typedef (VALUE_TYPE (value));
CORE_ADDR vtable_address;
- struct value *vtable;
+ struct value *vtable, *vtable_addr_value, *vtable_field;
struct minimal_symbol *vtable_symbol;
const char *vtable_symbol_name;
const char *class_name;
@@ -207,9 +207,20 @@ gnuv3_rtti_type (struct value *value,
return NULL;
/* Fetch VALUE's virtual table pointer, and tweak it to point at
- an instance of our imaginary gdb_gnu_v3_abi_vtable structure. */
+ an instance of our imaginary gdb_gnu_v3_abi_vtable structure.
+ The type of the field may not be a pointer type. In a derived
+ class with a virtual base class, it will be the type of the base
+ class. Thus we need to cast. */
+ vtable_field = value_field (value,
+ TYPE_VPTR_FIELDNO (value_type));
+ vtable_addr_value =
+ value_at (builtin_type_void_data_ptr,
+ VALUE_ADDRESS (vtable_field)
+ + VALUE_OFFSET (vtable_field)
+ + VALUE_EMBEDDED_OFFSET (vtable_field),
+ VALUE_BFD_SECTION (value));
vtable_address
- = value_as_address (value_field (value, TYPE_VPTR_FIELDNO (value_type)));
+ = value_as_address (vtable_addr_value);
vtable = value_at_lazy (vtable_type,
vtable_address - vtable_address_point_offset (),
VALUE_BFD_SECTION (value));
@@ -277,7 +288,7 @@ gnuv3_virtual_fn_field (struct value **v
struct type *value_type = check_typedef (VALUE_TYPE (value));
struct type *vfn_base;
CORE_ADDR vtable_address;
- struct value *vtable;
+ struct value *vtable, *vtable_addr_value, *vtable_field;
struct value *vfn;
/* Some simple sanity checks. */
@@ -309,9 +320,19 @@ gnuv3_virtual_fn_field (struct value **v
value = value_ind (value_cast (vfn_base, value_addr (value)));
/* Now value is an object of the appropriate base type. Fetch its
- virtual table. */
+ virtual table. As in gnuv3_rtti_type, the type of the field may
+ not be a pointer type. In a derived class with a virtual base class,
+ it will be the type of the base class. Thus we need to cast. */
+ vtable_field = value_field (value,
+ TYPE_VPTR_FIELDNO (vfn_base));
+ vtable_addr_value =
+ value_at (builtin_type_void_data_ptr,
+ VALUE_ADDRESS (vtable_field)
+ + VALUE_OFFSET (vtable_field)
+ + VALUE_EMBEDDED_OFFSET (vtable_field),
+ VALUE_BFD_SECTION (value));
vtable_address
- = value_as_address (value_field (value, TYPE_VPTR_FIELDNO (vfn_base)));
+ = value_as_address (vtable_addr_value);
vtable = value_at_lazy (vtable_type,
vtable_address - vtable_address_point_offset (),
VALUE_BFD_SECTION (value));
next prev parent reply other threads:[~2001-11-26 18:02 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-13 9:24 Daniel Jacobowitz
2001-11-13 9:24 ` Daniel Jacobowitz [this message]
2001-11-13 9:34 ` Kevin Buettner
2001-11-26 18:25 ` Kevin Buettner
2001-11-26 21:07 ` Andrew Cagney
2001-11-13 21:56 ` Andrew Cagney
2001-11-14 22:09 ` Jim Blandy
2001-11-27 12:48 ` Jim Blandy
2001-11-26 18:02 ` Daniel Jacobowitz
2001-11-13 18:02 ` Jim Blandy
2001-11-14 9:33 ` Daniel Jacobowitz
2001-11-14 22:39 ` Jim Blandy
2001-11-14 22:41 ` Daniel Jacobowitz
2001-11-27 13:26 ` Daniel Jacobowitz
2001-11-21 13:03 ` Daniel Jacobowitz
2001-11-22 13:53 ` Jim Blandy
2001-11-30 11:42 ` Jim Blandy
2001-11-29 22:41 ` Daniel Jacobowitz
2001-11-30 8:48 ` Andrew Cagney
2001-11-21 17:30 ` Andrew Cagney
2001-11-30 8:57 ` Daniel Jacobowitz
2001-11-21 23:07 ` Daniel Jacobowitz
2001-11-27 13:16 ` Jim Blandy
2001-11-26 23:08 ` Daniel Jacobowitz
2001-11-26 20:38 ` Jim Blandy
2001-11-26 21:36 ` Daniel Jacobowitz
2001-11-14 0:12 ` Daniel Jacobowitz
2001-11-26 22:05 ` Daniel Berlin
2001-11-14 0:15 ` Daniel Berlin
2001-11-27 7:15 ` Jim Blandy
2001-11-14 13:02 ` Jim Blandy
2001-11-27 7:45 ` Daniel Jacobowitz
2001-11-14 13:55 ` Daniel Jacobowitz
2001-11-26 17:19 ` Daniel Jacobowitz
2001-11-15 14:06 Michael Elizabeth Chastain
2001-11-16 11:52 ` Daniel Berlin
2001-11-27 20:49 ` Daniel Berlin
2001-11-27 20:38 ` Michael Elizabeth Chastain
2001-11-30 9:00 Michael Elizabeth Chastain
2001-11-21 23:07 ` Michael Elizabeth Chastain
2001-11-22 3:17 ` Daniel Jacobowitz
2001-11-30 9:52 ` Daniel Jacobowitz
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=20011126210231.A32203@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb-patches@sources.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