Skip to content

Instantly share code, notes, and snippets.

@gmh5225
Forked from GavinRay97/Makefile
Last active February 17, 2024 05:07
Show Gist options
  • Save gmh5225/d879942bd2c6d125139086b0d1c7d149 to your computer and use it in GitHub Desktop.
Save gmh5225/d879942bd2c6d125139086b0d1c7d149 to your computer and use it in GitHub Desktop.
Dump C/C++ vtable & record layout information (clang + msvc + gcc)
# 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