Print layout of C++ object with g++ compiler

杀马特。学长 韩版系。学妹 提交于 2019-11-29 06:14:44

Looking at the man pages, -fdump-class-hierarchy maybe?

The information you seek is needed by debuggers and is emitted for them when you compile with -g. On ELF/DWARF platforms (such as Linux), you can see what's there by executing:

g++ -g -c foo.cc
readelf -w foo.o

On other platforms, objdump -g foo.o may work.

For ELF/DWARF, pahole looks like a good place to start.

C++ doesn't have introspection. Once your code is compiled, every piece of information about classes is lost except for what typeid and std::type_info can give you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!