This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [5/5] reimplement 'set print vtbl on'
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 01 Mar 2012 14:44:34 +0000
- Subject: Re: [5/5] reimplement 'set print vtbl on'
- References: <87ipiqpr35.fsf@fleche.redhat.com>
On 02/28/2012 09:48 PM, Tom Tromey wrote:
> I noticed that 'set print vtbl on' doesn't seem to do anything with code
> generated by a modern GCC. I think "modern" includes anything starting
> with GCC 3.0 -- which by now is rather ancient.
>
> It is hard to tell what this command was really supposed to do. There
> are no tests for it and the documentation is light. Basically, though,
> it seems to boil down to looking up the vtable's minsym and printing
> that when printing the vtable pointer.
Yeah, from:
/* Return truth value for the assertion that TYPE is of the type
"pointer to virtual function table". */
int
cp_is_vtbl_member (struct type *type)
{
/* With older versions of g++, the vtbl field pointed to an array of
structures. Nowadays it points directly to the structure. */
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
type = TYPE_TARGET_TYPE (type);
if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
and the code that reads "Print vtbl's nicely.", which calls
cp_is_vtbl_member, and does:
vt_val = value_at (wtype, vt_address);
common_val_print (vt_val, stream, recurse + 1,
options, current_language);
it seems to me that with older gccs this wasn't just printing the
pointer to the vtable, but it was also printing the vtable
array itself, including all its elements.
--
Pedro Alves