diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index bfd249ccd43f2..0120daccc12cf 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # # GNUWin32 uname gives "windows32" or "server version windows32" while # some versions of MSYS uname return "MSYS_NT*", but most environments -# standardize on "Windows_NT", so we'll make it consistent here. +# standardize on "Windows_NT", so we'll make it consistent here. # When running tests from Visual Studio, the environment variable isn't # inherited all the way down to the process spawned for make. #---------------------------------------------------------------------- @@ -210,6 +210,12 @@ else ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" DSYM = $(EXE).debug endif + + ifeq "$(MERGE_DWOS)" "YES" + MAKE_DWO := YES + DWP_NAME = $(EXE).dwp + DYLIB_DWP_NAME = $(DYLIB_NAME).dwp + endif endif LIMIT_DEBUG_INFO_FLAGS = @@ -357,6 +363,7 @@ ifneq "$(OS)" "Darwin" OBJCOPY ?= $(call replace_cc_with,objcopy) ARCHIVER ?= $(call replace_cc_with,ar) + DWP ?= $(call replace_cc_with,dwp) override AR = $(ARCHIVER) endif @@ -565,9 +572,16 @@ else endif else ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" + ifneq "$(KEEP_FULL_DEBUG_BINARY)" "YES" $(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)" + else + cp "$(EXE)" "$(DSYM)" + endif $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)" endif +ifeq "$(MERGE_DWOS)" "YES" + $(DWP) -o "$(DWP_NAME)" $(DWOS) +endif endif #---------------------------------------------------------------------- @@ -610,9 +624,16 @@ endif else $(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)" ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" + ifneq "$(KEEP_FULL_DEBUG_BINARY)" "YES" + cp "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug" + else $(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).debug" + endif $(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)" endif +ifeq "$(MERGE_DWOS)" "YES" + $(DWP) -o $(DYLIB_DWP_FILE) $(DYLIB_DWOS) +endif endif #---------------------------------------------------------------------- diff --git a/lldb/source/Plugins/SymbolLocator/CMakeLists.txt b/lldb/source/Plugins/SymbolLocator/CMakeLists.txt index ca969626f4ffc..3367022639ab8 100644 --- a/lldb/source/Plugins/SymbolLocator/CMakeLists.txt +++ b/lldb/source/Plugins/SymbolLocator/CMakeLists.txt @@ -1,5 +1,10 @@ +# Order matters here: the first symbol locator prevents further searching. +# For DWARF binaries that are both stripped and split, the Default plugin +# will return the stripped binary when asked for the ObjectFile, which then +# prevents an unstripped binary from being requested from the Debuginfod +# provider. +add_subdirectory(Debuginfod) add_subdirectory(Default) if (CMAKE_SYSTEM_NAME MATCHES "Darwin") add_subdirectory(DebugSymbols) endif() -add_subdirectory(Debuginfod) diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp index b5fe35d71032a..ec734b8bb64f8 100644 --- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp +++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp @@ -44,6 +44,25 @@ llvm::StringRef SymbolVendorELF::GetPluginDescriptionStatic() { "executables."; } +// If this is needed elsewhere, it can be exported/moved. +static bool IsDwpSymbolFile(const lldb::ModuleSP &module_sp, + const FileSpec &file_spec) { + DataBufferSP dwp_file_data_sp; + lldb::offset_t dwp_file_data_offset = 0; + // Try to create an ObjectFile from the file_spec. + ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin( + module_sp, &file_spec, 0, FileSystem::Instance().GetByteSize(file_spec), + dwp_file_data_sp, dwp_file_data_offset); + if (!ObjectFileELF::classof(dwp_obj_file.get())) + return false; + // The presence of a debug_cu_index section is the key identifying feature of + // a DWP file. + if (!dwp_obj_file || !dwp_obj_file->GetSectionList()->FindSectionByType( + eSectionTypeDWARFDebugCuIndex, false)) + return false; + return true; +} + // CreateInstance // // Platforms can register a callback to use when creating symbol vendors to @@ -87,8 +106,15 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp, FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths(); FileSpec dsym_fspec = PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); - if (!dsym_fspec) - return nullptr; + if (!dsym_fspec || IsDwpSymbolFile(module_sp, dsym_fspec)) { + // If we have a stripped binary or if we got a DWP file, we should prefer + // symbols in the executable acquired through a plugin. + ModuleSpec unstripped_spec = + PluginManager::LocateExecutableObjectFile(module_spec); + if (!unstripped_spec) + return nullptr; + dsym_fspec = unstripped_spec.GetFileSpec(); + } DataBufferSP dsym_file_data_sp; lldb::offset_t dsym_file_data_offset = 0; diff --git a/lldb/test/API/debuginfod/Normal/Makefile b/lldb/test/API/debuginfod/Normal/Makefile new file mode 100644 index 0000000000000..9c191de0d0aaa --- /dev/null +++ b/lldb/test/API/debuginfod/Normal/Makefile @@ -0,0 +1,32 @@ +C_SOURCES := main.c +LD_EXTRAS := -Wl,--build-id + +# For normal (non DWP) Debuginfod tests, we need: + +# * The "full" binary: a.out.debug +# Produced by Makefile.rules with KEEP_FULL_DEBUG_BINARY set to YES and +# SPLIT_DEBUG_SYMBOLS set to YES + +# * The stripped binary (a.out) +# Produced by Makefile.rules with SPLIT_DEBUG_SYMBOLS set to YES + +# * The 'only-keep-debug' binary (a.out.dbg) +# Produced below + +# * The .uuid file (for a little easier testing code) +# Produced below + +# Don't strip the debug info from a.out: +SPLIT_DEBUG_SYMBOLS := YES +KEEP_FULL_DEBUG_BINARY := YES + +all: a.out a.out.uuid a.out.dbg a.out.debug + +# Put the build-id into a file by itself for minimum effort in Python +a.out.uuid: a.out + $(OBJCOPY) --dump-section=.note.gnu.build-id=$@ $< + +a.out.dbg: a.out.debug + $(OBJCOPY) --only-keep-debug $< $@ + +include Makefile.rules diff --git a/lldb/test/API/debuginfod/Normal/TestDebuginfod.py b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py new file mode 100644 index 0000000000000..5c1e2b4f31635 --- /dev/null +++ b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py @@ -0,0 +1,130 @@ +""" +Test support for the DebugInfoD network symbol acquisition protocol. +""" + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + +def getUUID(aoutuuid): + """ + Pull the 20 byte UUID out of the .note.gnu.build-id section that was dumped + to a file already, as part of the build. + """ + import struct + with open(aoutuuid, "rb") as f: + data = f.read(36) + if len(data) != 36: + return None + header = struct.unpack_from("<4I", data) + if len(header) != 4: + return None + # 4 element 'prefix', 20 bytes of uuid, 3 byte long string, 'GNU': + if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554e47: + return None + return data[16:].hex() + +def config_test(local_files, uuid, debuginfo, executable): + """ + Set up a test with local_files[] copied to a particular location + so that we control which files are, or are not, found in the file system. + Also, create a stand-alone file-system 'hosted' debuginfod server for the + given UUID. + + Make the filesystem look like: + + /tmp//test/[local_files] + + /tmp//cache (for lldb to use as a temp cache) + + /tmp//buildid//executable -> + /tmp//buildid//debuginfo -> + Returns the /tmp/ path + """ + import os + import shutil + import tempfile + + tmp_dir = tempfile.mkdtemp() + test_dir = os.path.join(tmp_dir, "test") + uuid_dir = os.path.join(tmp_dir, "buildid", uuid) + + # Make the 3 directories + os.makedirs(os.path.join(tmp_dir, "cache")) + os.makedirs(uuid_dir) + os.makedirs(test_dir) + + # Copy the files used by the test: + for f in local_files: + shutil.copy(f, test_dir) + + # Fill in the 'file://...' mocked Debuginfod server + if debuginfo: + shutil.move(debuginfo, os.path.join(uuiddir, "debuginfo")) + if executable: + shutil.move(executable, os.path.join(uuiddir, "executable")) + + return tmp_dir + + +# Need to test 5 different scenarios: +# 1 - A stripped binary with it's corresponding unstripped binary: +# 2 - A stripped binary with a corresponding --only-keep-debug symbols file +# 3 - A split binary with it's corresponding DWP file +# 4 - A stripped, split binary with an unstripped binary and a DWP file +# 5 - A stripped, split binary with an --only-keep-debug symbols file and a DWP file + +class DebugInfodTests(TestBase): + # No need to try every flavor of debug inf. + NO_DEBUG_INFO_TESTCASE = True + + def test_stuff(self): + """This should test stuff.""" + self.build() + # Pull the UUID out of the binary. + uuid_file = self.getBuildArtifact("a.out.uuid") + self.aout = self.getBuildArtifact("a.out") + self.debugbin = self.getBuildArtifact("a.out.debug") + self.dwp = self.getBuildArtifact("a.out.dwp") + self.uuid = getUUID(uuid_file) + # Setup the fake DebugInfoD server. + server_root = config_fake_debuginfod_server(self.uuid, self.dwp, self.debugbin) + + # Configure LLDB properly + self.runCmd("settings set symbols.enable-external-lookup true") + self.runCmd("settings set plugin.symbol-locator.debuginfod.cache-path %s/cache" % server_root) + self.runCmd("settings clear plugin.symbol-locator.debuginfod.server-urls") + cmd = "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%s" % server_root + self.runCmd(cmd) + print(cmd) + # Check to see if the symbol file is properly loaded + self.main_source_file = lldb.SBFileSpec("main.c") + self.sample_test() + + def sample_test(self): + """You might use the test implementation in several ways, say so here.""" + # This function starts a process, "a.out" by default, sets a source + # breakpoint, runs to it, and returns the thread, process & target. + # It optionally takes an SBLaunchOption argument if you want to pass + # arguments or environment variables. + target = target = self.dbg.CreateTarget(self.aout) + self.assertTrue(target and target.IsValid(), "Target is valid") + bp = target.BreakpointCreateByName("func") + self.assertTrue(bp and bp.IsValid(), "Breakpoint is valid") + self.assertEqual(bp.GetNumLocations(), 1) + print("Loc @ Index 0:") + print(bp.GetLocationAtIndex(0)) + loc = bp.GetLocationAtIndex(0) + self.assertTrue(loc and loc.IsValid(), "Location is valid") + addr = loc.GetAddress() + self.assertTrue(addr and addr.IsValid(), "Loc address is valid") + line_entry = addr.GetLineEntry() + self.assertTrue(line_entry and line_entry.IsValid(), "Loc line entry is valid") + self.assertEqual(line_entry.GetLine(), 18) + self.assertEqual(loc.GetLineEntry().GetFileSpec().GetFilename(), self.main_source_file.GetFilename()) + + def sample_test_no_launch(self): + """Same as above but doesn't launch a process.""" + + target = self.createTestTarget() + self.expect_expr("global_test_var", result_value="10") diff --git a/lldb/test/API/debuginfod/Normal/main.c b/lldb/test/API/debuginfod/Normal/main.c new file mode 100644 index 0000000000000..2cc7e1557f40c --- /dev/null +++ b/lldb/test/API/debuginfod/Normal/main.c @@ -0,0 +1,9 @@ +// This is a dump little pair of test files + +int func(int argc, const char *argv[]) { + return (argc + 1) * (argv[argc][0] + 2); +} + +int main(int argc, const char *argv[]) { + return func(0, argv); +} diff --git a/lldb/test/API/debuginfod/SplitDWARF/Makefile b/lldb/test/API/debuginfod/SplitDWARF/Makefile new file mode 100644 index 0000000000000..38d0a419e105b --- /dev/null +++ b/lldb/test/API/debuginfod/SplitDWARF/Makefile @@ -0,0 +1,36 @@ +C_SOURCES := main.c +LD_EXTRAS := -Wl,--build-id + +# For split-dwarf Debuginfod tests, we need: + +# * A .DWP file (a.out.dwp) +# Produced by Makefile.rules with MAKE_DWO and MERGE_DWOS both set to YES + +# * The "full" binary: it's missing things that live in .dwo's (a.out.debug) +# Produced by Makefile.rules with KEEP_FULL_DEBUG_BINARY set to YES and +# SPLIT_DEBUG_SYMBOLS set to YES + +# * The stripped binary (a.out) +# Produced by Makefile.rules + +# * The 'only-keep-debug' binary (a.out.dbg) +# Produced below + +# * The .uuid file (for a little easier testing code) +# Produced here in the rule below + +MAKE_DWO := YES +MERGE_DWOS := YES +SPLIT_DEBUG_SYMBOLS := YES +KEEP_FULL_DEBUG_BINARY := YES + +all: a.out.uuid a.out a.out.debug a.out.dbg + +a.out.dbg: a.out.debug + $(OBJCOPY) --only-keep-debug $< $@ + +# Put the build-id into a file by itself for minimum effort in Python +a.out.uuid: a.out + $(OBJCOPY) --dump-section=.note.gnu.build-id=$@ $< + +include Makefile.rules diff --git a/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py new file mode 100644 index 0000000000000..fb33c0788b38e --- /dev/null +++ b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py @@ -0,0 +1,116 @@ +""" +Test support for the DebugInfoD network symbol acquisition protocol. +""" + +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + +def getUUID(aoutuuid): + """ + Pull the 20 byte UUID out of the .note.gnu.build-id section that was dumped + to a file already, as part of the build. + """ + import struct + with open(aoutuuid, "rb") as f: + data = f.read(36) + if len(data) != 36: + return None + header = struct.unpack_from("<4I", data) + if len(header) != 4: + return None + # 4 element 'prefix', 20 bytes of uuid, 3 byte long string, 'GNU': + if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554e47: + return None + return data[16:].hex() + +def config_fake_debuginfod_server(uuid, debuginfo, executable): + """ + Create a file-system 'hosted' debuginfod server for the given UUID. + Make the filesystem look like: + /tmp//cache (for lldb to use as a temp cache) + /tmp//buildid//executable -> + /tmp//buildid//debuginfo -> + + Returns the /tmp/ path + """ + import os + import shutil + import tempfile + tmpdir = tempfile.mkdtemp() + uuiddir = os.path.join(tmpdir, "buildid", uuid) + os.makedirs(uuiddir) + os.makedirs(os.path.join(tmpdir, "cache")) + # Move the files to the correct location for debuginfod to find + if debuginfo: + pass + #shutil.move(debuginfo, os.path.join(uuiddir, "debuginfo")) + + if executable: + pass + #shutil.move(executable, os.path.join(uuiddir, "executable")) + + return tmpdir + + +# Need to test 5 different scenarios: +# 1 - A stripped binary with it's corresponding unstripped binary: +# 2 - A stripped binary with a corresponding --only-keep-debug symbols file +# 3 - A split binary with it's corresponding DWP file +# 4 - A stripped, split binary with an unstripped binary and a DWP file +# 5 - A stripped, split binary with an --only-keep-debug symbols file and a DWP file + +class DebugInfodTests(TestBase): + # No need to try every flavor of debug inf. + NO_DEBUG_INFO_TESTCASE = True + + def test_stuff(self): + """This should test stuff.""" + self.build() + # Pull the UUID out of the binary. + uuid_file = self.getBuildArtifact("a.out.uuid") + self.aout = self.getBuildArtifact("a.out") + self.debugbin = self.getBuildArtifact("a.out.debug") + self.dwp = self.getBuildArtifact("a.out.dwp") + self.uuid = getUUID(uuid_file) + # Setup the fake DebugInfoD server. + server_root = config_fake_debuginfod_server(self.uuid, self.dwp, self.debugbin) + + # Configure LLDB properly + self.runCmd("settings set symbols.enable-external-lookup true") + self.runCmd("settings set plugin.symbol-locator.debuginfod.cache-path %s/cache" % server_root) + self.runCmd("settings clear plugin.symbol-locator.debuginfod.server-urls") + cmd = "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%s" % server_root + self.runCmd(cmd) + print(cmd) + # Check to see if the symbol file is properly loaded + self.main_source_file = lldb.SBFileSpec("main.c") + self.sample_test() + + def sample_test(self): + """You might use the test implementation in several ways, say so here.""" + # This function starts a process, "a.out" by default, sets a source + # breakpoint, runs to it, and returns the thread, process & target. + # It optionally takes an SBLaunchOption argument if you want to pass + # arguments or environment variables. + target = target = self.dbg.CreateTarget(self.aout) + self.assertTrue(target and target.IsValid(), "Target is valid") + bp = target.BreakpointCreateByName("func") + self.assertTrue(bp and bp.IsValid(), "Breakpoint is valid") + self.assertEqual(bp.GetNumLocations(), 1) + print("Loc @ Index 0:") + print(bp.GetLocationAtIndex(0)) + loc = bp.GetLocationAtIndex(0) + self.assertTrue(loc and loc.IsValid(), "Location is valid") + addr = loc.GetAddress() + self.assertTrue(addr and addr.IsValid(), "Loc address is valid") + line_entry = addr.GetLineEntry() + self.assertTrue(line_entry and line_entry.IsValid(), "Loc line entry is valid") + self.assertEqual(line_entry.GetLine(), 18) + self.assertEqual(loc.GetLineEntry().GetFileSpec().GetFilename(), self.main_source_file.GetFilename()) + + def sample_test_no_launch(self): + """Same as above but doesn't launch a process.""" + + target = self.createTestTarget() + self.expect_expr("global_test_var", result_value="10") diff --git a/lldb/test/API/debuginfod/SplitDWARF/main.c b/lldb/test/API/debuginfod/SplitDWARF/main.c new file mode 100644 index 0000000000000..2cc7e1557f40c --- /dev/null +++ b/lldb/test/API/debuginfod/SplitDWARF/main.c @@ -0,0 +1,9 @@ +// This is a dump little pair of test files + +int func(int argc, const char *argv[]) { + return (argc + 1) * (argv[argc][0] + 2); +} + +int main(int argc, const char *argv[]) { + return func(0, argv); +} diff --git a/lldb/test/Shell/Debuginfod/Debuginfod-testing.md b/lldb/test/Shell/Debuginfod/Debuginfod-testing.md new file mode 100644 index 0000000000000..116bcc5c0ed7a --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Debuginfod-testing.md @@ -0,0 +1,64 @@ +# Tests for basic Debuginfod functionality + +Because the Debuginfod protocol is a simple HTTP path-based system, one can +mimic a Debuginfod server by setting up a directory structure to reflect the +protocol properly. That's how all these tests operate. We override the default +`DEBUGINFOD_URLS` property with a `file://` URL and populate it with the symbol +files we need for testing. + +## What's being tested + +- For assumption validation, the `*-no-locator` tests verify that lldb works as + the test expects when files that Debuginfod should provide (`.dwp` files, + `.gnu.debuglink`'ed files, etc...) are _already_ there. +- The `*-negative` tests validate that symbols _aren't_ found without + Debuginfod, to ensure they haven't been cached from previous runs (in the + hopes of preventing false positive testing). +- The `*-positive*` tests check that the Debuginfod symbol locator is providing + the expected symbols when the debugger doesn't already have them available. + +### Symbol file variations tested + +There are 5 variations of symbol data where Debuginfod provides value: + +1. The `strip` build variation is a binary built with debug information (`-g`), + but stripped for deployment. The Debuginfod service can then host the + unstripped binary (as either `executable` or `debuginfo`). +2. The `okdstrip` build variation is a binary build with `-g`, stripped for + deployment, where the Debuginfod service is hosting the output of + `objcopy --only-keep-debug` (which should also be linked to the stripped file + using `--add-gnu-debuglink`). Again, the file could be hosted as either + `executable` or `debuginfo`. +3. The `split` build variation is a binary built with `-gsplit-dwarf` that + produces `.dwo` which are subsequently linked together (using `llvm-dwp`) + into a single `.dwp` file. The Debuginfod service hosts the `.dwp` file as + `debuginfo`. +4. The `split-strip` build variation is a binary built with `-gsplit-dwarf`, + then stripped in the same manner as variation #1. For this variation, + Debuginfod hosts the unstripped binary as `executable` and the `.dwp` file as + `debuginfo`. +5. The `split-okdstrip` build variation is the combination of variations 2 and + 3, where Debuginfod hosts the `.gnu.debuglink`'ed file as `executable` and + the `.dwp` as `debuginfo`. + +### Lack of clarity/messy capabilities from Debuginfod + +The [debuginfod protocol](https://sourceware.org/elfutils/Debuginfod.html) is +underspecified for some variations of symbol file deployment. The protocol +itself is quite simple: query an HTTP server with the path +`buildid/{.note.gnu.build-id hash}/debuginfo` or +`buildid/{.note.gnu.build-id hash}/executable` to acquire "symbol data" or "the +executable". Where there is lack of clarity, `debuginfo` is requested first, +falling back to `executable` (Scenarios #1 & #2). For Scenario #5, the stripped +(i.e. not full) executable, which contains a number of sections necessary to +correctly symbolicate, is hosted from the `executable` API. Depending upon how +Debuginfod hosting services choose to support `.dwp` paired with stripped files, +these assumptions may need to be revisited. + +The `.dwp` file is treated as `debuginfo`, and the "only-keep-debug" stripped +binary is treated as `executable`. This scenario does not appear to work at all +in GDB. It seems more straightforward to support it in this manner, rather than +attempting to extend the protocol. While the protocol does support querying for +section contents by name for a given build ID, support for that capability in +LLDB is not implemented (and LLVM's Debuginfod library does not support it at +this time). diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml new file mode 100644 index 0000000000000..ed3fd4d949ea6 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml @@ -0,0 +1,212 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x401030 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x400000 + Align: 0x1000 + Offset: 0x0 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + VAddr: 0x401000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .rodata + LastSec: .eh_frame + VAddr: 0x402000 + Align: 0x1000 + Offset: 0x2000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Align: 0x1000 + Offset: 0x2FF8 + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x4001C8 + Align: 0x4 + Offset: 0x1C8 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x10 + Offset: 0x0 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Offset: 0x2FF8 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x4001C8 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 6E10CF17A4D84D5622C67A2FD38282BF121C67D5 + Type: NT_PRPSINFO + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x401000 + AddressAlign: 0x10 + Offset: 0x1000 + Content: 554889E5897DFC488975F08B45FC83C001488B4DF0486355FC488B0CD10FBE0983C1020FAFC15DC30F1F840000000000554889E54883E4F04883EC10488B05B52F00004889442408488D74240831FFE8ACFFFFFF48C7C03C00000048C7C7000000000F05 + - Name: .rodata + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] + Address: 0x402000 + AddressAlign: 0x1 + EntSize: 0x1 + Offset: 0x2000 + Content: '00' + - Name: .eh_frame + Type: SHT_X86_64_UNWIND + Flags: [ SHF_ALLOC ] + Address: 0x402008 + AddressAlign: 0x8 + Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000D8EFFFFF2800000000410E108602430D06630C0708000000180000003C000000E8EFFFFF3400000000410E108602430D06000000 + - Name: .data.rel.ro + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x403FF8 + AddressAlign: 0x8 + Offset: 0x2FF8 + Content: '0020400000000000' + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000000B02A1000339000000043D0000000100050306010604080707012800000001560500037E0000000802917C0800037E00000008029170090003820000000009023400000001560700070A02770809000B9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 011101252513050325721710171B25111B12067317000002340049133A0B3B0B02180000030101491300000421004913370B000005240003253E0B0B0B000006240003250B0B3E0B0000072E01111B1206401803253A0B3B0B271949133F190000080500021803253A0B3B0B49130000092E01111B1206401803253A0B3B0B27193F1900000A3400021803253A0B3B0B491300000B0F00491300000C26004913000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 2F686F6D652F667265696B2F6C6C766D2D73616E642F6C6C766D2F6C6C64622F746573742F5368656C6C2F4465627567696E666F642F496E70757473006D61696E2E6300 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 2C00000005000000000000006B00000072000000AF000000B4000000C8000000CD000000D1000000D8000000DD000000 +Symbols: + - Name: .note.gnu.build-id + Type: STT_SECTION + Section: .note.gnu.build-id + Value: 0x4001C8 + - Name: .text + Type: STT_SECTION + Section: .text + Value: 0x401000 + - Name: .rodata + Type: STT_SECTION + Section: .rodata + Value: 0x402000 + - Name: .eh_frame + Type: STT_SECTION + Section: .eh_frame + Value: 0x402008 + - Name: .data.rel.ro + Type: STT_SECTION + Section: .data.rel.ro + Value: 0x403FF8 + - Name: .comment + Type: STT_SECTION + Section: .comment + - Name: .debug_info + Type: STT_SECTION + Section: .debug_info + - Name: .debug_abbrev + Type: STT_SECTION + Section: .debug_abbrev + - Name: .debug_line + Type: STT_SECTION + Section: .debug_line + - Name: .debug_str + Type: STT_SECTION + Section: .debug_str + - Name: .debug_addr + Type: STT_SECTION + Section: .debug_addr + - Name: .debug_line_str + Type: STT_SECTION + Section: .debug_line_str + - Name: .debug_str_offsets + Type: STT_SECTION + Section: .debug_str_offsets + - Name: main.c + Type: STT_FILE + Index: SHN_ABS + - Name: _start + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401030 + Size: 0x34 + - Name: __bss_start + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: func + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401000 + Size: 0x28 + - Name: _edata + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: _end + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 +DWARF: + debug_str: + - 'Facebook clang version 15.0.0 (git@github.com:kevinfrei/llvm.git c240e4904407d0d937863fe30c2ebe77dc693225)' + - main.c + - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs' + - char + - __ARRAY_SIZE_TYPE__ + - func + - int + - _start + - argc + - argv + debug_addr: + - Length: 0x1C + Version: 0x5 + AddressSize: 0x8 + Entries: + - Address: 0x402000 + - Address: 0x401000 + - Address: 0x401030 +... diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml new file mode 100644 index 0000000000000..b3bbff01a3689 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml @@ -0,0 +1,50 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 + SectionHeaderStringTable: .strtab +Sections: + - Name: .debug_abbrev.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x1 + Content: 0111012525130503257625000002340049133A0B3B0B02180000030101491300000421004913370B000005240003253E0B0B0B000006240003250B0B3E0B0000072E01111B1206401803253A0B3B0B271949133F190000080500021803253A0B3B0B49130000092E015523401803253A0B3B0B27193F1900000A3400021803253A0B3B0B491300000B0F00491300000C26004913000000 + - Name: .debug_rnglists.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x1 + Content: '1000000005000800010000000400000004306400' + - Name: .debug_str.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 63686172005F5F41525241595F53495A455F545950455F5F0066756E6300696E74005F7374617274006172676300617267760046616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E676974206332343065343930343430376430643933373836336665333063326562653737646336393332323529006D61696E2E630067656E2F62696E2D73706C69742E64776F00 + - Name: .debug_str_offsets.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x1 + Content: 2C000000050000000000000005000000190000001E00000022000000290000002E000000330000009E000000A5000000 + - Name: .debug_info.dwo + Type: SHT_PROGBITS + Flags: [ SHF_EXCLUDE ] + AddressAlign: 0x1 + Content: 8D00000005000508000000008094E89A08DB62C101071D0008090224000000000B02A10003300000000434000000010005000601060108070701280000000156020003710000000802917C05000371000000080291700600037500000000090001560400070A02770806000B8400000000050305040B7A0000000B7F0000000C30000000037A0000000434000000010000 + - Name: .debug_cu_index + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 050000000400000001000000020000008094E89A08DB62C100000000000000000100000000000000010000000300000006000000080000000000000000000000000000000000000091000000970000003000000014000000 + - Type: SectionHeaderTable + Sections: + - Name: .strtab + - Name: .debug_abbrev.dwo + - Name: .debug_rnglists.dwo + - Name: .debug_str.dwo + - Name: .debug_str_offsets.dwo + - Name: .debug_info.dwo + - Name: .debug_cu_index + - Name: .symtab +Symbols: [] +... diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml new file mode 100644 index 0000000000000..7c0c95d4d7bac --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml @@ -0,0 +1,146 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x401030 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x400000 + Align: 0x1000 + Offset: 0x0 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + VAddr: 0x401000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .rodata + LastSec: .eh_frame + VAddr: 0x402000 + Align: 0x1000 + Offset: 0x2000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Align: 0x1000 + Offset: 0x2FF8 + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x4001C8 + Align: 0x4 + Offset: 0x1C8 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x10 + Offset: 0x0 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Offset: 0x2FF8 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x4001C8 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 14FE1776C0055EA25EFD58D934BB305FBBACDAC3 + Type: NT_PRPSINFO + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x401000 + AddressAlign: 0x10 + Offset: 0x1000 + Content: 554889E5897DFC488975F08B45FC83C001488B4DF0486355FC488B0CD10FBE0983C1020FAFC15DC30F1F840000000000554889E54883E4F04883EC10488B05B52F00004889442408488D74240831FFE8ACFFFFFF48C7C03C00000048C7C7000000000F05 + - Name: .rodata + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] + Address: 0x402000 + AddressAlign: 0x1 + EntSize: 0x1 + Offset: 0x2000 + Content: '00' + - Name: .eh_frame + Type: SHT_X86_64_UNWIND + Flags: [ SHF_ALLOC ] + Address: 0x402008 + AddressAlign: 0x8 + Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000D8EFFFFF2800000000410E108602430D06630C0708000000180000003C000000E8EFFFFF3400000000410E108602430D06000000 + - Name: .data.rel.ro + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x403FF8 + AddressAlign: 0x8 + Offset: 0x2FF8 + Content: '0020400000000000' + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900 +Symbols: + - Name: .note.gnu.build-id + Type: STT_SECTION + Section: .note.gnu.build-id + Value: 0x4001C8 + - Name: .text + Type: STT_SECTION + Section: .text + Value: 0x401000 + - Name: .rodata + Type: STT_SECTION + Section: .rodata + Value: 0x402000 + - Name: .eh_frame + Type: STT_SECTION + Section: .eh_frame + Value: 0x402008 + - Name: .data.rel.ro + Type: STT_SECTION + Section: .data.rel.ro + Value: 0x403FF8 + - Name: .comment + Type: STT_SECTION + Section: .comment + - Name: _start + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401030 + Size: 0x34 + - Name: __bss_start + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: func + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401000 + Size: 0x28 + - Name: _edata + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: _end + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 +... diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml new file mode 100644 index 0000000000000..e3679b3ca5b63 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml @@ -0,0 +1,217 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x401030 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x400000 + Align: 0x1000 + Offset: 0x0 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + VAddr: 0x401000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .rodata + LastSec: .eh_frame + VAddr: 0x402000 + Align: 0x1000 + Offset: 0x2000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Align: 0x1000 + Offset: 0x2FF8 + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x4001C8 + Align: 0x4 + Offset: 0x1C8 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x10 + Offset: 0x0 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Offset: 0x2FF8 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x4001C8 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 14FE1776C0055EA25EFD58D934BB305FBBACDAC3 + Type: NT_PRPSINFO + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x401000 + AddressAlign: 0x10 + Offset: 0x1000 + Content: 554889E5897DFC488975F08B45FC83C001488B4DF0486355FC488B0CD10FBE0983C1020FAFC15DC30F1F840000000000554889E54883E4F04883EC10488B05B52F00004889442408488D74240831FFE8ACFFFFFF48C7C03C00000048C7C7000000000F05 + - Name: .rodata + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] + Address: 0x402000 + AddressAlign: 0x1 + EntSize: 0x1 + Offset: 0x2000 + Content: '00' + - Name: .eh_frame + Type: SHT_X86_64_UNWIND + Flags: [ SHF_ALLOC ] + Address: 0x402008 + AddressAlign: 0x8 + Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000D8EFFFFF2800000000410E108602430D06630C0708000000180000003C000000E8EFFFFF3400000000410E108602430D06000000 + - Name: .data.rel.ro + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x403FF8 + AddressAlign: 0x8 + Offset: 0x2FF8 + Content: '0020400000000000' + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 2400000005000408000000008094E89A08DB62C10100000000080000000001016400000008000000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 014A00101772171B25B442197625111B12067317000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 2F686F6D652F667265696B2F6C6C766D2D73616E642F6C6C766D2F6C6C64622F746573742F5368656C6C2F4465627567696E666F642F496E70757473006D61696E2E6300 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 0C00000005000000000000003D000000 + - Name: .debug_gnu_pubnames + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 2A000000020000000000280000001A000000A000380000003066756E63005E000000305F73746172740000000000 + - Name: .debug_gnu_pubtypes + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: '2100000002000000000028000000300000009063686172007100000090696E740000000000' +Symbols: + - Name: .note.gnu.build-id + Type: STT_SECTION + Section: .note.gnu.build-id + Value: 0x4001C8 + - Name: .text + Type: STT_SECTION + Section: .text + Value: 0x401000 + - Name: .rodata + Type: STT_SECTION + Section: .rodata + Value: 0x402000 + - Name: .eh_frame + Type: STT_SECTION + Section: .eh_frame + Value: 0x402008 + - Name: .data.rel.ro + Type: STT_SECTION + Section: .data.rel.ro + Value: 0x403FF8 + - Name: .comment + Type: STT_SECTION + Section: .comment + - Name: .debug_info + Type: STT_SECTION + Section: .debug_info + - Name: .debug_abbrev + Type: STT_SECTION + Section: .debug_abbrev + - Name: .debug_line + Type: STT_SECTION + Section: .debug_line + - Name: .debug_str + Type: STT_SECTION + Section: .debug_str + - Name: .debug_addr + Type: STT_SECTION + Section: .debug_addr + - Name: .debug_line_str + Type: STT_SECTION + Section: .debug_line_str + - Name: .debug_str_offsets + Type: STT_SECTION + Section: .debug_str_offsets + - Name: .debug_gnu_pubnames + Type: STT_SECTION + Section: .debug_gnu_pubnames + - Name: .debug_gnu_pubtypes + Type: STT_SECTION + Section: .debug_gnu_pubtypes + - Name: main.c + Type: STT_FILE + Index: SHN_ABS + - Name: _start + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401030 + Size: 0x34 + - Name: __bss_start + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: func + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401000 + Size: 0x28 + - Name: _edata + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: _end + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 +DWARF: + debug_str: + - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs' + - 'gen/bin-split.dwo' + debug_addr: + - Length: 0x14 + Version: 0x5 + AddressSize: 0x8 + Entries: + - Address: 0x402000 + - Address: 0x401000 +... diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml new file mode 100644 index 0000000000000..f81ce51e4de1b --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml @@ -0,0 +1,146 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x401030 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x400000 + Align: 0x1000 + Offset: 0x0 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + VAddr: 0x401000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .rodata + LastSec: .eh_frame + VAddr: 0x402000 + Align: 0x1000 + Offset: 0x2000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Align: 0x1000 + Offset: 0x2FF8 + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x4001C8 + Align: 0x4 + Offset: 0x1C8 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x10 + Offset: 0x0 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Offset: 0x2FF8 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x4001C8 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 6E10CF17A4D84D5622C67A2FD38282BF121C67D5 + Type: NT_PRPSINFO + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x401000 + AddressAlign: 0x10 + Offset: 0x1000 + Content: 554889E5897DFC488975F08B45FC83C001488B4DF0486355FC488B0CD10FBE0983C1020FAFC15DC30F1F840000000000554889E54883E4F04883EC10488B05B52F00004889442408488D74240831FFE8ACFFFFFF48C7C03C00000048C7C7000000000F05 + - Name: .rodata + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] + Address: 0x402000 + AddressAlign: 0x1 + EntSize: 0x1 + Offset: 0x2000 + Content: '00' + - Name: .eh_frame + Type: SHT_X86_64_UNWIND + Flags: [ SHF_ALLOC ] + Address: 0x402008 + AddressAlign: 0x8 + Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000D8EFFFFF2800000000410E108602430D06630C0708000000180000003C000000E8EFFFFF3400000000410E108602430D06000000 + - Name: .data.rel.ro + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x403FF8 + AddressAlign: 0x8 + Offset: 0x2FF8 + Content: '0020400000000000' + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900 +Symbols: + - Name: .note.gnu.build-id + Type: STT_SECTION + Section: .note.gnu.build-id + Value: 0x4001C8 + - Name: .text + Type: STT_SECTION + Section: .text + Value: 0x401000 + - Name: .rodata + Type: STT_SECTION + Section: .rodata + Value: 0x402000 + - Name: .eh_frame + Type: STT_SECTION + Section: .eh_frame + Value: 0x402008 + - Name: .data.rel.ro + Type: STT_SECTION + Section: .data.rel.ro + Value: 0x403FF8 + - Name: .comment + Type: STT_SECTION + Section: .comment + - Name: _start + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401030 + Size: 0x34 + - Name: __bss_start + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: func + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401000 + Size: 0x28 + - Name: _edata + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: _end + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 +... diff --git a/lldb/test/Shell/Debuginfod/Inputs/main.c b/lldb/test/Shell/Debuginfod/Inputs/main.c new file mode 100644 index 0000000000000..584eb11072953 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/main.c @@ -0,0 +1,10 @@ +// A script to (re)create the .yaml files is in 'make-inputs'. If you make changes +// you'll need to update the .note.gnu.buildid values in the tests, as the cache names + +int func(int argc, const char **argv) { + return (argc + 1) * (argv[argc][0] + 2); +} + +int main(int argc, const char *argv[]) { + return func(0, argv); +} diff --git a/lldb/test/Shell/Debuginfod/Inputs/make-inputs b/lldb/test/Shell/Debuginfod/Inputs/make-inputs new file mode 100755 index 0000000000000..c1ec233d10d0b --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/make-inputs @@ -0,0 +1,86 @@ +#!/bin/sh + +# Testing 5 different scenarios: +# 1 - A stripped binary with it's corresponding unstripped binary: +# 2 - A stripped binary with a corresponding --only-keep-debug symbols file +# 3 - A split binary with it's corresponding DWP file +# 4 - A stripped, split binary with an unstripped binary and a DWP file +# 5 - A stripped, split binary with an --only-keep-debug symbols file and a DWP file + +mkdir -p gen +mkdir -p run + +# First, compile & link the binaries (normal and split) + +${builddir}/bin/clang -g -o gen/bin-normal.o -O0 -c main.c +ld -nostdlib gen/bin-normal.o --build-id=sha1 -o gen/bin-normal +${builddir}/bin/clang -g -gsplit-dwarf -o gen/bin-split.o -O0 -c main.c +ld -nostdlib gen/bin-split.o --build-id=sha1 -o gen/bin-split + +# Next, create the file variations we need + +# Variation 1: -g, stripped +${builddir}/bin/llvm-objcopy --strip-debug gen/bin-normal gen/bin-stripped +# Variation 2: -g, stripped, --only-keep-debug symbols +${builddir}/bin/llvm-objcopy --only-keep-debug gen/bin-normal gen/sym-stripped +# Variation 3: -gsplit-dwarf: .dwp +${builddir}/bin/llvm-dwp -e gen/bin-split -o gen/bin-split.dwp +# Variation 4: -gsplit-dwarf: stripped, .dwp +${builddir}/bin/llvm-objcopy --strip-debug gen/bin-split gen/bin-split-stripped +# Variation 5: -gsplit-dwarf: stripped, --only-keep-debug + .dwp +${builddir}/bin/llvm-objcopy --only-keep-debug gen/bin-split gen/sym-split + +# Finally, produce the .yaml files for testing + +# Scenario 1: +# target: bin-stripped +# Scenario 1a: +# symbols: bin-normal (hosted as debuginfo) +# Scenario 1b: +# symbols: bin-normal (hosted as executable) +${builddir}/bin/obj2yaml gen/bin-stripped -o bin-stripped.yaml +${builddir}/bin/obj2yaml gen/bin-normal -o bin-normal.yaml +# @ testing time: yaml2obj bin-stripped.yaml -o ${out}/bin-stripped +# @ testing time: yaml2obj bin-normal.yaml -o ${out}/bin-normal + + +# Scenario 2: +# target: bin-stripped-okd +# Scenario 2a: +# symbols: sym-stripped (hosted as debuginfo) +# Scenario 2b: +# symbols: sym-stripped (hosted as executable) +${builddir}/bin/obj2yaml gen/sym-stripped -o sym-stripped.yaml +# To produce a correct .gnu.debuglink, you have to do it at test generation time. +# The section includes a CRC that yaml2obj doesn't properly produce. +# @ testing time: yaml2obj sym-stripped.yaml -o ${out}/sym-stripped +# @ testing time: llvm-objcopy bin-stripped --add-gnu-debuglink=${out}/sym-stripped ${out}/bin-stripped-okd + +# Scenario 3: +# target: bin-split +# DWP: bin-split.dwp (hosted as debuginfo) +${builddir}/bin/obj2yaml gen/bin-split -o bin-split.yaml +${builddir}/bin/obj2yaml gen/bin-split.dwp -o bin-split-dwp.yaml +# @ testing time: yaml2obj bin-split.yaml -o ${out}/bin-split +# @ testing time: yaml2obj bin-split-dwp.yaml -o ${out}/bin-split.dwp + +# Scenario 4: +# target: bin-split-stripped +# symbols: bin-split (hosted as executable) +# DWP bin-split.dwp (hosted as debuginfo) +# This doesn't work from a file system "as is". +# I believe you can set the symbol file manually to the bin-split file. +# TODO: Need to check for the -no-locator test to see what the name of +# the .dwp is expected to be. +${builddir}/bin/obj2yaml gen/bin-split-stripped -o bin-split-stripped.yaml +# bin-split and bin-split.dwp already generated in Scenario 3 +# @ testing time: yaml2obj bin-split-stripped.yaml -o ${out}/bin-split-stripped + +# Scenario 5: +# target: bin-split-stripped-okd +# symbols: sym-split (hosted as executable) +# DWP: bin-split.dwp (hosted as debuginfo) +${builddir}/bin/obj2yaml gen/sym-split -o sym-split.yaml +# @ testing time: yaml2obj main-split-nodbg.yaml -o gen/main-split-nodbg.tmp +# @ testing time: yaml2obj main-split-dbg.yaml -o run/main-split-dbg +# @ testing time: llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg diff --git a/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml b/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml new file mode 100644 index 0000000000000..9cebffacac747 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml @@ -0,0 +1,216 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x401030 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x400000 + Align: 0x1000 + Offset: 0x0 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + VAddr: 0x401000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .rodata + LastSec: .eh_frame + VAddr: 0x402000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Align: 0x1000 + Offset: 0x1FF8 + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x4001C8 + Align: 0x4 + Offset: 0x1C8 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x10 + Offset: 0x0 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Offset: 0x1FF8 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x4001C8 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 14FE1776C0055EA25EFD58D934BB305FBBACDAC3 + Type: NT_PRPSINFO + - Name: .text + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x401000 + AddressAlign: 0x10 + Offset: 0x1000 + Size: 0x64 + - Name: .rodata + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] + Address: 0x402000 + AddressAlign: 0x1 + EntSize: 0x1 + Size: 0x1 + - Name: .eh_frame + Type: SHT_NOBITS + Flags: [ SHF_ALLOC ] + Address: 0x402008 + AddressAlign: 0x8 + Size: 0x54 + - Name: .data.rel.ro + Type: SHT_NOBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x403FF8 + AddressAlign: 0x8 + Offset: 0x1FF8 + Size: 0x8 + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 2400000005000408000000008094E89A08DB62C10100000000080000000001016400000008000000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 014A00101772171B25B442197625111B12067317000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 2F686F6D652F667265696B2F6C6C766D2D73616E642F6C6C766D2F6C6C64622F746573742F5368656C6C2F4465627567696E666F642F496E70757473006D61696E2E6300 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 0C00000005000000000000003D000000 + - Name: .debug_gnu_pubnames + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 2A000000020000000000280000001A000000A000380000003066756E63005E000000305F73746172740000000000 + - Name: .debug_gnu_pubtypes + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: '2100000002000000000028000000300000009063686172007100000090696E740000000000' +Symbols: + - Name: .note.gnu.build-id + Type: STT_SECTION + Section: .note.gnu.build-id + Value: 0x4001C8 + - Name: .text + Type: STT_SECTION + Section: .text + Value: 0x401000 + - Name: .rodata + Type: STT_SECTION + Section: .rodata + Value: 0x402000 + - Name: .eh_frame + Type: STT_SECTION + Section: .eh_frame + Value: 0x402008 + - Name: .data.rel.ro + Type: STT_SECTION + Section: .data.rel.ro + Value: 0x403FF8 + - Name: .comment + Type: STT_SECTION + Section: .comment + - Name: .debug_info + Type: STT_SECTION + Section: .debug_info + - Name: .debug_abbrev + Type: STT_SECTION + Section: .debug_abbrev + - Name: .debug_line + Type: STT_SECTION + Section: .debug_line + - Name: .debug_str + Type: STT_SECTION + Section: .debug_str + - Name: .debug_addr + Type: STT_SECTION + Section: .debug_addr + - Name: .debug_line_str + Type: STT_SECTION + Section: .debug_line_str + - Name: .debug_str_offsets + Type: STT_SECTION + Section: .debug_str_offsets + - Name: .debug_gnu_pubnames + Type: STT_SECTION + Section: .debug_gnu_pubnames + - Name: .debug_gnu_pubtypes + Type: STT_SECTION + Section: .debug_gnu_pubtypes + - Name: main.c + Type: STT_FILE + Index: SHN_ABS + - Name: _start + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401030 + Size: 0x34 + - Name: __bss_start + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: func + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401000 + Size: 0x28 + - Name: _edata + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: _end + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 +DWARF: + debug_str: + - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs' + - 'gen/bin-split.dwo' + debug_addr: + - Length: 0x14 + Version: 0x5 + AddressSize: 0x8 + Entries: + - Address: 0x402000 + - Address: 0x401000 +... diff --git a/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml new file mode 100644 index 0000000000000..b9118d1a1820a --- /dev/null +++ b/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml @@ -0,0 +1,211 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 + Entry: 0x401030 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x400000 + Align: 0x1000 + Offset: 0x0 + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .text + VAddr: 0x401000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_R ] + FirstSec: .rodata + LastSec: .eh_frame + VAddr: 0x402000 + Align: 0x1000 + Offset: 0x1000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Align: 0x1000 + Offset: 0x1FF8 + - Type: PT_NOTE + Flags: [ PF_R ] + FirstSec: .note.gnu.build-id + LastSec: .note.gnu.build-id + VAddr: 0x4001C8 + Align: 0x4 + Offset: 0x1C8 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x10 + Offset: 0x0 + - Type: PT_GNU_RELRO + Flags: [ PF_R ] + FirstSec: .data.rel.ro + LastSec: .data.rel.ro + VAddr: 0x403FF8 + Offset: 0x1FF8 +Sections: + - Name: .note.gnu.build-id + Type: SHT_NOTE + Flags: [ SHF_ALLOC ] + Address: 0x4001C8 + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 6E10CF17A4D84D5622C67A2FD38282BF121C67D5 + Type: NT_PRPSINFO + - Name: .text + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x401000 + AddressAlign: 0x10 + Offset: 0x1000 + Size: 0x64 + - Name: .rodata + Type: SHT_NOBITS + Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ] + Address: 0x402000 + AddressAlign: 0x1 + EntSize: 0x1 + Size: 0x1 + - Name: .eh_frame + Type: SHT_NOBITS + Flags: [ SHF_ALLOC ] + Address: 0x402008 + AddressAlign: 0x8 + Size: 0x54 + - Name: .data.rel.ro + Type: SHT_NOBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x403FF8 + AddressAlign: 0x8 + Offset: 0x1FF8 + Size: 0x8 + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000000B02A1000339000000043D0000000100050306010604080707012800000001560500037E0000000802917C0800037E00000008029170090003820000000009023400000001560700070A02770809000B9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000 + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 011101252513050325721710171B25111B12067317000002340049133A0B3B0B02180000030101491300000421004913370B000005240003253E0B0B0B000006240003250B0B3E0B0000072E01111B1206401803253A0B3B0B271949133F190000080500021803253A0B3B0B49130000092E01111B1206401803253A0B3B0B27193F1900000A3400021803253A0B3B0B491300000B0F00491300000C26004913000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101 + - Name: .debug_line_str + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 2F686F6D652F667265696B2F6C6C766D2D73616E642F6C6C766D2F6C6C64622F746573742F5368656C6C2F4465627567696E666F642F496E70757473006D61696E2E6300 + - Name: .debug_str_offsets + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 2C00000005000000000000006B00000072000000AF000000B4000000C8000000CD000000D1000000D8000000DD000000 +Symbols: + - Name: .note.gnu.build-id + Type: STT_SECTION + Section: .note.gnu.build-id + Value: 0x4001C8 + - Name: .text + Type: STT_SECTION + Section: .text + Value: 0x401000 + - Name: .rodata + Type: STT_SECTION + Section: .rodata + Value: 0x402000 + - Name: .eh_frame + Type: STT_SECTION + Section: .eh_frame + Value: 0x402008 + - Name: .data.rel.ro + Type: STT_SECTION + Section: .data.rel.ro + Value: 0x403FF8 + - Name: .comment + Type: STT_SECTION + Section: .comment + - Name: .debug_info + Type: STT_SECTION + Section: .debug_info + - Name: .debug_abbrev + Type: STT_SECTION + Section: .debug_abbrev + - Name: .debug_line + Type: STT_SECTION + Section: .debug_line + - Name: .debug_str + Type: STT_SECTION + Section: .debug_str + - Name: .debug_addr + Type: STT_SECTION + Section: .debug_addr + - Name: .debug_line_str + Type: STT_SECTION + Section: .debug_line_str + - Name: .debug_str_offsets + Type: STT_SECTION + Section: .debug_str_offsets + - Name: main.c + Type: STT_FILE + Index: SHN_ABS + - Name: _start + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401030 + Size: 0x34 + - Name: __bss_start + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: func + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x401000 + Size: 0x28 + - Name: _edata + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 + - Name: _end + Section: .data.rel.ro + Binding: STB_GLOBAL + Value: 0x404000 +DWARF: + debug_str: + - 'Facebook clang version 15.0.0 (git@github.com:kevinfrei/llvm.git c240e4904407d0d937863fe30c2ebe77dc693225)' + - main.c + - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs' + - char + - __ARRAY_SIZE_TYPE__ + - func + - int + - _start + - argc + - argv + debug_addr: + - Length: 0x1C + Version: 0x5 + AddressSize: 0x8 + Entries: + - Address: 0x402000 + - Address: 0x401000 + - Address: 0x401030 +... diff --git a/lldb/test/Shell/Debuginfod/okdstrip-negative.test b/lldb/test/Shell/Debuginfod/okdstrip-negative.test new file mode 100644 index 0000000000000..8b0603e6f5860 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/okdstrip-negative.test @@ -0,0 +1,24 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 2 negative: +# * A stripped binary, with an "-only-keep-debug" symbols which is *not* there. +# * LLDB should fail to find the OKD file automatically using .gnu.debuglink. + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped.tmp +# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/bin-stripped.dbg +# RUN: llvm-objcopy %t/bin-stripped.tmp --add-gnu-debuglink=%t/bin-stripped.dbg %t/bin-stripped +# RUN: rm %t/bin-stripped.dbg +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should NOT have source file information: + +# CHECK: Breakpoint 1: where = bin-stripped`func, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test b/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test new file mode 100644 index 0000000000000..4fd8463744d2c --- /dev/null +++ b/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test @@ -0,0 +1,22 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 2 baseline: +# * A stripped binary, with an "-only-keep-debug" symbols file. +# * LLDB should find the OKD file automatically using .gnu.debuglink. + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped.tmp +# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/bin-stripped.dbg +# RUN: llvm-objcopy %t/bin-stripped.tmp --add-gnu-debuglink=%t/bin-stripped.dbg %t/bin-stripped +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should have source file and line information: +# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:4:11, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test b/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test new file mode 100644 index 0000000000000..00e1b7c5bc72c --- /dev/null +++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test @@ -0,0 +1,28 @@ +# REQUIRES: curl && system-linux && native && target-x86_64 + +# Scenario 2a: +# A stripped binary, with an "-only-keep-debug" symbols file. +# LLDB should request the symbols from Debuginfod as 'debuginfo'. + +# Set up a file-system 'hosted' Debuginfod server. +# RUN: rm -rf %t +# RUN: mkdir -p %t/cache +# RUN: mkdir -p %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5 + +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped.tmp +# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/bin-stripped.dbg +# RUN: llvm-objcopy %t/bin-stripped.tmp --add-gnu-debuglink=%t/bin-stripped.dbg %t/bin-stripped +# RUN: mv %t/bin-stripped.dbg %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5/debuginfo +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup true" \ +# RUN: -o "settings set plugin.symbol-locator.debuginfod.cache-path %t/cache" \ +# RUN: -o "settings clear plugin.symbol-locator.debuginfod.server-urls" \ +# RUN: -o "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%t" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should have source file and line information: +# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:4:11, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test b/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test new file mode 100644 index 0000000000000..c4444ce166811 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test @@ -0,0 +1,28 @@ +# REQUIRES: curl && system-linux && native && target-x86_64 + +# Scenario 2b: +# A stripped binary, with an "-only-keep-debug" symbols file. +# LLDB should request the symbols from Debuginfod as 'executable'. + +# Set up a file-system 'hosted' Debuginfod server. +# RUN: rm -rf %t +# RUN: mkdir -p %t/cache +# RUN: mkdir -p %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5 + +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped.tmp +# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/bin-stripped.dbg +# RUN: llvm-objcopy %t/bin-stripped.tmp --add-gnu-debuglink=%t/bin-stripped.dbg %t/bin-stripped +# RUN: mv %t/bin-stripped.dbg %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5/executable +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup true" \ +# RUN: -o "settings set plugin.symbol-locator.debuginfod.cache-path %t/cache" \ +# RUN: -o "settings clear plugin.symbol-locator.debuginfod.server-urls" \ +# RUN: -o "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%t" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should have source file and line information: +# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:4:11, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/split-negative.test b/lldb/test/Shell/Debuginfod/split-negative.test new file mode 100644 index 0000000000000..6458abd4485df --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-negative.test @@ -0,0 +1,23 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 3 negative: +# * A split-dwarf binary with a *missing* .dwp file (validate nothing's cached). + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/bin-split +# RUN: chmod a+x %t/bin-split + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-split" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Symbol file: {{.*}}/bin-split +# CHECK-NEXT: Type: "dwo" +# CHECK-NEXT: Dwo ID{{.*}} +# CHECK-NEXT: {{^[- ]+$}} +# Verify it's missing the DWP file (and DWOs) +# CHECK-NEXT: 0x{{[0-9a-f]+.*}} unable to locate .dwo debug file {{.*}}bin-split.dwo{{.*}} for skeleton DIE 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/split-no-locator.test b/lldb/test/Shell/Debuginfod/split-no-locator.test new file mode 100644 index 0000000000000..11ac3c60d5b87 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-no-locator.test @@ -0,0 +1,24 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 3 baseline: +# * A split-dwarf binary with the .dwp file right next to the binary. + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/bin-split +# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/bin-split.dwp +# RUN: chmod a+x %t/bin-split + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-split" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Symbol file: {{.*}}/bin-split +# CHECK-NEXT: Type: "dwo" +# CHECK-NEXT: Dwo ID{{.*}} +# CHECK-NEXT: {{^[- ]+$}} +# Verify it found the DWP file properly: +# CHECK-NEXT: 0x{{[0-9a-f]+.* +}}/{{.*}}/bin-split.dwp({{.*}}bin-split.dwo){{ *$}} diff --git a/lldb/test/Shell/Debuginfod/split-okdstrip-negative.test b/lldb/test/Shell/Debuginfod/split-okdstrip-negative.test new file mode 100644 index 0000000000000..0b2267329650a --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-okdstrip-negative.test @@ -0,0 +1,24 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 5 negative: +# * An "only-keep-debug" stripped, split binary with a _missing_ +# * --add-gnu-debuglink symbol file. + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/bin-split-stripped.tmp +# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/sym-split +# RUN: llvm-objcopy %t/bin-split-stripped.tmp --add-gnu-debuglink=%t/sym-split %t/bin-split-stripped +# RUN: rm %t/sym-split +# RUN: chmod a+x %t/bin-split-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-split-stripped" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Current executable set to {{.*}}/bin-split-stripped' (x86_64). +# CHECK-NEXT: target modules dump separate-debug-info +# CHECK-NEXT: error: no matching executable images found diff --git a/lldb/test/Shell/Debuginfod/split-okdstrip-no-locator.test b/lldb/test/Shell/Debuginfod/split-okdstrip-no-locator.test new file mode 100644 index 0000000000000..c4574257b5d07 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-okdstrip-no-locator.test @@ -0,0 +1,27 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 5 baseline: +# * A stripped, split binary, with --add-gnu-debuglink symbols automatically +# * found, with a .dwp file located next to the binary. + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/bin-split-stripped.tmp +# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/sym-split +# RUN: llvm-objcopy %t/bin-split-stripped.tmp --add-gnu-debuglink=%t/sym-split %t/bin-split-stripped +# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/bin-split-stripped.dwp +# RUN: chmod a+x %t/bin-split-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-split-stripped" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Symbol file: {{.*}}/bin-split-stripped +# CHECK-NEXT: Type: "dwo" +# CHECK-NEXT: Dwo ID{{.*}} +# CHECK-NEXT: {{[- ]+}} +# Verify it found the DWP file properly +# CHECK-NEXT: 0x{{[0-9a-f]+.* +}}/{{.*}}/bin-split-stripped.dwp({{.*}}bin-split.dwo){{ *$}} diff --git a/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test new file mode 100644 index 0000000000000..0197b0b5e4101 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test @@ -0,0 +1,32 @@ +# REQUIRES: curl && system-linux && native && target-x86_64 + +# Scenario 5: +# * A stripped, split binary, with --add-gnu-debuglink symbol file where +# * both files are *only* available through Debuginfod. + +# Set up a file-system 'hosted' Debuginfod server +# RUN: rm -rf %t +# RUN: mkdir -p %t/cache +# RUN: mkdir -p %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3 + +# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/bin-split-stripped.tmp +# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/sym-split +# RUN: llvm-objcopy %t/bin-split-stripped.tmp --add-gnu-debuglink=%t/sym-split %t/bin-split-stripped +# RUN: mv %t/sym-split %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3/executable +# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3/debuginfo +# RUN: chmod a+x %t/bin-split-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup true" \ +# RUN: -o "settings set plugin.symbol-locator.debuginfod.cache-path %t/cache" \ +# RUN: -o "settings clear plugin.symbol-locator.debuginfod.server-urls" \ +# RUN: -o "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%t" \ +# RUN: -o "target create %t/bin-split-stripped" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Symbol file: {{.*}}/bin-split-stripped +# CHECK-NEXT: Type: "dwo" +# CHECK-NEXT: Dwo ID{{.*}} +# CHECK-NEXT: {{[- ]+}} +# CHECK-NEXT: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-14969591668314937758{{ *$}} diff --git a/lldb/test/Shell/Debuginfod/split-positive.test b/lldb/test/Shell/Debuginfod/split-positive.test new file mode 100644 index 0000000000000..3621b3f8d2113 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-positive.test @@ -0,0 +1,30 @@ +# REQUIRES: curl && system-linux && native && target-x86_64 + +# Scenario 3: +# * A split-dwarf binary with a Debuginfod-hosted .dwp file. + +# Set up a file-system 'hosted' Debuginfod server +# RUN: rm -rf %t +# RUN: mkdir -p %t/cache +# RUN: mkdir -p %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3 + +# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/bin-split +# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3/debuginfo +# RUN: chmod a+x %t/bin-split + +# RUN: %lldb -o "settings set symbols.enable-external-lookup true" \ +# RUN: -o "settings set plugin.symbol-locator.debuginfod.cache-path %t/cache" \ +# RUN: -o "settings clear plugin.symbol-locator.debuginfod.server-urls" \ +# RUN: -o "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%t" \ +# RUN: -o "target create %t/bin-split" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Symbol file: {{.*}}/bin-split +# CHECK-NEXT: Type: "dwo" +# CHECK-NEXT: Dwo ID{{.*}} +# CHECK-NEXT: {{[- ]+}} +# The cache key is stable, so mandating it's location verifies it was cached. +# The '.tmp' (sort of) ensures the cache is our private cache, not the system cache. +# CHECK-NEXT: {{0x[0-9a-f]+.* +}}/{{.*}}.tmp/cache/llvmcache-14969591668314937758{{ *$}} diff --git a/lldb/test/Shell/Debuginfod/split-strip-negative.test b/lldb/test/Shell/Debuginfod/split-strip-negative.test new file mode 100644 index 0000000000000..0359fdb0cfb7d --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-strip-negative.test @@ -0,0 +1,19 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 4 negative: +# * A stripped, split binary with missing symbols and missing .dwp file. + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/bin-split-stripped +# RUN: chmod a+x %t/bin-split-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-split-stripped" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Current executable set to '{{.*}}/bin-split-stripped' +# CHECK: error: no matching executable images found diff --git a/lldb/test/Shell/Debuginfod/split-strip-no-locator.test b/lldb/test/Shell/Debuginfod/split-strip-no-locator.test new file mode 100644 index 0000000000000..a7638f918811d --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-strip-no-locator.test @@ -0,0 +1,27 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 4 baseline: +# * A stripped, split binary, with symbols manually added and the +# * .dwp file located (automatically) sitting next to the binary. + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/bin-split-stripped +# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/bin-split +# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/bin-split-stripped.dwp +# RUN: chmod a+x %t/bin-split-stripped +# RUN: chmod a+x %t/bin-split + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-split-stripped" \ +# RUN: -o "target symbols add %t/bin-split" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Symbol file: {{.*}}/bin-split-stripped +# CHECK-NEXT: Type: "dwo" +# CHECK-NEXT: Dwo ID{{.*}} +# CHECK-NEXT: {{^[- ]+$}} +# CHECK-NEXT: {{0x[0-9a-f]+.* +.*}}/bin-split-stripped.dwp({{.*}}/bin-split.dwo){{ *$}} diff --git a/lldb/test/Shell/Debuginfod/split-strip-positive.test b/lldb/test/Shell/Debuginfod/split-strip-positive.test new file mode 100644 index 0000000000000..4c6510986913f --- /dev/null +++ b/lldb/test/Shell/Debuginfod/split-strip-positive.test @@ -0,0 +1,32 @@ +# REQUIRES: curl && system-linux && native && target-x86_64 + +# Scenario 4: +# * A stripped, split binary, with the unstripped binary and .dwp file +# * hosted by Debuginfod. + +# Set up a file-system 'hosted' Debuginfod server. +# RUN: rm -rf %t +# RUN: mkdir -p %t/cache +# RUN: mkdir -p %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3 + +# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/bin-split-stripped +# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3/executable +# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/14fe1776c0055ea25efd58d934bb305fbbacdac3/debuginfo +# RUN: chmod a+x %t/bin-split-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup true" \ +# RUN: -o "settings set plugin.symbol-locator.debuginfod.cache-path %t/cache" \ +# RUN: -o "settings clear plugin.symbol-locator.debuginfod.server-urls" \ +# RUN: -o "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%t" \ +# RUN: -o "target create %t/bin-split-stripped" \ +# RUN: -o "target modules dump separate-debug-info" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: Symbol file: {{.*}}/bin-split-stripped +# CHECK-NEXT: Type: "dwo" +# CHECK-NEXT: Dwo ID{{.*}} +# CHECK-NEXT: {{^[- ]+$}} +# The cache key is stable, so mandating it's location verifies it was cached. +# The '.tmp' (sort of) ensures the cache is our private cache, not the system cache. +# CHECK-NEXT: {{0x[0-9a-f]+.* +}}/{{.*}}.tmp/cache/llvmcache-14969591668314937758{{ *$}} diff --git a/lldb/test/Shell/Debuginfod/strip-negative.test b/lldb/test/Shell/Debuginfod/strip-negative.test new file mode 100644 index 0000000000000..5aae7189678a1 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/strip-negative.test @@ -0,0 +1,20 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 1 negative: +# * A plain stripped binary, no symbols available +# * Negative test: make sure nothing's been cached + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should NOT have source file information: +# CHECK: Breakpoint 1: where = bin-stripped`func, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/strip-no-locator.test b/lldb/test/Shell/Debuginfod/strip-no-locator.test new file mode 100644 index 0000000000000..562c8d8e620b4 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/strip-no-locator.test @@ -0,0 +1,22 @@ +# REQUIRES: system-linux && native && target-x86_64 + +# Scenario 1 baseline: +# * A plain stripped binary, add the unstripped binary as a symbol file +# * Sanity for functional parity with Debuginfod-provided symbols + +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/bin-normal +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "target symbols add %t/bin-normal" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should have correct source file and line information: +# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:4:11, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/strip-positive-a.test b/lldb/test/Shell/Debuginfod/strip-positive-a.test new file mode 100644 index 0000000000000..72e3c8801d749 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/strip-positive-a.test @@ -0,0 +1,26 @@ +# REQUIRES: curl && system-linux && native && target-x86_64 + +# Scenario 1a: +# * A plain stripped binary +# * Debuginfod has the unstripped binary as the 'debuginfo' + +# Set up a file-system 'hosted' Debuginfod server: +# RUN: rm -rf %t +# RUN: mkdir -p %t/cache +# RUN: mkdir -p %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5 + +# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5/debuginfo +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup true" \ +# RUN: -o "settings set plugin.symbol-locator.debuginfod.cache-path %t/cache" \ +# RUN: -o "settings clear plugin.symbol-locator.debuginfod.server-urls" \ +# RUN: -o "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%t" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should have source file and line info: +# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:4:11, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/Debuginfod/strip-positive-b.test b/lldb/test/Shell/Debuginfod/strip-positive-b.test new file mode 100644 index 0000000000000..b3344228bcbb0 --- /dev/null +++ b/lldb/test/Shell/Debuginfod/strip-positive-b.test @@ -0,0 +1,26 @@ +# REQUIRES: curl && system-linux && native && target-x86_64 + +# Scenario 1b: +# * A plain stripped binary +# * Debuginfod has the unstripped binary as the 'executable' + +# Set up a file-system 'hosted' Debuginfod server: +# RUN: rm -rf %t +# RUN: mkdir -p %t/cache +# RUN: mkdir -p %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5 + +# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5/executable +# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/bin-stripped +# RUN: chmod a+x %t/bin-stripped + +# RUN: %lldb -o "settings set symbols.enable-external-lookup true" \ +# RUN: -o "settings set plugin.symbol-locator.debuginfod.cache-path %t/cache" \ +# RUN: -o "settings clear plugin.symbol-locator.debuginfod.server-urls" \ +# RUN: -o "settings insert-before plugin.symbol-locator.debuginfod.server-urls 0 file://%t" \ +# RUN: -o "target create %t/bin-stripped" \ +# RUN: -o "b func" \ +# RUN: -o "quit" \ +# RUN: 2>&1 | FileCheck %s + +# Should have source file and line info: +# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:4:11, address = 0x{{[0-9a-f]+}} diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py index d75c1f532e147..9a596a40b2966 100644 --- a/lldb/test/Shell/lit.cfg.py +++ b/lldb/test/Shell/lit.cfg.py @@ -144,6 +144,9 @@ def calculate_arch_features(arch_string): if config.lldb_system_debugserver: config.available_features.add("system-debugserver") +if config.llvm_enable_curl: + config.available_features.add("curl") + if config.have_lldb_server: config.available_features.add("lldb-server") diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in index 736dfc335732b..5428691c129a1 100644 --- a/lldb/test/Shell/lit.site.cfg.py.in +++ b/lldb/test/Shell/lit.site.cfg.py.in @@ -19,6 +19,7 @@ config.python_executable = "@Python3_EXECUTABLE@" config.have_zlib = @LLVM_ENABLE_ZLIB@ config.objc_gnustep_dir = "@LLDB_TEST_OBJC_GNUSTEP_DIR@" config.lldb_enable_lzma = @LLDB_ENABLE_LZMA@ +config.llvm_enable_curl = @LLVM_ENABLE_CURL@ config.host_triple = "@LLVM_HOST_TRIPLE@" config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@