Visual C++ Compiler Option To Dump Class Hierarchy
Asked Answered
U

2

5

Is there any compiler option in MS Visual C++ equivalent to GCC's -fdump-class-hierarchy? i.e. showing the virtual function table layout.

Urfa answered 13/6, 2010 at 18:16 Comment(0)
K
8

try

cl.exe /d1reportAllClassLayout test.cpp

The output is something like:

class request_handlerAttribute  size(8):
        +---
 0      | name
 4      | sdl
        +---



class perfmonAttribute  size(8):
        +---
 0      | name
 4      | register
        |  (size=3)
        +---

Found doing:

+ findstr /i class c1xx.dll > c1xx.txt
+ and then manually inspecting c1xx.txt

Hope it can help, Benedetto

PS: This obviously is an undocumented and unsupported switch.
Look also here for a similar switch.

Kyd answered 17/6, 2010 at 17:17 Comment(0)
E
0

I'm quite certain there's not any documented switch. If you do a bit of looking at cl.exe, you can find various strings, some of which appear to be related to command line options. One of those says something like: "Partitioning (options = %s)\0nul\0map\0ast".

That "ast" may refer to an abstract syntax tree, which may imply that some sort of dump of the compiler's AST is possible -- but I haven't really looked in any detail to figure out what it's talking about, aimed at, or much of anything else. For that matter, the "ast" and "options = " may not be related at all. Even if it can dump ASTs, that doesn't necessarily mean it can tell you anything about vtable layout.

To make a long story short, there's enough there to make it difficult to rule out with real certainty. At the same time, there's little enough there that it would take a lot more work to do more than hint at the vague possibility that the compiler may have some undocumented ability to dump some internal structures.

Earnest answered 13/6, 2010 at 19:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.