summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-11-08 18:50:31 +0000
committerZachary Turner <zturner@google.com>2018-11-08 18:50:31 +0000
commit91dbd52890041a6ff494e007c5b42bea4d18b519 (patch)
tree568617b7ea52353542a6f20c5977160e838cfc9d
parent056e4ab497b54cc5362e0761b58fb51620dc9a1d (diff)
downloadbcm5719-llvm-91dbd52890041a6ff494e007c5b42bea4d18b519.tar.gz
bcm5719-llvm-91dbd52890041a6ff494e007c5b42bea4d18b519.zip
Fix bug in PE/COFF plugin and ValueObjectVariable.
There are two bugs here. The first is that MSVC and clang-cl emit their bss section under the name '.data' instead of '.bss' but with the size and file offset set to 0. ObjectFilePECOFF didn't handle this, and would only recognize a section as bss if it was actually called '.bss'. The effect of this is that if we tried to print the value of a variable that lived in BSS we would fail. The second bug is that ValueObjectVariable was only returning the forward type, which is insufficient to print the value of an enum. So we bump this up to the layout type. Differential Revision: https://reviews.llvm.org/D54241 llvm-svn: 346430
-rw-r--r--lldb/lit/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit3
-rw-r--r--lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp15
-rw-r--r--lldb/lit/SymbolFile/NativePDB/globals-bss.cpp35
-rw-r--r--lldb/source/Core/ValueObjectVariable.cpp13
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp6
5 files changed, 61 insertions, 11 deletions
diff --git a/lldb/lit/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit b/lldb/lit/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit
new file mode 100644
index 00000000000..9bf066ee2af
--- /dev/null
+++ b/lldb/lit/SymbolFile/NativePDB/Inputs/globals-bss.lldbinit
@@ -0,0 +1,3 @@
+target variable GlobalVariable
+
+quit
diff --git a/lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp b/lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp
index d3d36749e84..535c316db76 100644
--- a/lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp
+++ b/lldb/lit/SymbolFile/NativePDB/ast-reconstruction.cpp
@@ -89,22 +89,23 @@ Anonymous<A::B::C<int>>::D AnonABCVoidD;
// CHECK: (TrivialC) TC = {}
// CHECK: (TrivialS) TS = {}
// CHECK: (TrivialU) TU = {}
-// CHECK: (TrivialE) TE = <Unable to determine byte size.>
-// CHECK: (A::B::C<int>) ABCInt = (ABCMember = <read memory from {{.*}} failed>)
-// CHECK: (A::B::C<float>) ABCFloat = (ABCMember = <read memory from {{.*}} failed>)
-// CHECK: (A::B::C<void>) ABCVoid = (ABCSpecializationMember = <read memory from {{.*}} failed>)
+// CHECK: (TrivialE) TE = TE_A
+// CHECK: (A::B::C<int>) ABCInt = (ABCMember = 0)
+// CHECK: (A::B::C<float>) ABCFloat = (ABCMember = 0)
+// CHECK: (A::B::C<void>) ABCVoid = (ABCSpecializationMember = 0x0000000000000000)
// CHECK: (A::C<0>) AC0 = {}
// CHECK: (A::C<-1>) ACNeg1 = {}
-// CHECK: (A::C<0>::D) AC0D = (ACDMember = <read memory from {{.*}} failed>, CPtr = <read memory from {{.*}} failed>)
-// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = <read memory from {{.*}} failed>, CPtr = <read memory from {{.*}} failed>)
+// CHECK: (A::C<0>::D) AC0D = (ACDMember = 0, CPtr = 0x0000000000000000)
+// CHECK: (A::C<-1>::D) ACNeg1D = (ACDMember = 0, CPtr = 0x0000000000000000)
// CHECK: (A::D) AD = {}
-// CHECK: (A::D::E) ADE = (ADDMember = <read memory from {{.*}} failed>)
+// CHECK: (A::D::E) ADE = (ADDMember = 0)
// CHECK: Dumping clang ast for 1 modules.
// CHECK: TranslationUnitDecl {{.*}}
// CHECK: |-CXXRecordDecl {{.*}} class TrivialC definition
// CHECK: |-CXXRecordDecl {{.*}} struct TrivialS definition
// CHECK: |-CXXRecordDecl {{.*}} union TrivialU definition
// CHECK: |-EnumDecl {{.*}} TrivialE
+// CHECK: | `-EnumConstantDecl {{.*}} TE_A 'int'
// CHECK: |-NamespaceDecl {{.*}} A
// CHECK: | |-NamespaceDecl {{.*}} B
// CHECK: | | |-CXXRecordDecl {{.*}} struct C<int> definition
diff --git a/lldb/lit/SymbolFile/NativePDB/globals-bss.cpp b/lldb/lit/SymbolFile/NativePDB/globals-bss.cpp
new file mode 100644
index 00000000000..57149b96681
--- /dev/null
+++ b/lldb/lit/SymbolFile/NativePDB/globals-bss.cpp
@@ -0,0 +1,35 @@
+// clang-format off
+// REQUIRES: lld
+
+// Make sure we can read variables from BSS
+// RUN: clang-cl /Z7 /GS- /GR- /c /Fo%t.obj -- %s
+// RUN: lld-link /DEBUG /nodefaultlib /entry:main /OUT:%t.exe /PDB:%t.pdb -- %t.obj
+// RUN: llvm-readobj -s %t.exe | FileCheck --check-prefix=BSS %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb -f %t.exe -s \
+// RUN: %p/Inputs/globals-bss.lldbinit 2>&1 | FileCheck %s
+
+int GlobalVariable = 0;
+
+int main(int argc, char **argv) {
+ return 0;
+}
+
+// BSS: Section {
+// BSS: Number: 3
+// BSS: Name: .data
+// BSS-NEXT: VirtualSize: 0x4
+// BSS-NEXT: VirtualAddress:
+// BSS-NEXT: RawDataSize: 0
+// BSS-NEXT: PointerToRawData: 0x0
+// BSS-NEXT: PointerToRelocations: 0x0
+// BSS-NEXT: PointerToLineNumbers: 0x0
+// BSS-NEXT: RelocationCount: 0
+// BSS-NEXT: LineNumberCount: 0
+// BSS-NEXT: Characteristics [ (0xC0000040)
+// BSS-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
+// BSS-NEXT: IMAGE_SCN_MEM_READ (0x40000000)
+// BSS-NEXT: IMAGE_SCN_MEM_WRITE (0x80000000)
+// BSS-NEXT: ]
+// BSS-NEXT: }
+
+// CHECK: (int) GlobalVariable = 0
diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index 2f017aa36f7..229cdd8bacd 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -66,9 +66,16 @@ ValueObjectVariable::~ValueObjectVariable() {}
CompilerType ValueObjectVariable::GetCompilerTypeImpl() {
Type *var_type = m_variable_sp->GetType();
- if (var_type)
- return var_type->GetForwardCompilerType();
- return CompilerType();
+ if (!var_type)
+ return CompilerType();
+
+ // It's important to return the layout type here. If we have an enum then the
+ // symbol file plugin may have decided to complete it lazily, in which case a
+ // forward type won't be sufficient to display the variable. On the other
+ // hand, if we have a pointer to a class type, then getting the full type will
+ // resolve the class type, which is too much. The layout type is both
+ // necessary and sufficient.
+ return var_type->GetLayoutCompilerType();
}
ConstString ValueObjectVariable::GetTypeName() {
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 40637574e4b..78d03e27d8f 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -710,7 +710,10 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA &&
((const_sect_name == g_data_sect_name) ||
(const_sect_name == g_DATA_sect_name))) {
- section_type = eSectionTypeData;
+ if (m_sect_headers[idx].size == 0 && m_sect_headers[idx].offset == 0)
+ section_type = eSectionTypeZeroFill;
+ else
+ section_type = eSectionTypeData;
} else if (m_sect_headers[idx].flags &
llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA &&
((const_sect_name == g_bss_sect_name) ||
@@ -1053,6 +1056,7 @@ ObjectFile::Type ObjectFilePECOFF::CalculateType() {
}
ObjectFile::Strata ObjectFilePECOFF::CalculateStrata() { return eStrataUser; }
+
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
OpenPOWER on IntegriCloud