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 03/02/2012 09:51 PM, Tom Tromey wrote:

>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> Yeah, from:
> [...]
> Pedro> it seems to me that with older gccs this wasn't just printing the
> Pedro> pointer to the vtable, but it was also printing the vtable
> Pedro> array itself, including all its elements.
> 
> Yeah.  It wasn't clear to me initially but I see I was confused about
> what was going on.
> 
> I could implement this instead, I suppose.  I prefer what I've done,


You mean "info vtable"?  Yeah, that stands on it's own, IMO.

> though, I think printing the vtables in the objects is going to be ugly;

Yeah, possible.  We don't need to enable it by default though.

IIUC, your patch just changes GDB from

    $1 = {
      <interface> = {
        _vptr.interface = 0x4008c0
      }, <No data fields>}

to

    $1 = {
      <interface> = {
        _vptr.interface = 0x4008c0 <vtable for Obj+32>
      }, <No data fields>}

which we could claim isn't that much that it justifies a need to toggle
a switch, IMO.  We could consider making that unconditional?  But note the
user can just do:

(gdb) info symbol 0x4008c0
vtable for Obj + 32 in section .rodata of /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.cp/virtfunc2

> but I am open to suggestions.
> I can also leave the old code lying around.  I would imagine that many

> of gdb's C++ features are already broken against such an old compiler
> already, but I don't know for sure.


Would it be hard to make "set print vtbl on" do with newer binaries what
it supposedly does with older compiler built binaries, given the code
you've written for "info vtable"?

OTOH, syntax for doing the equivalent of "print o->_vptr.interface[0]",
or "call o->_vptr.interface.do_print()" would be (perhaps more) interesting.

-- 
Pedro Alves


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