This is an archive of the discontinued LLVM Phabricator instance.

Emit debug info for dynamic classes if they are imported from a DLL
ClosedPublic

Authored by amccarth on Aug 12 2016, 1:28 PM.

Details

Reviewers
rnk
Summary

With -debug-info-kind=limited, we omit debug info for dynamic classes that live in other TUs. This reduces duplicate type information. When statically linked, the type information comes together. But if your binary has a class derived from a base in a DLL, the base class info is not available to the debugger.

The decision is made in shouldOmitDefinition (CGDebugInfo.cpp). Per a suggestion from rnk, I've tweaked the decision so that we do include definitions for classes marked as DLL imports. This should be a relatively small number of classes, so we don't pay a large price for duplication of the type info, yet it should cover most cases on Windows.

Essentially this makes debug info for DLLs independent, but we still assume that all TUs within the same DLL will be consistently built with (or without) debug info and the debugger will be able to search across the debug info within that scope to resolve any declarations into definitions, etc.

Tested manually on Windows. I'm working on a lit test, and I'll update this patch with it when it's finished.

Diff Detail

Event Timeline

amccarth updated this revision to Diff 67891.Aug 12 2016, 1:28 PM
amccarth retitled this revision from to Emit debug info for abstract classes if they are imported from a DLL.
amccarth updated this object.
amccarth added a reviewer: rnk.
amccarth added a subscriber: cfe-commits.
dblaikie retitled this revision from Emit debug info for abstract classes if they are imported from a DLL to Emit debug info for dynamic classes if they are imported from a DLL.Aug 15 2016, 1:27 PM
dblaikie updated this object.
amccarth updated this revision to Diff 68114.Aug 15 2016, 4:56 PM

Added a test.

Thank, dblaikie, for correcting my terminology.

rnk added inline comments.Aug 16 2016, 8:20 AM
lib/CodeGen/CGDebugInfo.cpp
1688–1694

David, since we're doing this check to work around a limitation of PDB-based debuggers, do you think we should guard check with EmitCodeView, so that we don't emit the full type if we're emitting DWARF?

After that, I'd add a comment like:

// Only emit complete debug info for a dynamic class when its vtable is emitted. However,
// Microsoft debuggers are unable to resolve type information across DLL boundaries,
// so skip this optimization if the class is marked dllimport.
amccarth added inline comments.Aug 16 2016, 11:02 AM
lib/CodeGen/CGDebugInfo.cpp
1688–1694

Comment added.

I don't think the EmitCodeView check is necessary because it seems unlikely the DLLImportAttr would be set with DWARF debug info, and, even if it is, I wouldn't expect it to do any harm. But I'll defer to dblaikie or other DWARF experts.

amccarth updated this revision to Diff 68225.Aug 16 2016, 11:04 AM

Add comment as requested.

rnk accepted this revision.Aug 16 2016, 2:36 PM
rnk edited edge metadata.

lgtm

This revision is now accepted and ready to land.Aug 16 2016, 2:36 PM
amccarth closed this revision.Aug 16 2016, 3:24 PM

Closed by r278861