dump contents of a module (.pcm) file

How can I dump the contents of a module (.pcm) file in a human-readable form for debugging? I’d like to at least see the exported symbols.

Precompiled Header and Modules Internals mentions that the llvm-objdump utility provides a -raw-clang-ast option but running

llvm-objdump -raw-clang-ast test.pcm

gives the error:

The file was not recognized as a valid object file


Sometimes clang AST files are in an ELF wrapper so they can (eg) have accompanying debug information; llvm-objdump -raw-clang-ast extracts the clang AST from the wrapper. But you probably don’t have ELF-wrapped AST, just plain AST.

To inspect an AST file, you can use llvm-bcanalyzer (which will give you summary information) or llvm-bcanalyzer -dump (which will extract the raw AST records from the file). Neither of those is particularly useful unless you also have the Clang serialization code to hand so you can figure out what the various record entries mean. (For instance, there is no list of exported symbols in an AST file.)

Your best bet for applying semantic queries to an AST file would be to write a tool against the Clang API or one of its language bindings.