Index: unittests/Core/CMakeLists.txt =================================================================== --- unittests/Core/CMakeLists.txt +++ unittests/Core/CMakeLists.txt @@ -15,8 +15,3 @@ LINK_COMPONENTS Support ) - -set(test_inputs - mangled-function-names.yaml - ) -add_unittest_inputs(LLDBCoreTests "${test_inputs}") Index: unittests/Core/Inputs/mangled-function-names.yaml =================================================================== --- unittests/Core/Inputs/mangled-function-names.yaml +++ /dev/null @@ -1,129 +0,0 @@ ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - AddressAlign: 0x0000000000000010 - Content: 554889E58B0425A80000005DC30F1F00 - - Name: .anothertext - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Address: 0x0000000000000010 - AddressAlign: 0x0000000000000010 - Content: 554889E54883EC20488D0425A8000000C745FC00000000488945F0488B45F08B08894DECE8C7FFFFFF8B4DEC01C189C84883C4205D746573742073747200C3 - - Name: .eh_frame - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC ] - Address: 0x0000000000000050 - AddressAlign: 0x0000000000000008 - Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C00000090FFFFFF0D00000000410E108602430D06000000000000001C0000003C00000080FFFFFF3F00000000410E108602430D0600000000000000 - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_WRITE, SHF_ALLOC ] - Address: 0x00000000000000A8 - AddressAlign: 0x0000000000000004 - Content: '01000000' - - Name: .comment - Type: SHT_PROGBITS - Flags: [ SHF_MERGE, SHF_STRINGS ] - AddressAlign: 0x0000000000000001 - Content: 5562756E747520636C616E672076657273696F6E20332E352D317562756E74753120287472756E6B2920286261736564206F6E204C4C564D20332E352900 -Symbols: - - Type: STT_SECTION - Section: .text - - Type: STT_SECTION - Section: .anothertext - Value: 0x0000000000000010 - - Type: STT_SECTION - Section: .eh_frame - Value: 0x0000000000000050 - - Type: STT_SECTION - Section: .data - Value: 0x00000000000000A8 - - Type: STT_SECTION - Section: .comment - - Name: /tmp/a.c - Type: STT_FILE - - Type: STT_FILE - - Name: somedata - Type: STT_OBJECT - Section: .anothertext - Value: 0x0000000000000045 - Binding: STB_GLOBAL - - Name: main - Type: STT_FUNC - Section: .anothertext - Value: 0x0000000000000010 - Size: 0x000000000000003F - Binding: STB_GLOBAL - - Name: _Z3foov - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: puts@GLIBC_2.5 - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: puts@GLIBC_2.6 - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _Z5annotv@VERSION3 - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _ZN1AC2Ev - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _ZN1AD2Ev - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _ZN1A3barEv - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _ZGVZN4llvm4dbgsEvE7thestrm - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _ZZN4llvm4dbgsEvE7thestrm - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _ZTVN5clang4DeclE - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: -[ObjCfoo] - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: +[B ObjCbar(WithCategory)] - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL - - Name: _Z12undemangableEvx42 - Type: STT_FUNC - Section: .text - Size: 0x000000000000000D - Binding: STB_GLOBAL -... Index: unittests/Core/MangledTest.cpp =================================================================== --- unittests/Core/MangledTest.cpp +++ unittests/Core/MangledTest.cpp @@ -56,15 +56,113 @@ ObjectFileELF::Initialize(); SymbolFileSymtab::Initialize(); - llvm::SmallString<128> Obj; - ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile( - "mangled-function-names-%%%%%%", "obj", Obj)); - llvm::FileRemover Deleter(Obj); - ASSERT_THAT_ERROR(ReadYAMLObjectFile("mangled-function-names.yaml", Obj), - llvm::Succeeded()); - - ModuleSpec Spec{FileSpec(Obj)}; - Spec.GetSymbolFileSpec().SetFile(Obj, FileSpec::Style::native); + auto ExpectedFile = TestFile::fromYaml(R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 0x0000000000000010 + Size: 0x20 + - Name: .anothertext + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000000010 + AddressAlign: 0x0000000000000010 + Size: 0x40 + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x00000000000000A8 + AddressAlign: 0x0000000000000004 + Content: '01000000' +Symbols: + - Name: somedata + Type: STT_OBJECT + Section: .anothertext + Value: 0x0000000000000045 + Binding: STB_GLOBAL + - Name: main + Type: STT_FUNC + Section: .anothertext + Value: 0x0000000000000010 + Size: 0x000000000000003F + Binding: STB_GLOBAL + - Name: _Z3foov + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: puts@GLIBC_2.5 + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: puts@GLIBC_2.6 + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _Z5annotv@VERSION3 + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _ZN1AC2Ev + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _ZN1AD2Ev + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _ZN1A3barEv + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _ZGVZN4llvm4dbgsEvE7thestrm + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _ZZN4llvm4dbgsEvE7thestrm + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _ZTVN5clang4DeclE + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: -[ObjCfoo] + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: +[B ObjCbar(WithCategory)] + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL + - Name: _Z12undemangableEvx42 + Type: STT_FUNC + Section: .text + Size: 0x000000000000000D + Binding: STB_GLOBAL +... +)"); + ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded()); + + ModuleSpec Spec{FileSpec(ExpectedFile->name())}; auto M = std::make_shared(Spec); auto Count = [M](const char *Name, FunctionNameType Type) -> int { Index: unittests/ObjectFile/ELF/CMakeLists.txt =================================================================== --- unittests/ObjectFile/ELF/CMakeLists.txt +++ unittests/ObjectFile/ELF/CMakeLists.txt @@ -11,6 +11,5 @@ set(test_inputs early-section-headers.so - sections-resolve-consistently.yaml ) add_unittest_inputs(ObjectFileELFTests "${test_inputs}") Index: unittests/ObjectFile/ELF/Inputs/sections-resolve-consistently.yaml =================================================================== --- unittests/ObjectFile/ELF/Inputs/sections-resolve-consistently.yaml +++ /dev/null @@ -1,52 +0,0 @@ ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 - Entry: 0x0000000000400180 -Sections: - - Name: .note.gnu.build-id - Type: SHT_NOTE - Flags: [ SHF_ALLOC ] - Address: 0x0000000000400158 - AddressAlign: 0x0000000000000004 - Content: 040000001400000003000000474E55003F3EC29E3FD83E49D18C4D49CD8A730CC13117B6 - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Address: 0x0000000000400180 - AddressAlign: 0x0000000000000010 - Content: 554889E58B042500106000890425041060005DC3 - - Name: .data - Type: SHT_PROGBITS - Flags: [ SHF_WRITE, SHF_ALLOC ] - Address: 0x0000000000601000 - AddressAlign: 0x0000000000000004 - Content: 2F000000 - - Name: .bss - Type: SHT_NOBITS - Flags: [ SHF_WRITE, SHF_ALLOC ] - Address: 0x0000000000601004 - AddressAlign: 0x0000000000000004 - Size: 0x0000000000000004 -Symbols: - - Name: Y - Type: STT_OBJECT - Section: .data - Value: 0x0000000000601000 - Size: 0x0000000000000004 - Binding: STB_GLOBAL - - Name: _start - Type: STT_FUNC - Section: .text - Value: 0x0000000000400180 - Size: 0x0000000000000014 - Binding: STB_GLOBAL - - Name: X - Type: STT_OBJECT - Section: .bss - Value: 0x0000000000601004 - Size: 0x0000000000000004 - Binding: STB_GLOBAL -... Index: unittests/ObjectFile/ELF/TestObjectFileELF.cpp =================================================================== --- unittests/ObjectFile/ELF/TestObjectFileELF.cpp +++ unittests/ObjectFile/ELF/TestObjectFileELF.cpp @@ -48,16 +48,65 @@ }; TEST_F(ObjectFileELFTest, SectionsResolveConsistently) { - llvm::SmallString<128> obj; - ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile( - "sections-resolve-consistently-%%%%%%", "obj", obj)); - llvm::FileRemover remover(obj); - ASSERT_THAT_ERROR( - ReadYAMLObjectFile("sections-resolve-consistently.yaml", obj), - llvm::Succeeded()); + auto ExpectedFile = TestFile::fromYaml(R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x0000000000400180 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400158 + AddressAlign: 0x0000000000000004 + Content: 040000001400000003000000474E55003F3EC29E3FD83E49D18C4D49CD8A730CC13117B6 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000400180 + AddressAlign: 0x0000000000000010 + Content: 554889E58B042500106000890425041060005DC3 + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x0000000000601000 + AddressAlign: 0x0000000000000004 + Content: 2F000000 + - Name: .bss + Type: SHT_NOBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x0000000000601004 + AddressAlign: 0x0000000000000004 + Size: 0x0000000000000004 +Symbols: + - Name: Y + Type: STT_OBJECT + Section: .data + Value: 0x0000000000601000 + Size: 0x0000000000000004 + Binding: STB_GLOBAL + - Name: _start + Type: STT_FUNC + Section: .text + Value: 0x0000000000400180 + Size: 0x0000000000000014 + Binding: STB_GLOBAL + - Name: X + Type: STT_OBJECT + Section: .bss + Value: 0x0000000000601004 + Size: 0x0000000000000004 + Binding: STB_GLOBAL +... +)"); + ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded()); - ModuleSpec spec{FileSpec(obj)}; - spec.GetSymbolFileSpec().SetFile(obj, FileSpec::Style::native); + ModuleSpec spec{FileSpec(ExpectedFile->name())}; + spec.GetSymbolFileSpec().SetFile(ExpectedFile->name(), + FileSpec::Style::native); auto module_sp = std::make_shared(spec); SectionList *list = module_sp->GetSectionList(); ASSERT_NE(nullptr, list); Index: unittests/Symbol/CMakeLists.txt =================================================================== --- unittests/Symbol/CMakeLists.txt +++ unittests/Symbol/CMakeLists.txt @@ -16,9 +16,3 @@ lldbPluginSymbolFileSymtab LLVMTestingSupport ) - -set(test_inputs - basic-call-frame-info.yaml - inlined-functions.yaml - ) -add_unittest_inputs(SymbolTests "${test_inputs}") Index: unittests/Symbol/Inputs/basic-call-frame-info.yaml =================================================================== --- unittests/Symbol/Inputs/basic-call-frame-info.yaml +++ /dev/null @@ -1,140 +0,0 @@ ---- !ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_DYN - Machine: EM_X86_64 - Entry: 0x0000000000000260 -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Address: 0x0000000000000260 - AddressAlign: 0x0000000000000010 - Content: 554889E5897DFC8B45FC5DC30F1F4000554889E5897DFC8B45FC5DC30F1F4000554889E5897DFC8B45FC5DC3 -#0000000000000260 : -# 260: 55 push %rbp -# 261: 48 89 e5 mov %rsp,%rbp -# 264: 89 7d fc mov %edi,-0x4(%rbp) -# 267: 8b 45 fc mov -0x4(%rbp),%eax -# 26a: 5d pop %rbp -# 26b: c3 retq -# 26c: 0f 1f 40 00 nopl 0x0(%rax) -# -#0000000000000270 : -# 270: 55 push %rbp -# 271: 48 89 e5 mov %rsp,%rbp -# 274: 89 7d fc mov %edi,-0x4(%rbp) -# 277: 8b 45 fc mov -0x4(%rbp),%eax -# 27a: 5d pop %rbp -# 27b: c3 retq -# 27c: 0f 1f 40 00 nopl 0x0(%rax) -# -#0000000000000280 : -# 280: 55 push %rbp -# 281: 48 89 e5 mov %rsp,%rbp -# 284: 89 7d fc mov %edi,-0x4(%rbp) -# 287: 8b 45 fc mov -0x4(%rbp),%eax -# 28a: 5d pop %rbp -# 28b: c3 retq - - Name: .eh_frame - Type: SHT_X86_64_UNWIND - Flags: [ SHF_ALLOC ] - Address: 0x0000000000000290 - AddressAlign: 0x0000000000000008 - Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000B0FFFFFF0C00000000410E108602430D0600000000000000 -#00000000 0000000000000014 00000000 CIE -# Version: 1 -# Augmentation: "zR" -# Code alignment factor: 1 -# Data alignment factor: -8 -# Return address column: 16 -# Augmentation data: 1b -# -# DW_CFA_def_cfa: r7 (rsp) ofs 8 -# DW_CFA_offset: r16 (rip) at cfa-8 -# DW_CFA_nop -# DW_CFA_nop -# -#00000018 000000000000001c 0000001c FDE cie=00000000 pc=ffffffffffffffd0..ffffffffffffffdc -# DW_CFA_advance_loc: 1 to ffffffffffffffd1 -# DW_CFA_def_cfa_offset: 16 -# DW_CFA_offset: r6 (rbp) at cfa-16 -# DW_CFA_advance_loc: 3 to ffffffffffffffd4 -# DW_CFA_def_cfa_register: r6 (rbp) -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop - - Name: .debug_frame - Type: SHT_PROGBITS - AddressAlign: 0x0000000000000008 - Content: 14000000FFFFFFFF03000178100C070890010000000000001C0000000000000070020000000000000C00000000000000410E108602430D0614000000FFFFFFFF040008000178100C07089001000000001C0000003800000080020000000000000C00000000000000410E108602430D06 -#00000000 0000000000000014 ffffffff CIE -# Version: 3 -# Augmentation: "" -# Code alignment factor: 1 -# Data alignment factor: -8 -# Return address column: 16 -# -# DW_CFA_def_cfa: r7 (rsp) ofs 8 -# DW_CFA_offset: r16 (rip) at cfa-8 -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# -#00000018 000000000000001c 00000000 FDE cie=00000000 pc=0000000000000270..000000000000027c -# DW_CFA_advance_loc: 1 to 0000000000000271 -# DW_CFA_def_cfa_offset: 16 -# DW_CFA_offset: r6 (rbp) at cfa-16 -# DW_CFA_advance_loc: 3 to 0000000000000274 -# DW_CFA_def_cfa_register: r6 (rbp) -# -#00000038 0000000000000014 ffffffff CIE -# Version: 4 -# Augmentation: "" -# Pointer Size: 8 -# Segment Size: 0 -# Code alignment factor: 1 -# Data alignment factor: -8 -# Return address column: 16 -# -# DW_CFA_def_cfa: r7 (rsp) ofs 8 -# DW_CFA_offset: r16 (rip) at cfa-8 -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# DW_CFA_nop -# -#00000050 000000000000001c 00000038 FDE cie=00000038 pc=0000000000000280..000000000000028c -# DW_CFA_advance_loc: 1 to 0000000000000281 -# DW_CFA_def_cfa_offset: 16 -# DW_CFA_offset: r6 (rbp) at cfa-16 -# DW_CFA_advance_loc: 3 to 0000000000000284 -# DW_CFA_def_cfa_register: r6 (rbp) -Symbols: - - Name: eh_frame - Type: STT_FUNC - Section: .text - Value: 0x0000000000000260 - Size: 0x000000000000000C - Binding: STB_GLOBAL - - Name: debug_frame3 - Type: STT_FUNC - Section: .text - Value: 0x0000000000000270 - Size: 0x000000000000000C - Binding: STB_GLOBAL - - Name: debug_frame4 - Type: STT_FUNC - Section: .text - Value: 0x0000000000000280 - Size: 0x000000000000000C - Binding: STB_GLOBAL -... Index: unittests/Symbol/Inputs/inlined-functions.yaml =================================================================== --- unittests/Symbol/Inputs/inlined-functions.yaml +++ /dev/null @@ -1,943 +0,0 @@ ---- !mach-o -FileHeader: - magic: 0xFEEDFACF - cputype: 0x01000007 - cpusubtype: 0x00000003 - filetype: 0x00000001 - ncmds: 4 - sizeofcmds: 1160 - flags: 0x00002000 - reserved: 0x00000000 -LoadCommands: - - cmd: LC_SEGMENT_64 - cmdsize: 1032 - segname: '' - vmaddr: 0 - vmsize: 2022 - fileoff: 1192 - filesize: 2022 - maxprot: 7 - initprot: 7 - nsects: 6 - flags: 0 - Sections: - - sectname: __text - segname: __TEXT - addr: 0x0000000000000000 - size: 224 - offset: 0x000004A8 - align: 4 - reloff: 0x00000C90 - nreloc: 1 - flags: 0x80000400 - reserved1: 0x00000000 - reserved2: 0x00000000 - reserved3: 0x00000000 - - sectname: __debug_str - segname: __DWARF - addr: 0x00000000000000E0 - size: 223 - offset: 0x00000588 - align: 0 - reloff: 0x00000000 - nreloc: 0 - flags: 0x02000000 - reserved1: 0x00000000 - reserved2: 0x00000000 - reserved3: 0x00000000 - - sectname: __debug_abbrev - segname: __DWARF - addr: 0x00000000000001BF - size: 190 - offset: 0x00000667 - align: 0 - reloff: 0x00000000 - nreloc: 0 - flags: 0x02000000 - reserved1: 0x00000000 - reserved2: 0x00000000 - reserved3: 0x00000000 - - sectname: __debug_info - segname: __DWARF - addr: 0x000000000000027D - size: 583 - offset: 0x00000725 - align: 0 - reloff: 0x00000C98 - nreloc: 8 - flags: 0x02000000 - reserved1: 0x00000000 - reserved2: 0x00000000 - reserved3: 0x00000000 - - sectname: __compact_unwind - segname: __LD - addr: 0x0000000000000670 - size: 64 - offset: 0x00000B18 - align: 3 - reloff: 0x00000CD8 - nreloc: 2 - flags: 0x02000000 - reserved1: 0x00000000 - reserved2: 0x00000000 - reserved3: 0x00000000 - - sectname: __debug_line - segname: __DWARF - addr: 0x0000000000000718 - size: 206 - offset: 0x00000BC0 - align: 0 - reloff: 0x00000CE8 - nreloc: 1 - flags: 0x02000000 - reserved1: 0x00000000 - reserved2: 0x00000000 - reserved3: 0x00000000 - - cmd: LC_BUILD_VERSION - cmdsize: 24 - platform: 1 - minos: 658944 - sdk: 658944 - ntools: 0 - - cmd: LC_SYMTAB - cmdsize: 24 - symoff: 3312 - nsyms: 2 - stroff: 3344 - strsize: 20 - - cmd: LC_DYSYMTAB - cmdsize: 80 - ilocalsym: 0 - nlocalsym: 0 - iextdefsym: 0 - nextdefsym: 2 - iundefsym: 2 - nundefsym: 0 - tocoff: 0 - ntoc: 0 - modtaboff: 0 - nmodtab: 0 - extrefsymoff: 0 - nextrefsyms: 0 - indirectsymoff: 0 - nindirectsyms: 0 - extreloff: 0 - nextrel: 0 - locreloff: 0 - nlocrel: 0 -LinkEditData: - NameList: - - n_strx: 7 - n_type: 0x0F - n_sect: 1 - n_desc: 0 - n_value: 0 - - n_strx: 1 - n_type: 0x0F - n_sect: 1 - n_desc: 0 - n_value: 32 - StringTable: - - '' - - _main - - __Z4sum3iii - - '' -DWARF: - debug_str: - - 'Apple LLVM version 10.0.1 (clang-1001.0.46.3)' - - inlined-functions.cpp - - '/Users/aadsm/Projects/llvm-project/lldb/unittests/Symbol/Inputs' - - sum3 - - _Z4sum3iii - - _Z4sum2ii - - sum2 - - int - - a - - b - - result - - _Z4sum4iiii - - sum4 - - c - - d - - main - - argc - - argv - - char - - sum - debug_abbrev: - - Code: 0x00000001 - Tag: DW_TAG_compile_unit - Children: DW_CHILDREN_yes - Attributes: - - Attribute: DW_AT_producer - Form: DW_FORM_strp - - Attribute: DW_AT_language - Form: DW_FORM_data2 - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_stmt_list - Form: DW_FORM_sec_offset - - Attribute: DW_AT_comp_dir - Form: DW_FORM_strp - - Attribute: DW_AT_low_pc - Form: DW_FORM_addr - - Attribute: DW_AT_high_pc - Form: DW_FORM_data4 - - Code: 0x00000002 - Tag: DW_TAG_subprogram - Children: DW_CHILDREN_yes - Attributes: - - Attribute: DW_AT_low_pc - Form: DW_FORM_addr - - Attribute: DW_AT_high_pc - Form: DW_FORM_data4 - - Attribute: DW_AT_frame_base - Form: DW_FORM_exprloc - - Attribute: DW_AT_linkage_name - Form: DW_FORM_strp - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_decl_file - Form: DW_FORM_data1 - - Attribute: DW_AT_decl_line - Form: DW_FORM_data1 - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - - Attribute: DW_AT_external - Form: DW_FORM_flag_present - - Code: 0x00000003 - Tag: DW_TAG_formal_parameter - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_location - Form: DW_FORM_exprloc - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_decl_file - Form: DW_FORM_data1 - - Attribute: DW_AT_decl_line - Form: DW_FORM_data1 - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - - Code: 0x00000004 - Tag: DW_TAG_variable - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_location - Form: DW_FORM_exprloc - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_decl_file - Form: DW_FORM_data1 - - Attribute: DW_AT_decl_line - Form: DW_FORM_data1 - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - - Code: 0x00000005 - Tag: DW_TAG_subprogram - Children: DW_CHILDREN_yes - Attributes: - - Attribute: DW_AT_linkage_name - Form: DW_FORM_strp - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_decl_file - Form: DW_FORM_data1 - - Attribute: DW_AT_decl_line - Form: DW_FORM_data1 - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - - Attribute: DW_AT_external - Form: DW_FORM_flag_present - - Attribute: DW_AT_inline - Form: DW_FORM_data1 - - Code: 0x00000006 - Tag: DW_TAG_formal_parameter - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_decl_file - Form: DW_FORM_data1 - - Attribute: DW_AT_decl_line - Form: DW_FORM_data1 - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - - Code: 0x00000007 - Tag: DW_TAG_variable - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_decl_file - Form: DW_FORM_data1 - - Attribute: DW_AT_decl_line - Form: DW_FORM_data1 - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - - Code: 0x00000008 - Tag: DW_TAG_base_type - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_encoding - Form: DW_FORM_data1 - - Attribute: DW_AT_byte_size - Form: DW_FORM_data1 - - Code: 0x00000009 - Tag: DW_TAG_subprogram - Children: DW_CHILDREN_yes - Attributes: - - Attribute: DW_AT_low_pc - Form: DW_FORM_addr - - Attribute: DW_AT_high_pc - Form: DW_FORM_data4 - - Attribute: DW_AT_frame_base - Form: DW_FORM_exprloc - - Attribute: DW_AT_name - Form: DW_FORM_strp - - Attribute: DW_AT_decl_file - Form: DW_FORM_data1 - - Attribute: DW_AT_decl_line - Form: DW_FORM_data1 - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - - Attribute: DW_AT_external - Form: DW_FORM_flag_present - - Code: 0x0000000A - Tag: DW_TAG_inlined_subroutine - Children: DW_CHILDREN_yes - Attributes: - - Attribute: DW_AT_abstract_origin - Form: DW_FORM_ref4 - - Attribute: DW_AT_low_pc - Form: DW_FORM_addr - - Attribute: DW_AT_high_pc - Form: DW_FORM_data4 - - Attribute: DW_AT_call_file - Form: DW_FORM_data1 - - Attribute: DW_AT_call_line - Form: DW_FORM_data1 - - Code: 0x0000000B - Tag: DW_TAG_formal_parameter - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_location - Form: DW_FORM_exprloc - - Attribute: DW_AT_abstract_origin - Form: DW_FORM_ref4 - - Code: 0x0000000C - Tag: DW_TAG_variable - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_location - Form: DW_FORM_exprloc - - Attribute: DW_AT_abstract_origin - Form: DW_FORM_ref4 - - Code: 0x0000000D - Tag: DW_TAG_pointer_type - Children: DW_CHILDREN_no - Attributes: - - Attribute: DW_AT_type - Form: DW_FORM_ref4 - debug_info: - - Length: - TotalLength: 579 - Version: 4 - AbbrOffset: 0 - AddrSize: 8 - Entries: - - AbbrCode: 0x00000001 - Values: - - Value: 0x0000000000000000 - - Value: 0x0000000000000004 - - Value: 0x000000000000002E - - Value: 0x0000000000000000 - - Value: 0x0000000000000044 - - Value: 0x0000000000000000 - - Value: 0x00000000000000E0 - - AbbrCode: 0x00000002 - Values: - - Value: 0x0000000000000000 - - Value: 0x000000000000001E - - Value: 0x0000000000000001 - BlockData: - - 0x56 - - Value: 0x0000000000000089 - - Value: 0x0000000000000084 - - Value: 0x0000000000000001 - - Value: 0x0000000000000006 - - Value: 0x00000000000000B2 - - Value: 0x0000000000000001 - - AbbrCode: 0x00000003 - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x7C - - Value: 0x00000000000000A7 - - Value: 0x0000000000000001 - - Value: 0x0000000000000006 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000003 - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x78 - - Value: 0x00000000000000A9 - - Value: 0x0000000000000001 - - Value: 0x0000000000000006 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000003 - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x74 - - Value: 0x00000000000000C3 - - Value: 0x0000000000000001 - - Value: 0x0000000000000006 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000004 - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x70 - - Value: 0x00000000000000AB - - Value: 0x0000000000000001 - - Value: 0x0000000000000007 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x00000005 - Values: - - Value: 0x0000000000000094 - - Value: 0x000000000000009E - - Value: 0x0000000000000001 - - Value: 0x0000000000000001 - - Value: 0x00000000000000B2 - - Value: 0x0000000000000001 - - Value: 0x0000000000000001 - - AbbrCode: 0x00000006 - Values: - - Value: 0x00000000000000A7 - - Value: 0x0000000000000001 - - Value: 0x0000000000000001 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000006 - Values: - - Value: 0x00000000000000A9 - - Value: 0x0000000000000001 - - Value: 0x0000000000000001 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000007 - Values: - - Value: 0x00000000000000AB - - Value: 0x0000000000000001 - - Value: 0x0000000000000002 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x00000008 - Values: - - Value: 0x00000000000000A3 - - Value: 0x0000000000000005 - - Value: 0x0000000000000004 - - AbbrCode: 0x00000005 - Values: - - Value: 0x00000000000000B2 - - Value: 0x00000000000000BE - - Value: 0x0000000000000001 - - Value: 0x000000000000000B - - Value: 0x00000000000000B2 - - Value: 0x0000000000000001 - - Value: 0x0000000000000001 - - AbbrCode: 0x00000006 - Values: - - Value: 0x00000000000000A7 - - Value: 0x0000000000000001 - - Value: 0x000000000000000B - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000006 - Values: - - Value: 0x00000000000000A9 - - Value: 0x0000000000000001 - - Value: 0x000000000000000B - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000006 - Values: - - Value: 0x00000000000000C3 - - Value: 0x0000000000000001 - - Value: 0x000000000000000B - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000006 - Values: - - Value: 0x00000000000000C5 - - Value: 0x0000000000000001 - - Value: 0x000000000000000B - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000007 - Values: - - Value: 0x00000000000000AB - - Value: 0x0000000000000001 - - Value: 0x000000000000000C - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x00000009 - Values: - - Value: 0x0000000000000020 - - Value: 0x00000000000000C0 - - Value: 0x0000000000000001 - BlockData: - - 0x56 - - Value: 0x00000000000000C7 - - Value: 0x0000000000000001 - - Value: 0x0000000000000011 - - Value: 0x00000000000000B2 - - Value: 0x0000000000000001 - - AbbrCode: 0x00000003 - Values: - - Value: 0x0000000000000003 - BlockData: - - 0x91 - - 0xB4 - - 0x7F - - Value: 0x00000000000000CC - - Value: 0x0000000000000001 - - Value: 0x0000000000000011 - - Value: 0x00000000000000B2 - - AbbrCode: 0x00000003 - Values: - - Value: 0x0000000000000003 - BlockData: - - 0x91 - - 0xA8 - - 0x7F - - Value: 0x00000000000000D1 - - Value: 0x0000000000000001 - - Value: 0x0000000000000011 - - Value: 0x0000000000000235 - - AbbrCode: 0x00000004 - Values: - - Value: 0x0000000000000003 - BlockData: - - 0x91 - - 0xA4 - - 0x7F - - Value: 0x00000000000000DB - - Value: 0x0000000000000001 - - Value: 0x0000000000000013 - - Value: 0x00000000000000B2 - - AbbrCode: 0x0000000A - Values: - - Value: 0x0000000000000080 - - Value: 0x000000000000005A - - Value: 0x0000000000000025 - - Value: 0x0000000000000001 - - Value: 0x0000000000000012 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x44 - - Value: 0x0000000000000090 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x40 - - Value: 0x000000000000009B - - AbbrCode: 0x0000000C - Values: - - Value: 0x0000000000000003 - BlockData: - - 0x91 - - 0xBC - - 0x7F - - Value: 0x00000000000000A6 - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x0000000A - Values: - - Value: 0x00000000000000B9 - - Value: 0x000000000000007F - - Value: 0x000000000000003C - - Value: 0x0000000000000001 - - Value: 0x0000000000000013 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x64 - - Value: 0x00000000000000C9 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x60 - - Value: 0x00000000000000D4 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x5C - - Value: 0x00000000000000DF - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x58 - - Value: 0x00000000000000EA - - AbbrCode: 0x0000000C - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x54 - - Value: 0x00000000000000F5 - - AbbrCode: 0x0000000A - Values: - - Value: 0x0000000000000080 - - Value: 0x000000000000008B - - Value: 0x000000000000000C - - Value: 0x0000000000000001 - - Value: 0x000000000000000C - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x70 - - Value: 0x0000000000000090 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x6C - - Value: 0x000000000000009B - - AbbrCode: 0x0000000C - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x68 - - Value: 0x00000000000000A6 - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x0000000A - Values: - - Value: 0x0000000000000080 - - Value: 0x00000000000000A3 - - Value: 0x0000000000000009 - - Value: 0x0000000000000001 - - Value: 0x000000000000000C - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x7C - - Value: 0x0000000000000090 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x78 - - Value: 0x000000000000009B - - AbbrCode: 0x0000000C - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x74 - - Value: 0x00000000000000A6 - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x0000000A - Values: - - Value: 0x0000000000000080 - - Value: 0x00000000000000CC - - Value: 0x0000000000000009 - - Value: 0x0000000000000001 - - Value: 0x0000000000000014 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x50 - - Value: 0x0000000000000090 - - AbbrCode: 0x0000000B - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x4C - - Value: 0x000000000000009B - - AbbrCode: 0x0000000C - Values: - - Value: 0x0000000000000002 - BlockData: - - 0x91 - - 0x48 - - Value: 0x00000000000000A6 - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x00000000 - Values: [] - - AbbrCode: 0x0000000D - Values: - - Value: 0x000000000000023A - - AbbrCode: 0x0000000D - Values: - - Value: 0x000000000000023F - - AbbrCode: 0x00000008 - Values: - - Value: 0x00000000000000D6 - - Value: 0x0000000000000006 - - Value: 0x0000000000000001 - - AbbrCode: 0x00000000 - Values: [] - debug_line: - - Length: - TotalLength: 202 - Version: 4 - PrologueLength: 45 - MinInstLength: 1 - MaxOpsPerInst: 1 - DefaultIsStmt: 1 - LineBase: 251 - LineRange: 14 - OpcodeBase: 13 - StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ] - IncludeDirs: [] - Files: - - Name: inlined-functions.cpp - DirIdx: 0 - ModTime: 0 - Length: 0 - Opcodes: - - Opcode: DW_LNS_extended_op - ExtLen: 9 - SubOpcode: DW_LNE_set_address - Data: 0 - - Opcode: 0x17 - Data: 0 - - Opcode: DW_LNS_set_column - Data: 18 - - Opcode: DW_LNS_set_prologue_end - Data: 18 - - Opcode: 0xC9 - Data: 18 - - Opcode: DW_LNS_set_column - Data: 20 - - Opcode: DW_LNS_negate_stmt - Data: 20 - - Opcode: 0x3C - Data: 20 - - Opcode: DW_LNS_set_column - Data: 24 - - Opcode: 0x3C - Data: 24 - - Opcode: DW_LNS_set_column - Data: 9 - - Opcode: 0x3C - Data: 9 - - Opcode: DW_LNS_set_column - Data: 12 - - Opcode: DW_LNS_negate_stmt - Data: 12 - - Opcode: 0x3D - Data: 12 - - Opcode: DW_LNS_set_column - Data: 5 - - Opcode: DW_LNS_negate_stmt - Data: 5 - - Opcode: 0x3C - Data: 5 - - Opcode: DW_LNS_set_column - Data: 0 - - Opcode: DW_LNS_negate_stmt - Data: 0 - - Opcode: DW_LNS_advance_line - SData: 9 - Data: 0 - - Opcode: 0x4A - Data: 0 - - Opcode: DW_LNS_set_column - Data: 5 - - Opcode: DW_LNS_set_prologue_end - Data: 5 - - Opcode: DW_LNS_const_add_pc - Data: 5 - - Opcode: 0x59 - Data: 5 - - Opcode: DW_LNS_set_column - Data: 18 - - Opcode: DW_LNS_advance_line - SData: -16 - Data: 18 - - Opcode: DW_LNS_advance_pc - Data: 36 - - Opcode: DW_LNS_copy - Data: 36 - - Opcode: DW_LNS_set_column - Data: 20 - - Opcode: DW_LNS_negate_stmt - Data: 20 - - Opcode: 0x3C - Data: 20 - - Opcode: DW_LNS_set_column - Data: 9 - - Opcode: 0x3C - Data: 9 - - Opcode: DW_LNS_set_column - Data: 23 - - Opcode: DW_LNS_negate_stmt - Data: 23 - - Opcode: DW_LNS_advance_line - SData: 10 - Data: 23 - - Opcode: DW_LNS_const_add_pc - Data: 23 - - Opcode: 0xD6 - Data: 23 - - Opcode: DW_LNS_set_column - Data: 26 - - Opcode: DW_LNS_negate_stmt - Data: 26 - - Opcode: 0x3C - Data: 26 - - Opcode: DW_LNS_set_column - Data: 18 - - Opcode: DW_LNS_negate_stmt - Data: 18 - - Opcode: DW_LNS_advance_line - SData: -10 - Data: 18 - - Opcode: 0x90 - Data: 18 - - Opcode: DW_LNS_set_column - Data: 20 - - Opcode: DW_LNS_negate_stmt - Data: 20 - - Opcode: 0x3C - Data: 20 - - Opcode: DW_LNS_set_column - Data: 9 - - Opcode: 0x3C - Data: 9 - - Opcode: DW_LNS_set_column - Data: 12 - - Opcode: DW_LNS_negate_stmt - Data: 12 - - Opcode: 0x3D - Data: 12 - - Opcode: DW_LNS_set_column - Data: 36 - - Opcode: DW_LNS_advance_line - SData: 9 - Data: 36 - - Opcode: 0x3C - Data: 36 - - Opcode: DW_LNS_set_column - Data: 39 - - Opcode: DW_LNS_negate_stmt - Data: 39 - - Opcode: 0x3C - Data: 39 - - Opcode: DW_LNS_set_column - Data: 18 - - Opcode: DW_LNS_negate_stmt - Data: 18 - - Opcode: DW_LNS_advance_line - SData: -10 - Data: 18 - - Opcode: 0x90 - Data: 18 - - Opcode: DW_LNS_set_column - Data: 20 - - Opcode: DW_LNS_negate_stmt - Data: 20 - - Opcode: 0x3C - Data: 20 - - Opcode: DW_LNS_set_column - Data: 9 - - Opcode: 0x3C - Data: 9 - - Opcode: DW_LNS_set_column - Data: 29 - - Opcode: DW_LNS_negate_stmt - Data: 29 - - Opcode: DW_LNS_advance_line - SData: 10 - Data: 29 - - Opcode: 0x3C - Data: 29 - - Opcode: DW_LNS_set_column - Data: 9 - - Opcode: DW_LNS_negate_stmt - Data: 9 - - Opcode: 0x3C - Data: 9 - - Opcode: DW_LNS_set_column - Data: 12 - - Opcode: DW_LNS_negate_stmt - Data: 12 - - Opcode: 0x3D - Data: 12 - - Opcode: 0x67 - Data: 12 - - Opcode: DW_LNS_set_column - Data: 9 - - Opcode: 0x41 - Data: 9 - - Opcode: DW_LNS_set_column - Data: 18 - - Opcode: DW_LNS_advance_line - SData: -17 - Data: 18 - - Opcode: DW_LNS_const_add_pc - Data: 18 - - Opcode: 0x12 - Data: 18 - - Opcode: DW_LNS_set_column - Data: 20 - - Opcode: DW_LNS_negate_stmt - Data: 20 - - Opcode: 0x3C - Data: 20 - - Opcode: DW_LNS_set_column - Data: 9 - - Opcode: 0x3C - Data: 9 - - Opcode: DW_LNS_set_column - Data: 5 - - Opcode: DW_LNS_negate_stmt - Data: 5 - - Opcode: DW_LNS_advance_line - SData: 19 - Data: 5 - - Opcode: 0x3C - Data: 5 - - Opcode: DW_LNS_advance_pc - Data: 11 - - Opcode: DW_LNS_extended_op - ExtLen: 1 - SubOpcode: DW_LNE_end_sequence - Data: 11 -... Index: unittests/Symbol/TestDWARFCallFrameInfo.cpp =================================================================== --- unittests/Symbol/TestDWARFCallFrameInfo.cpp +++ unittests/Symbol/TestDWARFCallFrameInfo.cpp @@ -87,14 +87,152 @@ void DWARFCallFrameInfoTest::TestBasic(DWARFCallFrameInfo::Type type, llvm::StringRef symbol) { - llvm::SmallString<128> obj; - ASSERT_NO_ERROR(llvm::sys::fs::createTemporaryFile( - "basic-call-frame-info-%%%%%%", "obj", obj)); - llvm::FileRemover obj_remover(obj); - ASSERT_THAT_ERROR(ReadYAMLObjectFile("basic-call-frame-info.yaml", obj), - llvm::Succeeded()); - - auto module_sp = std::make_shared(ModuleSpec(FileSpec(obj))); + auto ExpectedFile = TestFile::fromYaml(R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 + Entry: 0x0000000000000260 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x0000000000000260 + AddressAlign: 0x0000000000000010 + Content: 554889E5897DFC8B45FC5DC30F1F4000554889E5897DFC8B45FC5DC30F1F4000554889E5897DFC8B45FC5DC3 +#0000000000000260 : +# 260: 55 push %rbp +# 261: 48 89 e5 mov %rsp,%rbp +# 264: 89 7d fc mov %edi,-0x4(%rbp) +# 267: 8b 45 fc mov -0x4(%rbp),%eax +# 26a: 5d pop %rbp +# 26b: c3 retq +# 26c: 0f 1f 40 00 nopl 0x0(%rax) +# +#0000000000000270 : +# 270: 55 push %rbp +# 271: 48 89 e5 mov %rsp,%rbp +# 274: 89 7d fc mov %edi,-0x4(%rbp) +# 277: 8b 45 fc mov -0x4(%rbp),%eax +# 27a: 5d pop %rbp +# 27b: c3 retq +# 27c: 0f 1f 40 00 nopl 0x0(%rax) +# +#0000000000000280 : +# 280: 55 push %rbp +# 281: 48 89 e5 mov %rsp,%rbp +# 284: 89 7d fc mov %edi,-0x4(%rbp) +# 287: 8b 45 fc mov -0x4(%rbp),%eax +# 28a: 5d pop %rbp +# 28b: c3 retq + - Name: .eh_frame + Type: SHT_X86_64_UNWIND + Flags: [ SHF_ALLOC ] + Address: 0x0000000000000290 + AddressAlign: 0x0000000000000008 + Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000B0FFFFFF0C00000000410E108602430D0600000000000000 +#00000000 0000000000000014 00000000 CIE +# Version: 1 +# Augmentation: "zR" +# Code alignment factor: 1 +# Data alignment factor: -8 +# Return address column: 16 +# Augmentation data: 1b +# +# DW_CFA_def_cfa: r7 (rsp) ofs 8 +# DW_CFA_offset: r16 (rip) at cfa-8 +# DW_CFA_nop +# DW_CFA_nop +# +#00000018 000000000000001c 0000001c FDE cie=00000000 pc=ffffffffffffffd0..ffffffffffffffdc +# DW_CFA_advance_loc: 1 to ffffffffffffffd1 +# DW_CFA_def_cfa_offset: 16 +# DW_CFA_offset: r6 (rbp) at cfa-16 +# DW_CFA_advance_loc: 3 to ffffffffffffffd4 +# DW_CFA_def_cfa_register: r6 (rbp) +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop + - Name: .debug_frame + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000008 + Content: 14000000FFFFFFFF03000178100C070890010000000000001C0000000000000070020000000000000C00000000000000410E108602430D0614000000FFFFFFFF040008000178100C07089001000000001C0000003800000080020000000000000C00000000000000410E108602430D06 +#00000000 0000000000000014 ffffffff CIE +# Version: 3 +# Augmentation: "" +# Code alignment factor: 1 +# Data alignment factor: -8 +# Return address column: 16 +# +# DW_CFA_def_cfa: r7 (rsp) ofs 8 +# DW_CFA_offset: r16 (rip) at cfa-8 +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# +#00000018 000000000000001c 00000000 FDE cie=00000000 pc=0000000000000270..000000000000027c +# DW_CFA_advance_loc: 1 to 0000000000000271 +# DW_CFA_def_cfa_offset: 16 +# DW_CFA_offset: r6 (rbp) at cfa-16 +# DW_CFA_advance_loc: 3 to 0000000000000274 +# DW_CFA_def_cfa_register: r6 (rbp) +# +#00000038 0000000000000014 ffffffff CIE +# Version: 4 +# Augmentation: "" +# Pointer Size: 8 +# Segment Size: 0 +# Code alignment factor: 1 +# Data alignment factor: -8 +# Return address column: 16 +# +# DW_CFA_def_cfa: r7 (rsp) ofs 8 +# DW_CFA_offset: r16 (rip) at cfa-8 +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# DW_CFA_nop +# +#00000050 000000000000001c 00000038 FDE cie=00000038 pc=0000000000000280..000000000000028c +# DW_CFA_advance_loc: 1 to 0000000000000281 +# DW_CFA_def_cfa_offset: 16 +# DW_CFA_offset: r6 (rbp) at cfa-16 +# DW_CFA_advance_loc: 3 to 0000000000000284 +# DW_CFA_def_cfa_register: r6 (rbp) +Symbols: + - Name: eh_frame + Type: STT_FUNC + Section: .text + Value: 0x0000000000000260 + Size: 0x000000000000000C + Binding: STB_GLOBAL + - Name: debug_frame3 + Type: STT_FUNC + Section: .text + Value: 0x0000000000000270 + Size: 0x000000000000000C + Binding: STB_GLOBAL + - Name: debug_frame4 + Type: STT_FUNC + Section: .text + Value: 0x0000000000000280 + Size: 0x000000000000000C + Binding: STB_GLOBAL +... +)"); + ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded()); + + auto module_sp = + std::make_shared(ModuleSpec(FileSpec(ExpectedFile->name()))); SectionList *list = module_sp->GetSectionList(); ASSERT_NE(nullptr, list); Index: unittests/Symbol/TestLineEntry.cpp =================================================================== --- unittests/Symbol/TestLineEntry.cpp +++ unittests/Symbol/TestLineEntry.cpp @@ -33,13 +33,7 @@ class LineEntryTest : public testing::Test { public: - void SetUp() override { - FileSystem::Initialize(); - HostInfo::Initialize(); - ObjectFileMachO::Initialize(); - SymbolFileDWARF::Initialize(); - ClangASTContext::Initialize(); - } + void SetUp() override; void TearDown() override { ClangASTContext::Terminate(); @@ -50,44 +44,976 @@ } protected: - llvm::Expected GetModule(); llvm::Expected GetLineEntryForLine(uint32_t line); + llvm::Optional m_file; ModuleSP m_module_sp; }; -llvm::Expected LineEntryTest::GetModule() { - if (m_module_sp) - return m_module_sp; - - llvm::SmallString<128> obj; - if (auto ec = llvm::sys::fs::createTemporaryFile("source-%%%%%%", "obj", obj)) - return llvm::errorCodeToError(ec); - llvm::FileRemover obj_remover(obj); - if (auto error = ReadYAMLObjectFile("inlined-functions.yaml", obj)) - return llvm::Error(std::move(error)); - - m_module_sp = std::make_shared(ModuleSpec(FileSpec(obj))); - // Preload because the temporary file will be gone once we exit this function. - m_module_sp->PreloadSymbols(); - return m_module_sp; +void LineEntryTest::SetUp() { + FileSystem::Initialize(); + HostInfo::Initialize(); + ObjectFileMachO::Initialize(); + SymbolFileDWARF::Initialize(); + ClangASTContext::Initialize(); + auto ExpectedFile = TestFile::fromYaml(R"( +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x00000001 + ncmds: 4 + sizeofcmds: 1160 + flags: 0x00002000 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 1032 + segname: '' + vmaddr: 0 + vmsize: 2022 + fileoff: 1192 + filesize: 2022 + maxprot: 7 + initprot: 7 + nsects: 6 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000000 + size: 224 + offset: 0x000004A8 + align: 4 + reloff: 0x00000C90 + nreloc: 1 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_str + segname: __DWARF + addr: 0x00000000000000E0 + size: 223 + offset: 0x00000588 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_abbrev + segname: __DWARF + addr: 0x00000000000001BF + size: 190 + offset: 0x00000667 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_info + segname: __DWARF + addr: 0x000000000000027D + size: 583 + offset: 0x00000725 + align: 0 + reloff: 0x00000C98 + nreloc: 8 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __compact_unwind + segname: __LD + addr: 0x0000000000000670 + size: 64 + offset: 0x00000B18 + align: 3 + reloff: 0x00000CD8 + nreloc: 2 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_line + segname: __DWARF + addr: 0x0000000000000718 + size: 206 + offset: 0x00000BC0 + align: 0 + reloff: 0x00000CE8 + nreloc: 1 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_BUILD_VERSION + cmdsize: 24 + platform: 1 + minos: 658944 + sdk: 658944 + ntools: 0 + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 3312 + nsyms: 2 + stroff: 3344 + strsize: 20 + - cmd: LC_DYSYMTAB + cmdsize: 80 + ilocalsym: 0 + nlocalsym: 0 + iextdefsym: 0 + nextdefsym: 2 + iundefsym: 2 + nundefsym: 0 + tocoff: 0 + ntoc: 0 + modtaboff: 0 + nmodtab: 0 + extrefsymoff: 0 + nextrefsyms: 0 + indirectsymoff: 0 + nindirectsyms: 0 + extreloff: 0 + nextrel: 0 + locreloff: 0 + nlocrel: 0 +LinkEditData: + NameList: + - n_strx: 7 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 0 + - n_strx: 1 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 32 + StringTable: + - '' + - _main + - __Z4sum3iii + - '' +DWARF: + debug_str: + - 'Apple LLVM version 10.0.1 (clang-1001.0.46.3)' + - inlined-functions.cpp + - '/Users/aadsm/Projects/llvm-project/lldb/unittests/Symbol/Inputs' + - sum3 + - _Z4sum3iii + - _Z4sum2ii + - sum2 + - int + - a + - b + - result + - _Z4sum4iiii + - sum4 + - c + - d + - main + - argc + - argv + - char + - sum + debug_abbrev: + - Code: 0x00000001 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_producer + Form: DW_FORM_strp + - Attribute: DW_AT_language + Form: DW_FORM_data2 + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_stmt_list + Form: DW_FORM_sec_offset + - Attribute: DW_AT_comp_dir + Form: DW_FORM_strp + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Code: 0x00000002 + Tag: DW_TAG_subprogram + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Attribute: DW_AT_frame_base + Form: DW_FORM_exprloc + - Attribute: DW_AT_linkage_name + Form: DW_FORM_strp + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Attribute: DW_AT_external + Form: DW_FORM_flag_present + - Code: 0x00000003 + Tag: DW_TAG_formal_parameter + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000004 + Tag: DW_TAG_variable + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000005 + Tag: DW_TAG_subprogram + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_linkage_name + Form: DW_FORM_strp + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Attribute: DW_AT_external + Form: DW_FORM_flag_present + - Attribute: DW_AT_inline + Form: DW_FORM_data1 + - Code: 0x00000006 + Tag: DW_TAG_formal_parameter + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000007 + Tag: DW_TAG_variable + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000008 + Tag: DW_TAG_base_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_encoding + Form: DW_FORM_data1 + - Attribute: DW_AT_byte_size + Form: DW_FORM_data1 + - Code: 0x00000009 + Tag: DW_TAG_subprogram + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Attribute: DW_AT_frame_base + Form: DW_FORM_exprloc + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Attribute: DW_AT_external + Form: DW_FORM_flag_present + - Code: 0x0000000A + Tag: DW_TAG_inlined_subroutine + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_abstract_origin + Form: DW_FORM_ref4 + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Attribute: DW_AT_call_file + Form: DW_FORM_data1 + - Attribute: DW_AT_call_line + Form: DW_FORM_data1 + - Code: 0x0000000B + Tag: DW_TAG_formal_parameter + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_abstract_origin + Form: DW_FORM_ref4 + - Code: 0x0000000C + Tag: DW_TAG_variable + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_abstract_origin + Form: DW_FORM_ref4 + - Code: 0x0000000D + Tag: DW_TAG_pointer_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + debug_info: + - Length: + TotalLength: 579 + Version: 4 + AbbrOffset: 0 + AddrSize: 8 + Entries: + - AbbrCode: 0x00000001 + Values: + - Value: 0x0000000000000000 + - Value: 0x0000000000000004 + - Value: 0x000000000000002E + - Value: 0x0000000000000000 + - Value: 0x0000000000000044 + - Value: 0x0000000000000000 + - Value: 0x00000000000000E0 + - AbbrCode: 0x00000002 + Values: + - Value: 0x0000000000000000 + - Value: 0x000000000000001E + - Value: 0x0000000000000001 + BlockData: + - 0x56 + - Value: 0x0000000000000089 + - Value: 0x0000000000000084 + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x7C + - Value: 0x00000000000000A7 + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x78 + - Value: 0x00000000000000A9 + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x74 + - Value: 0x00000000000000C3 + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000004 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x70 + - Value: 0x00000000000000AB + - Value: 0x0000000000000001 + - Value: 0x0000000000000007 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000005 + Values: + - Value: 0x0000000000000094 + - Value: 0x000000000000009E + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000A7 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000A9 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000007 + Values: + - Value: 0x00000000000000AB + - Value: 0x0000000000000001 + - Value: 0x0000000000000002 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000008 + Values: + - Value: 0x00000000000000A3 + - Value: 0x0000000000000005 + - Value: 0x0000000000000004 + - AbbrCode: 0x00000005 + Values: + - Value: 0x00000000000000B2 + - Value: 0x00000000000000BE + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000A7 + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000A9 + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000C3 + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000C5 + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000007 + Values: + - Value: 0x00000000000000AB + - Value: 0x0000000000000001 + - Value: 0x000000000000000C + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000009 + Values: + - Value: 0x0000000000000020 + - Value: 0x00000000000000C0 + - Value: 0x0000000000000001 + BlockData: + - 0x56 + - Value: 0x00000000000000C7 + - Value: 0x0000000000000001 + - Value: 0x0000000000000011 + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xB4 + - 0x7F + - Value: 0x00000000000000CC + - Value: 0x0000000000000001 + - Value: 0x0000000000000011 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xA8 + - 0x7F + - Value: 0x00000000000000D1 + - Value: 0x0000000000000001 + - Value: 0x0000000000000011 + - Value: 0x0000000000000235 + - AbbrCode: 0x00000004 + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xA4 + - 0x7F + - Value: 0x00000000000000DB + - Value: 0x0000000000000001 + - Value: 0x0000000000000013 + - Value: 0x00000000000000B2 + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x000000000000005A + - Value: 0x0000000000000025 + - Value: 0x0000000000000001 + - Value: 0x0000000000000012 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x44 + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x40 + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xBC + - 0x7F + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000A + Values: + - Value: 0x00000000000000B9 + - Value: 0x000000000000007F + - Value: 0x000000000000003C + - Value: 0x0000000000000001 + - Value: 0x0000000000000013 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x64 + - Value: 0x00000000000000C9 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x60 + - Value: 0x00000000000000D4 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x5C + - Value: 0x00000000000000DF + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x58 + - Value: 0x00000000000000EA + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x54 + - Value: 0x00000000000000F5 + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x000000000000008B + - Value: 0x000000000000000C + - Value: 0x0000000000000001 + - Value: 0x000000000000000C + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x70 + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x6C + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x68 + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x00000000000000A3 + - Value: 0x0000000000000009 + - Value: 0x0000000000000001 + - Value: 0x000000000000000C + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x7C + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x78 + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x74 + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x00000000000000CC + - Value: 0x0000000000000009 + - Value: 0x0000000000000001 + - Value: 0x0000000000000014 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x50 + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x4C + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x48 + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000D + Values: + - Value: 0x000000000000023A + - AbbrCode: 0x0000000D + Values: + - Value: 0x000000000000023F + - AbbrCode: 0x00000008 + Values: + - Value: 0x00000000000000D6 + - Value: 0x0000000000000006 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000000 + Values: [] + debug_line: + - Length: + TotalLength: 202 + Version: 4 + PrologueLength: 45 + MinInstLength: 1 + MaxOpsPerInst: 1 + DefaultIsStmt: 1 + LineBase: 251 + LineRange: 14 + OpcodeBase: 13 + StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ] + IncludeDirs: [] + Files: + - Name: inlined-functions.cpp + DirIdx: 0 + ModTime: 0 + Length: 0 + Opcodes: + - Opcode: DW_LNS_extended_op + ExtLen: 9 + SubOpcode: DW_LNE_set_address + Data: 0 + - Opcode: 0x17 + Data: 0 + - Opcode: DW_LNS_set_column + Data: 18 + - Opcode: DW_LNS_set_prologue_end + Data: 18 + - Opcode: 0xC9 + Data: 18 + - Opcode: DW_LNS_set_column + Data: 20 + - Opcode: DW_LNS_negate_stmt + Data: 20 + - Opcode: 0x3C + Data: 20 + - Opcode: DW_LNS_set_column + Data: 24 + - Opcode: 0x3C + Data: 24 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: 0x3C + Data: 9 + - Opcode: DW_LNS_set_column + Data: 12 + - Opcode: DW_LNS_negate_stmt + Data: 12 + - Opcode: 0x3D + Data: 12 + - Opcode: DW_LNS_set_column + Data: 5 + - Opcode: DW_LNS_negate_stmt + Data: 5 + - Opcode: 0x3C + Data: 5 + - Opcode: DW_LNS_set_column + Data: 0 + - Opcode: DW_LNS_negate_stmt + Data: 0 + - Opcode: DW_LNS_advance_line + SData: 9 + Data: 0 + - Opcode: 0x4A + Data: 0 + - Opcode: DW_LNS_set_column + Data: 5 + - Opcode: DW_LNS_set_prologue_end + Data: 5 + - Opcode: DW_LNS_const_add_pc + Data: 5 + - Opcode: 0x59 + Data: 5 + - Opcode: DW_LNS_set_column + Data: 18 + - Opcode: DW_LNS_advance_line + SData: -16 + Data: 18 + - Opcode: DW_LNS_advance_pc + Data: 36 + - Opcode: DW_LNS_copy + Data: 36 + - Opcode: DW_LNS_set_column + Data: 20 + - Opcode: DW_LNS_negate_stmt + Data: 20 + - Opcode: 0x3C + Data: 20 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: 0x3C + Data: 9 + - Opcode: DW_LNS_set_column + Data: 23 + - Opcode: DW_LNS_negate_stmt + Data: 23 + - Opcode: DW_LNS_advance_line + SData: 10 + Data: 23 + - Opcode: DW_LNS_const_add_pc + Data: 23 + - Opcode: 0xD6 + Data: 23 + - Opcode: DW_LNS_set_column + Data: 26 + - Opcode: DW_LNS_negate_stmt + Data: 26 + - Opcode: 0x3C + Data: 26 + - Opcode: DW_LNS_set_column + Data: 18 + - Opcode: DW_LNS_negate_stmt + Data: 18 + - Opcode: DW_LNS_advance_line + SData: -10 + Data: 18 + - Opcode: 0x90 + Data: 18 + - Opcode: DW_LNS_set_column + Data: 20 + - Opcode: DW_LNS_negate_stmt + Data: 20 + - Opcode: 0x3C + Data: 20 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: 0x3C + Data: 9 + - Opcode: DW_LNS_set_column + Data: 12 + - Opcode: DW_LNS_negate_stmt + Data: 12 + - Opcode: 0x3D + Data: 12 + - Opcode: DW_LNS_set_column + Data: 36 + - Opcode: DW_LNS_advance_line + SData: 9 + Data: 36 + - Opcode: 0x3C + Data: 36 + - Opcode: DW_LNS_set_column + Data: 39 + - Opcode: DW_LNS_negate_stmt + Data: 39 + - Opcode: 0x3C + Data: 39 + - Opcode: DW_LNS_set_column + Data: 18 + - Opcode: DW_LNS_negate_stmt + Data: 18 + - Opcode: DW_LNS_advance_line + SData: -10 + Data: 18 + - Opcode: 0x90 + Data: 18 + - Opcode: DW_LNS_set_column + Data: 20 + - Opcode: DW_LNS_negate_stmt + Data: 20 + - Opcode: 0x3C + Data: 20 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: 0x3C + Data: 9 + - Opcode: DW_LNS_set_column + Data: 29 + - Opcode: DW_LNS_negate_stmt + Data: 29 + - Opcode: DW_LNS_advance_line + SData: 10 + Data: 29 + - Opcode: 0x3C + Data: 29 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: DW_LNS_negate_stmt + Data: 9 + - Opcode: 0x3C + Data: 9 + - Opcode: DW_LNS_set_column + Data: 12 + - Opcode: DW_LNS_negate_stmt + Data: 12 + - Opcode: 0x3D + Data: 12 + - Opcode: 0x67 + Data: 12 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: 0x41 + Data: 9 + - Opcode: DW_LNS_set_column + Data: 18 + - Opcode: DW_LNS_advance_line + SData: -17 + Data: 18 + - Opcode: DW_LNS_const_add_pc + Data: 18 + - Opcode: 0x12 + Data: 18 + - Opcode: DW_LNS_set_column + Data: 20 + - Opcode: DW_LNS_negate_stmt + Data: 20 + - Opcode: 0x3C + Data: 20 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: 0x3C + Data: 9 + - Opcode: DW_LNS_set_column + Data: 5 + - Opcode: DW_LNS_negate_stmt + Data: 5 + - Opcode: DW_LNS_advance_line + SData: 19 + Data: 5 + - Opcode: 0x3C + Data: 5 + - Opcode: DW_LNS_advance_pc + Data: 11 + - Opcode: DW_LNS_extended_op + ExtLen: 1 + SubOpcode: DW_LNE_end_sequence + Data: 11 +... +)"); + ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded()); + m_file.emplace(std::move(*ExpectedFile)); + m_module_sp = std::make_shared(ModuleSpec(FileSpec(m_file->name()))); } llvm::Expected LineEntryTest::GetLineEntryForLine(uint32_t line) { - auto expected_module_so = GetModule(); - - if (!expected_module_so) - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Not able to get module for test object."); - - auto module = expected_module_so->get(); bool check_inlines = true; bool exact = true; SymbolContextList sc_comp_units; SymbolContextList sc_line_entries; FileSpec file_spec("inlined-functions.cpp"); - module->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines, - lldb::eSymbolContextCompUnit, - sc_comp_units); + m_module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines, + lldb::eSymbolContextCompUnit, + sc_comp_units); if (sc_comp_units.GetSize() == 0) return llvm::createStringError(llvm::inconvertibleErrorCode(), "No comp unit found on the test object."); Index: unittests/TestingSupport/CMakeLists.txt =================================================================== --- unittests/TestingSupport/CMakeLists.txt +++ unittests/TestingSupport/CMakeLists.txt @@ -8,7 +8,5 @@ LINK_COMPONENTS Support + ObjectYAML ) - -add_dependencies(lldbUtilityHelpers yaml2obj) -add_definitions(-DYAML2OBJ="$") \ No newline at end of file Index: unittests/TestingSupport/TestUtilities.h =================================================================== --- unittests/TestingSupport/TestUtilities.h +++ unittests/TestingSupport/TestUtilities.h @@ -12,6 +12,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Error.h" +#include "llvm/Support/FileUtilities.h" #include #define ASSERT_NO_ERROR(x) \ @@ -27,8 +28,25 @@ namespace lldb_private { std::string GetInputFilePath(const llvm::Twine &name); -llvm::Error ReadYAMLObjectFile(const llvm::Twine &yaml_name, - llvm::SmallString<128> &obj); + +class TestFile { +public: + static llvm::Expected fromYaml(llvm::StringRef Yaml); + TestFile(TestFile &&RHS) : Name(std::move(RHS.Name)) { + RHS.Name = llvm::None; + } + ~TestFile(); + + llvm::StringRef name() { return *Name; } + +private: + TestFile(llvm::StringRef Name, llvm::FileRemover &&Remover) : Name(Name) { + Remover.releaseFile(); + } + void operator=(const TestFile &) = delete; + + llvm::Optional Name; +}; } #endif Index: unittests/TestingSupport/TestUtilities.cpp =================================================================== --- unittests/TestingSupport/TestUtilities.cpp +++ unittests/TestingSupport/TestUtilities.cpp @@ -8,9 +8,14 @@ #include "TestUtilities.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ObjectYAML/yaml2obj.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Program.h" +#include "llvm/Support/YAMLTraits.h" +#include "gtest/gtest.h" + +using namespace lldb_private; extern const char *TestMainArgv0; @@ -21,23 +26,30 @@ return result.str(); } -llvm::Error -lldb_private::ReadYAMLObjectFile(const llvm::Twine &yaml_name, - llvm::SmallString<128> &object_file) { - std::string yaml = GetInputFilePath(yaml_name); - llvm::StringRef args[] = {YAML2OBJ, yaml}; - llvm::StringRef obj_ref = object_file; - const llvm::Optional redirects[] = {llvm::None, obj_ref, - llvm::None}; - if (llvm::sys::ExecuteAndWait(YAML2OBJ, args, llvm::None, redirects) != 0) - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Error running yaml2obj %s.", yaml.c_str()); - uint64_t size; - if (auto ec = llvm::sys::fs::file_size(object_file, size)) - return llvm::errorCodeToError(ec); - if (size == 0) - return llvm::createStringError( - llvm::inconvertibleErrorCode(), - "Empty object file created from yaml2obj %s.", yaml.c_str()); - return llvm::Error::success(); +llvm::Expected TestFile::fromYaml(llvm::StringRef Yaml) { + const auto *Info = testing::UnitTest::GetInstance()->current_test_info(); + assert(Info); + llvm::SmallString<128> Name; + int FD; + if (std::error_code EC = llvm::sys::fs::createTemporaryFile( + llvm::Twine(Info->test_case_name()) + "-" + Info->name(), "test", FD, + Name)) + return llvm::errorCodeToError(EC); + llvm::FileRemover Remover(Name); + { + llvm::raw_fd_ostream OS(FD, /*shouldClose*/ true); + llvm::yaml::Input YIn(Yaml); + if (llvm::Error E = llvm::yaml::convertYAML(YIn, OS)) + return std::move(E); + } + return TestFile(Name, std::move(Remover)); +} + +TestFile::~TestFile() { + if (!Name) + return; + if (std::error_code EC = + llvm::sys::fs::remove(*Name, /*IgnoreNonExisting*/ false)) + GTEST_LOG_(WARNING) << "Failed to delete `" << Name->c_str() + << "`: " << EC.message(); }