Repository navigation
Conversation
|
@llvm/pr-subscribers-lldb Author: Walnut (Walnut356) ChangesResolves #235686 TL;DR brings PDB handling in-line with DWARF handling, such that it no longer pretends 0-sized fields don't exist. Worth noting that this change still has slightly different behavior than DWARF handling, though I'm not 100% sure if that's due to LLDB, LLVM, or the PDB format itself. For the same struct definition: #[repr(C)]
struct A {
x: u64,
y: u16,
data: [Sized],
}the PDB type listing is as follows: struct A {
unsigned long long x;
unsigned short y;
temp::Sized data[0];
}Where the type of Conversely, the DWARF data is listed as: struct A {
unsigned long long x;
unsigned short y;
temp::Sized data[];
}where the type of Regardless, this change allows users to interact with all 0-sized fields, which is helpful for the visualizer scripts, particularly for Rust's dynamically sized types (e.g. the example struct above) and 1 Files Affected:
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
index 417d7630a93753..4d15e1c20d9635 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
@@ -294,8 +294,7 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
lldb::AccessType access = TranslateMemberAccess(data_member.getAccess());
size_t field_size =
bitfield_width ? bitfield_width : GetSizeOfType(ti, m_index.tpi()) * 8;
- if (field_size == 0)
- return Error::success();
+
m_record.CollectMember(data_member.Name, offset, field_size, member_qt,
access, bitfield_width, m_member_index);
return Error::success();
|
|
Hmm, I'll need to look more into that test failure I think. I don't have a great mental model of how LLDB's "incomplete types" work and whether or not the change from to is a bad thing. cc @Nerixyz |
|
Off the top of my head: size=0 is sometimes used to detect incomplete types. I wonder why this works with dwarf in that case though. |
|
If I'm understanding this correctly, it looks like DWARF can represent the absence of a length, in which case llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Lines 1496 to 1511 in f7c2c49 PDB passes the length in directly instead of so presumably LLVM is setting the length of an Based on the codeview spec, it looks like maybe |
|
One other question, is "incomplete type" an LLDB/clang implementation detail, or is it just a synonym for "forward ref"? |
|
Ah, found the culprit llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Lines 1791 to 1796 in 65303e8 I'll give it a test some time this week and see if MSVC's debugger freaks out when encountering |
A forward reference is CodeView/PDB specific, because of the constraint that type records cannot contain type indices higher than their own.
In C, |
Whoops, i could have worded that better. When i said "is considered to be" i meant that if you ask LLDB what size it is via |
Yet another node that's in the spec, but that visual studio's debugger can't handle Neither old nor new WinDbg handle it properly either |
|
I guess a simple (but imperfect) fix would be to skip the |
Sure. I think it's easier to judge if this is correct when there are tests. |
Resolves #235686
TL;DR brings PDB handling in-line with DWARF handling, such that it no longer pretends 0-sized fields don't exist.
Worth noting that this change still has slightly different behavior than DWARF handling, though I'm not 100% sure if that's due to LLDB, LLVM, or the PDB format itself. For the same struct definition:
the PDB type listing is as follows:
Where the type of
datais considered to be 0-sized.Conversely, the DWARF data is listed as:
where the type of
datais considered to be the size of 1temp::Sizedelement.Regardless, this change allows users to interact with all 0-sized fields, which is helpful for the visualizer scripts, particularly for Rust's dynamically sized types (e.g. the example struct above) and
PhantomData<T>.