This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add SubstTemplateTypeParm to RemoveWrappingTypes
ClosedPublic

Authored by teemperor on Aug 3 2020, 6:59 AM.

Details

Summary

Like the other type sugar removed by RemoveWrappingTypes, SubstTemplateTypeParm is just
pure sugar that should be ignored. If we don't ignore it (as we do now), LLDB will fail to
read values from record fields that have a SubstTemplateTypeParm type.

Only way to produce such a type in LLDB is to either use the import-std-module setting
to get a template into the expression parser or just create your own template directly
in the expression parser which is what we do in the test.

Diff Detail

Event Timeline

teemperor created this revision.Aug 3 2020, 6:59 AM
teemperor requested review of this revision.Aug 3 2020, 6:59 AM
jarin accepted this revision.Aug 11 2020, 3:05 AM

Looks good.

I did not realize that types propagate from one evaluation to another. This is not possible to reproduce without introducing the template in the evaluation right? (Or could it repro with simple expressions if the debuggee contained modules with the templates?)

lldb/test/API/lang/cpp/subst_template_type_param/TestSubstTemplateTypeParam.py
4

Typos in the comment: produces -> produced, parameter -> parameters

31

Non-actionable comment: Interesting, I did not know you can use types from previous evaluations.

This revision is now accepted and ready to land.Aug 11 2020, 3:05 AM

Looks good.

I did not realize that types propagate from one evaluation to another. This is not possible to reproduce without introducing the template in the evaluation right? (Or could it repro with simple expressions if the debuggee contained modules with the templates?)

If you mean with modules = normal debug-info modules, then yes, it's to my knowledge not possible to reproduce this with just normal debug info. We don't manually create SubstTemplateTypeParm types within LLDB and they are only created by Clang during template instantiation (and we never create real templates in LLDB, so we don't use Clang's template instantiation logic). But maybe if we have better template support in the future we might encounter these types even with debug info.

if you mean modules = Clang modules, then it's straightforward to reproduce (pretty much by just copying the expression we have here into the Clang module). But C++ Clang modules are really just supported by accident at the moment.

lldb/test/API/lang/cpp/subst_template_type_param/TestSubstTemplateTypeParam.py
4

Thanks!

31

Declarations from 'top-level' expressions will be exported to the scratch AST (that's actually the only use case of top-level expressions). You can also prefix the name of most declarations with a $ and then you can use them in follow-up expressions:

(lldb) expr struct $Foo { int i; }
(lldb) expr $Foo f; f
($Foo) $0 = (i = 0)

That feature is also the fastest way to break the expression evaluator :p

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2020, 5:32 AM