This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Removing TYPE_VPTR_FIELDNO uses (was: Re: [patch ping] SetTYPE_VPTR_BASETYPE/TYPE_VPTR_FIELDNO of XL C++ virtual class)
- From: Wu Zhou <woodzltc at cn dot ibm dot com>
- To: Daniel Jacobowitz <drow at false dot org>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Tue, 11 Oct 2005 13:52:12 +0800 (CST)
- Subject: Re: Removing TYPE_VPTR_FIELDNO uses (was: Re: [patch ping] SetTYPE_VPTR_BASETYPE/TYPE_VPTR_FIELDNO of XL C++ virtual class)
- References: <1127969598.433b733eedab9@imap.linux.ibm.com><20051002222103.GA32728@nevyn.them.org>
Hi Daniel,
I have one more question about the offset of vptr.
On Sun, 2 Oct 2005, Daniel Jacobowitz wrote:
> > - gnu-v3-abi.c: VPTRs is used for rtti, virtual function and virtual base
> > class offset.
>
> In this file, I think we can skip all the rigamarole with debug
> information to find the vptr. It's very easy: it's the size of a
> pointer, and it's at offset 0. Always.
By saying above, do you means that the pointer to the vtable is always at
the beginning of the fields, so we can calculate the vtable_address using
the following code?
vtable_address
= value_as_address (value_field (value, 0 /* TYPE_VPTR_FIELDNO (values_type) */));
But I found that in some testcase (such as class A in gdb.cp/virtfunc.cc),
the offset is 1. Did I misunderstand something? If so, please help me
point out. Thanks a bunch!
Best Regards
- Wu Zhou