[SOLVED] Any option in GCC to SEE the dynamic bindings processing happening, in the compilation output?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Well, make does post output, but not GCC. Of course, you do get error messages from GCC, but that's normal. I suppose if you have enough programming skills you could fork GCC to make it display a progress bar or something (or maybe create a GUI frontend to GCC), but either of these things would be pushing it.
No, I am not talking about linking the dynamic libraries,
I am talking about the dynamic binding happening w.r.t
the virtual functions.
C++, right? It's been a while since I've used virtual functions, or even C++. Could you illustrate with a tiny, compilable C++ program we can play around with?
I thought I asked a pathetic question I have an example too and have found a possible solution option too, but
it doesn't seem to work , soon I'll present them here.
#include <iostream>
using namespace std;
class a
{
public:
virtual void f1 ();
};
void a :: f1 () {}
class b : public a
{
public:
void f1 ();
};
void b :: f1 () {}
int main ()
{
b obj1;
obj1.f1 ();
return 0;
}
rm -f *.class; cat > virtual.cpp <<EOD; g++ -Wall -Wextra virtual.cpp -fdump-class-hierarchy; ls -l virtual*.class; cat virtual*.class
#include <iostream>
using namespace std;
class a
{
public:
virtual void f1 ();
};
void a :: f1 () {}
class b : public a
{
public:
void f1 ();
};
void b :: f1 () {}
int main ()
{
b obj1;
obj1.f1 ();
return 0;
}
EOD
I got this output (snipped in the middle for brevity):
Code:
-rw------- 1 wally wally 67688 Feb 22 02:57 virtual.cpp.002t.class
Class <anonymous struct>::<anonymous union>
size=4 align=4
base size=4 base align=4
<anonymous struct>::<anonymous union> (0xb777c078) 0
Class <anonymous struct>
size=8 align=4
base size=8 base align=4
<anonymous struct> (0xb777c000) 0
Class __locale_struct
size=116 align=4
base size=116 base align=4
__locale_struct (0xb777c0b4) 0
Vtable for std::exception
std::exception::_ZTVSt9exception: 5u entries
0 (int (*)(...))0
4 (int (*)(...))(& _ZTISt9exception)
8 std::exception::~exception
12 std::exception::~exception
16 std::exception::what
Class std::exception
size=4 align=4
base size=4 base align=4
std::exception (0xb777c708) 0 nearly-empty
vptr=((& std::exception::_ZTVSt9exception) + 8u)
---------->8---------->8---------->8----------
Class std::basic_iostream<wchar_t, std::char_traits<wchar_t> >
size=152 align=4
base size=12 base align=4
std::basic_iostream<wchar_t, std::char_traits<wchar_t> > (0xb706ebd0) 0
vptridx=0u vptr=((& std::basic_iostream<wchar_t, std::char_traits<wchar_t> >::_ZTVSt14basic_iostreamIwSt11char_traitsIwEE) + 12u)
std::basic_istream<wchar_t, std::char_traits<wchar_t> > (0xb7252840) 0
primary-for std::basic_iostream<wchar_t, std::char_traits<wchar_t> > (0xb706ebd0)
subvttidx=4u
std::basic_ios<wchar_t, std::char_traits<wchar_t> > (0xb7252880) 12 virtual
vptridx=20u vbaseoffset=-0x0000000000000000c vptr=((& std::basic_iostream<wchar_t, std::char_traits<wchar_t> >::_ZTVSt14basic_iostreamIwSt11char_traitsIwEE) + 52u)
std::ios_base (0xb721da14) 12
primary-for std::basic_ios<wchar_t, std::char_traits<wchar_t> > (0xb7252880)
std::basic_ostream<wchar_t, std::char_traits<wchar_t> > (0xb72528c0) 8 nearly-empty
subvttidx=12u vptridx=24u vptr=((& std::basic_iostream<wchar_t, std::char_traits<wchar_t> >::_ZTVSt14basic_iostreamIwSt11char_traitsIwEE) + 32u)
std::basic_ios<wchar_t, std::char_traits<wchar_t> > (0xb7252880) alternative-path
Vtable for a
a::_ZTV1a: 3u entries
0 (int (*)(...))0
4 (int (*)(...))(& _ZTI1a)
8 a::f1
Class a
size=4 align=4
base size=4 base align=4
a (0xb721ddd4) 0 nearly-empty
vptr=((& a::_ZTV1a) + 8u)
Vtable for b
b::_ZTV1b: 3u entries
0 (int (*)(...))0
4 (int (*)(...))(& _ZTI1b)
8 b::f1
Class b
size=4 align=4
base size=4 base align=4
b (0xb7252a40) 0 nearly-empty
vptr=((& b::_ZTV1b) + 8u)
a (0xb721dfb4) 0 nearly-empty
primary-for b (0xb7252a40)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.