Last active
October 8, 2024 18:58
-
-
Save GavinRay97/700ff1631d7e5ac460efd0780759c908 to your computer and use it in GitHub Desktop.
Dump C/C++ vtable & record layout information (clang + msvc + gcc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requirements: | |
# clang - The classes/structs you want to dump must be used in code at least once, not just defined. | |
# MSVC - The classes/structs you want to dump must have "MEOW" in the name for "reportSingleClass" to work. | |
# Usage: | |
# $ make dump_vtables file=test.cpp | |
dump_vtables: | |
clang -cc1 -fdump-record-layouts -emit-llvm $(file) > clang-vtable-layout-$(file).txt | |
clang -cc1 -fdump-vtable-layouts -emit-llvm $(file) > clang-record-layout-$(file).txt | |
g++ -fdump-lang-class=$(file).txt $(file) | |
cl.exe $(file) /d1reportSingleClassLayoutMEOW > msvc-single-class-vtable-layout-$(file).txt | |
cl.exe $(file) /d1reportAllClassLayout > msvc-all-class-vtable-layout-$(file).txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Heya,
On the lefthand side are the offsets from the start of the struct for each field, and on the right is the description of the field itself.
At the bottom is summary information:
One other useful bit of information is there is another form of this flag,
-fdump-record-layouts-simple
, which gives output like below: