[lldb-dev] [PATCH] Have clang list the imported modules in the debug info

Adrian Prantl aprantl at apple.com
Tue Jan 20 09:39:03 PST 2015


As a complementary part of the module debugging story, here is a proposal to list the imported modules in the debug info. This patch is not about efficiency, but rather enables a cool debugging feature:

Record the clang modules imported by the current compile unit in the debug info. This allows a module-aware debugger (such as LLDB) to @import all modules visible in the current context before evaluating an expression, thus making available all declarations in the current context (that originate from a module) and not just the ones that were actually used by the program.

This implementation uses existing DWARF mechanisms as much as possible by emitting a DW_TAG_imported_module that references a DW_TAG_module, which contains the information necessary for the debugger to rebuild the module. This is similar to how C++ using declarations are encoded in DWARF, with the difference that we're importing a module instead of a namespace.
The information stored for a module includes the umbrella directory, any config macros passed in via the command line that affect the module, and the filename of the raw .pcm file. Why include all these parameters when we have the .pcm file? Apart from module chache volatility, there is no guarantee that the debugger was linked against the same version of clang that generated the .pcm, so it may need to regenerate the module while importing it.

Let me know what you think!
-- adrian


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Record-the-clang-modules-imported-by-the-current-com.patch
Type: application/octet-stream
Size: 10854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150120/a657bb61/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Introduce-DIModule-a-wrapper-for-DW_TAG_module-to-em.patch
Type: application/octet-stream
Size: 19181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150120/a657bb61/attachment-0001.obj>


More information about the lldb-dev mailing list