473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to dump inheritance information of c++ binaries?

Hello,

i am looking for a tool, which dumps inheritance information of c++
binaries. Does such a tool exist??

Can I retrieve interitance from the output of objdump or something
else? Does someone have an idea?

Thanks!!
Pet

Jul 23 '05 #1
9 1756
Peter Jakobi wrote:
Hello,

i am looking for a tool, which dumps inheritance information of c++
binaries. Does such a tool exist??


Not easily. Unlike Java, C++ doesn't build a debugger into every
application.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #2
>> Hello,
i am looking for a tool, which dumps inheritance information of c++
binaries. Does such a tool exist??
Not easily. Unlike Java, C++ doesn't build a debugger into every
application.


Maybe there are hints for inheritance in the objdump output?
Unfortunately I am not a profi in disassembler code.

Pet

Jul 23 '05 #3
Peter Jakobi wrote:
i am looking for a tool, which dumps inheritance information of c++
binaries. Does such a tool exist??

Can I retrieve interitance from the output of objdump or something
else? Does someone have an idea?


Search the archive for "decompiler" and read those
threads. Also look for "cow from burger" and "pig
from sausages."

And consider that even if debug information is included,
it does not necessarily include inheritance info. For
example, if a prog defines A->B->C->D then only uses C,
you may not have any infor about classes A,B, and D
in the binary, even in debug.
Socks

Jul 23 '05 #4
Hello,

I am not sure. But is there not a certain table in each binary which
stores the inheritance??

For example: Someone calls a funtion abc() of a object A. But class A
does not implement this method. The method is implemented by a
superclass B.

Resolves this problem the compiler? Or contains the binary some
information about superclasses or inherit methods?

Thanks,
Pet

Jul 23 '05 #5
Peter Jakobi wrote:
I am not sure. But is there not a certain table in each binary which
stores the inheritance??
No. Inheritance is a concept the programmer uses when writing code.
Binaries are concept-free. They only contain machine instructions and
some limited amount of data.
For example: Someone calls a funtion abc() of a object A. But class A
does not implement this method. The method is implemented by a
superclass B.
If someone calls 'A::abc()' for an object A, and class A does not
implement it, there will be an error.
Resolves this problem the compiler? Or contains the binary some
information about superclasses or inherit methods?


I think you need to read "Inside the C++ Object Model". Whatever you're
asking is (a) phrased too vaguely and (b) cannot be answered using some
few sentences in a newsgroup post.

V
Jul 23 '05 #6
Peter Jakobi wrote:
Hello,

I am not sure. But is there not a certain table in each binary which
stores the inheritance??
Hi,

It's up to the implementation, but in Stroustrup's book The C++ Programming
Language he describes a possible scheme (probably used by most compilers)
where there is an array of function pointers called _vtab[] (if I remember
correctly), which point to the inherited functions.

For example: Someone calls a funtion abc() of a object A. But class A
does not implement this method. The method is implemented by a
superclass B.
In this case _vtab will just have one entry:

_vtab[0] = (the address of) B:abc()

It's been a long time, but I seem to remember that there is one vtab for
each virual function in each object.

If A did override abc, then there would be two entries in the array.
Resolves this problem the compiler? Or contains the binary some
information about superclasses or inherit methods?


Both, I figure.

Michael Davis
Toronto

Jul 23 '05 #7
Hi Michael,

thank you very much!! I think the _vtab[] is exactly that, what I need.
Now I have to find out a way to dump the information which are stored
in the _vtab[].

Maybe there are some tools for that kind of work??

Unfortunately I don't find such a tool. Can you give me some hints,
please?

Pet

Jul 23 '05 #8
It's up to the implementation, but in Stroustrup's book The C++ Programming Language he describes a possible scheme (probably used by most compilers)
where there is an array of function pointers called _vtab[] (if I remember
correctly), which point to the inherited functions.


Would you tell me on which page is _vtab[] described?? I have been reading
the book for years yet I still haven't got anything like that...??

ben
Jul 23 '05 #9
Michael Davis wrote:
Peter Jakobi wrote:
Hello,

I am not sure. But is there not a certain table in each binary which
stores the inheritance??
Hi,

It's up to the implementation, but in Stroustrup's book The C++ Programming
Language he describes a possible scheme (probably used by most compilers)
where there is an array of function pointers called _vtab[] (if I remember
correctly), which point to the inherited functions.


Names vary, but the implementation is a common one.
It works especially well in the presence of single
non-virtual inheritance. However, it's not the only
possible mechanism, and other mechanisms /must/ be used
for virtual inheritance.
For example: Someone calls a funtion abc() of a object A. But class A
does not implement this method. The method is implemented by a
superclass B.


In this case _vtab will just have one entry:

_vtab[0] = (the address of) B:abc()


Perhaps. Another possibility is that the compiler knows
at compile time that you're working on an A, that A has
no abc so you must mean B::abc. In that case it will just
substitute a call to B::abc(). If that's the only call to
abc(), it doesn't even have to appear in the vtable
It's been a long time, but I seem to remember that there is one vtab for
each virual function in each object.
One vtable entry, that is, and per class (not object).
Again, the same disclaimers (not universal, especially
not for complex cases, not when optimized out) apply.
If A did override abc, then there would be two entries in the array.


No. There would be two vtables, each with one entry. Each
object would point to the correct one, set by the ctor.
So if you construct an A, you get the A vtable and A::abc()
even if you use a B* pointer to the A.

(and this all aplies to virtual functions only, hence the
v in vtable.)

You might want to look at "typeid".

HTH,
Michiel Salters

Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
8
by: Gerhard Wolfstieg | last post by:
The following situation: class A0 { static A0 *a0; // something like this to publish the pointer public: A0() { a0 = this; } virtual ~A0(){}
8
by: Sim Smith | last post by:
This is the problem: I have to inherit a third party class file in my library. If I directly do it, I will have to ship the third party header files to my customers as well. I do not want to...
20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
9
by: Microsoft News Server | last post by:
Hi, I am currently having a problem with random, intermittent lock ups in my ASP.net application on our production server (99% CPU usage by 3 threads, indefinately). I currently use IIS Debug...
5
by: Chris Stankevitz | last post by:
My app reliably dies after a long time. I would like to dump core before it dies, and use that core as a starting point in debugging to save me from having to spend so much time waiting. Is...
4
by: Marcin Rzeznicki | last post by:
Hello, Is it possible to generate dump file at some execution point in managed application? I would like to be able to gather information about exceptions and their context from users running my...
4
by: Joe | last post by:
We are working on a project that requires 3rd parties (ie, consultants) to use our ASP.net webforms in a very reusable manner. The big catch is that we are not allowed to give them source. There...
0
by: Scott David Daniels | last post by:
Here are some tweaks on both bits of code: Paul McGuire wrote: .... m = for b in bases: if hasattr(b, '__mro__'): if MetaHocObject.ho in b.__mro__: m.append(b) if m:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.