This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

Virtual methods table printing [Re: Expressions Status andOustanding Tasks]


On Fri, 27 Mar 2009 01:15:34 +0100, Tom Tromey wrote:
> >>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
> 
> Keith> * Virtual methods table printing (print OBJ->VIRTFUNC) using
> Keith> DW_AT_vtable_elem_location.
> 
> Keith> I don't know if anyone has addressed this at all. I know I
> Keith> haven't. [I'm not even sure I completely understand what this task
> Keith> is.] I presume that this is just a general item for virtual
> Keith> class/methods.
> 
> I'm not sure I know what this one is either.  It may have come from
> bugzilla ... anybody know?  If nobody knows, let's delete it from the
> wiki.

It was from me.  The original request was for Firefox to print virtual methods
table pointers.  That time I did not know `set print object on' suggested
later by Tom Tromey which may somehow solve it:

------------------------------------------------------------------------------
class base1
{
  virtual int func1() { return 5; }
};

class base2
{
  virtual int func2() { return 5; }
};

class derived : public base1, public base2
{
  virtual int func1() { return 6; }
  virtual int func2() { return 6; }
};

int
main (void)
{
  derived var;
  base1 *base1p = &var;

  (void) base1p;
  return 0;     /* line 24 */
}
------------------------------------------------------------------------------
Breakpoint 1, main () at virtual.C:24
24	  return 0;	/* line 24 */
(gdb) p base1p
$1 = (base1 *) 0x7fffffffd3f0
(gdb) p *base1p
$2 = {_vptr.base1 = 0x400810}
(gdb) ptype base1p
type = class base1 {
  private:
    virtual int func1();
} *
(gdb) p base1p->func1
$3 = {int (base1 *)} 0x40063c <base1::func1()>

(gdb) set print object on
(gdb) p base1p
$4 = (derived *) 0x7fffffffd3f0
(gdb) p *base1p
$5 = (derived) {<base1> = {_vptr.base1 = 0x400810}, <base2> = {_vptr.base2 = 0x400830}, <No data fields>}
(gdb) ptype base1p
type = /* real type = derived * */
class base1 {
  private:
    virtual int func1();
} *
(gdb) ptype derived
type = class derived : public base1, public base2 {
  private:
    virtual int func1();
    virtual int func2();
}
(gdb) p base1p->func1
$6 = {int (derived *)} 0x40065c <derived::func1()>
(gdb) p base1p->func2
$7 = {int (derived *)} 0x400672 <derived::func2()>
(gdb) 
------------------------------------------------------------------------------

Assuming one should have a simple commend to get some listing:
(gdb) describe-me base1p
func1: {int (derived *)} 0x40065c <derived::func1()>
func2: {int (derived *)} 0x400672 <derived::func2()>

But I am not a C++ programmer, maybe `set print object on' is sufficient?

Also at least Archer should have `set print object on' set by default.



Regards,
Jan


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