[Lldb-commits] [lldb] r345373 - [NativePDB] Add the ability to dump dump global variables.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 26 02:06:38 PDT 2018


Author: zturner
Date: Fri Oct 26 02:06:38 2018
New Revision: 345373

URL: http://llvm.org/viewvc/llvm-project?rev=345373&view=rev
Log:
[NativePDB] Add the ability to dump dump global variables.

LLDB has the ability to display global variables, even without a running
process, via the target variable command. This is because global
variables are linker initialized, so their values are embedded directly
into the executables. This gives us great power for testing native PDB
functionality in a cross-platform manner, because we don't actually need
a running process. We can just create a target using an EXE file, and
display global variables. And global variables can have arbitrarily
complex types, so in theory we can fully exercise the type system,
record layout, and data formatters for native PDB files and PE/COFF
executables on any host platform, as long as our type does not require a
dynamic initializer.

This patch adds basic support for finding variables by name, and adds an
exhaustive test for fundamental data types and pointers / references to
fundamental data types.

Subsequent patches will extend this to typedefs, classes, pointers to
functions, and other cases.

Differential Revision: https://reviews.llvm.org/D53731

Added:
    lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit
    lldb/trunk/lit/SymbolFile/NativePDB/globals-fundamental.cpp
Modified:
    lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
    lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
    lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Added: lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit?rev=345373&view=auto
==============================================================================
--- lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit Fri Oct 26 02:06:38 2018
@@ -0,0 +1,220 @@
+target variable BFalse
+target variable BTrue
+target variable CA
+target variable CZ
+target variable SCa
+target variable SCz
+target variable UC24
+target variable UC42
+target variable C16_24
+target variable C32_42
+target variable WC1
+target variable WCP
+target variable SMax
+target variable SMin
+target variable USMax
+target variable USMin
+target variable IMax
+target variable IMin
+target variable UIMax
+target variable UIMin
+target variable LMax
+target variable LMin
+target variable ULMax
+target variable ULMin
+target variable LLMax
+target variable LLMin
+target variable ULLMax
+target variable ULLMin
+target variable F
+target variable D
+
+target variable CBFalse
+target variable CBTrue
+target variable CCA
+target variable CCZ
+target variable CSCa
+target variable CSCz
+target variable CUC24
+target variable CUC42
+target variable CC16_24
+target variable CC32_42
+target variable CWC1
+target variable CWCP
+target variable CSMax
+target variable CSMin
+target variable CUSMax
+target variable CUSMin
+target variable CIMax
+target variable CIMin
+target variable CUIMax
+target variable CUIMin
+target variable CLMax
+target variable CLMin
+target variable CULMax
+target variable CULMin
+target variable CLLMax
+target variable CLLMin
+target variable CULLMax
+target variable CULLMin
+target variable CF
+target variable CD
+
+target variable ConstexprBFalse
+target variable ConstexprBTrue
+target variable ConstexprCA
+target variable ConstexprCZ
+target variable ConstexprSCa
+target variable ConstexprSCz
+target variable ConstexprUC24
+target variable ConstexprUC42
+target variable ConstexprC16_24
+target variable ConstexprC32_42
+target variable ConstexprWC1
+target variable ConstexprWCP
+target variable ConstexprSMax
+target variable ConstexprSMin
+target variable ConstexprUSMax
+target variable ConstexprUSMin
+target variable ConstexprIMax
+target variable ConstexprIMin
+target variable ConstexprUIMax
+target variable ConstexprUIMin
+target variable ConstexprLMax
+target variable ConstexprLMin
+target variable ConstexprULMax
+target variable ConstexprULMin
+target variable ConstexprLLMax
+target variable ConstexprLLMin
+target variable ConstexprULLMax
+target variable ConstexprULLMin
+target variable ConstexprF
+target variable ConstexprD
+
+target variable PBFalse
+target variable PBTrue
+target variable PCA
+target variable PCZ
+target variable PSCa
+target variable PSCz
+target variable PUC24
+target variable PUC42
+target variable PC16_24
+target variable PC32_42
+target variable PWC1
+target variable PWCP
+target variable PSMax
+target variable PSMin
+target variable PUSMax
+target variable PUSMin
+target variable PIMax
+target variable PIMin
+target variable PUIMax
+target variable PUIMin
+target variable PLMax
+target variable PLMin
+target variable PULMax
+target variable PULMin
+target variable PLLMax
+target variable PLLMin
+target variable PULLMax
+target variable PULLMin
+target variable PF
+target variable PD
+
+target variable CPBFalse
+target variable CPBTrue
+target variable CPCA
+target variable CPCZ
+target variable CPSCa
+target variable CPSCz
+target variable CPUC24
+target variable CPUC42
+target variable CPC16_24
+target variable CPC32_42
+target variable CPWC1
+target variable CPWCP
+target variable CPSMax
+target variable CPSMin
+target variable CPUSMax
+target variable CPUSMin
+target variable CPIMax
+target variable CPIMin
+target variable CPUIMax
+target variable CPUIMin
+target variable CPLMax
+target variable CPLMin
+target variable CPULMax
+target variable CPULMin
+target variable CPLLMax
+target variable CPLLMin
+target variable CPULLMax
+target variable CPULLMin
+target variable CPF
+target variable CPD
+
+target variable RBFalse
+target variable RBTrue
+target variable RCA
+target variable RCZ
+target variable RSCa
+target variable RSCz
+target variable RUC24
+target variable RUC42
+target variable RSMax
+target variable RSMin
+target variable RUSMax
+target variable RUSMin
+target variable RIMax
+target variable RIMin
+target variable RUIMax
+target variable RUIMin
+target variable RLMax
+target variable RLMin
+target variable RULMax
+target variable RULMin
+target variable RLLMax
+target variable RLLMin
+target variable RULLMax
+target variable RULLMin
+target variable RF
+target variable RD
+
+target variable CRBFalse
+target variable CRBTrue
+target variable CRCA
+target variable CRCZ
+target variable CRSCa
+target variable CRSCz
+target variable CRUC24
+target variable CRUC42
+target variable CRSMax
+target variable CRSMin
+target variable CRUSMax
+target variable CRUSMin
+target variable CRIMax
+target variable CRIMin
+target variable CRUIMax
+target variable CRUIMin
+target variable CRLMax
+target variable CRLMin
+target variable CRULMax
+target variable CRULMin
+target variable CRLLMax
+target variable CRLLMin
+target variable CRULLMax
+target variable CRULLMin
+target variable CRF
+target variable CRD
+
+target variable RC16_24
+target variable RC32_42
+target variable RWC1
+target variable RWCP
+target variable CRC16_24
+target variable CRC32_42
+target variable CRWC1
+target variable CRWCP
+
+
+quit
\ No newline at end of file

Added: lldb/trunk/lit/SymbolFile/NativePDB/globals-fundamental.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/globals-fundamental.cpp?rev=345373&view=auto
==============================================================================
--- lldb/trunk/lit/SymbolFile/NativePDB/globals-fundamental.cpp (added)
+++ lldb/trunk/lit/SymbolFile/NativePDB/globals-fundamental.cpp Fri Oct 26 02:06:38 2018
@@ -0,0 +1,668 @@
+// clang-format off
+// REQUIRES: lld
+
+// Test that we can display tag types.
+// RUN: clang-cl /Z7 /GS- /GR- /c -Xclang -fkeep-static-consts /Fo%t.obj -- %s
+// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
+// RUN:     %p/Inputs/globals-fundamental.lldbinit | FileCheck %s
+
+
+// Fundamental data types
+bool BFalse = false;
+// CHECK: (lldb) target variable BFalse
+// CHECK-NEXT: (bool) BFalse = false
+bool BTrue = true;
+// CHECK-NEXT: (lldb) target variable BTrue
+// CHECK-NEXT: (bool) BTrue = true
+char CA = 'A';
+// CHECK-NEXT: (lldb) target variable CA
+// CHECK-NEXT: (char) CA = 'A'
+char CZ = 'Z';
+// CHECK-NEXT: (lldb) target variable CZ
+// CHECK-NEXT: (char) CZ = 'Z'
+signed char SCa = 'a';
+// CHECK-NEXT: (lldb) target variable SCa
+// CHECK-NEXT: (signed char) SCa = 'a'
+signed char SCz = 'z';
+// CHECK-NEXT: (lldb) target variable SCz
+// CHECK-NEXT: (signed char) SCz = 'z'
+unsigned char UC24 = 24;
+// CHECK-NEXT: (lldb) target variable UC24
+// CHECK-NEXT: (unsigned char) UC24 = '\x18'
+unsigned char UC42 = 42;
+// CHECK-NEXT: (lldb) target variable UC42
+// CHECK-NEXT: (unsigned char) UC42 = '*'
+char16_t C16_24 = u'\24';
+// CHECK-NEXT: (lldb) target variable C16_24
+// CHECK-NEXT: (char16_t) C16_24 = U+0014
+char32_t C32_42 = U'\42';
+// CHECK-NEXT: (lldb) target variable C32_42
+// CHECK-NEXT: (char32_t) C32_42 = U+0x00000022
+wchar_t WC1 = L'1';
+// CHECK-NEXT: (lldb) target variable WC1
+// CHECK-NEXT: (wchar_t) WC1 = L'1'
+wchar_t WCP = L'P';
+// CHECK-NEXT: (lldb) target variable WCP
+// CHECK-NEXT: (wchar_t) WCP = L'P'
+short SMax = 32767;
+// CHECK-NEXT: (lldb) target variable SMax
+// CHECK-NEXT: (short) SMax = 32767
+short SMin = -32768;
+// CHECK-NEXT: (lldb) target variable SMin
+// CHECK-NEXT: (short) SMin = -32768
+unsigned short USMax = 65535;
+// CHECK-NEXT: (lldb) target variable USMax
+// CHECK-NEXT: (unsigned short) USMax = 65535
+unsigned short USMin = 0;
+// CHECK-NEXT: (lldb) target variable USMin
+// CHECK-NEXT: (unsigned short) USMin = 0
+int IMax = 2147483647;
+// CHECK-NEXT: (lldb) target variable IMax
+// CHECK-NEXT: (int) IMax = 2147483647
+int IMin = -2147483648;
+// CHECK-NEXT: (lldb) target variable IMin
+// CHECK-NEXT: (int) IMin = -2147483648
+unsigned int UIMax = 4294967295;
+// CHECK-NEXT: (lldb) target variable UIMax
+// CHECK-NEXT: (unsigned int) UIMax = 4294967295
+unsigned int UIMin = 0;
+// CHECK-NEXT: (lldb) target variable UIMin
+// CHECK-NEXT: (unsigned int) UIMin = 0
+long LMax = 2147483647;
+// CHECK-NEXT: (lldb) target variable LMax
+// CHECK-NEXT: (long) LMax = 2147483647
+long LMin = -2147483648;
+// CHECK-NEXT: (lldb) target variable LMin
+// CHECK-NEXT: (long) LMin = -2147483648
+unsigned long ULMax = 4294967295;
+// CHECK-NEXT: (lldb) target variable ULMax
+// CHECK-NEXT: (unsigned long) ULMax = 4294967295
+unsigned long ULMin = 0;
+// CHECK-NEXT: (lldb) target variable ULMin
+// CHECK-NEXT: (unsigned long) ULMin = 0
+long long LLMax = 9223372036854775807LL;
+// CHECK-NEXT: (lldb) target variable LLMax
+// CHECK-NEXT: (long long) LLMax = 9223372036854775807
+long long LLMin = -9223372036854775807i64 - 1;
+// CHECK-NEXT: (lldb) target variable LLMin
+// CHECK-NEXT: (long long) LLMin = -9223372036854775808
+unsigned long long ULLMax = 18446744073709551615ULL;
+// CHECK-NEXT: (lldb) target variable ULLMax
+// CHECK-NEXT: (unsigned long long) ULLMax = 18446744073709551615
+unsigned long long ULLMin = 0;
+// CHECK-NEXT: (lldb) target variable ULLMin
+// CHECK-NEXT: (unsigned long long) ULLMin = 0
+float F = 3.1415f;
+// CHECK-NEXT: (lldb) target variable F
+// CHECK-NEXT: (float) F = 3.1415
+double D = 3.1415;
+// CHECK-NEXT: (lldb) target variable D
+// CHECK-NEXT: (double) D = 3.1415
+
+const bool CBFalse = false;
+// CHECK-NEXT: (lldb) target variable CBFalse
+// CHECK-NEXT: (const bool) CBFalse = false
+const bool CBTrue = true;
+// CHECK-NEXT: (lldb) target variable CBTrue
+// CHECK-NEXT: (const bool) CBTrue = true
+const char CCA = 'A';
+// CHECK-NEXT: (lldb) target variable CCA
+// CHECK-NEXT: (const char) CCA = 'A'
+const char CCZ = 'Z';
+// CHECK-NEXT: (lldb) target variable CCZ
+// CHECK-NEXT: (const char) CCZ = 'Z'
+const signed char CSCa = 'a';
+// CHECK-NEXT: (lldb) target variable CSCa
+// CHECK-NEXT: (const signed char) CSCa = 'a'
+const signed char CSCz = 'z';
+// CHECK-NEXT: (lldb) target variable CSCz
+// CHECK-NEXT: (const signed char) CSCz = 'z'
+const unsigned char CUC24 = 24;
+// CHECK-NEXT: (lldb) target variable CUC24
+// CHECK-NEXT: (const unsigned char) CUC24 = '\x18'
+const unsigned char CUC42 = 42;
+// CHECK-NEXT: (lldb) target variable CUC42
+// CHECK-NEXT: (const unsigned char) CUC42 = '*'
+const char16_t CC16_24 = u'\24';
+// CHECK-NEXT: (lldb) target variable CC16_24
+// CHECK-NEXT: (const char16_t) CC16_24 = U+0014
+const char32_t CC32_42 = U'\42';
+// CHECK-NEXT: (lldb) target variable CC32_42
+// CHECK-NEXT: (const char32_t) CC32_42 = U+0x00000022
+const wchar_t CWC1 = L'1';
+// CHECK-NEXT: (lldb) target variable CWC1
+// CHECK-NEXT: (const wchar_t) CWC1 = L'1'
+const wchar_t CWCP = L'P';
+// CHECK-NEXT: (lldb) target variable CWCP
+// CHECK-NEXT: (const wchar_t) CWCP = L'P'
+const short CSMax = 32767;
+// CHECK-NEXT: (lldb) target variable CSMax
+// CHECK-NEXT: (const short) CSMax = 32767
+const short CSMin = -32768;
+// CHECK-NEXT: (lldb) target variable CSMin
+// CHECK-NEXT: (const short) CSMin = -32768
+const unsigned short CUSMax = 65535;
+// CHECK-NEXT: (lldb) target variable CUSMax
+// CHECK-NEXT: (const unsigned short) CUSMax = 65535
+const unsigned short CUSMin = 0;
+// CHECK-NEXT: (lldb) target variable CUSMin
+// CHECK-NEXT: (const unsigned short) CUSMin = 0
+const int CIMax = 2147483647;
+// CHECK-NEXT: (lldb) target variable CIMax
+// CHECK-NEXT: (const int) CIMax = 2147483647
+const int CIMin = -2147483648;
+// CHECK-NEXT: (lldb) target variable CIMin
+// CHECK-NEXT: (const int) CIMin = -2147483648
+const unsigned int CUIMax = 4294967295;
+// CHECK-NEXT: (lldb) target variable CUIMax
+// CHECK-NEXT: (const unsigned int) CUIMax = 4294967295
+const unsigned int CUIMin = 0;
+// CHECK-NEXT: (lldb) target variable CUIMin
+// CHECK-NEXT: (const unsigned int) CUIMin = 0
+const long CLMax = 2147483647;
+// CHECK-NEXT: (lldb) target variable CLMax
+// CHECK-NEXT: (const long) CLMax = 2147483647
+const long CLMin = -2147483648;
+// CHECK-NEXT: (lldb) target variable CLMin
+// CHECK-NEXT: (const long) CLMin = -2147483648
+const unsigned long CULMax = 4294967295;
+// CHECK-NEXT: (lldb) target variable CULMax
+// CHECK-NEXT: (const unsigned long) CULMax = 4294967295
+const unsigned long CULMin = 0;
+// CHECK-NEXT: (lldb) target variable CULMin
+// CHECK-NEXT: (const unsigned long) CULMin = 0
+const long long CLLMax = 9223372036854775807i64;
+// CHECK-NEXT: (lldb) target variable CLLMax
+// CHECK-NEXT: (const long long) CLLMax = 9223372036854775807
+const long long CLLMin = -9223372036854775807i64 - 1;
+// CHECK-NEXT: (lldb) target variable CLLMin
+// CHECK-NEXT: (const long long) CLLMin = -9223372036854775808
+const unsigned long long CULLMax = 18446744073709551615ULL;
+// CHECK-NEXT: (lldb) target variable CULLMax
+// CHECK-NEXT: (const unsigned long long) CULLMax = 18446744073709551615
+const unsigned long long CULLMin = 0;
+// CHECK-NEXT: (lldb) target variable CULLMin
+// CHECK-NEXT: (const unsigned long long) CULLMin = 0
+const float CF = 3.1415f;
+// CHECK-NEXT: (lldb) target variable CF
+// CHECK-NEXT: (const float) CF = 3.1415
+const double CD = 3.1415;
+// CHECK-NEXT: (lldb) target variable CD
+// CHECK-NEXT: (const double) CD = 3.1415
+
+// constexpr fundamental data types.
+constexpr bool ConstexprBFalse = false;
+// CHECK-NEXT: (lldb) target variable ConstexprBFalse
+// CHECK-NEXT: (const bool) ConstexprBFalse = false
+constexpr bool ConstexprBTrue = true;
+// CHECK-NEXT: (lldb) target variable ConstexprBTrue
+// CHECK-NEXT: (const bool) ConstexprBTrue = true
+constexpr char ConstexprCA = 'A';
+// CHECK-NEXT: (lldb) target variable ConstexprCA
+// CHECK-NEXT: (const char) ConstexprCA = 'A'
+constexpr char ConstexprCZ = 'Z';
+// CHECK-NEXT: (lldb) target variable ConstexprCZ
+// CHECK-NEXT: (const char) ConstexprCZ = 'Z'
+constexpr signed char ConstexprSCa = 'a';
+// CHECK-NEXT: (lldb) target variable ConstexprSCa
+// CHECK-NEXT: (const signed char) ConstexprSCa = 'a'
+constexpr signed char ConstexprSCz = 'z';
+// CHECK-NEXT: (lldb) target variable ConstexprSCz
+// CHECK-NEXT: (const signed char) ConstexprSCz = 'z'
+constexpr unsigned char ConstexprUC24 = 24;
+// CHECK-NEXT: (lldb) target variable ConstexprUC24
+// CHECK-NEXT: (const unsigned char) ConstexprUC24 = '\x18'
+constexpr unsigned char ConstexprUC42 = 42;
+// CHECK-NEXT: (lldb) target variable ConstexprUC42
+// CHECK-NEXT: (const unsigned char) ConstexprUC42 = '*'
+constexpr char16_t ConstexprC16_24 = u'\24';
+// CHECK-NEXT: (lldb) target variable ConstexprC16_24
+// CHECK-NEXT: (const char16_t) ConstexprC16_24 = U+0014
+constexpr char32_t ConstexprC32_42 = U'\42';
+// CHECK-NEXT: (lldb) target variable ConstexprC32_42
+// CHECK-NEXT: (const char32_t) ConstexprC32_42 = U+0x00000022
+constexpr wchar_t ConstexprWC1 = L'1';
+// CHECK-NEXT: (lldb) target variable ConstexprWC1
+// CHECK-NEXT: (const wchar_t) ConstexprWC1 = L'1'
+constexpr wchar_t ConstexprWCP = L'P';
+// CHECK-NEXT: (lldb) target variable ConstexprWCP
+// CHECK-NEXT: (const wchar_t) ConstexprWCP = L'P'
+constexpr short ConstexprSMax = 32767;
+// CHECK-NEXT: (lldb) target variable ConstexprSMax
+// CHECK-NEXT: (const short) ConstexprSMax = 32767
+constexpr short ConstexprSMin = -32768;
+// CHECK-NEXT: (lldb) target variable ConstexprSMin
+// CHECK-NEXT: (const short) ConstexprSMin = -32768
+constexpr unsigned short ConstexprUSMax = 65535;
+// CHECK-NEXT: (lldb) target variable ConstexprUSMax
+// CHECK-NEXT: (const unsigned short) ConstexprUSMax = 65535
+constexpr unsigned short ConstexprUSMin = 0;
+// CHECK-NEXT: (lldb) target variable ConstexprUSMin
+// CHECK-NEXT: (const unsigned short) ConstexprUSMin = 0
+constexpr int ConstexprIMax = 2147483647;
+// CHECK-NEXT: (lldb) target variable ConstexprIMax
+// CHECK-NEXT: (const int) ConstexprIMax = 2147483647
+constexpr int ConstexprIMin = -2147483648;
+// CHECK-NEXT: (lldb) target variable ConstexprIMin
+// CHECK-NEXT: (const int) ConstexprIMin = -2147483648
+constexpr unsigned int ConstexprUIMax = 4294967295;
+// CHECK-NEXT: (lldb) target variable ConstexprUIMax
+// CHECK-NEXT: (const unsigned int) ConstexprUIMax = 4294967295
+constexpr unsigned int ConstexprUIMin = 0;
+// CHECK-NEXT: (lldb) target variable ConstexprUIMin
+// CHECK-NEXT: (const unsigned int) ConstexprUIMin = 0
+constexpr long ConstexprLMax = 2147483647;
+// CHECK-NEXT: (lldb) target variable ConstexprLMax
+// CHECK-NEXT: (const long) ConstexprLMax = 2147483647
+constexpr long ConstexprLMin = -2147483648;
+// CHECK-NEXT: (lldb) target variable ConstexprLMin
+// CHECK-NEXT: (const long) ConstexprLMin = -2147483648
+constexpr unsigned long ConstexprULMax = 4294967295;
+// CHECK-NEXT: (lldb) target variable ConstexprULMax
+// CHECK-NEXT: (const unsigned long) ConstexprULMax = 4294967295
+constexpr unsigned long ConstexprULMin = 0;
+// CHECK-NEXT: (lldb) target variable ConstexprULMin
+// CHECK-NEXT: (const unsigned long) ConstexprULMin = 0
+constexpr long long ConstexprLLMax = 9223372036854775807i64;
+// CHECK-NEXT: (lldb) target variable ConstexprLLMax
+// CHECK-NEXT: (const long long) ConstexprLLMax = 9223372036854775807
+constexpr long long ConstexprLLMin = -9223372036854775807i64 - 1;
+// CHECK-NEXT: (lldb) target variable ConstexprLLMin
+// CHECK-NEXT: (const long long) ConstexprLLMin = -9223372036854775808
+constexpr unsigned long long ConstexprULLMax = 18446744073709551615ULL;
+// CHECK-NEXT: (lldb) target variable ConstexprULLMax
+// CHECK-NEXT: (const unsigned long long) ConstexprULLMax = 18446744073709551615
+constexpr unsigned long long ConstexprULLMin = 0;
+// CHECK-NEXT: (lldb) target variable ConstexprULLMin
+// CHECK-NEXT: (const unsigned long long) ConstexprULLMin = 0
+constexpr float ConstexprF = 3.1415f;
+// CHECK-NEXT: (lldb) target variable ConstexprF
+// CHECK-NEXT: (const float) ConstexprF = 3.1415
+constexpr double ConstexprD = 3.1415;
+// CHECK-NEXT: (lldb) target variable ConstexprD
+// CHECK-NEXT: (const double) ConstexprD = 3.1415
+
+
+// FIXME: LLDB currently doesn't resolve pointers within the target without a
+// running process (I haven't checked whether or not it can with a running
+// process). So currently it will just print an address, which is unstable and
+// should not be relied upon for testing. So for now we're just checking that
+// the variable name and type is correct. We should fix this in LLDB and then
+// update the tests.
+bool *PBFalse = &BFalse;
+// CHECK-NEXT: (lldb) target variable PBFalse
+// CHECK-NEXT: (bool *) PBFalse = {{.*}}
+bool *PBTrue = &BTrue;
+// CHECK-NEXT: (lldb) target variable PBTrue
+// CHECK-NEXT: (bool *) PBTrue = {{.*}}
+char *PCA = &CA;
+// CHECK-NEXT: (lldb) target variable PCA
+// CHECK-NEXT: (char *) PCA = {{.*}}
+char *PCZ = &CZ;
+// CHECK-NEXT: (lldb) target variable PCZ
+// CHECK-NEXT: (char *) PCZ = {{.*}}
+signed char *PSCa = &SCa;
+// CHECK-NEXT: (lldb) target variable PSCa
+// CHECK-NEXT: (signed char *) PSCa = {{.*}}
+signed char *PSCz = &SCz;
+// CHECK-NEXT: (lldb) target variable PSCz
+// CHECK-NEXT: (signed char *) PSCz = {{.*}}
+unsigned char *PUC24 = &UC24;
+// CHECK-NEXT: (lldb) target variable PUC24
+// CHECK-NEXT: (unsigned char *) PUC24 = {{.*}}
+unsigned char *PUC42 = &UC42;
+// CHECK-NEXT: (lldb) target variable PUC42
+// CHECK-NEXT: (unsigned char *) PUC42 = {{.*}}
+char16_t *PC16_24 = &C16_24;
+// CHECK-NEXT: (lldb) target variable PC16_24
+// CHECK-NEXT: (char16_t *) PC16_24 = {{.*}}
+char32_t *PC32_42 = &C32_42;
+// CHECK-NEXT: (lldb) target variable PC32_42
+// CHECK-NEXT: (char32_t *) PC32_42 = {{.*}}
+wchar_t *PWC1 = &WC1;
+// CHECK-NEXT: (lldb) target variable PWC1
+// CHECK-NEXT: (wchar_t *) PWC1 = {{.*}}
+wchar_t *PWCP = &WCP;
+// CHECK-NEXT: (lldb) target variable PWCP
+// CHECK-NEXT: (wchar_t *) PWCP = {{.*}}
+short *PSMax = &SMax;
+// CHECK-NEXT: (lldb) target variable PSMax
+// CHECK-NEXT: (short *) PSMax = {{.*}}
+short *PSMin = &SMin;
+// CHECK-NEXT: (lldb) target variable PSMin
+// CHECK-NEXT: (short *) PSMin = {{.*}}
+unsigned short *PUSMax = &USMax;
+// CHECK-NEXT: (lldb) target variable PUSMax
+// CHECK-NEXT: (unsigned short *) PUSMax = {{.*}}
+unsigned short *PUSMin = &USMin;
+// CHECK-NEXT: (lldb) target variable PUSMin
+// CHECK-NEXT: (unsigned short *) PUSMin = {{.*}}
+int *PIMax = &IMax;
+// CHECK-NEXT: (lldb) target variable PIMax
+// CHECK-NEXT: (int *) PIMax = {{.*}}
+int *PIMin = &IMin;
+// CHECK-NEXT: (lldb) target variable PIMin
+// CHECK-NEXT: (int *) PIMin = {{.*}}
+unsigned int *PUIMax = &UIMax;
+// CHECK-NEXT: (lldb) target variable PUIMax
+// CHECK-NEXT: (unsigned int *) PUIMax = {{.*}}
+unsigned int *PUIMin = &UIMin;
+// CHECK-NEXT: (lldb) target variable PUIMin
+// CHECK-NEXT: (unsigned int *) PUIMin = {{.*}}
+long *PLMax = &LMax;
+// CHECK-NEXT: (lldb) target variable PLMax
+// CHECK-NEXT: (long *) PLMax = {{.*}}
+long *PLMin = &LMin;
+// CHECK-NEXT: (lldb) target variable PLMin
+// CHECK-NEXT: (long *) PLMin = {{.*}}
+unsigned long *PULMax = &ULMax;
+// CHECK-NEXT: (lldb) target variable PULMax
+// CHECK-NEXT: (unsigned long *) PULMax = {{.*}}
+unsigned long *PULMin = &ULMin;
+// CHECK-NEXT: (lldb) target variable PULMin
+// CHECK-NEXT: (unsigned long *) PULMin = {{.*}}
+long long *PLLMax = &LLMax;
+// CHECK-NEXT: (lldb) target variable PLLMax
+// CHECK-NEXT: (long long *) PLLMax = {{.*}}
+long long *PLLMin = &LLMin;
+// CHECK-NEXT: (lldb) target variable PLLMin
+// CHECK-NEXT: (long long *) PLLMin = {{.*}}
+unsigned long long *PULLMax = &ULLMax;
+// CHECK-NEXT: (lldb) target variable PULLMax
+// CHECK-NEXT: (unsigned long long *) PULLMax = {{.*}}
+unsigned long long *PULLMin = &ULLMin;
+// CHECK-NEXT: (lldb) target variable PULLMin
+// CHECK-NEXT: (unsigned long long *) PULLMin = {{.*}}
+float *PF = &F;
+// CHECK-NEXT: (lldb) target variable PF
+// CHECK-NEXT: (float *) PF = {{.*}}
+double *PD = &D;
+// CHECK-NEXT: (lldb) target variable PD
+// CHECK-NEXT: (double *) PD = {{.*}}
+
+// Const pointers to fundamental data types
+const bool *CPBFalse = &BFalse;
+// CHECK-NEXT: (lldb) target variable CPBFalse
+// CHECK-NEXT: (const bool *) CPBFalse = {{.*}}
+const bool *CPBTrue = &BTrue;
+// CHECK-NEXT: (lldb) target variable CPBTrue
+// CHECK-NEXT: (const bool *) CPBTrue = {{.*}}
+const char *CPCA = &CA;
+// CHECK-NEXT: (lldb) target variable CPCA
+// CHECK-NEXT: (const char *) CPCA = {{.*}}
+const char *CPCZ = &CZ;
+// CHECK-NEXT: (lldb) target variable CPCZ
+// CHECK-NEXT: (const char *) CPCZ = {{.*}}
+const signed char *CPSCa = &SCa;
+// CHECK-NEXT: (lldb) target variable CPSCa
+// CHECK-NEXT: (const signed char *) CPSCa = {{.*}}
+const signed char *CPSCz = &SCz;
+// CHECK-NEXT: (lldb) target variable CPSCz
+// CHECK-NEXT: (const signed char *) CPSCz = {{.*}}
+const unsigned char *CPUC24 = &UC24;
+// CHECK-NEXT: (lldb) target variable CPUC24
+// CHECK-NEXT: (const unsigned char *) CPUC24 = {{.*}}
+const unsigned char *CPUC42 = &UC42;
+// CHECK-NEXT: (lldb) target variable CPUC42
+// CHECK-NEXT: (const unsigned char *) CPUC42 = {{.*}}
+const char16_t *CPC16_24 = &C16_24;
+// CHECK-NEXT: (lldb) target variable CPC16_24
+// CHECK-NEXT: (const char16_t *) CPC16_24 = {{.*}}
+const char32_t *CPC32_42 = &C32_42;
+// CHECK-NEXT: (lldb) target variable CPC32_42
+// CHECK-NEXT: (const char32_t *) CPC32_42 = {{.*}}
+const wchar_t *CPWC1 = &WC1;
+// CHECK-NEXT: (lldb) target variable CPWC1
+// CHECK-NEXT: (const wchar_t *) CPWC1 = {{.*}}
+const wchar_t *CPWCP = &WCP;
+// CHECK-NEXT: (lldb) target variable CPWCP
+// CHECK-NEXT: (const wchar_t *) CPWCP = {{.*}}
+const short *CPSMax = &SMax;
+// CHECK-NEXT: (lldb) target variable CPSMax
+// CHECK-NEXT: (const short *) CPSMax = {{.*}}
+const short *CPSMin = &SMin;
+// CHECK-NEXT: (lldb) target variable CPSMin
+// CHECK-NEXT: (const short *) CPSMin = {{.*}}
+const unsigned short *CPUSMax = &USMax;
+// CHECK-NEXT: (lldb) target variable CPUSMax
+// CHECK-NEXT: (const unsigned short *) CPUSMax = {{.*}}
+const unsigned short *CPUSMin = &USMin;
+// CHECK-NEXT: (lldb) target variable CPUSMin
+// CHECK-NEXT: (const unsigned short *) CPUSMin = {{.*}}
+const int *CPIMax = &IMax;
+// CHECK-NEXT: (lldb) target variable CPIMax
+// CHECK-NEXT: (const int *) CPIMax = {{.*}}
+const int *CPIMin = &IMin;
+// CHECK-NEXT: (lldb) target variable CPIMin
+// CHECK-NEXT: (const int *) CPIMin = {{.*}}
+const unsigned int *CPUIMax = &UIMax;
+// CHECK-NEXT: (lldb) target variable CPUIMax
+// CHECK-NEXT: (const unsigned int *) CPUIMax = {{.*}}
+const unsigned int *CPUIMin = &UIMin;
+// CHECK-NEXT: (lldb) target variable CPUIMin
+// CHECK-NEXT: (const unsigned int *) CPUIMin = {{.*}}
+const long *CPLMax = &LMax;
+// CHECK-NEXT: (lldb) target variable CPLMax
+// CHECK-NEXT: (const long *) CPLMax = {{.*}}
+const long *CPLMin = &LMin;
+// CHECK-NEXT: (lldb) target variable CPLMin
+// CHECK-NEXT: (const long *) CPLMin = {{.*}}
+const unsigned long *CPULMax = &ULMax;
+// CHECK-NEXT: (lldb) target variable CPULMax
+// CHECK-NEXT: (const unsigned long *) CPULMax = {{.*}}
+const unsigned long *CPULMin = &ULMin;
+// CHECK-NEXT: (lldb) target variable CPULMin
+// CHECK-NEXT: (const unsigned long *) CPULMin = {{.*}}
+const long long *CPLLMax = &LLMax;
+// CHECK-NEXT: (lldb) target variable CPLLMax
+// CHECK-NEXT: (const long long *) CPLLMax = {{.*}}
+const long long *CPLLMin = &LLMin;
+// CHECK-NEXT: (lldb) target variable CPLLMin
+// CHECK-NEXT: (const long long *) CPLLMin = {{.*}}
+const unsigned long long *CPULLMax = &ULLMax;
+// CHECK-NEXT: (lldb) target variable CPULLMax
+// CHECK-NEXT: (const unsigned long long *) CPULLMax = {{.*}}
+const unsigned long long *CPULLMin = &ULLMin;
+// CHECK-NEXT: (lldb) target variable CPULLMin
+// CHECK-NEXT: (const unsigned long long *) CPULLMin = {{.*}}
+const float *CPF = &F;
+// CHECK-NEXT: (lldb) target variable CPF
+// CHECK-NEXT: (const float *) CPF = {{.*}}
+const double *CPD = &D;
+// CHECK-NEXT: (lldb) target variable CPD
+// CHECK-NEXT: (const double *) CPD = {{.*}}
+
+
+// References to fundamental data types
+
+bool &RBFalse = BFalse;
+// CHECK-NEXT: (lldb) target variable RBFalse
+// CHECK-NEXT: (bool &) RBFalse = {{.*}} (&::RBFalse = false)
+bool &RBTrue = BTrue;
+// CHECK-NEXT: (lldb) target variable RBTrue
+// CHECK-NEXT: (bool &) RBTrue = {{.*}} (&::RBTrue = true)
+char &RCA = CA;
+// CHECK-NEXT: (lldb) target variable RCA
+// CHECK-NEXT: (char &) RCA = {{.*}} (&::RCA = 'A')
+char &RCZ = CZ;
+// CHECK-NEXT: (lldb) target variable RCZ
+// CHECK-NEXT: (char &) RCZ = {{.*}} (&::RCZ = 'Z')
+signed char &RSCa = SCa;
+// CHECK-NEXT: (lldb) target variable RSCa
+// CHECK-NEXT: (signed char &) RSCa = {{.*}} (&::RSCa = 'a')
+signed char &RSCz = SCz;
+// CHECK-NEXT: (lldb) target variable RSCz
+// CHECK-NEXT: (signed char &) RSCz = {{.*}} (&::RSCz = 'z')
+unsigned char &RUC24 = UC24;
+// CHECK-NEXT: (lldb) target variable RUC24
+// CHECK-NEXT: (unsigned char &) RUC24 = {{.*}} (&::RUC24 = '\x18')
+unsigned char &RUC42 = UC42;
+// CHECK-NEXT: (lldb) target variable RUC42
+// CHECK-NEXT: (unsigned char &) RUC42 = {{.*}} (&::RUC42 = '*')
+short &RSMax = SMax;
+// CHECK-NEXT: (lldb) target variable RSMax
+// CHECK-NEXT: (short &) RSMax = {{.*}} (&::RSMax = 32767)
+short &RSMin = SMin;
+// CHECK-NEXT: (lldb) target variable RSMin
+// CHECK-NEXT: (short &) RSMin = {{.*}} (&::RSMin = -32768)
+unsigned short &RUSMax = USMax;
+// CHECK-NEXT: (lldb) target variable RUSMax
+// CHECK-NEXT: (unsigned short &) RUSMax = {{.*}} (&::RUSMax = 65535)
+unsigned short &RUSMin = USMin;
+// CHECK-NEXT: (lldb) target variable RUSMin
+// CHECK-NEXT: (unsigned short &) RUSMin = {{.*}} (&::RUSMin = 0)
+int &RIMax = IMax;
+// CHECK-NEXT: (lldb) target variable RIMax
+// CHECK-NEXT: (int &) RIMax = {{.*}} (&::RIMax = 2147483647)
+int &RIMin = IMin;
+// CHECK-NEXT: (lldb) target variable RIMin
+// CHECK-NEXT: (int &) RIMin = {{.*}} (&::RIMin = -2147483648)
+unsigned int &RUIMax = UIMax;
+// CHECK-NEXT: (lldb) target variable RUIMax
+// CHECK-NEXT: (unsigned int &) RUIMax = {{.*}} (&::RUIMax = 4294967295)
+unsigned int &RUIMin = UIMin;
+// CHECK-NEXT: (lldb) target variable RUIMin
+// CHECK-NEXT: (unsigned int &) RUIMin = {{.*}} (&::RUIMin = 0)
+long &RLMax = LMax;
+// CHECK-NEXT: (lldb) target variable RLMax
+// CHECK-NEXT: (long &) RLMax = {{.*}} (&::RLMax = 2147483647)
+long &RLMin = LMin;
+// CHECK-NEXT: (lldb) target variable RLMin
+// CHECK-NEXT: (long &) RLMin = {{.*}} (&::RLMin = -2147483648)
+unsigned long &RULMax = ULMax;
+// CHECK-NEXT: (lldb) target variable RULMax
+// CHECK-NEXT: (unsigned long &) RULMax = {{.*}} (&::RULMax = 4294967295)
+unsigned long &RULMin = ULMin;
+// CHECK-NEXT: (lldb) target variable RULMin
+// CHECK-NEXT: (unsigned long &) RULMin = {{.*}} (&::RULMin = 0)
+long long &RLLMax = LLMax;
+// CHECK-NEXT: (lldb) target variable RLLMax
+// CHECK-NEXT: (long long &) RLLMax = {{.*}} (&::RLLMax = 9223372036854775807)
+long long &RLLMin = LLMin;
+// CHECK-NEXT: (lldb) target variable RLLMin
+// CHECK-NEXT: (long long &) RLLMin = {{.*}} (&::RLLMin = -9223372036854775808)
+unsigned long long &RULLMax = ULLMax;
+// CHECK-NEXT: (lldb) target variable RULLMax
+// CHECK-NEXT: (unsigned long long &) RULLMax = {{.*}} (&::RULLMax = 18446744073709551615)
+unsigned long long &RULLMin = ULLMin;
+// CHECK-NEXT: (lldb) target variable RULLMin
+// CHECK-NEXT: (unsigned long long &) RULLMin = {{.*}} (&::RULLMin = 0)
+float &RF = F;
+// CHECK-NEXT: (lldb) target variable RF
+// CHECK-NEXT: (float &) RF = {{.*}} (&::RF = 3.1415)
+double &RD = D;
+// CHECK-NEXT: (lldb) target variable RD
+// CHECK-NEXT: (double &) RD = {{.*}} (&::RD = 3.1415000000000002)
+
+// const references to fundamental data types
+const bool &CRBFalse = BFalse;
+// CHECK-NEXT: (lldb) target variable CRBFalse
+// CHECK-NEXT: (const bool &) CRBFalse = {{.*}} (&::CRBFalse = false)
+const bool &CRBTrue = BTrue;
+// CHECK-NEXT: (lldb) target variable CRBTrue
+// CHECK-NEXT: (const bool &) CRBTrue = {{.*}} (&::CRBTrue = true)
+const char &CRCA = CA;
+// CHECK-NEXT: (lldb) target variable CRCA
+// CHECK-NEXT: (const char &) CRCA = {{.*}} (&::CRCA = 'A')
+const char &CRCZ = CZ;
+// CHECK-NEXT: (lldb) target variable CRCZ
+// CHECK-NEXT: (const char &) CRCZ = {{.*}} (&::CRCZ = 'Z')
+const signed char &CRSCa = SCa;
+// CHECK-NEXT: (lldb) target variable CRSCa
+// CHECK-NEXT: (const signed char &) CRSCa = {{.*}} (&::CRSCa = 'a')
+const signed char &CRSCz = SCz;
+// CHECK-NEXT: (lldb) target variable CRSCz
+// CHECK-NEXT: (const signed char &) CRSCz = {{.*}} (&::CRSCz = 'z')
+const unsigned char &CRUC24 = UC24;
+// CHECK-NEXT: (lldb) target variable CRUC24
+// CHECK-NEXT: (const unsigned char &) CRUC24 = {{.*}} (&::CRUC24 = '\x18')
+const unsigned char &CRUC42 = UC42;
+// CHECK-NEXT: (lldb) target variable CRUC42
+// CHECK-NEXT: (const unsigned char &) CRUC42 = {{.*}} (&::CRUC42 = '*')
+const short &CRSMax = SMax;
+// CHECK-NEXT: (lldb) target variable CRSMax
+// CHECK-NEXT: (const short &) CRSMax = {{.*}} (&::CRSMax = 32767)
+const short &CRSMin = SMin;
+// CHECK-NEXT: (lldb) target variable CRSMin
+// CHECK-NEXT: (const short &) CRSMin = {{.*}} (&::CRSMin = -32768)
+const unsigned short &CRUSMax = USMax;
+// CHECK-NEXT: (lldb) target variable CRUSMax
+// CHECK-NEXT: (const unsigned short &) CRUSMax = {{.*}} (&::CRUSMax = 65535)
+const unsigned short &CRUSMin = USMin;
+// CHECK-NEXT: (lldb) target variable CRUSMin
+// CHECK-NEXT: (const unsigned short &) CRUSMin = {{.*}} (&::CRUSMin = 0)
+const int &CRIMax = IMax;
+// CHECK-NEXT: (lldb) target variable CRIMax
+// CHECK-NEXT: (const int &) CRIMax = {{.*}} (&::CRIMax = 2147483647)
+const int &CRIMin = IMin;
+// CHECK-NEXT: (lldb) target variable CRIMin
+// CHECK-NEXT: (const int &) CRIMin = {{.*}} (&::CRIMin = -2147483648)
+const unsigned int &CRUIMax = UIMax;
+// CHECK-NEXT: (lldb) target variable CRUIMax
+// CHECK-NEXT: (const unsigned int &) CRUIMax = {{.*}} (&::CRUIMax = 4294967295)
+const unsigned int &CRUIMin = UIMin;
+// CHECK-NEXT: (lldb) target variable CRUIMin
+// CHECK-NEXT: (const unsigned int &) CRUIMin = {{.*}} (&::CRUIMin = 0)
+const long &CRLMax = LMax;
+// CHECK-NEXT: (lldb) target variable CRLMax
+// CHECK-NEXT: (const long &) CRLMax = {{.*}} (&::CRLMax = 2147483647)
+const long &CRLMin = LMin;
+// CHECK-NEXT: (lldb) target variable CRLMin
+// CHECK-NEXT: (const long &) CRLMin = {{.*}} (&::CRLMin = -2147483648)
+const unsigned long &CRULMax = ULMax;
+// CHECK-NEXT: (lldb) target variable CRULMax
+// CHECK-NEXT: (const unsigned long &) CRULMax = {{.*}} (&::CRULMax = 4294967295)
+const unsigned long &CRULMin = ULMin;
+// CHECK-NEXT: (lldb) target variable CRULMin
+// CHECK-NEXT: (const unsigned long &) CRULMin = {{.*}} (&::CRULMin = 0)
+const long long &CRLLMax = LLMax;
+// CHECK-NEXT: (lldb) target variable CRLLMax
+// CHECK-NEXT: (const long long &) CRLLMax = {{.*}} (&::CRLLMax = 9223372036854775807)
+const long long &CRLLMin = LLMin;
+// CHECK-NEXT: (lldb) target variable CRLLMin
+// CHECK-NEXT: (const long long &) CRLLMin = {{.*}} (&::CRLLMin = -9223372036854775808)
+const unsigned long long &CRULLMax = ULLMax;
+// CHECK-NEXT: (lldb) target variable CRULLMax
+// CHECK-NEXT: (const unsigned long long &) CRULLMax = {{.*}} (&::CRULLMax = 18446744073709551615)
+const unsigned long long &CRULLMin = ULLMin;
+// CHECK-NEXT: (lldb) target variable CRULLMin
+// CHECK-NEXT: (const unsigned long long &) CRULLMin = {{.*}} (&::CRULLMin = 0)
+const float &CRF = F;
+// CHECK-NEXT: (lldb) target variable CRF
+// CHECK-NEXT: (const float &) CRF = {{.*}} (&::CRF = 3.1415)
+const double &CRD = D;
+// CHECK-NEXT: (lldb) target variable CRD
+// CHECK-NEXT: (const double &) CRD = {{.*}} (&::CRD = 3.1415000000000002)
+
+char16_t &RC16_24 = C16_24;
+// CHECK: (lldb) target variable RC16_24
+// FIXME: (char16_t &) RC16_24 = {{.*}} (&::RC16_24 = U+0014)
+char32_t &RC32_42 = C32_42;
+// CHECK: (lldb) target variable RC32_42
+// FIXME: (char32_t &) RC32_42 = {{.*}} (&::RC32_42 = U+0x00000022)
+wchar_t &RWC1 = WC1;
+// CHECK: (lldb) target variable RWC1
+// FIXME: (wchar_t &) RWC1 = {{.*}} (&::RWC1 = L'1')
+wchar_t &RWCP = WCP;
+// CHECK: (lldb) target variable RWCP
+// FIXME: (wchar_t &) RWCP = {{.*}} (&::RWCP = L'P')
+const char16_t &CRC16_24 = C16_24;
+// CHECK: (lldb) target variable CRC16_24
+// FIXME: (const char16_t &) CRC16_24 = {{.*}} (&::CRC16_24 = U+0014)
+const char32_t &CRC32_42 = C32_42;
+// CHECK: (lldb) target variable CRC32_42
+// FIXME: (const char32_t &) CRC32_42 = {{.*}} (&::CRC32_42 = U+0x00000022)
+const wchar_t &CRWC1 = WC1;
+// CHECK: (lldb) target variable CRWC1
+// FIXME: (const wchar_t &) CRWC1 = {{.*}} (&::CRWC1 = L'1')
+const wchar_t &CRWCP = WCP;
+// CHECK: (lldb) target variable CRWCP
+// FIXME: (const wchar_t &) CRWCP = {{.*}} (&::CRWCP = L'P')
+
+
+// CHECK: (lldb) quit
+
+int main(int argc, char **argv) {
+  return CIMax;
+}
\ No newline at end of file

Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h?rev=345373&r1=345372&r2=345373&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h Fri Oct 26 02:06:38 2018
@@ -32,7 +32,6 @@ namespace npdb {
 // the beginning so that the types are all layout-compatible with each
 // other, which is necessary in order to be able to safely access the tag
 // member through any union member.
-
 struct PdbCompilandId {
   uint64_t tag : 8;   // PDB_SymType::Compiland
   uint64_t modi : 16; // 0-based index of module in PDB
@@ -41,11 +40,14 @@ struct PdbCompilandId {
 struct PdbCuSymId {
   uint64_t tag : 8; // PDB_SymType::Data, Function, Block, etc.
   uint64_t
-      offset : 32;    // Offset of symbol's record in module stream.  This is
-                      // offset by 4 from the CVSymbolArray's notion of offset
-                      // due to the debug magic at the beginning of the stream.
-  uint64_t modi : 16; // 0-based index of module in PDB
+      offset : 30;     // Offset of symbol's record in module stream.  This is
+                       // offset by 4 from the CVSymbolArray's notion of offset
+                       // due to the debug magic at the beginning of the stream.
+  uint64_t global : 1; // True if this is from the globals stream.
+  uint64_t unused : 1;
+  uint64_t modi : 16; // For non-global, this is the 0-based index of module.
 };
+
 struct PdbTypeSymId {
   uint64_t tag : 8;    // PDB_SymType::FunctionSig, Enum, PointerType, etc.
   uint64_t is_ipi : 8; // 1 if this value is from the IPI stream, 0 for TPI.
@@ -125,10 +127,21 @@ public:
     PdbSymUid uid;
     uid.m_uid.cu_sym.modi = modi;
     uid.m_uid.cu_sym.offset = offset;
+    uid.m_uid.cu_sym.global = false;
     uid.m_uid.cu_sym.tag = static_cast<uint8_t>(type);
     return uid;
   }
 
+  static PdbSymUid makeGlobalVariableUid(uint32_t offset) {
+    PdbSymUid uid = {};
+    uid.m_uid.cu_sym.modi = 0;
+    uid.m_uid.cu_sym.offset = offset;
+    uid.m_uid.cu_sym.global = 1;
+    uid.m_uid.cu_sym.unused = 0;
+    uid.m_uid.cu_sym.tag = static_cast<uint8_t>(llvm::pdb::PDB_SymType::Data);
+    return uid;
+  }
+
   static PdbSymUid makeCompilandId(llvm::codeview::ProcRefSym sym) {
     // S_PROCREF symbols are 1-based
     lldbassert(sym.Module > 0);
@@ -172,6 +185,11 @@ public:
   bool isCompiland() const {
     return tag() == llvm::pdb::PDB_SymType::Compiland;
   }
+  bool isGlobalVariable() const {
+    if (tag() != llvm::pdb::PDB_SymType::Data)
+      return false;
+    return static_cast<bool>(asCuSym().global);
+  }
 
   llvm::pdb::PDB_SymType tag() const {
     return static_cast<llvm::pdb::PDB_SymType>(m_uid.comp_id.tag);

Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp?rev=345373&r1=345372&r2=345373&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Fri Oct 26 02:06:38 2018
@@ -16,6 +16,7 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamBuffer.h"
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTImporter.h"
 #include "lldb/Symbol/ClangExternalASTSourceCommon.h"
@@ -24,6 +25,8 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Variable.h"
+#include "lldb/Symbol/VariableList.h"
 
 #include "llvm/DebugInfo/CodeView/CVRecord.h"
 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
@@ -887,6 +890,131 @@ TypeSP SymbolFileNativePDB::GetOrCreateT
   return CreateAndCacheType(type_uid);
 }
 
+static DWARFExpression MakeGlobalLocationExpression(uint16_t section,
+                                                    uint32_t offset,
+                                                    ModuleSP module) {
+  assert(section > 0);
+  assert(module);
+
+  const ArchSpec &architecture = module->GetArchitecture();
+  ByteOrder byte_order = architecture.GetByteOrder();
+  uint32_t address_size = architecture.GetAddressByteSize();
+  uint32_t byte_size = architecture.GetDataByteSize();
+  assert(byte_order != eByteOrderInvalid && address_size != 0);
+
+  RegisterKind register_kind = eRegisterKindDWARF;
+  StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order);
+  stream.PutHex8(DW_OP_addr);
+
+  SectionList *section_list = module->GetSectionList();
+  assert(section_list);
+
+  // Section indices in PDB are 1-based, but in DWARF they are 0-based, so we
+  // need to subtract 1.
+  uint32_t section_idx = section - 1;
+  if (section_idx >= section_list->GetSize())
+    return DWARFExpression(nullptr);
+
+  auto section_ptr = section_list->GetSectionAtIndex(section_idx);
+  if (!section_ptr)
+    return DWARFExpression(nullptr);
+
+  stream.PutMaxHex64(section_ptr->GetFileAddress() + offset, address_size,
+                     byte_order);
+  DataBufferSP buffer =
+      std::make_shared<DataBufferHeap>(stream.GetData(), stream.GetSize());
+  DataExtractor extractor(buffer, byte_order, address_size, byte_size);
+  DWARFExpression result(module, extractor, nullptr, 0, buffer->GetByteSize());
+  result.SetRegisterKind(register_kind);
+  return result;
+}
+
+VariableSP SymbolFileNativePDB::CreateGlobalVariable(PdbSymUid var_uid) {
+  const PdbCuSymId &cu_sym = var_uid.asCuSym();
+  lldbassert(cu_sym.global);
+  CVSymbol sym = m_index->symrecords().readRecord(cu_sym.offset);
+  lldb::ValueType scope = eValueTypeInvalid;
+  TypeIndex ti;
+  llvm::StringRef name;
+  lldb::addr_t addr = 0;
+  uint16_t section = 0;
+  uint32_t offset = 0;
+  bool is_external = false;
+  switch (sym.kind()) {
+  case S_GDATA32:
+    is_external = true;
+    LLVM_FALLTHROUGH;
+  case S_LDATA32: {
+    DataSym ds(sym.kind());
+    llvm::cantFail(SymbolDeserializer::deserializeAs<DataSym>(sym, ds));
+    ti = ds.Type;
+    scope = (sym.kind() == S_GDATA32) ? eValueTypeVariableGlobal
+                                      : eValueTypeVariableStatic;
+    name = ds.Name;
+    section = ds.Segment;
+    offset = ds.DataOffset;
+    addr = m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset);
+    break;
+  }
+  case S_GTHREAD32:
+    is_external = true;
+    LLVM_FALLTHROUGH;
+  case S_LTHREAD32: {
+    ThreadLocalDataSym tlds(sym.kind());
+    llvm::cantFail(
+        SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym, tlds));
+    ti = tlds.Type;
+    name = tlds.Name;
+    section = tlds.Segment;
+    offset = tlds.DataOffset;
+    addr = m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset);
+    scope = eValueTypeVariableThreadLocal;
+    break;
+  }
+  default:
+    llvm_unreachable("unreachable!");
+  }
+
+  CompUnitSP comp_unit;
+  llvm::Optional<uint16_t> modi = m_index->GetModuleIndexForVa(addr);
+  if (modi) {
+    PdbSymUid cuid = PdbSymUid::makeCompilandId(*modi);
+    CompilandIndexItem &cci = m_index->compilands().GetOrCreateCompiland(cuid);
+    comp_unit = GetOrCreateCompileUnit(cci);
+  }
+
+  Declaration decl;
+  PDB_SymType pdbst = GetPdbSymType(m_index->tpi(), ti);
+  PdbSymUid tuid = PdbSymUid::makeTypeSymId(pdbst, ti, false);
+  SymbolFileTypeSP type_sp =
+      std::make_shared<SymbolFileType>(*this, tuid.toOpaqueId());
+  Variable::RangeList ranges;
+
+  DWARFExpression location = MakeGlobalLocationExpression(
+      section, offset, GetObjectFile()->GetModule());
+
+  std::string global_name("::");
+  global_name += name;
+  VariableSP var_sp = std::make_shared<Variable>(
+      var_uid.toOpaqueId(), name.str().c_str(), global_name.c_str(), type_sp,
+      scope, comp_unit.get(), ranges, &decl, location, is_external, false,
+      false);
+  var_sp->SetLocationIsConstantValueData(false);
+
+  return var_sp;
+}
+
+VariableSP SymbolFileNativePDB::GetOrCreateGlobalVariable(PdbSymUid var_uid) {
+  lldbassert(var_uid.isGlobalVariable());
+
+  auto emplace_result =
+      m_global_vars.try_emplace(var_uid.toOpaqueId(), nullptr);
+  if (emplace_result.second)
+    emplace_result.first->second = CreateGlobalVariable(var_uid);
+
+  return emplace_result.first->second;
+}
+
 lldb::TypeSP
 SymbolFileNativePDB::GetOrCreateType(llvm::codeview::TypeIndex ti) {
   PDB_SymType pdbst = GetPdbSymType(m_index->tpi(), ti);
@@ -1146,6 +1274,32 @@ size_t SymbolFileNativePDB::ParseFunctio
   return 0;
 }
 
+uint32_t SymbolFileNativePDB::FindGlobalVariables(
+    const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+    uint32_t max_matches, VariableList &variables) {
+  using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
+
+  std::vector<SymbolAndOffset> results = m_index->globals().findRecordsByName(
+      name.GetStringRef(), m_index->symrecords());
+  for (const SymbolAndOffset &result : results) {
+    VariableSP var;
+    switch (result.second.kind()) {
+    case SymbolKind::S_GDATA32:
+    case SymbolKind::S_LDATA32:
+    case SymbolKind::S_GTHREAD32:
+    case SymbolKind::S_LTHREAD32: {
+      PdbSymUid uid = PdbSymUid::makeGlobalVariableUid(result.first);
+      var = GetOrCreateGlobalVariable(uid);
+      variables.AddVariable(var);
+      break;
+    }
+    default:
+      continue;
+    }
+  }
+  return variables.GetSize();
+}
+
 uint32_t SymbolFileNativePDB::FindFunctions(
     const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
     FunctionNameType name_type_mask, bool include_inlines, bool append,
@@ -1239,19 +1393,21 @@ Type *SymbolFileNativePDB::ResolveTypeUI
   auto iter = m_types.find(type_uid);
   // lldb should not be passing us non-sensical type uids.  the only way it
   // could have a type uid in the first place is if we handed it out, in which
-  // case we should know about the type.  So this is not a get-or-create type
-  // operation, it is strictly a get, and the type is guaranteed to exist.
-  //
-  // However, since the implementation is not yet complete, we don't currently
-  // support all possible use cases.  For example, we currently create all
-  // functions with indices of 0 for the signature type simply because this is
-  // not yet implemented.  At the time the function object is created we should
-  // be creating an lldb::TypeSP for this, adding it to the m_types, and
-  // returning a valid Type object for it and putting it in this map.  Once all
-  // cases like this are handled, we can promote this to an assert.
-  if (iter == m_types.end())
+  // case we should know about the type.  However, that doesn't mean we've
+  // instantiated it yet.  We can vend out a UID for a future type.  So if the
+  // type doesn't exist, let's instantiate it now.
+  if (iter != m_types.end())
+    return &*iter->second;
+
+  PdbSymUid uid = PdbSymUid::fromOpaqueId(type_uid);
+  lldbassert(uid.isTypeSym(uid.tag()));
+  const PdbTypeSymId &type_id = uid.asTypeSym();
+  TypeIndex ti(type_id.index);
+  if (ti.isNoneType())
     return nullptr;
-  return &*iter->second;
+
+  TypeSP type_sp = CreateAndCacheType(uid);
+  return &*type_sp;
 }
 
 bool SymbolFileNativePDB::CompleteType(CompilerType &compiler_type) {

Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h?rev=345373&r1=345372&r2=345373&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h Fri Oct 26 02:06:38 2018
@@ -103,6 +103,11 @@ public:
 
   size_t ParseFunctionBlocks(const SymbolContext &sc) override;
 
+  uint32_t FindGlobalVariables(const ConstString &name,
+                               const CompilerDeclContext *parent_decl_ctx,
+                               uint32_t max_matches,
+                               VariableList &variables) override;
+
   size_t ParseTypes(const SymbolContext &sc) override;
   size_t ParseVariablesForContext(const SymbolContext &sc) override {
     return 0;
@@ -175,11 +180,13 @@ private:
   lldb::CompUnitSP GetOrCreateCompileUnit(const CompilandIndexItem &cci);
   lldb::TypeSP GetOrCreateType(PdbSymUid type_uid);
   lldb::TypeSP GetOrCreateType(llvm::codeview::TypeIndex ti);
+  lldb::VariableSP GetOrCreateGlobalVariable(PdbSymUid var_uid);
 
   lldb::FunctionSP CreateFunction(PdbSymUid func_uid, const SymbolContext &sc);
   lldb::CompUnitSP CreateCompileUnit(const CompilandIndexItem &cci);
   lldb::TypeSP CreateType(PdbSymUid type_uid);
   lldb::TypeSP CreateAndCacheType(PdbSymUid type_uid);
+  lldb::VariableSP CreateGlobalVariable(PdbSymUid var_uid);
 
   llvm::BumpPtrAllocator m_allocator;
 
@@ -193,6 +200,7 @@ private:
 
   llvm::DenseMap<lldb::user_id_t, clang::TagDecl *> m_uid_to_decl;
 
+  llvm::DenseMap<lldb::user_id_t, lldb::VariableSP> m_global_vars;
   llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions;
   llvm::DenseMap<lldb::user_id_t, lldb::CompUnitSP> m_compilands;
   llvm::DenseMap<lldb::user_id_t, lldb::TypeSP> m_types;




More information about the lldb-commits mailing list