[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:21:36 PDT 2026


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

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).

>From d4162f8a970ee752b80b1932ff0b602a89513cfa Mon Sep 17 00:00:00 2001
From: Walnut <walnut356dev at gmail.com>
Date: Tue, 27 Oct 2026 01:30:58 -0500
Subject: [PATCH] [lldb] don't omit 0-sized struct fields

---
 .../source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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



More information about the lldb-commits mailing list