How to dump the vtable's or record's layout?

Hello all,

I would like to dump the vtable’s or record’s layout therefore I download the binary of Clang 3.7 for Linux from official site. But I got nothing with:

$ clang+llvm-3.7.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++ -cc1 -fdump-vtable-layouts vtable.cpp


$ clang+llvm-3.7.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++ -cc1 -fdump-record-layouts vtable.cpp

I am wondering how to dump vtable’s or record’s layout? Is there anything wrong with my instructions?


As per Reid’s early response, try adding -emit-llvm-only or -emit-obj.

btw, you might prefer to use -Xclang instead of using -cc1 directly, e.g,

clang++ -Xclang -fdump-record-layouts vtable.cpp

This way, you don’t need to worry about passing additional parameters to -cc1, and you get nice colors if you have a color terminal.