summaryrefslogtreecommitdiff
path: root/lldb/test/Shell/SymbolFile
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test/Shell/SymbolFile')
-rw-r--r--lldb/test/Shell/SymbolFile/DWARF/union-types-no-member-location.yaml182
-rw-r--r--lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp71
-rw-r--r--lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test129
-rw-r--r--lldb/test/Shell/SymbolFile/PDB/native-setting.cpp31
-rw-r--r--lldb/test/Shell/SymbolFile/PDB/udt-layout.test2
5 files changed, 408 insertions, 7 deletions
diff --git a/lldb/test/Shell/SymbolFile/DWARF/union-types-no-member-location.yaml b/lldb/test/Shell/SymbolFile/DWARF/union-types-no-member-location.yaml
new file mode 100644
index 000000000000..fbdc626ed113
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/union-types-no-member-location.yaml
@@ -0,0 +1,182 @@
+# This test produces DWARF that contains a union type whose DW_TAG_member does
+# not have a DW_AT_data_member_location set to zero. This is how GCC emits
+# debug information for unions. There was code in the DWARFASTParserClang that
+# was emitting an invalid error in this case. This test verifies that this
+# error does not get emitted.
+#
+# 0x0000000b: DW_TAG_compile_unit
+# DW_AT_name ("main.cpp")
+# DW_AT_language (DW_LANG_C)
+#
+# 0x00000011: DW_TAG_base_type
+# DW_AT_name ("int")
+# DW_AT_encoding (DW_ATE_signed_char)
+# DW_AT_byte_size (0x04)
+#
+# 0x00000018: DW_TAG_base_type
+# DW_AT_name ("__ARRAY_SIZE_TYPE__")
+# DW_AT_encoding (DW_ATE_unsigned)
+# DW_AT_byte_size (0x08)
+#
+# 0x0000001f: DW_TAG_array_type
+# DW_AT_type (0x00000011 "int")
+#
+# 0x00000024: DW_TAG_subrange_type
+# DW_AT_type (0x00000018 "__ARRAY_SIZE_TYPE__")
+# DW_AT_count (0x20)
+#
+# 0x0000002a: NULL
+#
+# 0x0000002b: DW_TAG_union_type
+# DW_AT_name ("UnionType")
+# DW_AT_byte_size (0x20)
+#
+# 0x00000031: DW_TAG_member
+# DW_AT_name ("array")
+# DW_AT_type (0x0000001f "int[32]")
+#
+# 0x0000003a: NULL
+#
+# 0x0000003b: DW_TAG_subprogram
+# DW_AT_low_pc (0x0000000000001000)
+# DW_AT_high_pc (0x0000000000001050)
+# DW_AT_name ("foo")
+# DW_AT_type (0x00000031 "array")
+#
+# 0x00000054: NULL
+
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test symbols --name=UnionType --find=type %t > %t.stdout
+# RUN: cat %t.stdout | FileCheck --check-prefix=STDOUT %s
+# RUN: lldb-test symbols --name=UnionType --find=type %t 2> %t.stderr
+# RUN: cat %t.stderr | FileCheck --allow-empty --check-prefix=STDERR %s
+
+# STDOUT: Found 1 types:
+# STDOUT: {{(0x)?[0-9a-fA-F]+}}: Type{0x0000002b} , name = "UnionType", size = 32, compiler_type = 0x{{[0-9a-fA-F]+}} union UnionType {
+
+# STDERR-NOT: error: union-types-no-member-location.yaml.tmp 0x00000031: DW_TAG_member 'array' refers to type 0x000000000000001f which extends beyond the bounds of 0x0000002b
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+DWARF:
+ debug_str:
+ - ''
+ - main.cpp
+ - int
+ - __ARRAY_SIZE_TYPE__
+ - UnionType
+ - array
+ debug_abbrev:
+ - ID: 0
+ Table:
+ - Code: 0x1
+ Tag: DW_TAG_compile_unit
+ Children: DW_CHILDREN_yes
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_language
+ Form: DW_FORM_udata
+ - Code: 0x2
+ Tag: DW_TAG_base_type
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_encoding
+ Form: DW_FORM_data1
+ - Attribute: DW_AT_byte_size
+ Form: DW_FORM_data1
+ - Code: 0x3
+ Tag: DW_TAG_array_type
+ Children: DW_CHILDREN_yes
+ Attributes:
+ - Attribute: DW_AT_type
+ Form: DW_FORM_ref4
+ - Code: 0x4
+ Tag: DW_TAG_subrange_type
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_type
+ Form: DW_FORM_ref4
+ - Attribute: DW_AT_count
+ Form: DW_FORM_data1
+ - Code: 0x5
+ Tag: DW_TAG_union_type
+ Children: DW_CHILDREN_yes
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_byte_size
+ Form: DW_FORM_data1
+ - Code: 0x6
+ Tag: DW_TAG_member
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_name
+ Form: DW_FORM_strp
+ - Attribute: DW_AT_type
+ Form: DW_FORM_ref4
+ - Code: 0x7
+ Tag: DW_TAG_subprogram
+ Children: DW_CHILDREN_no
+ Attributes:
+ - Attribute: DW_AT_low_pc
+ Form: DW_FORM_addr
+ - Attribute: DW_AT_high_pc
+ Form: DW_FORM_addr
+ - Attribute: DW_AT_name
+ Form: DW_FORM_string
+ - Attribute: DW_AT_type
+ Form: DW_FORM_ref4
+ debug_info:
+ - Length: 0x51
+ Version: 4
+ AbbrevTableID: 0
+ AbbrOffset: 0x0
+ AddrSize: 8
+ Entries:
+ - AbbrCode: 0x1
+ Values:
+ - Value: 0x1
+ - Value: 0x2
+ - AbbrCode: 0x2
+ Values:
+ - Value: 0xA
+ - Value: 0x6
+ - Value: 0x4
+ - AbbrCode: 0x2
+ Values:
+ - Value: 0xE
+ - Value: 0x7
+ - Value: 0x8
+ - AbbrCode: 0x3
+ Values:
+ - Value: 0x11
+ - AbbrCode: 0x4
+ Values:
+ - Value: 0x18
+ - Value: 0x20
+ - AbbrCode: 0x0
+ - AbbrCode: 0x5
+ Values:
+ - Value: 0x22
+ - Value: 0x20
+ - AbbrCode: 0x6
+ Values:
+ - Value: 0x2C
+ - Value: 0x1F
+ - AbbrCode: 0x0
+ - AbbrCode: 0x7
+ Values:
+ - Value: 0x1000
+ - Value: 0x1050
+ - Value: 0xDEADBEEFDEADBEEF
+ CStr: foo
+ - Value: 0x31
+ - AbbrCode: 0x0
+...
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
new file mode 100644
index 000000000000..dc26ec8d30cb
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
@@ -0,0 +1,71 @@
+// REQUIRES: !diasdk, target-windows
+
+// Test plugin.symbol-file.pdb.reader setting without the DIA SDK
+// RUN: %build -o %t.exe -- %s
+// RUN: env -u LLDB_USE_NATIVE_PDB_READER %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER= %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+
+// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=-1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-NATIVE %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-NATIVE %s
+
+// NO-ENV-NOT: warning:
+// NO-ENV: (lldb) target modules dump symfile
+// NO-ENV: Dumping debug symbols for 1 modules.
+// NO-ENV: SymbolFile native-pdb
+
+// ENV0: warning: the DIA PDB reader was explicitly requested, but LLDB was built without the DIA SDK. The native reader will be used instead
+// ENV0: (lldb) target modules dump symfile
+// ENV0: Dumping debug symbols for 1 modules.
+// ENV0: SymbolFile native-pdb
+
+// ENV1-NOT: warning:
+// ENV1: (lldb) target modules dump symfile
+// ENV1: Dumping debug symbols for 1 modules.
+// ENV1: SymbolFile native-pdb
+
+// ENV0-SET-DIA: warning: the DIA PDB reader was explicitly requested, but LLDB was built without the DIA SDK. The native reader will be used instead
+// ENV0-SET-DIA: (lldb) target modules dump symfile
+// ENV0-SET-DIA: Dumping debug symbols for 1 modules.
+// ENV0-SET-DIA: SymbolFile native-pdb
+
+// ENV1-SET-DIA: warning: the DIA PDB reader was explicitly requested, but LLDB was built without the DIA SDK. The native reader will be used instead
+// ENV1-SET-DIA: (lldb) target modules dump symfile
+// ENV1-SET-DIA: Dumping debug symbols for 1 modules.
+// ENV1-SET-DIA: SymbolFile native-pdb
+
+// ENV1-SET-NATIVE-NOT: warning:
+// ENV0-SET-NATIVE: (lldb) target modules dump symfile
+// ENV0-SET-NATIVE: Dumping debug symbols for 1 modules.
+// ENV0-SET-NATIVE: SymbolFile native-pdb
+
+// ENV1-SET-NATIVE-NOT: warning:
+// ENV1-SET-NATIVE: (lldb) target modules dump symfile
+// ENV1-SET-NATIVE: Dumping debug symbols for 1 modules.
+// ENV1-SET-NATIVE: SymbolFile native-pdb
+
+int main() {}
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 000000000000..6e971541de60
--- /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/native-setting.cpp b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
index a3077252f08f..f5e54592b0b3 100644
--- a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
+++ b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
@@ -2,49 +2,68 @@
// Test plugin.symbol-file.pdb.reader setting
// RUN: %build -o %t.exe -- %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump symfile' | FileCheck --check-prefix=ENV0 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump symfile' | FileCheck --check-prefix=ENV1 %s
+// RUN: env -u LLDB_USE_NATIVE_PDB_READER %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER= %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+
+// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=-1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+
// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
// RUN: -o 'target create %t.exe' \
// RUN: -o 'target modules dump symfile' \
-// RUN: | FileCheck --check-prefix=ENV0-SET-DIA %s
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-DIA %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
// RUN: -o 'target create %t.exe' \
// RUN: -o 'target modules dump symfile' \
-// RUN: | FileCheck --check-prefix=ENV1-SET-DIA %s
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-DIA %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
// RUN: -o 'target create %t.exe' \
// RUN: -o 'target modules dump symfile' \
-// RUN: | FileCheck --check-prefix=ENV0-SET-NATIVE %s
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-NATIVE %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
// RUN: -o 'target create %t.exe' \
// RUN: -o 'target modules dump symfile' \
-// RUN: | FileCheck --check-prefix=ENV1-SET-NATIVE %s
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-NATIVE %s
+
+// NO-ENV-NOT: warning:
+// NO-ENV: (lldb) target modules dump symfile
+// NO-ENV: Dumping debug symbols for 1 modules.
+// NO-ENV: SymbolFile pdb
+// ENV0-NOT: warning:
// ENV0: (lldb) target modules dump symfile
// ENV0: Dumping debug symbols for 1 modules.
// ENV0: SymbolFile pdb
+// ENV1-NOT: warning:
// ENV1: (lldb) target modules dump symfile
// ENV1: Dumping debug symbols for 1 modules.
// ENV1: SymbolFile native-pdb
+// ENV0-SET-DIA-NOT: warning:
// ENV0-SET-DIA: (lldb) target modules dump symfile
// ENV0-SET-DIA: Dumping debug symbols for 1 modules.
// ENV0-SET-DIA: SymbolFile pdb
+// ENV1-SET-DIA-NOT: warning:
// ENV1-SET-DIA: (lldb) target modules dump symfile
// ENV1-SET-DIA: Dumping debug symbols for 1 modules.
// ENV1-SET-DIA: SymbolFile pdb
+// ENV0-SET-NATIVE-NOT: warning:
// ENV0-SET-NATIVE: (lldb) target modules dump symfile
// ENV0-SET-NATIVE: Dumping debug symbols for 1 modules.
// ENV0-SET-NATIVE: SymbolFile native-pdb
+// ENV1-SET-NATIVE-NOT: warning:
// ENV1-SET-NATIVE: (lldb) target modules dump symfile
// ENV1-SET-NATIVE: Dumping debug symbols for 1 modules.
// ENV1-SET-NATIVE: SymbolFile native-pdb
diff --git a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
index bc68539e25ec..619646b3f12b 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