https://github.com/Nerixyz updated https://github.com/llvm/llvm-project/pull/159769
>From d2c6336279358e570dcdc4e4a1ce75baf0a048ee Mon Sep 17 00:00:00 2001 From: Nerixyz <nerix...@outlook.de> Date: Mon, 22 Sep 2025 11:57:34 +0200 Subject: [PATCH] [LLDB][PDB] Run UDT layout test with native PDB too --- .../SymbolFile/NativePDB/udt-layout.test | 129 ++++++++++++++++++ .../test/Shell/SymbolFile/PDB/udt-layout.test | 2 +- 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test diff --git a/lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test b/lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test new file mode 100644 index 0000000000000..6e971541de60c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test @@ -0,0 +1,129 @@ +# REQUIRES: target-windows + +# Test UDT layout reconstruction +# RUN: split-file %s %t +# RUN: %build --compiler=clang-cl -o %t.exe -- %t/main.cpp +# RUN: %lldb -f %t.exe -s %t/commands.input 2>&1 | FileCheck %s + +#--- main.cpp + +// this is from the DIA plugin (UdtLayoutTest.cpp) +struct A { + explicit A(int u) { _u._u3 = u; } + A(const A &) = default; + virtual ~A() = default; + +private: + union U { + char _u1; + short _u2; + int _u3; + }; + + A::U _u; +}; + +#pragma pack(push, 1) +template <int I> struct B : public virtual A { + B(char a, unsigned short b, int c) : A(a + b + c), _a(a), _b(b), _c(c) {} + +private: + char _a; + unsigned short : 3; + unsigned short _b : 6; + unsigned short : 4; + int _c; +}; +#pragma pack(pop) + +#pragma pack(push, 16) +class C : private virtual B<0>, public virtual B<1>, private B<2>, public B<3> { +public: + C(char x, char y, char z) + : A(x - y + z), B<0>(x, y, z), B<1>(x * 2, y * 2, z * 2), + B<2>(x * 3, y * 3, z * 3), B<3>(x * 4, y * 4, z * 4), _x(x * 5), + _y(y * 5), _z(z * 5) {} + + static int abc; + +private: + int _x; + short _y; + char _z; +}; +int C::abc = 123; +#pragma pack(pop) + +class List { +public: + List() = default; + List(List *p, List *n, C v) : Prev(p), Next(n), Value(v) {} + +private: + List *Prev = nullptr; + List *Next = nullptr; + C Value{1, 2, 3}; +}; + +int main() { + List ls[16]; + return 0; // break here +} + +#--- commands.input + +settings set target.max-children-depth 10 +br set -p "break here" +run +target variable +frame variable +quit + +# CHECK: (int) ::C::abc = 123 + +# CHECK: (List[16]) ls = { +# CHECK: [15] = { +# CHECK-NEXT: Prev = nullptr +# CHECK-NEXT: Next = nullptr +# CHECK-NEXT: Value = { +# CHECK-NEXT: B<2> = { +# CHECK-NEXT: A = { +# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +# CHECK-NEXT: } +# CHECK-NEXT: _a = '\x03' +# CHECK-NEXT: _b = 6 +# CHECK-NEXT: _c = 9 +# CHECK-NEXT: } +# CHECK-NEXT: B<3> = { +# CHECK-NEXT: A = { +# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +# CHECK-NEXT: } +# CHECK-NEXT: _a = '\x04' +# CHECK-NEXT: _b = 8 +# CHECK-NEXT: _c = 12 +# CHECK-NEXT: } +# CHECK-NEXT: A = { +# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +# CHECK-NEXT: } +# CHECK-NEXT: B<0> = { +# CHECK-NEXT: A = { +# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +# CHECK-NEXT: } +# CHECK-NEXT: _a = '\x01' +# CHECK-NEXT: _b = 2 +# CHECK-NEXT: _c = 3 +# CHECK-NEXT: } +# CHECK-NEXT: B<1> = { +# CHECK-NEXT: A = { +# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +# CHECK-NEXT: } +# CHECK-NEXT: _a = '\x02' +# CHECK-NEXT: _b = 4 +# CHECK-NEXT: _c = 6 +# CHECK-NEXT: } +# CHECK-NEXT: _x = 5 +# CHECK-NEXT: _y = 10 +# CHECK-NEXT: _z = '\x0f' +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT: } diff --git a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test index bc68539e25ec1..619646b3f12ba 100644 --- a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test +++ b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test @@ -1,4 +1,4 @@ -REQUIRES: target-windows, lld +REQUIRES: target-windows, lld, diasdk RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits