[Lldb-commits] [lldb] [lldb] Fix expressions that involve nested structs/classes/unions. (PR #77029)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 1 12:21:55 PST 2024
clayborg wrote:
> > But if it'd require substantial reengineering to clang to get this working - this seems an unfortunate regression to carry in the interim, and it might be worth reverting to the previous (differently buggy, but at least work-around-able) behavior.
>
> To clarify, the regression @dwblaikie reported in #79668 was introduced in #74786, not in this current PR. IIUC, this PR just _partially_ fixed #53904?
>
> > The new flow could be:
> >
> > * any struct/class gets created as a forward declaration and has the external AST source enabled
> > * the external AST calls to complete the type when needed by expression parser or LLDB APIs
> > * we complete the type
> > * we leave the external AST enabled so we can get called for contained types
> >
> > The last item here would require modifications to clang which could be debugger specific changes that are only enabled in a special debug compiler mode so they don't affect the actual compiler. Thoughts?
>
> Following overview of the clang<->lldb call-chain might be useful: [#53904 (comment)](https://github.com/llvm/llvm-project/issues/53904#issuecomment-1877114034). Not sure I fully understand the "we leave the external AST enabled so we can get called for contained types" idea. Happy to chat about how to make this work though
When we parse a class, we enable the external AST support on the CXXRecordDecl object. When we are asked to complete the type it will eventually make it down into `DWARFASTParserClang::CompleteTypeFromDWARF(...)` which will call:
```
// Disable external storage for this type so we don't get anymore
// clang::ExternalASTSource queries for this type.
m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false);
```
So we never get a query again to find anything inside of this class. That being said, I am not sure anything ever was doing another external AST lookup in this class after we completed it. But if we are able to add debugger specific support into the external AST virtual interface, we might be able to gets asked "withing this 'class A' please find me a contained type" and then modify the compiler to use the external AST source when a lookup in a contents fails.
We currently modified it so that when we parse a struct/union/class type, we also parse all contained child DIE types so that they are available. This is failing when some classes have contained types defined and others don't because we only add the contained types for the struct/class/union DIE we used to create the type. If we can modify the compiler to make an external lookup call only when debugging, we can avoid this need to parse all contained types and wait until the expresion parser asks for that type.
https://github.com/llvm/llvm-project/pull/77029
More information about the lldb-commits
mailing list