labath created this revision. labath added a reviewer: jankratochvil. The test was failing in remote debugging scenario with windows as a host as cmd.exe is not able to parse the complicated shell commands in the Makefile.
The test seemed like a perfect candidate for a more focused testing approach, so I have tried rewriting it this way. It uses two yaml files which represent "stripped" and "unstripped" versions of a binary. The unstripped version defines a symbol "main" while the stripped one doesn't. The test works by creating an SBModule pointing the the stripped file and verifies that we are able to locate the unstripped one by looking up the "main" symbol. https://reviews.llvm.org/D42914 Files: packages/Python/lldbsuite/test/linux/buildidcase/Makefile packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py packages/Python/lldbsuite/test/linux/buildidcase/main.c packages/Python/lldbsuite/test/linux/buildidcase/stripped.yaml packages/Python/lldbsuite/test/linux/buildidcase/unstripped.yaml
Index: packages/Python/lldbsuite/test/linux/buildidcase/unstripped.yaml =================================================================== --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidcase/unstripped.yaml @@ -0,0 +1,28 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004003D0 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400274 + AddressAlign: 0x0000000000000004 + Content: 040000001400000003000000474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name: .text + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004003D0 + AddressAlign: 0x0000000000000010 + Size: 0x0000000000000008 +Symbols: + Local: + - Name: main + Type: STT_FUNC + Section: .text + Value: 0x00000000004003D0 + Size: 0x0000000000000008 +... Index: packages/Python/lldbsuite/test/linux/buildidcase/stripped.yaml =================================================================== --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidcase/stripped.yaml @@ -0,0 +1,25 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x00000000004003D0 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x0000000000400274 + AddressAlign: 0x0000000000000004 + Content: 040000001400000003000000474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x00000000004003D0 + AddressAlign: 0x0000000000000010 + Content: DEADBEEFBAADF00D + - Name: .gnu_debuglink + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000004 + Content: 38613733616332333833393065333261376666346163386562653464366134316563663563392E646562756700000000ADEE50C1 +... Index: packages/Python/lldbsuite/test/linux/buildidcase/main.c =================================================================== --- packages/Python/lldbsuite/test/linux/buildidcase/main.c +++ /dev/null @@ -1,3 +0,0 @@ -int main() { - return 0; -} Index: packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py =================================================================== --- packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py +++ packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py @@ -13,9 +13,15 @@ mydir = TestBase.compute_mydir(__file__) @no_debug_info_test # Prevent the genaration of the dwarf version of this test - @skipUnlessPlatform(['linux']) def test_target_symbols_buildid_case(self): - self.build(clean=True) - exe = self.getBuildArtifact("stripped.out") + exe_name = self.getBuildArtifact("stripped.out") + self.yaml2obj(self.getSourcePath("stripped.yaml"), exe_name) + buildIdFolder = os.path.join(self.getBuildDir(), ".build-id", "1b") + lldbutil.mkdir_p(buildIdFolder) + self.yaml2obj(self.getSourcePath("unstripped.yaml"), + os.path.join(buildIdFolder, "8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug")) - lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe) + spec = lldb.SBModuleSpec() + spec.SetFileSpec(lldb.SBFileSpec(exe_name)) + module = lldb.SBModule(spec) + self.assertTrue(module.FindSymbol("main").IsValid()) Index: packages/Python/lldbsuite/test/linux/buildidcase/Makefile =================================================================== --- packages/Python/lldbsuite/test/linux/buildidcase/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -LEVEL = ../../make -C_SOURCES := main.c -LD_EXTRAS += -Wl,--build-id=sha1 - -all: stripped.out - -.PHONY: .build-id -stripped.out .build-id: a.out - $(OBJCOPY) -j .note.gnu.build-id -O binary $< tmp - rm -rf .build-id - fn=`od -An -tx1 <tmp|tr -d ' \n'|sed -e 's/^.\{32\}//' -e 's#^..#.build-id/&/#' -e 's#$$#.debug#'` && \ - mkdir -p `dirname $$fn` && \ - $(OBJCOPY) --only-keep-debug $< $$fn && \ - $(OBJCOPY) --strip-all --add-gnu-debuglink=$$fn $< stripped.out - $(RM) tmp - -clean:: - $(RM) -r stripped.out .build-id - -include $(LEVEL)/Makefile.rules
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits