[Lldb-commits] [lldb] [lldb][Native PDB] don't omit 0-sized struct fields (PR #237688)

via lldb-commits lldb-commits at lists.llvm.org
Sat Oct 31 23:22:10 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Walnut (Walnut356)

<details>
<summary>Changes</summary>

Resolves https://github.com/llvm/llvm-project/issues/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:

```rust
#[repr(C)]
struct A {
    x: u64,
    y: u16,
    data: [Sized],
}
```

the PDB type listing is as follows:

```c
struct A {
    unsigned long long x;
    unsigned short y;
    temp::Sized data[0];
}
```

Where the type of `data` is considered to be 0-sized. 

Conversely, the DWARF data is listed as:

```c
struct A {
    unsigned long long x;
    unsigned short y;
    temp::Sized data[];
}
```

where the type of `data` is considered to be the size of 1 `temp::Sized` element.

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](https://doc.rust-lang.org/reference/dynamically-sized-types.html) (e.g. the example struct above) and [`PhantomData<T>`](https://doc.rust-lang.org/std/marker/struct.PhantomData.html).

---
Full diff: https://github.com/llvm/llvm-project/pull/237688.diff


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp (+1-2) 


``````````diff
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();

``````````

</details>


https://github.com/llvm/llvm-project/pull/237688


More information about the lldb-commits mailing list