[DebugInfo] - Removed trailing whitespaces. NFC.

llvm-svn: 306518
This commit is contained in:
George Rimar 2017-06-28 08:26:57 +00:00
parent 1af3cb2912
commit 002655df17
1 changed files with 68 additions and 68 deletions

View File

@ -816,10 +816,10 @@ template <uint16_t Version, class AddrType> void TestAddresses() {
dwarfgen::Generator *DG = ExpectedDG.get().get(); dwarfgen::Generator *DG = ExpectedDG.get().get();
dwarfgen::CompileUnit &CU = DG->addCompileUnit(); dwarfgen::CompileUnit &CU = DG->addCompileUnit();
dwarfgen::DIE CUDie = CU.getUnitDIE(); dwarfgen::DIE CUDie = CU.getUnitDIE();
CUDie.addAttribute(DW_AT_name, DW_FORM_strp, "/tmp/main.c"); CUDie.addAttribute(DW_AT_name, DW_FORM_strp, "/tmp/main.c");
CUDie.addAttribute(DW_AT_language, DW_FORM_data2, DW_LANG_C); CUDie.addAttribute(DW_AT_language, DW_FORM_data2, DW_LANG_C);
// Create a subprogram DIE with no low or high PC. // Create a subprogram DIE with no low or high PC.
dwarfgen::DIE SubprogramNoPC = CUDie.addChild(DW_TAG_subprogram); dwarfgen::DIE SubprogramNoPC = CUDie.addChild(DW_TAG_subprogram);
SubprogramNoPC.addAttribute(DW_AT_name, DW_FORM_strp, "no_pc"); SubprogramNoPC.addAttribute(DW_AT_name, DW_FORM_strp, "no_pc");
@ -842,18 +842,18 @@ template <uint16_t Version, class AddrType> void TestAddresses() {
ActualHighPCOffset); ActualHighPCOffset);
else else
SubprogramLowHighPC.addAttribute(DW_AT_high_pc, DW_FORM_addr, ActualHighPC); SubprogramLowHighPC.addAttribute(DW_AT_high_pc, DW_FORM_addr, ActualHighPC);
StringRef FileBytes = DG->generate(); StringRef FileBytes = DG->generate();
MemoryBufferRef FileBuffer(FileBytes, "dwarf"); MemoryBufferRef FileBuffer(FileBytes, "dwarf");
auto Obj = object::ObjectFile::createObjectFile(FileBuffer); auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
EXPECT_TRUE((bool)Obj); EXPECT_TRUE((bool)Obj);
DWARFContextInMemory DwarfContext(*Obj.get()); DWARFContextInMemory DwarfContext(*Obj.get());
// Verify the number of compile units is correct. // Verify the number of compile units is correct.
uint32_t NumCUs = DwarfContext.getNumCompileUnits(); uint32_t NumCUs = DwarfContext.getNumCompileUnits();
EXPECT_EQ(NumCUs, 1u); EXPECT_EQ(NumCUs, 1u);
DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0); DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
// Get the compile unit DIE is valid. // Get the compile unit DIE is valid.
auto DieDG = U->getUnitDIE(false); auto DieDG = U->getUnitDIE(false);
EXPECT_TRUE(DieDG.isValid()); EXPECT_TRUE(DieDG.isValid());
@ -877,7 +877,7 @@ template <uint16_t Version, class AddrType> void TestAddresses() {
OptU64 = SubprogramDieNoPC.getHighPC(ActualLowPC); OptU64 = SubprogramDieNoPC.getHighPC(ActualLowPC);
EXPECT_FALSE((bool)OptU64); EXPECT_FALSE((bool)OptU64);
EXPECT_FALSE(SubprogramDieNoPC.getLowAndHighPC(LowPC, HighPC, SectionIndex)); EXPECT_FALSE(SubprogramDieNoPC.getLowAndHighPC(LowPC, HighPC, SectionIndex));
// Verify the that our subprogram with only a low PC value succeeds when // Verify the that our subprogram with only a low PC value succeeds when
// we ask for the Low PC, but fails appropriately when asked for the high PC // we ask for the Low PC, but fails appropriately when asked for the high PC
// or both low and high PC values. // or both low and high PC values.
@ -978,7 +978,7 @@ TEST(DWARFDebugInfo, TestRelations) {
// Test the DWARF APIs related to accessing the DW_AT_low_pc and // Test the DWARF APIs related to accessing the DW_AT_low_pc and
// DW_AT_high_pc. // DW_AT_high_pc.
uint16_t Version = 4; uint16_t Version = 4;
const uint8_t AddrSize = sizeof(void *); const uint8_t AddrSize = sizeof(void *);
initLLVMIfNeeded(); initLLVMIfNeeded();
Triple Triple = getHostTripleForAddrSize(AddrSize); Triple Triple = getHostTripleForAddrSize(AddrSize);
@ -987,7 +987,7 @@ TEST(DWARFDebugInfo, TestRelations) {
return; return;
dwarfgen::Generator *DG = ExpectedDG.get().get(); dwarfgen::Generator *DG = ExpectedDG.get().get();
dwarfgen::CompileUnit &CU = DG->addCompileUnit(); dwarfgen::CompileUnit &CU = DG->addCompileUnit();
enum class Tag: uint16_t { enum class Tag: uint16_t {
A = dwarf::DW_TAG_lo_user, A = dwarf::DW_TAG_lo_user,
B, B,
@ -1024,34 +1024,34 @@ TEST(DWARFDebugInfo, TestRelations) {
auto Obj = object::ObjectFile::createObjectFile(FileBuffer); auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
EXPECT_TRUE((bool)Obj); EXPECT_TRUE((bool)Obj);
DWARFContextInMemory DwarfContext(*Obj.get()); DWARFContextInMemory DwarfContext(*Obj.get());
// Verify the number of compile units is correct. // Verify the number of compile units is correct.
uint32_t NumCUs = DwarfContext.getNumCompileUnits(); uint32_t NumCUs = DwarfContext.getNumCompileUnits();
EXPECT_EQ(NumCUs, 1u); EXPECT_EQ(NumCUs, 1u);
DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0); DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
// Get the compile unit DIE is valid. // Get the compile unit DIE is valid.
auto CUDie = U->getUnitDIE(false); auto CUDie = U->getUnitDIE(false);
EXPECT_TRUE(CUDie.isValid()); EXPECT_TRUE(CUDie.isValid());
// The compile unit doesn't have a parent or a sibling. // The compile unit doesn't have a parent or a sibling.
auto ParentDie = CUDie.getParent(); auto ParentDie = CUDie.getParent();
EXPECT_FALSE(ParentDie.isValid()); EXPECT_FALSE(ParentDie.isValid());
auto SiblingDie = CUDie.getSibling(); auto SiblingDie = CUDie.getSibling();
EXPECT_FALSE(SiblingDie.isValid()); EXPECT_FALSE(SiblingDie.isValid());
// Get the children of the compile unit // Get the children of the compile unit
auto A = CUDie.getFirstChild(); auto A = CUDie.getFirstChild();
auto B = A.getFirstChild(); auto B = A.getFirstChild();
auto C = B.getSibling(); auto C = B.getSibling();
auto D = C.getSibling(); auto D = C.getSibling();
auto Null = D.getSibling(); auto Null = D.getSibling();
// Verify NULL Die is NULL and has no children or siblings // Verify NULL Die is NULL and has no children or siblings
EXPECT_TRUE(Null.isNULL()); EXPECT_TRUE(Null.isNULL());
EXPECT_FALSE(Null.getSibling().isValid()); EXPECT_FALSE(Null.getSibling().isValid());
EXPECT_FALSE(Null.getFirstChild().isValid()); EXPECT_FALSE(Null.getFirstChild().isValid());
// Verify all children of the compile unit DIE are correct. // Verify all children of the compile unit DIE are correct.
EXPECT_EQ(A.getTag(), (dwarf::Tag)Tag::A); EXPECT_EQ(A.getTag(), (dwarf::Tag)Tag::A);
EXPECT_EQ(B.getTag(), (dwarf::Tag)Tag::B); EXPECT_EQ(B.getTag(), (dwarf::Tag)Tag::B);
@ -1067,7 +1067,7 @@ TEST(DWARFDebugInfo, TestRelations) {
// Make sure the parent of all the children of the compile unit are the // Make sure the parent of all the children of the compile unit are the
// compile unit. // compile unit.
EXPECT_EQ(A.getParent(), CUDie); EXPECT_EQ(A.getParent(), CUDie);
// Make sure the parent of all the children of A are the A. // Make sure the parent of all the children of A are the A.
// B is the first child in A, so we need to verify we can get the previous // B is the first child in A, so we need to verify we can get the previous
// DIE as the parent. // DIE as the parent.
@ -1086,7 +1086,7 @@ TEST(DWARFDebugInfo, TestRelations) {
auto C1 = C.getFirstChild(); auto C1 = C.getFirstChild();
auto C2 = C1.getSibling(); auto C2 = C1.getSibling();
EXPECT_TRUE(C2.getSibling().isNULL()); EXPECT_TRUE(C2.getSibling().isNULL());
// Verify all children of the B DIE correctly valid or invalid. // Verify all children of the B DIE correctly valid or invalid.
EXPECT_EQ(C1.getTag(), (dwarf::Tag)Tag::C1); EXPECT_EQ(C1.getTag(), (dwarf::Tag)Tag::C1);
EXPECT_EQ(C2.getTag(), (dwarf::Tag)Tag::C2); EXPECT_EQ(C2.getTag(), (dwarf::Tag)Tag::C2);
@ -1109,7 +1109,7 @@ TEST(DWARFDebugInfo, TestChildIterators) {
// Test the DWARF APIs related to iterating across the children of a DIE using // Test the DWARF APIs related to iterating across the children of a DIE using
// the DWARFDie::iterator class. // the DWARFDie::iterator class.
uint16_t Version = 4; uint16_t Version = 4;
const uint8_t AddrSize = sizeof(void *); const uint8_t AddrSize = sizeof(void *);
initLLVMIfNeeded(); initLLVMIfNeeded();
Triple Triple = getHostTripleForAddrSize(AddrSize); Triple Triple = getHostTripleForAddrSize(AddrSize);
@ -1118,12 +1118,12 @@ TEST(DWARFDebugInfo, TestChildIterators) {
return; return;
dwarfgen::Generator *DG = ExpectedDG.get().get(); dwarfgen::Generator *DG = ExpectedDG.get().get();
dwarfgen::CompileUnit &CU = DG->addCompileUnit(); dwarfgen::CompileUnit &CU = DG->addCompileUnit();
enum class Tag: uint16_t { enum class Tag: uint16_t {
A = dwarf::DW_TAG_lo_user, A = dwarf::DW_TAG_lo_user,
B, B,
}; };
// Scope to allow us to re-use the same DIE names // Scope to allow us to re-use the same DIE names
{ {
// Create DWARF tree that looks like: // Create DWARF tree that looks like:
@ -1135,24 +1135,24 @@ TEST(DWARFDebugInfo, TestChildIterators) {
CUDie.addChild((dwarf::Tag)Tag::A); CUDie.addChild((dwarf::Tag)Tag::A);
CUDie.addChild((dwarf::Tag)Tag::B); CUDie.addChild((dwarf::Tag)Tag::B);
} }
MemoryBufferRef FileBuffer(DG->generate(), "dwarf"); MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
auto Obj = object::ObjectFile::createObjectFile(FileBuffer); auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
EXPECT_TRUE((bool)Obj); EXPECT_TRUE((bool)Obj);
DWARFContextInMemory DwarfContext(*Obj.get()); DWARFContextInMemory DwarfContext(*Obj.get());
// Verify the number of compile units is correct. // Verify the number of compile units is correct.
uint32_t NumCUs = DwarfContext.getNumCompileUnits(); uint32_t NumCUs = DwarfContext.getNumCompileUnits();
EXPECT_EQ(NumCUs, 1u); EXPECT_EQ(NumCUs, 1u);
DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0); DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
// Get the compile unit DIE is valid. // Get the compile unit DIE is valid.
auto CUDie = U->getUnitDIE(false); auto CUDie = U->getUnitDIE(false);
EXPECT_TRUE(CUDie.isValid()); EXPECT_TRUE(CUDie.isValid());
uint32_t Index; uint32_t Index;
DWARFDie A; DWARFDie A;
DWARFDie B; DWARFDie B;
// Verify the compile unit DIE's children. // Verify the compile unit DIE's children.
Index = 0; Index = 0;
for (auto Die : CUDie.children()) { for (auto Die : CUDie.children()) {
@ -1161,7 +1161,7 @@ TEST(DWARFDebugInfo, TestChildIterators) {
case 1: B = Die; break; case 1: B = Die; break;
} }
} }
EXPECT_EQ(A.getTag(), (dwarf::Tag)Tag::A); EXPECT_EQ(A.getTag(), (dwarf::Tag)Tag::A);
EXPECT_EQ(B.getTag(), (dwarf::Tag)Tag::B); EXPECT_EQ(B.getTag(), (dwarf::Tag)Tag::B);
@ -1210,7 +1210,7 @@ TEST(DWARFDebugInfo, TestEmptyChildren) {
// Get the compile unit DIE is valid. // Get the compile unit DIE is valid.
auto CUDie = U->getUnitDIE(false); auto CUDie = U->getUnitDIE(false);
EXPECT_TRUE(CUDie.isValid()); EXPECT_TRUE(CUDie.isValid());
// Verify that the CU Die that says it has children, but doesn't, actually // Verify that the CU Die that says it has children, but doesn't, actually
// has begin and end iterators that are equal. We want to make sure we don't // has begin and end iterators that are equal. We want to make sure we don't
// see the Null DIEs during iteration. // see the Null DIEs during iteration.
@ -1221,7 +1221,7 @@ TEST(DWARFDebugInfo, TestAttributeIterators) {
// Test the DWARF APIs related to iterating across all attribute values in a // Test the DWARF APIs related to iterating across all attribute values in a
// a DWARFDie. // a DWARFDie.
uint16_t Version = 4; uint16_t Version = 4;
const uint8_t AddrSize = sizeof(void *); const uint8_t AddrSize = sizeof(void *);
initLLVMIfNeeded(); initLLVMIfNeeded();
Triple Triple = getHostTripleForAddrSize(AddrSize); Triple Triple = getHostTripleForAddrSize(AddrSize);
@ -1232,7 +1232,7 @@ TEST(DWARFDebugInfo, TestAttributeIterators) {
dwarfgen::CompileUnit &CU = DG->addCompileUnit(); dwarfgen::CompileUnit &CU = DG->addCompileUnit();
const uint64_t CULowPC = 0x1000; const uint64_t CULowPC = 0x1000;
StringRef CUPath("/tmp/main.c"); StringRef CUPath("/tmp/main.c");
// Scope to allow us to re-use the same DIE names // Scope to allow us to re-use the same DIE names
{ {
auto CUDie = CU.getUnitDIE(); auto CUDie = CU.getUnitDIE();
@ -1244,44 +1244,44 @@ TEST(DWARFDebugInfo, TestAttributeIterators) {
// Encode an attribute value after an attribute with no data. // Encode an attribute value after an attribute with no data.
CUDie.addAttribute(DW_AT_low_pc, DW_FORM_addr, CULowPC); CUDie.addAttribute(DW_AT_low_pc, DW_FORM_addr, CULowPC);
} }
MemoryBufferRef FileBuffer(DG->generate(), "dwarf"); MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
auto Obj = object::ObjectFile::createObjectFile(FileBuffer); auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
EXPECT_TRUE((bool)Obj); EXPECT_TRUE((bool)Obj);
DWARFContextInMemory DwarfContext(*Obj.get()); DWARFContextInMemory DwarfContext(*Obj.get());
// Verify the number of compile units is correct. // Verify the number of compile units is correct.
uint32_t NumCUs = DwarfContext.getNumCompileUnits(); uint32_t NumCUs = DwarfContext.getNumCompileUnits();
EXPECT_EQ(NumCUs, 1u); EXPECT_EQ(NumCUs, 1u);
DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0); DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
// Get the compile unit DIE is valid. // Get the compile unit DIE is valid.
auto CUDie = U->getUnitDIE(false); auto CUDie = U->getUnitDIE(false);
EXPECT_TRUE(CUDie.isValid()); EXPECT_TRUE(CUDie.isValid());
auto R = CUDie.attributes(); auto R = CUDie.attributes();
auto I = R.begin(); auto I = R.begin();
auto E = R.end(); auto E = R.end();
ASSERT_NE(E, I); ASSERT_NE(E, I);
EXPECT_EQ(I->Attr, DW_AT_name); EXPECT_EQ(I->Attr, DW_AT_name);
auto ActualCUPath = I->Value.getAsCString(); auto ActualCUPath = I->Value.getAsCString();
EXPECT_EQ(CUPath, *ActualCUPath); EXPECT_EQ(CUPath, *ActualCUPath);
ASSERT_NE(E, ++I); ASSERT_NE(E, ++I);
EXPECT_EQ(I->Attr, DW_AT_declaration); EXPECT_EQ(I->Attr, DW_AT_declaration);
EXPECT_EQ(1ull, *I->Value.getAsUnsignedConstant()); EXPECT_EQ(1ull, *I->Value.getAsUnsignedConstant());
ASSERT_NE(E, ++I); ASSERT_NE(E, ++I);
EXPECT_EQ(I->Attr, DW_AT_low_pc); EXPECT_EQ(I->Attr, DW_AT_low_pc);
EXPECT_EQ(CULowPC, *I->Value.getAsAddress()); EXPECT_EQ(CULowPC, *I->Value.getAsAddress());
EXPECT_EQ(E, ++I); EXPECT_EQ(E, ++I);
} }
TEST(DWARFDebugInfo, TestFindRecurse) { TEST(DWARFDebugInfo, TestFindRecurse) {
uint16_t Version = 4; uint16_t Version = 4;
const uint8_t AddrSize = sizeof(void *); const uint8_t AddrSize = sizeof(void *);
initLLVMIfNeeded(); initLLVMIfNeeded();
Triple Triple = getHostTripleForAddrSize(AddrSize); Triple Triple = getHostTripleForAddrSize(AddrSize);
@ -1290,7 +1290,7 @@ TEST(DWARFDebugInfo, TestFindRecurse) {
return; return;
dwarfgen::Generator *DG = ExpectedDG.get().get(); dwarfgen::Generator *DG = ExpectedDG.get().get();
dwarfgen::CompileUnit &CU = DG->addCompileUnit(); dwarfgen::CompileUnit &CU = DG->addCompileUnit();
StringRef SpecDieName = "spec"; StringRef SpecDieName = "spec";
StringRef SpecLinkageName = "spec_linkage"; StringRef SpecLinkageName = "spec_linkage";
StringRef AbsDieName = "abs"; StringRef AbsDieName = "abs";
@ -1309,21 +1309,21 @@ TEST(DWARFDebugInfo, TestFindRecurse) {
VarAbsDie.addAttribute(DW_AT_name, DW_FORM_strp, AbsDieName); VarAbsDie.addAttribute(DW_AT_name, DW_FORM_strp, AbsDieName);
VarDie.addAttribute(DW_AT_abstract_origin, DW_FORM_ref4, VarAbsDie); VarDie.addAttribute(DW_AT_abstract_origin, DW_FORM_ref4, VarAbsDie);
} }
MemoryBufferRef FileBuffer(DG->generate(), "dwarf"); MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
auto Obj = object::ObjectFile::createObjectFile(FileBuffer); auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
EXPECT_TRUE((bool)Obj); EXPECT_TRUE((bool)Obj);
DWARFContextInMemory DwarfContext(*Obj.get()); DWARFContextInMemory DwarfContext(*Obj.get());
// Verify the number of compile units is correct. // Verify the number of compile units is correct.
uint32_t NumCUs = DwarfContext.getNumCompileUnits(); uint32_t NumCUs = DwarfContext.getNumCompileUnits();
EXPECT_EQ(NumCUs, 1u); EXPECT_EQ(NumCUs, 1u);
DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0); DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
// Get the compile unit DIE is valid. // Get the compile unit DIE is valid.
auto CUDie = U->getUnitDIE(false); auto CUDie = U->getUnitDIE(false);
EXPECT_TRUE(CUDie.isValid()); EXPECT_TRUE(CUDie.isValid());
auto FuncSpecDie = CUDie.getFirstChild(); auto FuncSpecDie = CUDie.getFirstChild();
auto FuncAbsDie = FuncSpecDie.getSibling(); auto FuncAbsDie = FuncSpecDie.getSibling();
auto FuncDie = FuncAbsDie.getSibling(); auto FuncDie = FuncAbsDie.getSibling();
@ -1348,11 +1348,11 @@ TEST(DWARFDebugInfo, TestFindRecurse) {
auto LinkageNameOpt = FuncDie.findRecursively(DW_AT_linkage_name); auto LinkageNameOpt = FuncDie.findRecursively(DW_AT_linkage_name);
EXPECT_EQ(SpecLinkageName, toString(LinkageNameOpt).getValueOr(nullptr)); EXPECT_EQ(SpecLinkageName, toString(LinkageNameOpt).getValueOr(nullptr));
// Make sure we can't extract the name from the abstract origin die when using // Make sure we can't extract the name from the abstract origin die when using
// DWARFDie::find() since it won't check the DW_AT_abstract_origin DIE. // DWARFDie::find() since it won't check the DW_AT_abstract_origin DIE.
EXPECT_FALSE(VarDie.find(DW_AT_name)); EXPECT_FALSE(VarDie.find(DW_AT_name));
// Make sure we can extract the name from the abstract origin die when using // Make sure we can extract the name from the abstract origin die when using
// DWARFDie::findRecursively() since it should recurse through the // DWARFDie::findRecursively() since it should recurse through the
// DW_AT_abstract_origin DIE. // DW_AT_abstract_origin DIE.
@ -1412,7 +1412,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
FormVal.setForm(DW_FORM_udata); FormVal.setForm(DW_FORM_udata);
FormVal.setUValue(UData8); FormVal.setUValue(UData8);
FormValOpt = FormVal; FormValOpt = FormVal;
EXPECT_FALSE(toString(FormValOpt).hasValue()); EXPECT_FALSE(toString(FormValOpt).hasValue());
EXPECT_TRUE(toUnsigned(FormValOpt).hasValue()); EXPECT_TRUE(toUnsigned(FormValOpt).hasValue());
EXPECT_FALSE(toReference(FormValOpt).hasValue()); EXPECT_FALSE(toReference(FormValOpt).hasValue());
@ -1432,7 +1432,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
FormVal.setForm(DW_FORM_ref_addr); FormVal.setForm(DW_FORM_ref_addr);
FormVal.setUValue(RefData); FormVal.setUValue(RefData);
FormValOpt = FormVal; FormValOpt = FormVal;
EXPECT_FALSE(toString(FormValOpt).hasValue()); EXPECT_FALSE(toString(FormValOpt).hasValue());
EXPECT_FALSE(toUnsigned(FormValOpt).hasValue()); EXPECT_FALSE(toUnsigned(FormValOpt).hasValue());
EXPECT_TRUE(toReference(FormValOpt).hasValue()); EXPECT_TRUE(toReference(FormValOpt).hasValue());
@ -1452,7 +1452,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
FormVal.setForm(DW_FORM_udata); FormVal.setForm(DW_FORM_udata);
FormVal.setSValue(SData8); FormVal.setSValue(SData8);
FormValOpt = FormVal; FormValOpt = FormVal;
EXPECT_FALSE(toString(FormValOpt).hasValue()); EXPECT_FALSE(toString(FormValOpt).hasValue());
EXPECT_TRUE(toUnsigned(FormValOpt).hasValue()); EXPECT_TRUE(toUnsigned(FormValOpt).hasValue());
EXPECT_FALSE(toReference(FormValOpt).hasValue()); EXPECT_FALSE(toReference(FormValOpt).hasValue());
@ -1473,7 +1473,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
FormVal.setForm(DW_FORM_block1); FormVal.setForm(DW_FORM_block1);
FormVal.setBlockValue(Array); FormVal.setBlockValue(Array);
FormValOpt = FormVal; FormValOpt = FormVal;
EXPECT_FALSE(toString(FormValOpt).hasValue()); EXPECT_FALSE(toString(FormValOpt).hasValue());
EXPECT_FALSE(toUnsigned(FormValOpt).hasValue()); EXPECT_FALSE(toUnsigned(FormValOpt).hasValue());
EXPECT_FALSE(toReference(FormValOpt).hasValue()); EXPECT_FALSE(toReference(FormValOpt).hasValue());
@ -1497,7 +1497,7 @@ TEST(DWARFDebugInfo, TestFindAttrs) {
// Test the DWARFDie::find() and DWARFDie::findRecursively() that take an // Test the DWARFDie::find() and DWARFDie::findRecursively() that take an
// ArrayRef<dwarf::Attribute> value to make sure they work correctly. // ArrayRef<dwarf::Attribute> value to make sure they work correctly.
uint16_t Version = 4; uint16_t Version = 4;
const uint8_t AddrSize = sizeof(void *); const uint8_t AddrSize = sizeof(void *);
initLLVMIfNeeded(); initLLVMIfNeeded();
Triple Triple = getHostTripleForAddrSize(AddrSize); Triple Triple = getHostTripleForAddrSize(AddrSize);
@ -1506,7 +1506,7 @@ TEST(DWARFDebugInfo, TestFindAttrs) {
return; return;
dwarfgen::Generator *DG = ExpectedDG.get().get(); dwarfgen::Generator *DG = ExpectedDG.get().get();
dwarfgen::CompileUnit &CU = DG->addCompileUnit(); dwarfgen::CompileUnit &CU = DG->addCompileUnit();
StringRef DieMangled("_Z3fooi"); StringRef DieMangled("_Z3fooi");
// Scope to allow us to re-use the same DIE names // Scope to allow us to re-use the same DIE names
{ {
@ -1516,21 +1516,21 @@ TEST(DWARFDebugInfo, TestFindAttrs) {
FuncSpecDie.addAttribute(DW_AT_MIPS_linkage_name, DW_FORM_strp, DieMangled); FuncSpecDie.addAttribute(DW_AT_MIPS_linkage_name, DW_FORM_strp, DieMangled);
FuncDie.addAttribute(DW_AT_specification, DW_FORM_ref4, FuncSpecDie); FuncDie.addAttribute(DW_AT_specification, DW_FORM_ref4, FuncSpecDie);
} }
MemoryBufferRef FileBuffer(DG->generate(), "dwarf"); MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
auto Obj = object::ObjectFile::createObjectFile(FileBuffer); auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
EXPECT_TRUE((bool)Obj); EXPECT_TRUE((bool)Obj);
DWARFContextInMemory DwarfContext(*Obj.get()); DWARFContextInMemory DwarfContext(*Obj.get());
// Verify the number of compile units is correct. // Verify the number of compile units is correct.
uint32_t NumCUs = DwarfContext.getNumCompileUnits(); uint32_t NumCUs = DwarfContext.getNumCompileUnits();
EXPECT_EQ(NumCUs, 1u); EXPECT_EQ(NumCUs, 1u);
DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0); DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
// Get the compile unit DIE is valid. // Get the compile unit DIE is valid.
auto CUDie = U->getUnitDIE(false); auto CUDie = U->getUnitDIE(false);
EXPECT_TRUE(CUDie.isValid()); EXPECT_TRUE(CUDie.isValid());
auto FuncSpecDie = CUDie.getFirstChild(); auto FuncSpecDie = CUDie.getFirstChild();
auto FuncDie = FuncSpecDie.getSibling(); auto FuncDie = FuncSpecDie.getSibling();
@ -1547,7 +1547,7 @@ TEST(DWARFDebugInfo, TestFindAttrs) {
// Make sure we can't extract the linkage name attributes when using // Make sure we can't extract the linkage name attributes when using
// DWARFDie::find() since it won't check the DW_AT_specification DIE. // DWARFDie::find() since it won't check the DW_AT_specification DIE.
EXPECT_FALSE(FuncDie.find(Attrs).hasValue()); EXPECT_FALSE(FuncDie.find(Attrs).hasValue());
// Make sure we can extract the name from the specification die when using // Make sure we can extract the name from the specification die when using
// DWARFDie::findRecursively() since it should recurse through the // DWARFDie::findRecursively() since it should recurse through the
// DW_AT_specification DIE. // DW_AT_specification DIE.
@ -2077,38 +2077,38 @@ TEST(DWARFDebugInfo, TestDwarfVerifyCUDontShareLineTable) {
- '' - ''
- /tmp/main.c - /tmp/main.c
- /tmp/foo.c - /tmp/foo.c
debug_abbrev: debug_abbrev:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
Attributes: Attributes:
- Attribute: DW_AT_name - Attribute: DW_AT_name
Form: DW_FORM_strp Form: DW_FORM_strp
- Attribute: DW_AT_stmt_list - Attribute: DW_AT_stmt_list
Form: DW_FORM_sec_offset Form: DW_FORM_sec_offset
debug_info: debug_info:
- Length: - Length:
TotalLength: 16 TotalLength: 16
Version: 4 Version: 4
AbbrOffset: 0 AbbrOffset: 0
AddrSize: 8 AddrSize: 8
Entries: Entries:
- AbbrCode: 0x00000001 - AbbrCode: 0x00000001
Values: Values:
- Value: 0x0000000000000001 - Value: 0x0000000000000001
- Value: 0x0000000000000000 - Value: 0x0000000000000000
- Length: - Length:
TotalLength: 16 TotalLength: 16
Version: 4 Version: 4
AbbrOffset: 0 AbbrOffset: 0
AddrSize: 8 AddrSize: 8
Entries: Entries:
- AbbrCode: 0x00000001 - AbbrCode: 0x00000001
Values: Values:
- Value: 0x000000000000000D - Value: 0x000000000000000D
- Value: 0x0000000000000000 - Value: 0x0000000000000000
debug_line: debug_line:
- Length: - Length:
TotalLength: 60 TotalLength: 60
Version: 2 Version: 2
PrologueLength: 34 PrologueLength: 34
@ -2118,14 +2118,14 @@ TEST(DWARFDebugInfo, TestDwarfVerifyCUDontShareLineTable) {
LineRange: 14 LineRange: 14
OpcodeBase: 13 OpcodeBase: 13
StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ] StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
IncludeDirs: IncludeDirs:
- /tmp - /tmp
Files: Files:
- Name: main.c - Name: main.c
DirIdx: 1 DirIdx: 1
ModTime: 0 ModTime: 0
Length: 0 Length: 0
Opcodes: Opcodes:
- Opcode: DW_LNS_extended_op - Opcode: DW_LNS_extended_op
ExtLen: 9 ExtLen: 9
SubOpcode: DW_LNE_set_address SubOpcode: DW_LNE_set_address