This is the mail archive of the gdb-prs@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]

[Bug c++/11864] New: Derived class when dereferencing a boost::shared_ptr


Many apologies if this has been reported a million times but both a bugzilla and
google search did not yield any relevant results for me (or perhaps my search
terms weren't good enough).

What I'm trying to achieve is to have gdb print the contents of a derived class
as in the following code and gdb session.

#include <boost/shared_ptr.hpp>

class A
{
public:
        A() {}
        virtual ~A() {}

        virtual void Do() = 0;
};

class B : public A
{
public:
        B() {}

        virtual void Do() {}

private:
        int x_;
};

int main()
{
        boost::shared_ptr<A> b(new B());
        b->Do();
}

Using gdb as

(gdb) break gdb_shared_ptr.cpp:26
Breakpoint 1 at 0x8048789: file gdb_shared_ptr.cpp, line 26.
(gdb) r
Starting program: /home/goncalo/swdev/gdb_shared_ptr/gdb_shared_ptr 

Breakpoint 1, main () at gdb_shared_ptr.cpp:26
26		b->Do();
(gdb) p B
Attempt to use a type name as an expression
(gdb) p b
$1 = {px = 0x804c008, pn = {pi_ = 0x804c018}}
(gdb) p b.px
$2 = (A *) 0x804c008
(gdb) p *b.px
$3 = {_vptr.A = 0x8048dc0}


I was hoping that dereferencing b would default print the B class object. But
perhaps there's some other way of achieving this? gdb-7.1 was compiled from
source using the default configure option on a 9.10 ubuntu.

-- 
           Summary: Derived class when dereferencing a boost::shared_ptr
           Product: gdb
           Version: 7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: glslang at gmail dot com
                CC: gdb-prs at sourceware dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=11864

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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