public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Getting to the source for a given C++ object
@ 2005-08-10 17:17 Alex Bennee
  2005-08-10 20:35 ` Jason Molenda
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Bennee @ 2005-08-10 17:17 UTC (permalink / raw)
  To: gdb

Hi,

I'm currently trying to debug a C++ program that makes heavy use of
templates and derived classes. Is there an easy way to get to the actual
code for a given class pointer?

At the moment if I look at the class pointer it gives me the template
instantiation which I can work it out from but as most of the parameters
are #define's is a rather labour intensive operation.

e.g.

(gdb) p currNode
$8 = (Operation<(ExpressionType)45, 0, 1, RegisterID, (ResultType)2> *)
0x3834a3d0


--
Alex, homepage: http://www.bennee.com/~alex/
Spirtle, n.: The fine stream from a grapefruit that always lands right
in your eye. -- Sniglets, "Rich Hall & Friends"

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Getting to the source for a given C++ object
  2005-08-10 17:17 Getting to the source for a given C++ object Alex Bennee
@ 2005-08-10 20:35 ` Jason Molenda
  2005-08-11  9:27   ` Alex Bennee
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Molenda @ 2005-08-10 20:35 UTC (permalink / raw)
  To: Alex Bennee; +Cc: gdb


On Aug 10, 2005, at 10:17 AM, Alex Bennee wrote:

> I'm currently trying to debug a C++ program that makes heavy use of
> templates and derived classes. Is there an easy way to get to the  
> actual
> code for a given class pointer?


I'm not sure  exactly what you're looking for.  ptype can tell you  
the class - is that what you want?  e.g.

(gdb) p beta
$1 = {<A> = {_vptr$A = 0x30b0, a1 = 200}, b1 = 201, b2 = 202}
(gdb) ptype beta
type = class B : public A {
   public:
     int b1;
     int b2;

     B(B const&);
     B(B const&);
     B();
     B();
     ~B();
     virtual ~B();
     virtual ~B();
}
(gdb)


J

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Getting to the source for a given C++ object
  2005-08-10 20:35 ` Jason Molenda
@ 2005-08-11  9:27   ` Alex Bennee
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Bennee @ 2005-08-11  9:27 UTC (permalink / raw)
  To: Jason Molenda; +Cc: gdb

On Wed, 2005-08-10 at 13:35 -0700, Jason Molenda wrote:
> On Aug 10, 2005, at 10:17 AM, Alex Bennee wrote:
> 
> > I'm currently trying to debug a C++ program that makes heavy use of
> > templates and derived classes. Is there an easy way to get to the  
> > actual
> > code for a given class pointer?
> 
> 
> I'm not sure  exactly what you're looking for.  ptype can tell you  
> the class - is that what you want?  e.g.
> 
> (gdb) p beta
> $1 = {<A> = {_vptr$A = 0x30b0, a1 = 200}, b1 = 201, b2 = 202}
> (gdb) ptype beta
> type = class B : public A {
>    public:
>      int b1;
>      int b2;
> 
>      B(B const&);
>      B(B const&);
>      B();
>      B();
>      ~B();
>      virtual ~B();
>      virtual ~B();
> }

Thats useful, but its the derived information I want. Basically how can
I get from that to the code for the virtual function used  by that
particular object.

The trouble is the class is specialised into a fair number of different
subclasses via templates. What I would ideally like is to do something
like "l beta.method" and be looking directly at the code for that
objects method call so I can set up breakpoints and the like.


--
Alex, homepage: http://www.bennee.com/~alex/
Actresses will happen in the best regulated families. -- Addison Mizner
and Oliver Herford, "The Entirely New Cynic's Calendar", 1905

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-08-11  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-10 17:17 Getting to the source for a given C++ object Alex Bennee
2005-08-10 20:35 ` Jason Molenda
2005-08-11  9:27   ` Alex Bennee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).