Rewrite TestTargetSymbolsBuildidCase to be more focused
Summary: 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 rewritten in on top of lldb-test's module-sections functionality. The slight gotcha there was that the Module::GetSectionList does not include the sections from the symbol file until someone manually calls Module::GetSymbolVendor. Normally, this is not an issue, because someone will have initialized the symbol vendor by the time anyone starts looking at the sections. However, when all one this is dump the section list, we run into this problem. I've tried making this behavior more automatic, but it turns out it's not that easy, so for now, I just manually initialize the Symbol Vendor before dumping out the sections in lldb-test. Reviewers: jankratochvil Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D42914 llvm-svn: 326805
This commit is contained in:
parent
c3e7c6d291
commit
96979ceecb
|
@ -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: 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: .debug_frame
|
||||
Type: SHT_PROGBITS
|
||||
AddressAlign: 0x0000000000000008
|
||||
Content: DEADBEEFBAADF00D
|
||||
Symbols:
|
||||
Local:
|
||||
- Name: main
|
||||
Type: STT_FUNC
|
||||
Section: .text
|
||||
Value: 0x00000000004003D0
|
||||
Size: 0x0000000000000008
|
||||
...
|
|
@ -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
|
|
@ -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)
|
|
@ -1,3 +0,0 @@
|
|||
int main() {
|
||||
return 0;
|
||||
}
|
|
@ -191,9 +191,11 @@ static void dumpModules(Debugger &Dbg) {
|
|||
|
||||
for (const auto &File : opts::module::InputFilenames) {
|
||||
ModuleSpec Spec{FileSpec(File, false)};
|
||||
Spec.GetSymbolFileSpec().SetFile(File, false);
|
||||
|
||||
auto ModulePtr = std::make_shared<lldb_private::Module>(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";
|
||||
|
|
Loading…
Reference in New Issue