llvm.org GIT mirror llvm / 39b79bc
[DebugInfo] - Removed trailing whitespaces. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306518 91177308-0d34-0410-b5e6-96231b3b80d8 George Rimar 2 years ago
1 changed file(s) with 68 addition(s) and 68 deletion(s). Raw diff Collapse all Expand all
815815 dwarfgen::Generator *DG = ExpectedDG.get().get();
816816 dwarfgen::CompileUnit &CU = DG->addCompileUnit();
817817 dwarfgen::DIE CUDie = CU.getUnitDIE();
818
818
819819 CUDie.addAttribute(DW_AT_name, DW_FORM_strp, "/tmp/main.c");
820820 CUDie.addAttribute(DW_AT_language, DW_FORM_data2, DW_LANG_C);
821
821
822822 // Create a subprogram DIE with no low or high PC.
823823 dwarfgen::DIE SubprogramNoPC = CUDie.addChild(DW_TAG_subprogram);
824824 SubprogramNoPC.addAttribute(DW_AT_name, DW_FORM_strp, "no_pc");
841841 ActualHighPCOffset);
842842 else
843843 SubprogramLowHighPC.addAttribute(DW_AT_high_pc, DW_FORM_addr, ActualHighPC);
844
844
845845 StringRef FileBytes = DG->generate();
846846 MemoryBufferRef FileBuffer(FileBytes, "dwarf");
847847 auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
848848 EXPECT_TRUE((bool)Obj);
849849 DWARFContextInMemory DwarfContext(*Obj.get());
850
850
851851 // Verify the number of compile units is correct.
852852 uint32_t NumCUs = DwarfContext.getNumCompileUnits();
853853 EXPECT_EQ(NumCUs, 1u);
854854 DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
855
855
856856 // Get the compile unit DIE is valid.
857857 auto DieDG = U->getUnitDIE(false);
858858 EXPECT_TRUE(DieDG.isValid());
876876 OptU64 = SubprogramDieNoPC.getHighPC(ActualLowPC);
877877 EXPECT_FALSE((bool)OptU64);
878878 EXPECT_FALSE(SubprogramDieNoPC.getLowAndHighPC(LowPC, HighPC, SectionIndex));
879
879
880880 // Verify the that our subprogram with only a low PC value succeeds when
881881 // we ask for the Low PC, but fails appropriately when asked for the high PC
882882 // or both low and high PC values.
977977 // Test the DWARF APIs related to accessing the DW_AT_low_pc and
978978 // DW_AT_high_pc.
979979 uint16_t Version = 4;
980
980
981981 const uint8_t AddrSize = sizeof(void *);
982982 initLLVMIfNeeded();
983983 Triple Triple = getHostTripleForAddrSize(AddrSize);
986986 return;
987987 dwarfgen::Generator *DG = ExpectedDG.get().get();
988988 dwarfgen::CompileUnit &CU = DG->addCompileUnit();
989
989
990990 enum class Tag: uint16_t {
991991 A = dwarf::DW_TAG_lo_user,
992992 B,
10231023 auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
10241024 EXPECT_TRUE((bool)Obj);
10251025 DWARFContextInMemory DwarfContext(*Obj.get());
1026
1026
10271027 // Verify the number of compile units is correct.
10281028 uint32_t NumCUs = DwarfContext.getNumCompileUnits();
10291029 EXPECT_EQ(NumCUs, 1u);
10301030 DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
1031
1031
10321032 // Get the compile unit DIE is valid.
10331033 auto CUDie = U->getUnitDIE(false);
10341034 EXPECT_TRUE(CUDie.isValid());
1035
1035
10361036 // The compile unit doesn't have a parent or a sibling.
10371037 auto ParentDie = CUDie.getParent();
10381038 EXPECT_FALSE(ParentDie.isValid());
10391039 auto SiblingDie = CUDie.getSibling();
10401040 EXPECT_FALSE(SiblingDie.isValid());
1041
1041
10421042 // Get the children of the compile unit
10431043 auto A = CUDie.getFirstChild();
10441044 auto B = A.getFirstChild();
10451045 auto C = B.getSibling();
10461046 auto D = C.getSibling();
10471047 auto Null = D.getSibling();
1048
1048
10491049 // Verify NULL Die is NULL and has no children or siblings
10501050 EXPECT_TRUE(Null.isNULL());
10511051 EXPECT_FALSE(Null.getSibling().isValid());
10521052 EXPECT_FALSE(Null.getFirstChild().isValid());
1053
1053
10541054 // Verify all children of the compile unit DIE are correct.
10551055 EXPECT_EQ(A.getTag(), (dwarf::Tag)Tag::A);
10561056 EXPECT_EQ(B.getTag(), (dwarf::Tag)Tag::B);
10661066 // Make sure the parent of all the children of the compile unit are the
10671067 // compile unit.
10681068 EXPECT_EQ(A.getParent(), CUDie);
1069
1069
10701070 // Make sure the parent of all the children of A are the A.
10711071 // B is the first child in A, so we need to verify we can get the previous
10721072 // DIE as the parent.
10851085 auto C1 = C.getFirstChild();
10861086 auto C2 = C1.getSibling();
10871087 EXPECT_TRUE(C2.getSibling().isNULL());
1088
1088
10891089 // Verify all children of the B DIE correctly valid or invalid.
10901090 EXPECT_EQ(C1.getTag(), (dwarf::Tag)Tag::C1);
10911091 EXPECT_EQ(C2.getTag(), (dwarf::Tag)Tag::C2);
11081108 // Test the DWARF APIs related to iterating across the children of a DIE using
11091109 // the DWARFDie::iterator class.
11101110 uint16_t Version = 4;
1111
1111
11121112 const uint8_t AddrSize = sizeof(void *);
11131113 initLLVMIfNeeded();
11141114 Triple Triple = getHostTripleForAddrSize(AddrSize);
11171117 return;
11181118 dwarfgen::Generator *DG = ExpectedDG.get().get();
11191119 dwarfgen::CompileUnit &CU = DG->addCompileUnit();
1120
1120
11211121 enum class Tag: uint16_t {
11221122 A = dwarf::DW_TAG_lo_user,
11231123 B,
11241124 };
1125
1125
11261126 // Scope to allow us to re-use the same DIE names
11271127 {
11281128 // Create DWARF tree that looks like:
11341134 CUDie.addChild((dwarf::Tag)Tag::A);
11351135 CUDie.addChild((dwarf::Tag)Tag::B);
11361136 }
1137
1137
11381138 MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
11391139 auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
11401140 EXPECT_TRUE((bool)Obj);
11411141 DWARFContextInMemory DwarfContext(*Obj.get());
1142
1142
11431143 // Verify the number of compile units is correct.
11441144 uint32_t NumCUs = DwarfContext.getNumCompileUnits();
11451145 EXPECT_EQ(NumCUs, 1u);
11461146 DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
1147
1147
11481148 // Get the compile unit DIE is valid.
11491149 auto CUDie = U->getUnitDIE(false);
11501150 EXPECT_TRUE(CUDie.isValid());
11511151 uint32_t Index;
11521152 DWARFDie A;
11531153 DWARFDie B;
1154
1154
11551155 // Verify the compile unit DIE's children.
11561156 Index = 0;
11571157 for (auto Die : CUDie.children()) {
11601160 case 1: B = Die; break;
11611161 }
11621162 }
1163
1163
11641164 EXPECT_EQ(A.getTag(), (dwarf::Tag)Tag::A);
11651165 EXPECT_EQ(B.getTag(), (dwarf::Tag)Tag::B);
11661166
12091209 // Get the compile unit DIE is valid.
12101210 auto CUDie = U->getUnitDIE(false);
12111211 EXPECT_TRUE(CUDie.isValid());
1212
1212
12131213 // Verify that the CU Die that says it has children, but doesn't, actually
12141214 // has begin and end iterators that are equal. We want to make sure we don't
12151215 // see the Null DIEs during iteration.
12201220 // Test the DWARF APIs related to iterating across all attribute values in a
12211221 // a DWARFDie.
12221222 uint16_t Version = 4;
1223
1223
12241224 const uint8_t AddrSize = sizeof(void *);
12251225 initLLVMIfNeeded();
12261226 Triple Triple = getHostTripleForAddrSize(AddrSize);
12311231 dwarfgen::CompileUnit &CU = DG->addCompileUnit();
12321232 const uint64_t CULowPC = 0x1000;
12331233 StringRef CUPath("/tmp/main.c");
1234
1234
12351235 // Scope to allow us to re-use the same DIE names
12361236 {
12371237 auto CUDie = CU.getUnitDIE();
12431243 // Encode an attribute value after an attribute with no data.
12441244 CUDie.addAttribute(DW_AT_low_pc, DW_FORM_addr, CULowPC);
12451245 }
1246
1246
12471247 MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
12481248 auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
12491249 EXPECT_TRUE((bool)Obj);
12501250 DWARFContextInMemory DwarfContext(*Obj.get());
1251
1251
12521252 // Verify the number of compile units is correct.
12531253 uint32_t NumCUs = DwarfContext.getNumCompileUnits();
12541254 EXPECT_EQ(NumCUs, 1u);
12551255 DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
1256
1256
12571257 // Get the compile unit DIE is valid.
12581258 auto CUDie = U->getUnitDIE(false);
12591259 EXPECT_TRUE(CUDie.isValid());
1260
1260
12611261 auto R = CUDie.attributes();
12621262 auto I = R.begin();
12631263 auto E = R.end();
1264
1264
12651265 ASSERT_NE(E, I);
12661266 EXPECT_EQ(I->Attr, DW_AT_name);
12671267 auto ActualCUPath = I->Value.getAsCString();
12681268 EXPECT_EQ(CUPath, *ActualCUPath);
1269
1269
12701270 ASSERT_NE(E, ++I);
12711271 EXPECT_EQ(I->Attr, DW_AT_declaration);
12721272 EXPECT_EQ(1ull, *I->Value.getAsUnsignedConstant());
1273
1273
12741274 ASSERT_NE(E, ++I);
12751275 EXPECT_EQ(I->Attr, DW_AT_low_pc);
12761276 EXPECT_EQ(CULowPC, *I->Value.getAsAddress());
1277
1277
12781278 EXPECT_EQ(E, ++I);
12791279 }
12801280
12811281 TEST(DWARFDebugInfo, TestFindRecurse) {
12821282 uint16_t Version = 4;
1283
1283
12841284 const uint8_t AddrSize = sizeof(void *);
12851285 initLLVMIfNeeded();
12861286 Triple Triple = getHostTripleForAddrSize(AddrSize);
12891289 return;
12901290 dwarfgen::Generator *DG = ExpectedDG.get().get();
12911291 dwarfgen::CompileUnit &CU = DG->addCompileUnit();
1292
1292
12931293 StringRef SpecDieName = "spec";
12941294 StringRef SpecLinkageName = "spec_linkage";
12951295 StringRef AbsDieName = "abs";
13081308 VarAbsDie.addAttribute(DW_AT_name, DW_FORM_strp, AbsDieName);
13091309 VarDie.addAttribute(DW_AT_abstract_origin, DW_FORM_ref4, VarAbsDie);
13101310 }
1311
1311
13121312 MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
13131313 auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
13141314 EXPECT_TRUE((bool)Obj);
13151315 DWARFContextInMemory DwarfContext(*Obj.get());
1316
1316
13171317 // Verify the number of compile units is correct.
13181318 uint32_t NumCUs = DwarfContext.getNumCompileUnits();
13191319 EXPECT_EQ(NumCUs, 1u);
13201320 DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
1321
1321
13221322 // Get the compile unit DIE is valid.
13231323 auto CUDie = U->getUnitDIE(false);
13241324 EXPECT_TRUE(CUDie.isValid());
1325
1325
13261326 auto FuncSpecDie = CUDie.getFirstChild();
13271327 auto FuncAbsDie = FuncSpecDie.getSibling();
13281328 auto FuncDie = FuncAbsDie.getSibling();
13471347
13481348 auto LinkageNameOpt = FuncDie.findRecursively(DW_AT_linkage_name);
13491349 EXPECT_EQ(SpecLinkageName, toString(LinkageNameOpt).getValueOr(nullptr));
1350
1350
13511351 // Make sure we can't extract the name from the abstract origin die when using
13521352 // DWARFDie::find() since it won't check the DW_AT_abstract_origin DIE.
13531353 EXPECT_FALSE(VarDie.find(DW_AT_name));
1354
1354
13551355 // Make sure we can extract the name from the abstract origin die when using
13561356 // DWARFDie::findRecursively() since it should recurse through the
13571357 // DW_AT_abstract_origin DIE.
14111411 FormVal.setForm(DW_FORM_udata);
14121412 FormVal.setUValue(UData8);
14131413 FormValOpt = FormVal;
1414
1414
14151415 EXPECT_FALSE(toString(FormValOpt).hasValue());
14161416 EXPECT_TRUE(toUnsigned(FormValOpt).hasValue());
14171417 EXPECT_FALSE(toReference(FormValOpt).hasValue());
14311431 FormVal.setForm(DW_FORM_ref_addr);
14321432 FormVal.setUValue(RefData);
14331433 FormValOpt = FormVal;
1434
1434
14351435 EXPECT_FALSE(toString(FormValOpt).hasValue());
14361436 EXPECT_FALSE(toUnsigned(FormValOpt).hasValue());
14371437 EXPECT_TRUE(toReference(FormValOpt).hasValue());
14511451 FormVal.setForm(DW_FORM_udata);
14521452 FormVal.setSValue(SData8);
14531453 FormValOpt = FormVal;
1454
1454
14551455 EXPECT_FALSE(toString(FormValOpt).hasValue());
14561456 EXPECT_TRUE(toUnsigned(FormValOpt).hasValue());
14571457 EXPECT_FALSE(toReference(FormValOpt).hasValue());
14721472 FormVal.setForm(DW_FORM_block1);
14731473 FormVal.setBlockValue(Array);
14741474 FormValOpt = FormVal;
1475
1475
14761476 EXPECT_FALSE(toString(FormValOpt).hasValue());
14771477 EXPECT_FALSE(toUnsigned(FormValOpt).hasValue());
14781478 EXPECT_FALSE(toReference(FormValOpt).hasValue());
14961496 // Test the DWARFDie::find() and DWARFDie::findRecursively() that take an
14971497 // ArrayRef value to make sure they work correctly.
14981498 uint16_t Version = 4;
1499
1499
15001500 const uint8_t AddrSize = sizeof(void *);
15011501 initLLVMIfNeeded();
15021502 Triple Triple = getHostTripleForAddrSize(AddrSize);
15051505 return;
15061506 dwarfgen::Generator *DG = ExpectedDG.get().get();
15071507 dwarfgen::CompileUnit &CU = DG->addCompileUnit();
1508
1508
15091509 StringRef DieMangled("_Z3fooi");
15101510 // Scope to allow us to re-use the same DIE names
15111511 {
15151515 FuncSpecDie.addAttribute(DW_AT_MIPS_linkage_name, DW_FORM_strp, DieMangled);
15161516 FuncDie.addAttribute(DW_AT_specification, DW_FORM_ref4, FuncSpecDie);
15171517 }
1518
1518
15191519 MemoryBufferRef FileBuffer(DG->generate(), "dwarf");
15201520 auto Obj = object::ObjectFile::createObjectFile(FileBuffer);
15211521 EXPECT_TRUE((bool)Obj);
15221522 DWARFContextInMemory DwarfContext(*Obj.get());
1523
1523
15241524 // Verify the number of compile units is correct.
15251525 uint32_t NumCUs = DwarfContext.getNumCompileUnits();
15261526 EXPECT_EQ(NumCUs, 1u);
15271527 DWARFCompileUnit *U = DwarfContext.getCompileUnitAtIndex(0);
1528
1528
15291529 // Get the compile unit DIE is valid.
15301530 auto CUDie = U->getUnitDIE(false);
15311531 EXPECT_TRUE(CUDie.isValid());
1532
1532
15331533 auto FuncSpecDie = CUDie.getFirstChild();
15341534 auto FuncDie = FuncSpecDie.getSibling();
15351535
15461546 // Make sure we can't extract the linkage name attributes when using
15471547 // DWARFDie::find() since it won't check the DW_AT_specification DIE.
15481548 EXPECT_FALSE(FuncDie.find(Attrs).hasValue());
1549
1549
15501550 // Make sure we can extract the name from the specification die when using
15511551 // DWARFDie::findRecursively() since it should recurse through the
15521552 // DW_AT_specification DIE.
20762076 - ''
20772077 - /tmp/main.c
20782078 - /tmp/foo.c
2079 debug_abbrev:
2079 debug_abbrev:
20802080 - Code: 0x00000001
20812081 Tag: DW_TAG_compile_unit
20822082 Children: DW_CHILDREN_no
2083 Attributes:
2083 Attributes:
20842084 - Attribute: DW_AT_name
20852085 Form: DW_FORM_strp
20862086 - Attribute: DW_AT_stmt_list
20872087 Form: DW_FORM_sec_offset
2088 debug_info:
2089 - Length:
2088 debug_info:
2089 - Length:
20902090 TotalLength: 16
20912091 Version: 4
20922092 AbbrOffset: 0
20932093 AddrSize: 8
2094 Entries:
2094 Entries:
20952095 - AbbrCode: 0x00000001
2096 Values:
2096 Values:
20972097 - Value: 0x0000000000000001
20982098 - Value: 0x0000000000000000
2099 - Length:
2099 - Length:
21002100 TotalLength: 16
21012101 Version: 4
21022102 AbbrOffset: 0
21032103 AddrSize: 8
2104 Entries:
2104 Entries:
21052105 - AbbrCode: 0x00000001
2106 Values:
2106 Values:
21072107 - Value: 0x000000000000000D
21082108 - Value: 0x0000000000000000
2109 debug_line:
2110 - Length:
2109 debug_line:
2110 - Length:
21112111 TotalLength: 60
21122112 Version: 2
21132113 PrologueLength: 34
21172117 LineRange: 14
21182118 OpcodeBase: 13
21192119 StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
2120 IncludeDirs:
2120 IncludeDirs:
21212121 - /tmp
2122 Files:
2122 Files:
21232123 - Name: main.c
21242124 DirIdx: 1
21252125 ModTime: 0
21262126 Length: 0
2127 Opcodes:
2127 Opcodes:
21282128 - Opcode: DW_LNS_extended_op
21292129 ExtLen: 9
21302130 SubOpcode: DW_LNE_set_address