[all-commits] [llvm/llvm-project] 34c697: [lldb] Don't recursively load types of static memb...
Raphael Isemann via All-commits
all-commits at lists.llvm.org
Mon Apr 12 05:37:57 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 34c697c85e9d0af11a72ac4df5578aac94a627b3
https://github.com/llvm/llvm-project/commit/34c697c85e9d0af11a72ac4df5578aac94a627b3
Author: Raphael Isemann <teemperor at gmail.com>
Date: 2021-04-12 (Mon, 12 Apr 2021)
Changed paths:
M lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
M lldb/test/API/functionalities/lazy-loading/TestLazyLoading.py
M lldb/test/API/functionalities/lazy-loading/main.cpp
A lldb/test/API/lang/cpp/static_member_type_depending_on_parent_size/Makefile
A lldb/test/API/lang/cpp/static_member_type_depending_on_parent_size/TestStaticMemberTypeDependingOnParentSize.py
A lldb/test/API/lang/cpp/static_member_type_depending_on_parent_size/main.cpp
Log Message:
-----------
[lldb] Don't recursively load types of static member variables in the DWARF AST parser
When LLDB's DWARF parser is parsing the member DIEs of a struct/class it
currently fully resolves the types of static member variables in a class before
adding the respective `VarDecl` to the record.
For record types fully resolving the type will also parse the member DIEs of the
respective class. The other way of resolving is just 'forward' resolving the type
which will try to load only the minimum amount of information about the type
(for records that would only be the name/kind of the type). Usually we always
resolve types on-demand so it's rarely useful to speculatively fully resolve
them on the first use.
This patch changes makes that we only 'forward' resolve the types of static
members. This solves the fact that LLDB unnecessarily loads debug information
to parse the type if it's maybe not needed later and it also avoids a crash where
the parsed type might in turn reference the surrounding class that is currently
being parsed.
The new test case demonstrates the crash that might happen. The crash happens
with the following steps:
1. We parse class `ToLayout` and it's members.
2. We parse the static class member and fully resolve its type
(`DependsOnParam2<ToLayout>`).
3. That type has a non-static class member `DependsOnParam1<ToLayout>` for which
LLDB will try to calculate the size.
4. The layout (and size)`DependsOnParam1<ToLayout>` turns depends on the
`ToLayout` size/layout.
5. Clang will calculate the record layout/size for `ToLayout` even though we are
currently parsing it and it's missing it's non-static member.
The created is missing the offset for the yet unparsed non-static member. If we
later try to get the offset we end up hitting different asserts. Most common is
the one in `TypeSystemClang::DumpValue` where it checks that the record layout
has offsets for the current FieldDecl.
```
assert(field_idx < record_layout.getFieldCount());
```
Fixed rdar://67910011
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D100180
More information about the All-commits
mailing list