2 Commits

Author SHA1 Message Date
Nerixyz
fb9a0cd278
[LLDB][NativePDB] Ignore indirect virtual bases (#185735)
When a class indirectly inherits from a class with virtual bases, it
will get an `LF_IVBCLASS` record in its fieldlist, even though it
doesn't directly inherit that class.

In the following example, `UserUser` inherits from `User`, which
virtually inherits from `VBase`:

```cpp
struct User : public virtual VBase {};
struct UserUser : public User {};
```

For this we get
```
  0x1015 | LF_FIELDLIST [size = 72]
           - LF_BCLASS
             type = 0x1002 (-> 0x102A), offset = 0, attrs = public
           - LF_IVBCLASS
             base = 0x1003, vbptr = 0x1005, vbptr offset = 0, vtable index = 1
             attrs = public (...)
  0x1016 | LF_STRUCTURE [size = 48] `UserUser`
           unique name: `.?AUUserUser@@`
           vtable: <no type>, base list: <no type>, field list: 0x1015
           options: has ctor / dtor | has unique name | overloaded operator | overloaded operator=, sizeof 16
  0x1029 | LF_FIELDLIST [size = 56]
           - LF_VBCLASS
             base = 0x1003, vbptr = 0x1005, vbptr offset = 0, vtable index = 1
             attrs = public (...)
  0x102A | LF_STRUCTURE [size = 40] `User`
           unique name: `.?AUUser@@`
           vtable: <no type>, base list: <no type>, field list: 0x1029
           options: has ctor / dtor | has unique name | overloaded operator | overloaded operator=, sizeof 16
```

If I understand correctly, then `LF_IVBCLASS` indicates that if this
class (e.g. `UserUser`) is created as the most derived object, it will
host the class (e.g. `VBase`).
The VS debugger actually shows this as a separate field. LLDB on the
other hand doesn't, so I removed it.

---------

Co-authored-by: Zequan Wu <zequanwu@google.com>
2026-03-11 12:19:15 +01:00
nerix
e08d8e3d16
[LLDB][PDB] Run UDT layout test with native PDB too (#159769)
This test was failing with the native plugin due to two reasons:

1. The static `C::abc` was printed as `(int) ::C::abc = 123`
2. The order of the base classes of [`C`
(`List::Value`)](b7e4edca3d/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp (L30))
is different between DIA and the native plugin. I don't know how the
order in the DIA plugin is determined - it prints `B<0>`, `B<1>`,
`B<2>`, `B<3>`, `A`. The native plugin follows the order of the bases in
memory and prints `B<2>`, `B<3>`, `A`, `B<0>`, `B<1>` (last three are
the virtual bases).
    <details><summary>Class layout of C</summary>
    
    ```
    class C size(88):
            +---
    0       | +--- (base class B<2>)
    0       | | {vbptr}
    8       | | _a
    9.      | | _b (bitstart=3,nbits=6)
    11      | | _c
            | +---
    15      | +--- (base class B<3>)
    15      | | {vbptr}
    23      | | _a
    24.     | | _b (bitstart=3,nbits=6)
    26      | | _c
            | +---
            | <alignment member> (size=2)
    32      | _x
    36      | _y
    38      | _z
            | <alignment member> (size=1)
            | <alignment member> (size=2)
            +---
            +--- (virtual base A)
    40      | {vfptr}
    48      | U _u
            | <alignment member> (size=4)
            +---
            +--- (virtual base B<0>)
    56      | {vbptr}
    64      | _a
    65.     | _b (bitstart=3,nbits=6)
    67      | _c
            +---
            +--- (virtual base B<1>)
    71      | {vbptr}
    79      | _a
    80.     | _b (bitstart=3,nbits=6)
    82      | _c
            +---
    ```
    </details>

I split the tests for the plugins for better readability.
2025-09-23 11:34:48 +02:00