forked from OSchip/llvm-project
d3492ed016
Previously, lldb mistook fields in anonymous union in a struct as the direct field of the struct, which causes lldb crashes due to multiple fields sharing the same offset in a struct. This patch fixes it. MSVC generated pdb doesn't have the debug info entity representing a anonymous union in a struct. It looks like the following: ``` struct S { union { char c; int i; }; }; 0x1004 | LF_FIELDLIST [size = 40] - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public] - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public] 0x1005 | LF_STRUCTURE [size = 32] `S` unique name: `.?AUS@@` vtable: <no type>, base list: <no type>, field list: 0x1004 ``` Clang generated pdb is similar, though due to the [[ https://github.com/llvm/llvm-project/issues/57999 | bug ]], it's not more useful than the debug info above. But that's not very relavent, lldb should still be able to understand MSVC geneerated pdb. ``` 0x1003 | LF_UNION [size = 60] `S::<unnamed-tag>` unique name: `.?AT<unnamed-type-$S1>@S@@` field list: <no type> options: forward ref (= 0x1003) | has unique name | is nested, sizeof 0 0x1004 | LF_FIELDLIST [size = 40] - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public] - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public] - LF_NESTTYPE [name = ``, parent = 0x1003] 0x1005 | LF_STRUCTURE [size = 32] `S` unique name: `.?AUS@@` vtable: <no type>, base list: <no type>, field list: 0x1004 options: contains nested class | has unique name, sizeof 4 0x1006 | LF_FIELDLIST [size = 28] - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public] - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public] 0x1007 | LF_UNION [size = 60] `S::<unnamed-tag>` unique name: `.?AT<unnamed-type-$S1>@S@@` field list: 0x1006 options: has unique name | is nested | sealed, sizeof ``` This patch delays the FieldDecl creation when travesing LF_FIELDLIST so we know if there are multiple fields are in the same offsets and are able to group them into different anonymous unions based on offsets. Nested anonymous union will be flatten into one anonymous union, because we simply don't have that info, but they are equivalent in terms of union layout. Differential Revision: https://reviews.llvm.org/D134849 |
||
---|---|---|
.. | ||
API | ||
Breakpoint | ||
Core | ||
DataFormatter | ||
Disassembler | ||
Editline | ||
Expression | ||
Host | ||
Instruction | ||
Interpreter | ||
Language | ||
ObjectFile | ||
Platform | ||
Process | ||
ScriptInterpreter | ||
Signals | ||
Symbol | ||
SymbolFile | ||
Target | ||
TestingSupport | ||
Thread | ||
UnwindAssembly | ||
Utility | ||
debugserver | ||
tools | ||
CMakeLists.txt | ||
gtest_common.h |