diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 19:22:02 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-10-09 19:22:02 +0000 |
| commit | 87aa9c9e4d41ed881453e2fab85b3d25f648bb55 (patch) | |
| tree | 63efe79832bf3de4f63e4e81c62e73923947b882 /lldb/test/Shell/SymbolFile/PDB | |
| parent | fd18e94697c987d5f24e25aa4e27adaffff3cce4 (diff) | |
| download | bcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.tar.gz bcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.zip | |
Re-land "[test] Split LLDB tests into API, Shell & Unit"
The original patch got reverted because it broke `check-lldb` on a clean
build. This fixes that.
llvm-svn: 374201
Diffstat (limited to 'lldb/test/Shell/SymbolFile/PDB')
40 files changed, 1263 insertions, 0 deletions
diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/AstRestoreTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/AstRestoreTest.cpp new file mode 100644 index 00000000000..8c9e26744d5 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/AstRestoreTest.cpp @@ -0,0 +1,55 @@ +namespace N0 { +namespace N1 { + +namespace { +enum Enum { Enum_0 = 1, Enum_1 = 2, Enum_2 = 4, Enum_3 = 8 }; +} + +Enum Global = Enum_3; + +struct Base { + Enum m_e = Enum_1; +}; + +class Class : public Base { +public: + Class(Enum e) : m_ce(e) {} + + static int StaticFunc(const Class &c) { + return c.PrivateFunc(c.m_inner) + Global + ClassStatic; + } + + const Enum m_ce; + + static int ClassStatic; + +private: + struct Inner { + char x; + short y; + int z; + }; + + int PrivateFunc(const Inner &i) const { return i.z; } + + Inner m_inner{}; +}; +int Class::ClassStatic = 7; + +template<typename T> +struct Template { + template<Enum E> + void TemplateFunc() { + T::StaticFunc(T(E)); + } +}; + +void foo() { Template<Class>().TemplateFunc<Enum_0>(); } + +} // namespace N1 +} // namespace N0 + +int main() { + N0::N1::foo(); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp new file mode 100644 index 00000000000..60854c04c60 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/CallingConventionsTest.cpp @@ -0,0 +1,20 @@ +int FuncCCall() { return 0; } +auto FuncCCallPtr = &FuncCCall; + +int __stdcall FuncStdCall() { return 0; } +auto FuncStdCallPtr = &FuncStdCall; + +int __fastcall FuncFastCall() { return 0; } +auto FuncFastCallPtr = &FuncFastCall; + +int __vectorcall FuncVectorCall() { return 0; } +auto FuncVectorCallPtr = &FuncVectorCall; + +struct S { + int FuncThisCall() { return 0; } +}; +auto FuncThisCallPtr = &S::FuncThisCall; + +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp new file mode 100644 index 00000000000..3c4b005cdf1 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp @@ -0,0 +1,111 @@ +// To avoid linking MSVC specific libs, we don't test virtual/override methods +// that needs vftable support in this file. + +// Enum. +enum Enum { RED, GREEN, BLUE }; +Enum EnumVar; + +// Union. +union Union { + short Row; + unsigned short Col; + int Line : 16; // Test named bitfield. + short : 8; // Unnamed bitfield symbol won't be generated in PDB. + long Table; +}; +Union UnionVar; + +// Struct. +struct Struct; +typedef Struct StructTypedef; + +struct Struct { + bool A; + unsigned char UCharVar; + unsigned int UIntVar; + long long LongLongVar; + Enum EnumVar; // Test struct has UDT member. + int array[10]; +}; +struct Struct StructVar; + +struct _List; // Forward declaration. +struct Complex { + struct _List *array[90]; + struct { // Test unnamed struct. MSVC treats it as `int x` + int x; + }; + union { // Test unnamed union. MSVC treats it as `int a; float b;` + int a; + float b; + }; +}; +struct Complex c; + +struct _List { // Test doubly linked list. + struct _List *current; + struct _List *previous; + struct _List *next; +}; +struct _List ListVar; + +typedef struct { + int a; +} UnnamedStruct; // Test unnamed typedef-ed struct. +UnnamedStruct UnnanmedVar; + +// Class. +namespace MemberTest { +class Base { +public: + Base() {} + ~Base() {} + +public: + int Get() { return 0; } + +protected: + int a; +}; +class Friend { +public: + int f() { return 3; } +}; +class Class : public Base { // Test base class. + friend Friend; + static int m_static; // Test static member variable. +public: + Class() : m_public(), m_private(), m_protected() {} + explicit Class(int a) { m_public = a; } // Test first reference of m_public. + ~Class() {} + + static int StaticMemberFunc(int a, ...) { + return 1; + } // Test static member function. + int Get() { return 1; } + int f(Friend c) { return c.f(); } + inline bool operator==(const Class &rhs) const // Test operator. + { + return (m_public == rhs.m_public); + } + +public: + int m_public; + struct Struct m_struct; + +private: + Union m_union; + int m_private; + +protected: + friend class Friend; + int m_protected; +}; +} // namespace MemberTest + +int main() { + MemberTest::Base B1; + B1.Get(); + MemberTest::Class::StaticMemberFunc(1, 10, 2); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/CompilandsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/CompilandsTest.cpp new file mode 100644 index 00000000000..4cce7f667ff --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/CompilandsTest.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest.cpp new file mode 100644 index 00000000000..3785cd3c64c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest.cpp @@ -0,0 +1,20 @@ +namespace N0 { +namespace N1 { + +char *buf0 = nullptr; +char buf1[] = {0, 1, 2, 3, 4, 5, 6, 7}; + +char sum(char *buf, int size) { + char result = 0; + for (int i = 0; i < size; i++) + result += buf[i]; + return result; +} + +} // namespace N1 +} // namespace N0 + +int main() { + char result = N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest0.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest0.script new file mode 100644 index 00000000000..d31a2abb68a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest0.script @@ -0,0 +1,7 @@ +breakpoint set --file ExpressionsTest.cpp --line 19 +run +print result +print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) +print N1::sum(N1::buf1, sizeof(N1::buf1)) +print sum(buf1, sizeof(buf1)) +print sum(buf1, 1000000000) diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script new file mode 100644 index 00000000000..dac887faa5b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest1.script @@ -0,0 +1 @@ +print sum(buf0, 1) diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script new file mode 100644 index 00000000000..b19240baf99 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ExpressionsTest2.script @@ -0,0 +1,2 @@ +print sum(buf0, result - 28) +print sum(buf1 + 3, 3) diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbols.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbols.cpp new file mode 100644 index 00000000000..ccccf6ffd10 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbols.cpp @@ -0,0 +1,16 @@ +// Static function +namespace { +static long StaticFunction(int a) +{ + return 2; +} +} + +// Inlined function +static inline int InlinedFunction(long a) { return 10; } + +void FunctionCall() +{ + StaticFunction(1); + InlinedFunction(1); +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp new file mode 100644 index 00000000000..17eeab7117b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FuncSymbolsTestMain.cpp @@ -0,0 +1,59 @@ + +// Global functions +int Func_arg_array(int array[]) { return 1; } +void Func_arg_void(void) { return; } +void Func_arg_none(void) { return; } +void Func_varargs(...) { return; } + +// Class +namespace MemberTest { + class A { + public: + int Func(int a, ...) { return 1; } + }; +} + +// Template +template <int N=1, class ...T> +void TemplateFunc(T ...Arg) { + return; +} + +// namespace +namespace { + void Func(int a, const long b, volatile bool c, ...) { return; } +} + +namespace NS { + void Func(char a, int b) { + return; + } +} + +// Static function +static long StaticFunction(int a) +{ + return 2; +} + +// Inlined function +inline void InlinedFunction(long a) { return; } + +extern void FunctionCall(); + +int main() { + MemberTest::A v1; + v1.Func('a',10); + + Func(1, 5, true, 10, 8); + NS::Func('c', 2); + + TemplateFunc(10); + TemplateFunc(10,11,88); + + StaticFunction(2); + InlinedFunction(1); + + FunctionCall(); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp new file mode 100644 index 00000000000..fa0030bacbf --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.cpp @@ -0,0 +1,9 @@ +#include "FunctionLevelLinkingTest.h" + +int foo() { + return 0; +} + +int main() { + return foo() + bar() + baz(); +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h new file mode 100644 index 00000000000..0cc9d80d85d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.h @@ -0,0 +1,12 @@ +#ifndef FUNCTION_LEVEL_LINKING_TEST_H +#define FUNCTION_LEVEL_LINKING_TEST_H + +int bar() { + return 0; +} + +int baz() { + return 0; +} + +#endif diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord new file mode 100644 index 00000000000..48abd0b872f --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionLevelLinkingTest.ord @@ -0,0 +1,4 @@ +?foo@@YAHXZ +?bar@@YAHXZ +main +?baz@@YAHXZ diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp new file mode 100644 index 00000000000..62e201df5fe --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/FunctionNestedBlockTest.cpp @@ -0,0 +1,8 @@ +int main() { + auto r = 0; + for (auto i = 1; i <= 10; i++) { + r += i & 1 + (i - 1) & 1 - 1; + } + + return r; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/PointerTypeTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/PointerTypeTest.cpp new file mode 100644 index 00000000000..6612c30f00d --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/PointerTypeTest.cpp @@ -0,0 +1,23 @@ +int main() { + // Test pointer to array. + int array[2][4]; + int(*array_pointer)[2][4] = &array; + + struct ST { + int a; + int f(int x) { return 1; } + }; + + ST s = {10}; + + // Test pointer to a local. + int *p_int = &s.a; + + // Test pointer to data member. + int ST::*p_member_field = &ST::a; + + // Test pointer to member function. + int (ST::*p_member_method)(int) = &ST::f; + + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp new file mode 100644 index 00000000000..de13a5b430c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/SimpleTypesTest.cpp @@ -0,0 +1,52 @@ +// typedef +typedef unsigned long ULongArrayTypedef[10]; +ULongArrayTypedef ULongArrayVar; + +typedef long double*& RefTypedef; +long double* LongDoublePtrVar = 0; +RefTypedef RefVar = LongDoublePtrVar; + +typedef long long (*FuncPtrTypedef)(int&, unsigned char**, short[], const double, volatile bool); +FuncPtrTypedef FuncVar; + +typedef char (*VarArgsFuncTypedef)(void*, long, unsigned short, unsigned int, ...); +VarArgsFuncTypedef VarArgsFuncVar; + +typedef float (*VarArgsFuncTypedefA)(...); +VarArgsFuncTypedefA VarArgsFuncVarA; + +// unscoped enum +enum Enum { RED, GREEN, BLUE }; +Enum EnumVar; + +enum EnumConst { LOW, NORMAL = 10, HIGH }; +EnumConst EnumConstVar; + +enum EnumEmpty {}; +EnumEmpty EnumEmptyVar; + +enum EnumUChar : unsigned char { ON, OFF, AUTO }; +EnumUChar EnumCharVar; + +// scoped enum +enum class EnumClass { YES, NO, DEFAULT }; +EnumClass EnumClassVar; + +enum struct EnumStruct { red, blue, black }; +EnumStruct EnumStructVar; + +typedef signed char SCharTypedef; +SCharTypedef SCVar; + +typedef char16_t WChar16Typedef; +WChar16Typedef WC16Var; + +typedef char32_t WChar32Typedef; +WChar32Typedef WC32Var; + +typedef wchar_t WCharTypedef; +WCharTypedef WCVar; + +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/TypeQualsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/TypeQualsTest.cpp new file mode 100644 index 00000000000..bedafcdacfc --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/TypeQualsTest.cpp @@ -0,0 +1,46 @@ +// Rank > 0 array +typedef volatile int* RankNArray[10][100]; +RankNArray ArrayVar; + +typedef int __unaligned *UnalignedTypedef; +UnalignedTypedef UnVar; + +typedef long* __restrict RestrictTypedef; +RestrictTypedef RestrictVar; + +void Func1(const int* a, int const* b, const int ** const c, const int* const* d) { + return; +} + +void Func2(volatile int* a, int volatile* b) { + return; +} + +void Func3(int*& a, int& b, const int&c, int&& d) { + return; +} + +void Func4(int* __unaligned a, __unaligned int* b) { + return; +} + +void Func5(int a, int* __restrict b, int& __restrict c) { + return; +} + +void Func6(const volatile int* __restrict b) { + return; +} + +// LValue +typedef int& IntRef; +int x = 0; +IntRef IVar = x; + +// RValue +typedef int&& IIRef; +IIRef IIVar = int(1); + +int main() { + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp new file mode 100644 index 00000000000..59a4fc585d7 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.cpp @@ -0,0 +1,61 @@ +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; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.script new file mode 100644 index 00000000000..91de55f4ade --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/UdtLayoutTest.script @@ -0,0 +1,4 @@ +breakpoint set --file UdtLayoutTest.cpp --line 60 +run +target variable +frame variable diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.cpp new file mode 100644 index 00000000000..a5e84bd3657 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.cpp @@ -0,0 +1,16 @@ +struct A { + char a = 1; +}; + +struct B { + int b = 2; +}; + +struct C : virtual A, virtual B { + short c = 3; +}; + +int main() { + C c{}; + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script new file mode 100644 index 00000000000..8675890b76e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VBases.script @@ -0,0 +1,7 @@ +breakpoint set --file VBases.cpp --line 15 + +run + +print c + +frame variable c
\ No newline at end of file diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp new file mode 100644 index 00000000000..7b7180a3ec4 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.cpp @@ -0,0 +1,26 @@ +int g_var = 2222; + +void __fastcall foo(short arg_0, float arg_1) { + char loc_0 = 'x'; + double loc_1 = 0.5678; +} + +__declspec(align(128)) struct S { + int a = 1234; +}; + +void bar(int arg_0) { + S loc_0; + int loc_1 = 5678; +} + + +int main(int argc, char *argv[]) { + bool loc_0 = true; + int loc_1 = 3333; + + foo(1111, 0.1234); + bar(22); + + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.script b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.script new file mode 100644 index 00000000000..7dd90352cce --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesLocationsTest.script @@ -0,0 +1,25 @@ +breakpoint set --file VariablesLocationsTest.cpp --line 6 +breakpoint set --file VariablesLocationsTest.cpp --line 15 + +run + +target variable g_var + +frame variable arg_0 +frame variable arg_1 + +frame variable loc_0 +frame variable loc_1 + +frame select 1 + +frame variable loc_0 +frame variable loc_1 + +continue + +frame variable arg_0 + +frame variable loc_0 +frame variable loc_1 + diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesTest.cpp new file mode 100644 index 00000000000..304d9056609 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/VariablesTest.cpp @@ -0,0 +1,50 @@ +typedef int IntTypedef; +IntTypedef g_IntVar; // Testing globals. + +typedef enum Enum { // Testing constants. + RED, + GREEN, + BLUE +} EnumTypedef; +EnumTypedef g_EnumVar; // Testing members. + +// FIXME: `sg_IntVar` appears both in global scope's children and compiland's +// children but with different symbol's id. +static int sg_IntVar = -1; // Testing file statics. + +// FIXME: `g_Const` appears both in global scope's children and compiland's +// children but with different symbol's id. +const int g_Const = 0x88; // Testing constant data. +const int *g_pConst = &g_Const; // Avoid optimizing the const away + +thread_local int g_tls = 0; // Testing thread-local storage. + +class Class { + static int m_StaticClassMember; +public: + explicit Class(int a) {} + void Func() {} +}; +int Class::m_StaticClassMember = 10; // Testing static class members. +Class ClassVar(1); + +int f(int var_arg1, int var_arg2) { // Testing parameters. + long same_name_var = -1; + return 1; +} + +int same_name_var = 100; +int main() { + int same_name_var = 0; // Testing locals. + const char local_const = 0x1; + + // FIXME: 'local_CString` is not found through compiland's children. + const char local_CString[] = "abc"; // Testing constant string. + const char *local_pCString = local_CString; // Avoid optimizing the const away + + int a = 10; + a++; + + ClassVar.Func(); + return 0; +} diff --git a/lldb/test/Shell/SymbolFile/PDB/ast-restore.test b/lldb/test/Shell/SymbolFile/PDB/ast-restore.test new file mode 100644 index 00000000000..14ec0d52f2e --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/ast-restore.test @@ -0,0 +1,83 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/AstRestoreTest.cpp +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=GLOBAL %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=BASE %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=CLASS %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=INNER %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=TEMPLATE %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=FOO %s +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck --check-prefix=MAIN %s + +ENUM: Module: {{.*}} +ENUM: namespace N0 { +ENUM: namespace N1 { +ENUM: namespace { +ENUM: enum Enum { +ENUM: Enum_0, +ENUM: Enum_1, +ENUM: Enum_2, +ENUM: Enum_3 +ENUM: }; +ENUM: } +ENUM: } +ENUM: } + +GLOBAL: Module: {{.*}} +GLOBAL: namespace N0 { +GLOBAL: namespace N1 { +GLOBAL: N0::N1::(anonymous namespace)::Enum Global; +GLOBAL: } +GLOBAL: } + +BASE: Module: {{.*}} +BASE: namespace N0 { +BASE: namespace N1 { +BASE: struct Base { +BASE: N0::N1::(anonymous namespace)::Enum m_e; +BASE: }; +BASE: } +BASE: } + +CLASS: Module: {{.*}} +CLASS: namespace N0 { +CLASS: namespace N1 { +CLASS: class Class : public N0::N1::Base { +CLASS-DAG: const N0::N1::(anonymous namespace)::Enum m_ce; +CLASS-DAG: static int ClassStatic; +CLASS-DAG: N0::N1::Class::Inner m_inner; +CLASS-DAG: {{(inline )?}}Class(N0::N1::(anonymous namespace)::Enum); +CLASS-DAG: static {{(inline )?}}int StaticFunc(const N0::N1::Class &); +CLASS-DAG: {{(inline )?}}int PrivateFunc(const N0::N1::Class::Inner &); +CLASS: }; +CLASS: } +CLASS: } + +INNER: Module: {{.*}} +INNER: namespace N0 { +INNER: namespace N1 { +INNER: class Class : public N0::N1::Base { +INNER: struct Inner { +INNER: char x; +INNER: short y; +INNER: int z; +INNER: }; +INNER: }; +INNER: } +INNER: } + +TEMPLATE: Module: {{.*}} +TEMPLATE: struct Template<N0::N1::Class> { +TEMPLATE: inline void TemplateFunc<1>(); +TEMPLATE: }; + +FOO: Module: {{.*}} +FOO: namespace N0 { +FOO: namespace N1 { +FOO: void foo(); +FOO: } +FOO: } + +MAIN: Module: {{.*}} +MAIN: int main(); diff --git a/lldb/test/Shell/SymbolFile/PDB/calling-conventions.test b/lldb/test/Shell/SymbolFile/PDB/calling-conventions.test new file mode 100644 index 00000000000..a85dc65ff04 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/calling-conventions.test @@ -0,0 +1,10 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%t.exe %S/Inputs/CallingConventionsTest.cpp +RUN: lldb-test symbols -dump-ast %t.exe | FileCheck %s + +CHECK: Module: {{.*}} +CHECK-DAG: int (*FuncCCallPtr)(); +CHECK-DAG: int (*FuncStdCallPtr)() __attribute__((stdcall)); +CHECK-DAG: int (*FuncFastCallPtr)() __attribute__((fastcall)); +CHECK-DAG: int (*FuncVectorCallPtr)() __attribute__((vectorcall)); +CHECK-DAG: int (S::*FuncThisCallPtr)() __attribute__((thiscall)); diff --git a/lldb/test/Shell/SymbolFile/PDB/class-layout.test b/lldb/test/Shell/SymbolFile/PDB/class-layout.test new file mode 100644 index 00000000000..fcd6b610826 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/class-layout.test @@ -0,0 +1,92 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/ClassLayoutTest.cpp.obj %S/Inputs/ClassLayoutTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/ClassLayoutTest.cpp.exe %T/ClassLayoutTest.cpp.obj +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=UNION %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=STRUCT %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=COMPLEX %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=LIST %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=UNNAMED-STRUCT %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=BASE %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=FRIEND %s +RUN: lldb-test symbols %T/ClassLayoutTest.cpp.exe | FileCheck --check-prefix=CLASS %s + +CHECK: Module [[MOD:.*]] +CHECK: SymbolFile pdb ([[MOD]]) +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\ClassLayoutTest.cpp' + +ENUM: name = "Enum", size = 4, decl = ClassLayoutTest.cpp:5 +ENUM-SAME: enum Enum { +ENUM: RED, +ENUM: GREEN, +ENUM: BLUE +ENUM:} + +UNION: name = "Union", size = 4, decl = ClassLayoutTest.cpp:9 +UNION-SAME: union Union { +UNION: short Row; +UNION: unsigned short Col; +UNION: int Line : 16; +UNION: long Table; +UNION:} + +STRUCT: name = "Struct", size = 64, decl = ClassLayoutTest.cpp:22 +STRUCT-SAME: struct Struct { +STRUCT: bool A; +STRUCT: unsigned char UCharVar; +STRUCT: unsigned int UIntVar; +STRUCT: long long LongLongVar; +STRUCT: Enum EnumVar; +STRUCT: int array[10]; +STRUCT:} + +COMPLEX: name = "Complex", size = 368, decl = ClassLayoutTest.cpp:33 +COMPLEX-SAME: struct Complex { +COMPLEX: _List *array[90]; +COMPLEX: int x; +COMPLEX: int a; +COMPLEX: float b; +COMPLEX:} + +LIST: name = "_List", size = 12, decl = ClassLayoutTest.cpp:45 +LIST-SAME: struct _List { +LIST: _List *current; +LIST: _List *previous; +LIST: _List *next; +LIST:} + +UNNAMED-STRUCT: name = "UnnamedStruct", size = 4, decl = ClassLayoutTest.cpp:52 +UNNAMED-STRUCT-SAME: struct UnnamedStruct { +UNNAMED-STRUCT: int a; +UNNAMED-STRUCT:} + +BASE: name = "Base", size = 4, decl = ClassLayoutTest.cpp:59 +BASE-SAME: class Base { +BASE: int a; +BASE: Base(); +BASE: ~Base(); +BASE: int Get(); +BASE:} + +FRIEND: name = "Friend", size = 1, decl = ClassLayoutTest.cpp:70 +FRIEND-SAME: class Friend { +FRIEND: int f(); +FRIEND: } + +CLASS: name = "Class", size = 88, decl = ClassLayoutTest.cpp:74 +CLASS-SAME: class Class : public MemberTest::Base { +CLASS: static int m_static; +CLASS: int m_public; +CLASS: Struct m_struct; +CLASS: Union m_union; +CLASS: int m_private; +CLASS: int m_protected; +CLASS: Class(); +CLASS: Class(int); +CLASS: ~Class(); +CLASS: static int {{.*}}StaticMemberFunc(int, ...); +CLASS: int Get(); +CLASS: int f(MemberTest::Friend); +CLASS: bool operator==(const MemberTest::Class &) +CLASS:} diff --git a/lldb/test/Shell/SymbolFile/PDB/compilands.test b/lldb/test/Shell/SymbolFile/PDB/compilands.test new file mode 100644 index 00000000000..0bda82ee236 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/compilands.test @@ -0,0 +1,11 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/CompilandsTest.cpp.obj %S/Inputs/CompilandsTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/CompilandsTest.cpp.exe %T/CompilandsTest.cpp.obj +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols %T/CompilandsTest.cpp.exe | FileCheck %s + +; Link default libraries + +CHECK: Module [[CU:.*]] +CHECK: SymbolFile pdb ([[CU]]) +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\CompilandsTest.cpp' diff --git a/lldb/test/Shell/SymbolFile/PDB/enums-layout.test b/lldb/test/Shell/SymbolFile/PDB/enums-layout.test new file mode 100644 index 00000000000..79efb259663 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/enums-layout.test @@ -0,0 +1,45 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --arch=32 --nodefaultlib --output=%T/SimpleTypesTest.cpp.enums.exe %S/Inputs/SimpleTypesTest.cpp +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CONST %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_EMPTY %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_UCHAR %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_CLASS %s +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.enums.exe | FileCheck --check-prefix=ENUM_STRUCT %s + +; FIXME: PDB does not have information about scoped enumeration (Enum class) so the +; compiler type used is the same as the one for unscoped enumeration. + +ENUM: Type{{.*}} , name = "Enum", size = 4, decl = simpletypestest.cpp:19, compiler_type = {{.*}} enum Enum { +ENUM_NEXT: RED, +ENUM_NEXT: GREEN, +ENUM_NEXT: BLUE +ENUM_NEXT:} + +ENUM_CONST: Type{{.*}} , name = "EnumConst", size = 4, decl = simpletypestest.cpp:22, compiler_type = {{.*}} enum EnumConst { +ENUM_CONST-NEXT: LOW, +ENUM_CONST-NEXT: NORMAL, +ENUM_CONST-NEXT: HIGH +ENUM_CONST-NEXT:} + +ENUM_EMPTY: Type{{.*}} , name = "EnumEmpty", size = 4, decl = simpletypestest.cpp:25, compiler_type = {{.*}} enum EnumEmpty { +ENUM_EMPTY-NEXT:} + +ENUM_UCHAR: Type{{.*}} , name = "EnumUChar", size = 1, decl = simpletypestest.cpp:28, compiler_type = {{.*}} enum EnumUChar { +ENUM_UCHAR-NEXT: ON, +ENUM_UCHAR-NEXT: OFF, +ENUM_UCHAR-NEXT: AUTO +ENUM_UCHAR-NEXT:} + +; Note that `enum EnumClass` is tested instead of `enum class EnumClass` +ENUM_CLASS: Type{{.*}} , name = "EnumClass", size = 4, decl = simpletypestest.cpp:32, compiler_type = {{.*}} enum EnumClass { +ENUM_CLASS-NEXT: YES, +ENUM_CLASS-NEXT: NO, +ENUM_CLASS-NEXT: DEFAULT +ENUM_CLASS-NEXT:} + +ENUM_STRUCT: Type{{.*}} , name = "EnumStruct", size = 4, decl = simpletypestest.cpp:35, compiler_type = {{.*}} enum EnumStruct { +ENUM_STRUCT-NEXT: red, +ENUM_STRUCT-NEXT: blue, +ENUM_STRUCT-NEXT: black +ENUM_STRUCT-NEXT:} diff --git a/lldb/test/Shell/SymbolFile/PDB/expressions.test b/lldb/test/Shell/SymbolFile/PDB/expressions.test new file mode 100644 index 00000000000..49016196117 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/expressions.test @@ -0,0 +1,35 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --nodefaultlib --output=%t.exe %S/Inputs/ExpressionsTest.cpp +RUN: %lldb -b -s %S/Inputs/ExpressionsTest0.script -s %S/Inputs/ExpressionsTest1.script -s %S/Inputs/ExpressionsTest2.script -- %t.exe 2>&1 | FileCheck %s + +// Check the variable value through `print` +CHECK: (lldb) print result +CHECK: (char) $0 = '\x1c' + +// Call the function just like in the code +CHECK: (lldb) print N0::N1::sum(N0::N1::buf1, sizeof(N0::N1::buf1)) +CHECK: (char) $1 = '\x1c' + +// Try the relaxed namespaces search +CHECK: (lldb) print N1::sum(N1::buf1, sizeof(N1::buf1)) +CHECK: (char) $2 = '\x1c' + +// Try the relaxed variables and functions search +CHECK: (lldb) print sum(buf1, sizeof(buf1)) +CHECK: (char) $3 = '\x1c' + +// Make a crash during expression calculation +CHECK: (lldb) print sum(buf1, 1000000000) +CHECK: The process has been returned to the state before expression evaluation. + +// Make one more crash +CHECK: (lldb) print sum(buf0, 1) +CHECK: The process has been returned to the state before expression evaluation. + +// Check if the process state was restored succesfully +CHECK: (lldb) print sum(buf0, result - 28) +CHECK: (char) $4 = '\0' + +// Call the function with arbitrary parameters +CHECK: (lldb) print sum(buf1 + 3, 3) +CHECK: (char) $5 = '\f' diff --git a/lldb/test/Shell/SymbolFile/PDB/func-symbols.test b/lldb/test/Shell/SymbolFile/PDB/func-symbols.test new file mode 100644 index 00000000000..676be1c632b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/func-symbols.test @@ -0,0 +1,46 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib --output=%T/FuncSymbolsTest.exe %S/Inputs/FuncSymbolsTestMain.cpp %S/Inputs/FuncSymbols.cpp +RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-ONE %s +RUN: lldb-test symbols %T/FuncSymbolsTest.exe | FileCheck --check-prefix=CHECK-TWO %s + +; Link multiple objects +; In this test, We don't check demangled name of a mangled function. + +CHECK-ONE: Module [[MD:.*]] +CHECK-ONE-DAG: SymbolFile pdb ([[MD]]) +CHECK-ONE-DAG: [[TY0:.*]]: Type{[[UID0:.*]]} , name = "Func_arg_array", decl = FuncSymbolsTestMain.cpp:3, compiler_type = {{.*}} int (int *) +CHECK-ONE-DAG: [[TY1:.*]]: Type{[[UID1:.*]]} , name = "Func_arg_void", decl = FuncSymbolsTestMain.cpp:4, compiler_type = {{.*}} void (void) +CHECK-ONE-DAG: [[TY2:.*]]: Type{[[UID2:.*]]} , name = "Func_arg_none", decl = FuncSymbolsTestMain.cpp:5, compiler_type = {{.*}} void (void) +CHECK-ONE-DAG: [[TY3:.*]]: Type{[[UID3:.*]]} , name = "Func_varargs", decl = FuncSymbolsTestMain.cpp:6, compiler_type = {{.*}} void (...) +CHECK-ONE-DAG: [[TY4:.*]]: Type{[[UID4:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:28, compiler_type = {{.*}} void (char, int) +CHECK-ONE-DAG: [[TY5:.*]]: Type{[[UID5:.*]]} , name = "main", decl = FuncSymbolsTestMain.cpp:44, compiler_type = {{.*}} int (void) +CHECK-ONE-DAG: [[TY6:.*]]: Type{[[UID6:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:24, compiler_type = {{.*}} void (int, const long, volatile _Bool, ...) +CHECK-ONE-DAG: [[TY7:.*]]: Type{[[UID7:.*]]} , name = "StaticFunction", decl = FuncSymbolsTestMain.cpp:35, compiler_type = {{.*}} long (int) +CHECK-ONE-DAG: [[TY8:.*]]: Type{[[UID8:.*]]} , name = "Func", decl = FuncSymbolsTestMain.cpp:12, compiler_type = {{.*}} int (int, ...) +CHECK-ONE-DAG: [[TY9:.*]]: Type{[[UID9:.*]]} , name = "TemplateFunc<1,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int) +CHECK-ONE-DAG: [[TY10:.*]]: Type{[[UID10:.*]]} , name = "TemplateFunc<1,int,int,int>", decl = FuncSymbolsTestMain.cpp:18, compiler_type = {{.*}} void (int, int, int) +CHECK-ONE-DAG: [[TY11:.*]]: Type{[[UID11:.*]]} , name = "InlinedFunction", decl = FuncSymbolsTestMain.cpp:40, compiler_type = {{.*}} void (long) + +CHECK-ONE: {{.*}}: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbolsTestMain.cpp' +CHECK-ONE-DAG: Function{[[UID0]]}, mangled = ?Func_arg_array@@YAHQAH@Z, demangled = {{.*}}, type = [[TY0]] +CHECK-ONE-DAG: Function{[[UID1]]}, mangled = ?Func_arg_void@@YAXXZ, demangled = {{.*}}, type = [[TY1]] +CHECK-ONE-DAG: Function{[[UID2]]}, mangled = ?Func_arg_none@@YAXXZ, demangled = {{.*}}, type = [[TY2]] +CHECK-ONE-DAG: Function{[[UID3]]}, mangled = ?Func_varargs@@YAXZZ, demangled = {{.*}}, type = [[TY3]] +CHECK-ONE-DAG: Function{[[UID4]]}, mangled = ?Func@NS@@YAXDH@Z, demangled = {{.*}}, type = [[TY4]] +CHECK-ONE-DAG: Function{[[UID5]]}, mangled = _main, demangled = {{.*}}, type = [[TY5]] +CHECK-ONE-DAG: Function{[[UID6]]}, demangled = {{.*}}`anonymous namespace'::Func{{.*}}, type = [[TY6]] +CHECK-ONE-DAG: Function{[[UID7]]}, demangled = {{.*}}StaticFunction{{.*}}, type = [[TY7]] +CHECK-ONE-DAG: Function{[[UID8]]}, mangled = ?Func@A@MemberTest@@QAAHHZZ, demangled = {{.*}}, type = [[TY8]] +CHECK-ONE-DAG: Function{[[UID9]]}, mangled = ??$TemplateFunc@$00H@@YAXH@Z, demangled = {{.*}}, type = [[TY9]] +CHECK-ONE-DAG: Function{[[UID10]]}, mangled = ??$TemplateFunc@$00HHH@@YAXHHH@Z, demangled = {{.*}}, type = [[TY10]] +CHECK-ONE-DAG: Function{[[UID11]]}, mangled = ?InlinedFunction@@YAXJ@Z, demangled = {{.*}}, type = [[TY11]] + +; We expect new types observed in another compile unit +CHECK-TWO-DAG: [[TY30:.*]]: Type{[[UID30:.*]]} , name = "FunctionCall", decl = FuncSymbols.cpp:13, compiler_type = {{.*}} void (void) +CHECK-TWO-DAG: [[TY31:.*]]: Type{[[UID31:.*]]} , name = "StaticFunction", decl = FuncSymbols.cpp:4, compiler_type = {{.*}} long (int) +CHECK-TWO-DAG: [[TY32:.*]]: Type{[[UID32:.*]]} , name = "InlinedFunction", decl = FuncSymbols.cpp:10, compiler_type = {{.*}} int (long) + +CHECK-TWO: {{.*}}: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\FuncSymbols.cpp' +CHECK-TWO-DAG: Function{[[UID30]]}, mangled = ?FunctionCall@@YAXXZ, demangled = {{.*}}, type = [[TY30]] +CHECK-TWO-DAG: Function{[[UID31]]}, demangled = {{.*}}`anonymous namespace'::StaticFunction{{.*}}, type = [[TY31]] +CHECK-TWO-DAG: Function{[[UID32]]}, demangled = {{.*}}InlinedFunction{{.*}}, type = [[TY32]] diff --git a/lldb/test/Shell/SymbolFile/PDB/function-level-linking.test b/lldb/test/Shell/SymbolFile/PDB/function-level-linking.test new file mode 100644 index 00000000000..37b2cbc761b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/function-level-linking.test @@ -0,0 +1,5 @@ +REQUIRES: system-windows, lld +RUN: %clang_cl /c /Zi /Gy %S/Inputs/FunctionLevelLinkingTest.cpp /o %t.obj +RUN: lld-link /debug:full /nodefaultlib /entry:main /order:@%S/Inputs/FunctionLevelLinkingTest.ord %t.obj /out:%t.exe +RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -verify %t.exe +RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -verify %t.exe diff --git a/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test b/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test new file mode 100644 index 00000000000..9057d01c258 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test @@ -0,0 +1,11 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --nodefaultlib --output=%t.exe %S/Inputs/FunctionNestedBlockTest.cpp +RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s +RUN: lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s + +CHECK-FUNCTION: Found 1 functions: +CHECK-FUNCTION: name = "{{.*}}", mangled = "{{_?}}main" + +CHECK-BLOCK: Found 1 blocks: +CHECK-BLOCK: Blocks: id = {{.*}}, range = {{.*}} +CHECK-BLOCK: id = {{.*}}, range = {{.*}} diff --git a/lldb/test/Shell/SymbolFile/PDB/pointers.test b/lldb/test/Shell/SymbolFile/PDB/pointers.test new file mode 100644 index 00000000000..a8f84f14783 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/pointers.test @@ -0,0 +1,38 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/PointerTypeTest.cpp.obj %S/Inputs/PointerTypeTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/PointerTypeTest.cpp.exe %T/PointerTypeTest.cpp.obj +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST-F %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN-ST %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=MAIN %s +RUN: lldb-test symbols %T/PointerTypeTest.cpp.exe | FileCheck --check-prefix=F %s + +CHECK: Module [[MOD:.*]] +CHECK: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\PointerTypeTest.cpp' + +MAIN-ST-F: name = "f" +MAIN-ST-F-SAME: decl = PointerTypeTest.cpp:8 +MAIN-ST-F-SAME: compiler_type = {{.*}} int (int) + +MAIN-ST: name = "ST", size = 4, decl = PointerTypeTest.cpp:6, compiler_type = {{.*}} struct ST { +MAIN-ST-NEXT: int a; +MAIN-ST-NEXT: int {{.*}}f(int); +MAIN-ST-NEXT:} + +MAIN: Function{[[FID1:.*]]}, mangled = _main +MAIN-NEXT: Block{[[FID1]]} +MAIN: Variable{{.*}}, name = "array_pointer" +MAIN-SAME: (int (*)[2][4]), scope = local +MAIN: Variable{{.*}}, name = "p_int" +MAIN-SAME: (int *), scope = local +MAIN: Variable{{.*}}, name = "p_member_field" +MAIN-SAME: (int ST::*), scope = local +MAIN: Variable{{.*}}, name = "p_member_method" +MAIN-SAME: (int (ST::*)(int) __attribute__((thiscall))), scope = local + +F: Function{[[FID2:.*]]}, demangled = {{.*}}f(int) +F-NEXT: Block{[[FID2]]} +F: Variable{{.*}}, name = "this" +F-SAME: (ST *), scope = parameter, location = {{.*}}, artificial +F: Variable{{.*}}, name = "x" +F-SAME: (int), scope = parameter, decl = PointerTypeTest.cpp:8 diff --git a/lldb/test/Shell/SymbolFile/PDB/type-quals.test b/lldb/test/Shell/SymbolFile/PDB/type-quals.test new file mode 100644 index 00000000000..cf65c79223b --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/type-quals.test @@ -0,0 +1,39 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=32 --nodefaultlib --output=%T/TypeQualsTest.cpp.obj %S/Inputs/TypeQualsTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=32 --nodefaultlib --output=%T/TypeQualsTest.cpp.exe %T/TypeQualsTest.cpp.obj +RUN: lldb-test symbols %T/TypeQualsTest.cpp.exe | FileCheck %s + +CHECK: Module [[MOD:.*]] +CHECK-DAG: SymbolFile pdb ([[MOD]]) +CHECK-DAG: Type{{.*}} , name = "const int", size = 4, compiler_type = {{.*}} const int +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int **const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int *const * +CHECK-DAG: Type{{.*}} , name = "Func1", {{.*}}, compiler_type = {{.*}} void (const int *, const int *, const int **const, const int *const *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} volatile int * +CHECK-DAG: Type{{.*}} , name = "Func2", {{.*}}, compiler_type = {{.*}} void (volatile int *, volatile int *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *& +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int && +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} const int & +CHECK-DAG: Type{{.*}} , name = "Func3", {{.*}}, compiler_type = {{.*}} void (int *&, int &, const int &, int &&) + +// FIXME: __unaligned is not supported. +CHECK-DAG: Type{{.*}} , name = "Func4", {{.*}}, compiler_type = {{.*}} void (int *, int *) + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int *__restrict +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int &__restrict +CHECK-DAG: Type{{.*}} , name = "Func5", {{.*}}, compiler_type = {{.*}} void (int, int *__restrict, int &__restrict) + +CHECK-DAG: Type{{.*}} , name = "Func6", {{.*}}, compiler_type = {{.*}} void (const volatile int *__restrict) + +CHECK-DAG: Type{{.*}} , size = 400, compiler_type = {{.*}} volatile int *[100] +CHECK-DAG: Type{{.*}} , size = 4000, compiler_type = {{.*}} volatile int *[10][100] + +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} long *__restrict + +CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\TypeQualsTest.cpp' diff --git a/lldb/test/Shell/SymbolFile/PDB/typedefs.test b/lldb/test/Shell/SymbolFile/PDB/typedefs.test new file mode 100644 index 00000000000..5f70d878230 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/typedefs.test @@ -0,0 +1,59 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=msvc --arch=32 --nodefaultlib --output=%T/SimpleTypesTest.cpp.typedefs.exe %S/Inputs/SimpleTypesTest.cpp +RUN: lldb-test symbols %T/SimpleTypesTest.cpp.typedefs.exe | FileCheck %s + +; Generate 32-bit target + +; FIXME: PDB does not have line information for typedef statements so source +; and line information for them is not tested. + +; Note, types `long double` and `double` have same bit size in MSVC and there +; is no information in the PDB to distinguish them. So the compiler type for +; both of them is the same. + +CHECK: Module [[MOD:.*]] +CHECK: SymbolFile pdb ([[MOD]]) +CHECK-DAG: name = "char32_t", size = 4, compiler_type = {{.*}} char32_t +CHECK-DAG: name = "char16_t", size = 2, compiler_type = {{.*}} char16_t +CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = {{.*}} unsigned long +CHECK-DAG: Type{{.*}} , size = 40, compiler_type = {{.*}} unsigned long [10] +CHECK-DAG: Type{{.*}} , name = "ULongArrayTypedef", compiler_type = {{.*}} typedef ULongArrayTypedef + +; Note: compiler_type of `long double` is represented by the one for `double` +CHECK-DAG: Type{{.*}} , name = "double", size = 8, compiler_type = {{.*}} double +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} double *& +CHECK-DAG: Type{{.*}} , name = "RefTypedef", compiler_type = {{.*}} typedef RefTypedef + +CHECK-DAG: Type{{.*}} , name = "wchar_t", size = 2, compiler_type = {{.*}} wchar_t + +CHECK-DAG: Type{{.*}} , name = "int", size = 4, compiler_type = {{.*}} int +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} int & +CHECK-DAG: Type{{.*}} , name = "unsigned char", size = 1, compiler_type = {{.*}} unsigned char +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char * +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} unsigned char ** +CHECK-DAG: Type{{.*}} , name = "short", size = 2, compiler_type = {{.*}} short +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} short * +CHECK-DAG: Type{{.*}} , name = "const double", size = 8, compiler_type = {{.*}} const double +CHECK-DAG: Type{{.*}} , name = "volatile bool", size = 1, compiler_type = {{.*}} volatile _Bool +CHECK-DAG: Type{{.*}} , name = "long long", size = 8, compiler_type = {{.*}} long long +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} long long (int &, unsigned char **, short *, const double, volatile _Bool) +CHECK-DAG: Type{{.*}} , name = "FuncPtrTypedef", compiler_type = {{.*}} typedef FuncPtrTypedef + +CHECK-DAG: Type{{.*}} , name = "void", compiler_type = {{.*}} void +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} void * +CHECK-DAG: Type{{.*}} , name = "long", size = 4, compiler_type = {{.*}} long +CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = {{.*}} unsigned short +CHECK-DAG: Type{{.*}} , name = "unsigned int", size = 4, compiler_type = {{.*}} unsigned int +CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = {{.*}} char +CHECK-DAG: Type{{.*}} , name = "signed char", size = 1, compiler_type = {{.*}} signed char +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} char (void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} char (*)(void *, long, unsigned short, unsigned int, ...) +CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedef", compiler_type = {{.*}} typedef VarArgsFuncTypedef + +CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = {{.*}} float +CHECK-DAG: Type{{.*}} , compiler_type = {{.*}} float (...) +CHECK-DAG: Type{{.*}} , size = 4, compiler_type = {{.*}} float (*)(...) +CHECK-DAG: Type{{.*}} , name = "VarArgsFuncTypedefA", compiler_type = {{.*}} typedef VarArgsFuncTypedefA + +CHECK-DAG: {{^[0-9A-F]+}}: CompileUnit{{[{]0x[0-9a-f]+[}]}}, language = "c++", file = '{{.*}}\SimpleTypesTest.cpp' diff --git a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test new file mode 100644 index 00000000000..726f633efe5 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test @@ -0,0 +1,51 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp +RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s + +CHECK:(int) int C::abc = 123 +CHECK:(List [16]) ls = { +CHECK: [15] = { +CHECK: Prev = 0x00000000 +CHECK: Next = 0x00000000 +CHECK: Value = { +CHECK: B<0> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x01' +CHECK: _b = 2 +CHECK: _c = 3 +CHECK: } +CHECK: B<1> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x02' +CHECK: _b = 4 +CHECK: _c = 6 +CHECK: } +CHECK: B<2> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x03' +CHECK: _b = 6 +CHECK: _c = 9 +CHECK: } +CHECK: B<3> = { +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _a = '\x04' +CHECK: _b = 8 +CHECK: _c = 12 +CHECK: } +CHECK: A = { +CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2) +CHECK: } +CHECK: _x = 5 +CHECK: _y = 10 +CHECK: _z = '\x0f' +CHECK: } +CHECK: } +CHECK:} diff --git a/lldb/test/Shell/SymbolFile/PDB/variables-locations.test b/lldb/test/Shell/SymbolFile/PDB/variables-locations.test new file mode 100644 index 00000000000..b5bfc6fe81a --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/variables-locations.test @@ -0,0 +1,20 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/VariablesLocationsTest.cpp +RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s +RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -b -s %S/Inputs/VariablesLocationsTest.script -- %t.exe | FileCheck %s + +CHECK: g_var = 2222 + +CHECK: arg_0 = 1111 +CHECK: arg_1 = 0.123 + +CHECK: loc_0 = 'x' +CHECK: loc_1 = 0.567 + +CHECK: loc_0 = true +CHECK: loc_1 = 3333 + +CHECK: arg_0 = 22 + +CHECK: loc_0 = (a = 1234) +CHECK: loc_1 = 5678 diff --git a/lldb/test/Shell/SymbolFile/PDB/variables.test b/lldb/test/Shell/SymbolFile/PDB/variables.test new file mode 100644 index 00000000000..ae14f02754c --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/variables.test @@ -0,0 +1,66 @@ +REQUIRES: system-windows, msvc +RUN: %build --compiler=clang-cl --mode=compile --arch=64 --nodefaultlib --output=%T/VariablesTest.cpp.obj %S/Inputs/VariablesTest.cpp +RUN: %build --compiler=msvc --mode=link --arch=64 --nodefaultlib --output=%T/VariablesTest.cpp.exe %T/VariablesTest.cpp.obj +RUN: lldb-test symbols %T/VariablesTest.cpp.exe > %T/VariablesTest.out +RUN: FileCheck --check-prefix=GLOBALS --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-F --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-MAIN --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-CONSTRUCTOR --input-file=%T/VariablesTest.out %s +RUN: FileCheck --check-prefix=FUNC-MEMBER --input-file=%T/VariablesTest.out %s + +GLOBALS: Module [[MOD:.*]] +GLOBALS: SymbolFile pdb ([[MOD]]) +GLOBALS: CompileUnit{{.*}}, language = "c++", file = '{{.*}}\VariablesTest.cpp' +GLOBALS-DAG: Variable{{.*}}, name = "g_IntVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "m_StaticClassMember" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_pConst" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "same_name_var" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_EnumVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_tls" +GLOBALS-SAME: scope = thread local, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "ClassVar" +GLOBALS-SAME: scope = global, location = {{.*}}, external +GLOBALS-DAG: Variable{{.*}}, name = "g_Const" +GLOBALS-SAME: scope = ??? (2) +GLOBALS: Function + +FUNC-F: Function{{.*}}, mangled = ?f@@YAHHH@Z +FUNC-F-NEXT: Block +FUNC-F-NEXT: Variable{{.*}}, name = "var_arg1" +FUNC-F-SAME: scope = parameter +FUNC-F-NEXT: Variable{{.*}}, name = "var_arg2" +FUNC-F-SAME: scope = parameter +FUNC-F-NEXT: Variable{{.*}}, name = "same_name_var" +FUNC-F-SAME: scope = local + +FUNC-MAIN: Function{{.*}}, mangled = main +FUNC-MAIN-NEXT: Block +FUNC-MAIN-NEXT: Variable{{.*}}, name = "same_name_var" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_const" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_CString" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "local_pCString" +FUNC-MAIN-SAME: scope = local +FUNC-MAIN-NEXT: Variable{{.*}}, name = "a" +FUNC-MAIN-SAME: scope = local + +FUNC-CONSTRUCTOR: Function{{.*}}, mangled = ??0Class@@QEAA@H@Z +FUNC-CONSTRUCTOR-NEXT: Block +FUNC-CONSTRUCTOR-NEXT: Variable{{.*}}, name = "this" +FUNC-CONSTRUCTOR-SAME: scope = parameter +FUNC-CONSTRUCTOR-SAME: artificial +FUNC-CONSTRUCTOR-NEXT: Variable{{.*}}, name = "a" +FUNC-CONSTRUCTOR-SAME: scope = parameter + +FUNC-MEMBER: Function{{.*}}, mangled = ?Func@Class@@QEAAXXZ +FUNC-MEMBER-NEXT: Block +FUNC-MEMBER-NEXT: Variable{{.*}}, name = "this" +FUNC-MEMBER-SAME: scope = parameter +FUNC-MEMBER-SAME: artificial diff --git a/lldb/test/Shell/SymbolFile/PDB/vbases.test b/lldb/test/Shell/SymbolFile/PDB/vbases.test new file mode 100644 index 00000000000..57239e07c87 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/PDB/vbases.test @@ -0,0 +1,15 @@ +REQUIRES: system-windows, lld +RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/VBases.cpp +RUN: %lldb -b -s %S/Inputs/VBases.script -- %t.exe | FileCheck %s + +CHECK: { +CHECK: A = (a = '\x01') +CHECK: B = (b = 2) +CHECK: c = 3 +CHECK: } + +CHECK: { +CHECK: A = (a = '\x01') +CHECK: B = (b = 2) +CHECK: c = 3 +CHECK: } |

