I am trying to debug a problem using dbx in sun 5.9. I want to print
the virtual table from dbx. Find the real address of the virtual
function of the object.
There might be a little misunderstanding here, or not. The virtual
function pointer usually will be the same for all the objects as the v-
table that contains the vptrs is common to the class. But there is a
pointer at the starting address of a polymorphic object that points to
the corresponding vtable. That pointer will be a different one but
will probably point on the same table depending upon the dynamic type
of the object. (-- all this, related to vtable/vfptr/vptr depends on
your particular compiler implementation of the runtime polymorphism/
dynamic dispatch).
I am not sure how the actual virtual function pointers are going to
help you with the debugging but then I don't know your problem at hand
as well. There are specific compiler flags that may be help you get
some data around the vtable structures. For example, with g++, you
could analyze that with the build option -fdump-class-hierarchy. There
might (or might not) be some other alternative for your specific
compiler. You could use that to see the v-table layout.
You could also, add some code to help you with that information at
runtime. This could be done by creating a bunch of objects of the
types that you are dealing with/want to analyze the v-table/v-ptrs of,
and take addresses of the various functions that are part of that
object's interface. You could tweak around the data that you want,
depending upon what actually do you want it for.