[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
This revision was automatically updated to reflect the committed changes. Closed by commit rL326805: Rewrite TestTargetSymbolsBuildidCase to be more focused (authored by labath, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D42914?vs=132851=137197#toc Repository: rL LLVM https://reviews.llvm.org/D42914 Files: lldb/trunk/lit/Modules/build-id-case.yaml lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/Makefile lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/main.c lldb/trunk/tools/lldb-test/lldb-test.cpp Index: lldb/trunk/tools/lldb-test/lldb-test.cpp === --- lldb/trunk/tools/lldb-test/lldb-test.cpp +++ lldb/trunk/tools/lldb-test/lldb-test.cpp @@ -191,9 +191,11 @@ for (const auto : opts::module::InputFilenames) { ModuleSpec Spec{FileSpec(File, false)}; -Spec.GetSymbolFileSpec().SetFile(File, false); auto ModulePtr = std::make_shared(Spec); +// Fetch symbol vendor before we get the section list to give the symbol +// vendor a chance to populate it. +ModulePtr->GetSymbolVendor(); SectionList *Sections = ModulePtr->GetSectionList(); if (!Sections) { llvm::errs() << "Could not load sections for module " << File << "\n"; Index: lldb/trunk/lit/Modules/build-id-case.yaml === --- lldb/trunk/lit/Modules/build-id-case.yaml +++ lldb/trunk/lit/Modules/build-id-case.yaml @@ -0,0 +1,42 @@ +# RUN: mkdir -p %t/.build-id/1b +# RUN: yaml2obj %s > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug +# RUN: cd %t +# RUN: llvm-objcopy --strip-all --add-gnu-debuglink=.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug %t/stripped.out +# RUN: lldb-test module-sections %t/stripped.out | FileCheck %s + +# CHECK: Name: .debug_frame +# CHECK-NEXT: VM size: 0 +# CHECK-NEXT: File size: 8 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data:ELFDATA2LSB + Type:ET_EXEC + Machine: EM_X86_64 + Entry: 0x004003D0 +Sections: + - Name:.note.gnu.build-id +Type:SHT_NOTE +Flags: [ SHF_ALLOC ] +Address: 0x00400274 +AddressAlign:0x0004 +Content: 040014000300474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name:.text +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +Address: 0x004003D0 +AddressAlign:0x0010 +Content: DEADBEEFBAADF00D + - Name:.debug_frame +Type:SHT_PROGBITS +AddressAlign:0x0008 +Content: DEADBEEFBAADF00D +Symbols: + Local: +- Name:main + Type:STT_FUNC + Section: .text + Value: 0x004003D0 + Size:0x0008 +... Index: lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/main.c === --- lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/main.c +++ lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/main.c @@ -1,3 +0,0 @@ -int main() { - return 0; -} Index: lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py === --- lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py +++ lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/TestTargetSymbolsBuildidCase.py @@ -1,22 +0,0 @@ -""" Testing separate debug info loading by its .build-id. """ -import os -import time -import lldb -import sys -from lldbsuite.test.decorators import * -from lldbsuite.test.lldbtest import * -from lldbsuite.test import lldbutil - - -class TestTargetSymbolsBuildidCase(TestBase): - -mydir = TestBase.compute_mydir(__file__) - -@no_debug_info_test # Prevent the genaration of the dwarf version of this test -@skipUnlessPlatform(['linux']) -@skipIf(hostoslist=['windows']) -def test_target_symbols_buildid_case(self): -self.build(clean=True) -exe = self.getBuildArtifact("stripped.out") - -lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe) Index: lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/Makefile === --- lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/Makefile +++ lldb/trunk/packages/Python/lldbsuite/test/linux/buildidcase/Makefile @@ -1,20 +0,0 @@ -LEVEL = ../../make -C_SOURCES := main.c -LD_EXTRAS += -Wl,--build-id=sha1 - -all:
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
labath added a comment. Heh, no good deed goes unpunished, right.. :) It occured to me that this could be testable using the existing `lldb-test module-sections` functionality (I don't need to use a symbol, I can easily use a section name to recognise that a debug info was loaded from the other file), but I ran into approximately two bugs that make that hard right now: 1. Module::GetSectionList will not return the extra sections unless some other call has been made to initialize the symbol vendor 2. the .debug_frame section (which i chose to use for the test) seems to be added twice I'll try to take a look at how hard is it to resolve those... https://reviews.llvm.org/D42914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
jankratochvil accepted this revision. jankratochvil added a comment. This revision is now accepted and ready to land. It does work for me also with: `r324254 - Fix parsing of object files with "early" section headers` https://reviews.llvm.org/D42914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
jankratochvil added a comment. This testcase does work for me only with newly written https://reviews.llvm.org/D42931. https://reviews.llvm.org/D42914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
davide added a comment. In https://reviews.llvm.org/D42914#997974, @zturner wrote: > Yea this seems like a good candidate for an lldb-test test. Something like > this. > > RUN: yaml2obj %S/Inputs/stripped.yaml > %t.stripped.out > RUN: yaml2obj %S/Inputs/unstripped.yaml > > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug > RUN: lldb-test symbols %t.stripped.out | FileCheck %s > > CHECK: main > Indeed. It wasn't 100% clear how to do this in my mind, thanks for clarifying :) - Davide https://reviews.llvm.org/D42914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
zturner added a comment. Yea this seems like a good candidate for an lldb-test test. Something like this. RUN: yaml2obj %S/Inputs/stripped.yaml > %t.stripped.out RUN: yaml2obj %S/Inputs/unstripped.yaml > %t/.build-id/1b/8a73ac238390e32a7ff4ac8ebe4d6a41ecf5c9.debug RUN: lldb-test symbols %t.stripped.out | FileCheck %s CHECK: main https://reviews.llvm.org/D42914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
jankratochvil added a comment. FYI it FAILs for me on Fedora 27 x86_64, it cannot find "main", debugging it. The .build-id/ separate debug info does work with GDB but not with LLDB. https://reviews.llvm.org/D42914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
davide added a comment. Nice :) This looks already fine as-is, but I wonder whether we can get rid of the python boilerplate altogether? There has been quite a bit of discussion about using `lldb-test` for this sort of more focused testing, so I wonder whether you gave it a try? (just a random thought, didn't see whether this is feasible). FWIW, I'm working on extending `lldb-test` as an experiment to test new functionalities so that we can test in a way that's more akin to llvm. https://reviews.llvm.org/D42914 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42914: Rewrite TestTargetSymbolsBuildidCase to be more focused
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: 0x004003D0 +Sections: + - Name:.note.gnu.build-id +Type:SHT_NOTE +Flags: [ SHF_ALLOC ] +Address: 0x00400274 +AddressAlign:0x0004 +Content: 040014000300474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name:.text +Type:SHT_NOBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +Address: 0x004003D0 +AddressAlign:0x0010 +Size:0x0008 +Symbols: + Local: +- Name:main + Type:STT_FUNC + Section: .text + Value: 0x004003D0 + Size:0x0008 +... 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: 0x004003D0 +Sections: + - Name:.note.gnu.build-id +Type:SHT_NOTE +Flags: [ SHF_ALLOC ] +Address: 0x00400274 +AddressAlign:0x0004 +Content: 040014000300474E55001B8A73AC238390E32A7FF4AC8EBE4D6A41ECF5C9 + - Name:.text +Type:SHT_PROGBITS +Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +Address: 0x004003D0 +AddressAlign:0x0010 +Content: DEADBEEFBAADF00D + - Name:.gnu_debuglink +Type:SHT_PROGBITS +AddressAlign:0x0004 +Content: 3861373361633233383339306533326137346163386562653464366134316563663563392E6465627567ADEE50C1 +... 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: