This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [5/5] reimplement 'set print vtbl on'


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]