[compiler-rt] [clang] [lldb] [clang-tools-extra] [libc] [flang] [llvm] LLDB Debuginfod usage tests (with fixes) (PR #79181)

Kevin Frei via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 26 09:37:58 PST 2024


https://github.com/kevinfrei updated https://github.com/llvm/llvm-project/pull/79181

>From 4e30a8bf6a93729b6fb367814c95becf16201057 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Thu, 18 Jan 2024 09:09:50 -0800
Subject: [PATCH 01/12] Added settings for cache location and timeout

---
 llvm/lib/Debuginfod/Debuginfod.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 4928fcb3b3f8791..0dd8a7de1245b31 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -159,6 +159,10 @@ Expected<std::string> getCachedOrDownloadDebuginfo(BuildIDRef ID) {
   return getCachedOrDownloadArtifact(getDebuginfodCacheKey(UrlPath), UrlPath);
 }
 
+Expected<std::string> getCachedOrDownloadDebuginfo(BuildIDRef ID) {
+  std::string UrlPath = getDebuginfodDebuginfoUrlPath(ID);
+  return getCachedOrDownloadArtifact(getDebuginfodCacheKey(UrlPath), UrlPath);
+}
 // General fetching function.
 Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
                                                   StringRef UrlPath) {

>From a1ee878e150c7ff3f3638bfbf10846c3f2cf16ac Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Fri, 19 Jan 2024 07:11:17 -0800
Subject: [PATCH 02/12] Continuing to pick my changes apart a little bit

---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp      |  18 ++
 .../SymbolFile/DWARF/SymbolFileDWARF.h        |   3 +
 .../Plugins/SymbolLocator/CMakeLists.txt      |   7 +-
 .../Debuginfod/SymbolLocatorDebuginfod.cpp    |   6 +-
 .../SymbolVendor/ELF/SymbolVendorELF.cpp      |  13 +-
 .../Shell/Debuginfod/Inputs/main-dbg.yaml     | 211 +++++++++++++++++
 .../Shell/Debuginfod/Inputs/main-dwp.yaml     |  50 ++++
 .../Shell/Debuginfod/Inputs/main-full.yaml    | 212 +++++++++++++++++
 .../Shell/Debuginfod/Inputs/main-nodbg.yaml   | 146 ++++++++++++
 .../Debuginfod/Inputs/main-split-dbg.yaml     | 216 +++++++++++++++++
 .../Debuginfod/Inputs/main-split-nodbg.yaml   | 146 ++++++++++++
 .../Shell/Debuginfod/Inputs/main-split.yaml   | 217 ++++++++++++++++++
 .../Debuginfod/Inputs/main-stripped.yaml      | 146 ++++++++++++
 lldb/test/Shell/Debuginfod/Inputs/main.c      |  82 +++++++
 lldb/test/Shell/Debuginfod/Inputs/mk          |  51 ++++
 .../Shell/Debuginfod/okd-split-negative.test  |  31 +++
 .../Shell/Debuginfod/okd-split-positive.test  |  40 ++++
 .../Debuginfod/okd-stripped-negative.test     |  32 +++
 .../Debuginfod/okd-stripped-positive.test     |  35 +++
 .../Shell/Debuginfod/simple-dwp-negative.test |  32 +++
 .../Shell/Debuginfod/simple-dwp-positive.test |  37 +++
 .../Debuginfod/simple-stripped-negative.test  |  32 +++
 .../Debuginfod/simple-stripped-positive.test  |  38 +++
 lldb/test/Shell/Debuginfod/tests.md           |  61 +++++
 llvm/lib/Debuginfod/Debuginfod.cpp            |  41 +++-
 .../gn/build/write_library_dependencies.py    |   1 +
 llvm/utils/lldbDataFormatters.py              |   2 +
 27 files changed, 1893 insertions(+), 13 deletions(-)
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-dbg.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-dwp.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-full.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-nodbg.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-split-dbg.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-split-nodbg.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-split.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-stripped.yaml
 create mode 100644 lldb/test/Shell/Debuginfod/Inputs/main.c
 create mode 100755 lldb/test/Shell/Debuginfod/Inputs/mk
 create mode 100644 lldb/test/Shell/Debuginfod/okd-split-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/okd-split-positive.test
 create mode 100644 lldb/test/Shell/Debuginfod/okd-stripped-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/okd-stripped-positive.test
 create mode 100644 lldb/test/Shell/Debuginfod/simple-dwp-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/simple-dwp-positive.test
 create mode 100644 lldb/test/Shell/Debuginfod/simple-stripped-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/simple-stripped-positive.test
 create mode 100644 lldb/test/Shell/Debuginfod/tests.md

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index fed97858c83f8e2..e25a0dcd640b2ad 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -39,6 +39,7 @@
 #include "lldb/Interpreter/OptionValueProperties.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Block.h"
@@ -4320,6 +4321,23 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {
   return m_debug_map_symfile;
 }
 
+bool SymbolFileDWARF::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 ObjectFileELF frorm the filespace
+  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;
+  static ConstString sect_name_debug_cu_index(".debug_cu_index");
+  if (!dwp_obj_file || !dwp_obj_file->GetSectionList()->FindSectionByName(
+                           sect_name_debug_cu_index))
+    return false;
+  return true;
+}
+
 const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
   llvm::call_once(m_dwp_symfile_once_flag, [this]() {
     ModuleSpec module_spec;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 26a9502f90aa006..1419604238d86c6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -267,6 +267,9 @@ class SymbolFileDWARF : public SymbolFileCommon {
 
   DWARFContext &GetDWARFContext() { return m_context; }
 
+  static bool IsDwpSymbolFile(const lldb::ModuleSP &module_sp,
+                              const FileSpec &file_spec);
+
   const std::shared_ptr<SymbolFileDWARFDwo> &GetDwpSymbolFile();
 
   FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
diff --git a/lldb/source/Plugins/SymbolLocator/CMakeLists.txt b/lldb/source/Plugins/SymbolLocator/CMakeLists.txt
index ca969626f4ffc4a..f536760d8feb0e8 100644
--- a/lldb/source/Plugins/SymbolLocator/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolLocator/CMakeLists.txt
@@ -1,5 +1,10 @@
+# Order matters here, as the first symbol locator will prevent further
+# searching. For DWARF binaries that are both stripped & split, the Default
+# plugin will return the stripped binary when asked for the ObjectFile,
+# preventing 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/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 2cd7bbbb2449028..81406654092b3c4 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -96,13 +96,13 @@ class PluginProperties : public Properties {
   Args m_server_urls;
 };
 
-} // namespace
-
-static PluginProperties &GetGlobalPluginProperties() {
+PluginProperties &GetGlobalPluginProperties() {
   static PluginProperties g_settings;
   return g_settings;
 }
 
+} // namespace
+
 SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {}
 
 void SymbolLocatorDebuginfod::Initialize() {
diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index b5fe35d71032a86..aeacf9c78ea70fd 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -11,6 +11,7 @@
 #include <cstring>
 
 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
@@ -87,8 +88,16 @@ 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 ||
+      plugin::dwarf::SymbolFileDWARF::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/Shell/Debuginfod/Inputs/main-dbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-dbg.yaml
new file mode 100644
index 000000000000000..1cc8bffc59ce3a8
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-dbg.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:            B4927EA09A08EE63313299CF347043010D03CC5E
+        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000004C02A1000339000000043D0000000100050306010604080707012800000001560500447E0000000802917C0800447E00000008029170090044820000000009023400000001560700480A02770809004C9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000
+  - Name:            .debug_abbrev
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         011101252513050325721710171B25111B12067317000002340049133A0B3B0B02180000030101491300000421004913370B000005240003253E0B0B0B000006240003250B0B3E0B0000072E01111B1206401803253A0B3B0B271949133F190000080500021803253A0B3B0B49130000092E01111B1206401803253A0B3B0B27193F1900000A3400021803253A0B3B0B491300000B0F00491300000C26004913000000
+  - Name:            .debug_line
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+  - 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 at github.com:kevinfrei/llvm.git 936cbb55363f8cc626d0a036fa840e87713572d9)'
+    - 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/main-dwp.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-dwp.yaml
new file mode 100644
index 000000000000000..60b086adf1d633f
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-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:         63686172005F5F41525241595F53495A455F545950455F5F0066756E6300696E74005F7374617274006172676300617267760046616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E676974203933366362623535333633663863633632366430613033366661383430653837373133353732643929006D61696E2E630067656E2F6D61696E2D73706C69742E64776F00
+  - 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:         8D00000005000508000000008094E89A08DB62C101071D0008090224000000004C02A10003300000000434000000010005000601060108070701280000000156020044710000000802917C05004471000000080291700600447500000000090001560400480A02770806004C8400000000050305040B7A0000000B7F0000000C30000000037A0000000434000000010000
+  - 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/main-full.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-full.yaml
new file mode 100644
index 000000000000000..bcaa75028954268
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-full.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:            B4927EA09A08EE63313299CF347043010D03CC5E
+        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000004C02A1000339000000043D0000000100050306010604080707012800000001560500447E0000000802917C0800447E00000008029170090044820000000009023400000001560700480A02770809004C9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000
+  - Name:            .debug_abbrev
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         011101252513050325721710171B25111B12067317000002340049133A0B3B0B02180000030101491300000421004913370B000005240003253E0B0B0B000006240003250B0B3E0B0000072E01111B1206401803253A0B3B0B271949133F190000080500021803253A0B3B0B49130000092E01111B1206401803253A0B3B0B27193F1900000A3400021803253A0B3B0B491300000B0F00491300000C26004913000000
+  - Name:            .debug_line
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x1
+    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+  - 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 at github.com:kevinfrei/llvm.git 936cbb55363f8cc626d0a036fa840e87713572d9)'
+    - 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/main-nodbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-nodbg.yaml
new file mode 100644
index 000000000000000..a4465d75fa6dafa
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-nodbg.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:            B4927EA09A08EE63313299CF347043010D03CC5E
+        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+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-split-dbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-split-dbg.yaml
new file mode 100644
index 000000000000000..34d157b66c6b79a
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-split-dbg.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:            8B5B6416F61ADC140AE457E208F1699F89BFDA86
+        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+  - 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:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+  - 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/main-split.dwo'
+  debug_addr:
+    - Length:          0x14
+      Version:         0x5
+      AddressSize:     0x8
+      Entries:
+        - Address:         0x402000
+        - Address:         0x401000
+...
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-split-nodbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-split-nodbg.yaml
new file mode 100644
index 000000000000000..11798976f5c15ab
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-split-nodbg.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:            8B5B6416F61ADC140AE457E208F1699F89BFDA86
+        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+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-split.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-split.yaml
new file mode 100644
index 000000000000000..e03ff90187f40dd
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-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:            8B5B6416F61ADC140AE457E208F1699F89BFDA86
+        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+  - 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:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+  - 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/main-split.dwo'
+  debug_addr:
+    - Length:          0x14
+      Version:         0x5
+      AddressSize:     0x8
+      Entries:
+        - Address:         0x402000
+        - Address:         0x401000
+...
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-stripped.yaml
new file mode 100644
index 000000000000000..a4465d75fa6dafa
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main-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:            B4927EA09A08EE63313299CF347043010D03CC5E
+        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+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 000000000000000..661e5771fcbeeb7
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/main.c
@@ -0,0 +1,82 @@
+/*
+
+script to (re)create the .yaml files:
+---------------------------------------------------------------------------
+#!/bin/sh
+
+# I need 4 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
+
+# Note: gnu-debuglink has to be added from the yaml2obj output,
+# as the CRC's are slightly different from the original binary
+
+mkdir -p gen
+mkdir -p run
+
+# First, compile & link the binary itself
+${builddir}/bin/clang -g -o gen/main-full.o -O0 -c main.c
+ld -nostdlib gen/main-full.o --build-id=sha1 -o gen/main-full
+${builddir}/bin/clang -g -gsplit-dwarf -o gen/main-split.o -O0 -c main.c
+ld -nostdlib gen/main-split.o --build-id=sha1 -o gen/main-split
+${builddir}/bin/llvm-dwp -e gen/main-split -o gen/main-split.dwp
+
+# Scenario 1: main-strip -> main-full (both executable and debuginfo)
+${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-stripped
+${builddir}/bin/obj2yaml gen/main-full > main-full.yaml
+${builddir}/bin/obj2yaml gen/main-stripped > main-stripped.yaml
+${builddir}/bin/yaml2obj main-full.yaml > run/main-full
+${builddir}/bin/yaml2obj main-stripped.yaml > run/main-stripped
+
+# Scenario 2: main-nodbg -> main-dbg (debuginfo)
+${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-full gen/main-dbg
+${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-nodbg
+${builddir}/bin/obj2yaml gen/main-nodbg > main-nodbg.yaml
+${builddir}/bin/obj2yaml gen/main-dbg > main-dbg.yaml
+${builddir}/bin/yaml2obj main-nodbg.yaml > gen/main-nodbg.tmp
+${builddir}/bin/yaml2obj main-dbg.yaml > run/main-dbg
+${builddir}/bin/llvm-objcopy gen/main-nodbg.tmp --add-gnu-debuglink=run/main-dbg run/main-nodbg
+
+# Scenario 3: main-split, main-split.dwp (debuginfo)
+${builddir}/bin/obj2yaml gen/main-split > main-split.yaml
+${builddir}/bin/obj2yaml gen/main-split.dwp > main-dwp.yaml
+${builddir}/bin/yaml2obj main-split.yaml > run/main-split
+${builddir}/bin/yaml2obj main-dwp.yaml > run/main-split.dwp
+
+# Scenario 4: main-split-nodbg, main-split-dbg (executable), main-split.dwp (debuginfo)
+${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-split gen/main-split-dbg
+${builddir}/bin/llvm-objcopy --strip-debug gen/main-split gen/main-split-nodbg
+${builddir}/bin/obj2yaml gen/main-split-nodbg > main-split-nodbg.yaml
+${builddir}/bin/obj2yaml gen/main-split-dbg > main-split-dbg.yaml
+${builddir}/bin/yaml2obj main-split-nodbg.yaml > gen/main-split-nodbg.tmp
+${builddir}/bin/yaml2obj main-split-dbg.yaml > run/main-split-dbg
+${builddir}/bin/llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg
+# the main-dwp.yaml should be the same for both Scenario 3 and 4
+
+chmod a+x 'run/'*
+
+---------------------------------------------------------------------------
+You need to re-generate the gnu-debuglinks after the yaml2obj step (in the test)
+
+You can find the build id's in the yaml files under "NT_PRPSINFO" from the YAML files
+(grep for 'Desc')
+
+*/
+
+int func(int argc, const char **argv) {
+  return (argc + 1) * (argv[argc][0] + 2);
+}
+
+__attribute__((force_align_arg_pointer)) void _start(void) {
+
+  /* main body of program: call main(), etc */
+
+  const char *argv[] = {""};
+  func(0, argv);
+
+  /* exit system call */
+  asm("mov $60,%rax; mov $0,%rdi; syscall");
+  __builtin_unreachable(); // tell the compiler to make sure side effects are done before the asm statement
+}
diff --git a/lldb/test/Shell/Debuginfod/Inputs/mk b/lldb/test/Shell/Debuginfod/Inputs/mk
new file mode 100755
index 000000000000000..a66f4a641b42752
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/Inputs/mk
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# I need 4 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
+
+mkdir -p gen
+mkdir -p run
+
+# First, compile & link the binary itself
+${builddir}/bin/clang -g -o gen/main-full.o -O0 -c main.c
+ld -nostdlib gen/main-full.o --build-id=sha1 -o gen/main-full
+${builddir}/bin/clang -g -gsplit-dwarf -o gen/main-split.o -O0 -c main.c
+ld -nostdlib gen/main-split.o --build-id=sha1 -o gen/main-split
+${builddir}/bin/llvm-dwp -e gen/main-split -o gen/main-split.dwp
+
+# Scenario 1: main-strip -> main-full (both executable and debuginfo)
+${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-stripped
+${builddir}/bin/obj2yaml gen/main-full > main-full.yaml
+${builddir}/bin/obj2yaml gen/main-stripped > main-stripped.yaml
+# MAKE: ${builddir}/bin/yaml2obj main-full.yaml > run/main-full
+# MAKE: ${builddir}/bin/yaml2obj main-stripped.yaml > run/main-stripped
+
+# Scenario 2: main-nodbg -> main-dbg (debuginfo)
+${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-full gen/main-dbg
+${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-nodbg
+${builddir}/bin/obj2yaml gen/main-nodbg > main-nodbg.yaml
+${builddir}/bin/obj2yaml gen/main-dbg > main-dbg.yaml
+# MAKE: ${builddir}/bin/yaml2obj main-nodbg.yaml > gen/main-nodbg.tmp
+# MAKE: ${builddir}/bin/yaml2obj main-dbg.yaml > run/main-dbg
+# MAKE: ${builddir}/bin/llvm-objcopy gen/main-nodbg.tmp --add-gnu-debuglink=run/main-dbg run/main-nodbg
+
+# Scenario 3: main-split, main-split.dwp (debuginfo)
+${builddir}/bin/obj2yaml gen/main-split > main-split.yaml
+${builddir}/bin/obj2yaml gen/main-split.dwp > main-dwp.yaml
+# MAKE: ${builddir}/bin/yaml2obj main-split.yaml > run/main-split
+# MAKE: ${builddir}/bin/yaml2obj main-dwp.yaml > run/main-split.dwp
+
+# Scenario 4: main-split-nodbg, main-split-dbg (executable), main-split.dwp (debuginfo)
+${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-split gen/main-split-dbg
+${builddir}/bin/llvm-objcopy --strip-debug gen/main-split gen/main-split-nodbg
+${builddir}/bin/obj2yaml gen/main-split-nodbg > main-split-nodbg.yaml
+${builddir}/bin/obj2yaml gen/main-split-dbg > main-split-dbg.yaml
+# MAKE: ${builddir}/bin/yaml2obj main-split-nodbg.yaml > gen/main-split-nodbg.tmp
+# MAKE: ${builddir}/bin/yaml2obj main-split-dbg.yaml > run/main-split-dbg
+# MAKE: ${builddir}/bin/llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg
+# the main-dwp.yaml should be the same, I believe
+
+# MAKE: chmod a+x run/*
diff --git a/lldb/test/Shell/Debuginfod/okd-split-negative.test b/lldb/test/Shell/Debuginfod/okd-split-negative.test
new file mode 100644
index 000000000000000..5d5ed250c4cc1d3
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okd-split-negative.test
@@ -0,0 +1,31 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
+
+# Scenario 4
+#  A stripped binary/split-dwarf combination
+# LLDB should ask Debuginfod for both it's executable AND it's symbols
+
+# RUN: yaml2obj %p/Inputs/main-split-nodbg.yaml -o %t/tmpstuff/main-split-nodbg.tmp
+# RUN: yaml2obj %p/Inputs/main-split-dbg.yaml -o %t/tmpstuff/main-split-dbg
+# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
+# RUN: llvm-objcopy %t/tmpstuff/main-split-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-split-dbg %t/output/main-split-nodbg
+# RUN: mv %t/tmpstuff/main-split-dbg %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/executable
+# RUN: chmod a+x %t/output/main-split-nodbg
+
+# Verify that we -don't- find symbols when not using the Debuginfod service
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/main-split-nodbg" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should NOT have source file information:
+# CHECK: Breakpoint 1: where = main-split-nodbg`func, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/okd-split-positive.test b/lldb/test/Shell/Debuginfod/okd-split-positive.test
new file mode 100644
index 000000000000000..3a3f20a5c82c4b1
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okd-split-positive.test
@@ -0,0 +1,40 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
+
+# Scenario 4
+#  A stripped binary/split-dwarf combination
+# LLDB should ask Debuginfod for both it's executable AND it's symbols
+
+# RUN: yaml2obj %p/Inputs/main-split-nodbg.yaml -o %t/tmpstuff/main-split-nodbg.tmp
+# RUN: yaml2obj %p/Inputs/main-split-dbg.yaml -o %t/tmpstuff/main-split-dbg
+# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
+# RUN: llvm-objcopy %t/tmpstuff/main-split-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-split-dbg %t/output/main-split-nodbg
+# RUN: mv %t/tmpstuff/main-split-dbg %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/executable
+# RUN: chmod a+x %t/output/main-split-nodbg
+
+# Verify that we find symbols from the Debuginfod service
+
+# 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/output/main-split-nodbg" \
+# RUN:       -o "target modules dump separate-debug-info" \
+# RUN:       -o "b main.c:69" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should have source file information:
+# CHECK: Symbol file: {{.*}}/main-split-nodbg
+# CHECK-NEXT: Type: "dwo"
+# CHECK-NEXT: Dwo ID{{.*}}
+# CHECK-NEXT: {{^[- ]+$}}
+# CHECK-NEXT: 0x{{[0-9a-f]+.*}} {{.*}}/cache/llvmcache-9657596136574283768
+# CHECK: Breakpoint 1: address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/okd-stripped-negative.test b/lldb/test/Shell/Debuginfod/okd-stripped-negative.test
new file mode 100644
index 000000000000000..f110db39c11ae75
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okd-stripped-negative.test
@@ -0,0 +1,32 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
+
+# Scenario 2
+#  A stripped binary, with an "-only-keep-debug" symbols file
+#  Debuginfo has the 'okd' file as the 'debuginfo' item
+# LLDB should ask Debuginfod for it's symbols
+
+# RUN: yaml2obj %p/Inputs/main-nodbg.yaml -o %t/tmpstuff/main-nodbg.tmp
+# RUN: yaml2obj %p/Inputs/main-dbg.yaml -o %t/tmpstuff/main-dbg
+# RUN: llvm-objcopy %t/tmpstuff/main-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-dbg %t/output/main-nodbg
+# RUN: mv %t/tmpstuff/main-dbg %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/debuginfo
+# RUN: chmod a+x %t/output/main-nodbg
+
+# Negative test (We don't find symbols without the Debuginfod service)
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/main-nodbg" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should NOT have source file information:
+
+# CHECK: Breakpoint 1: where = main-nodbg`func, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/okd-stripped-positive.test b/lldb/test/Shell/Debuginfod/okd-stripped-positive.test
new file mode 100644
index 000000000000000..67d55a16041d341
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okd-stripped-positive.test
@@ -0,0 +1,35 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
+
+# Scenario 2
+#  A stripped binary, with an "-only-keep-debug" symbols file
+#  Debuginfo has the 'okd' file as the 'debuginfo' item
+# LLDB should ask Debuginfod for it's symbols
+
+# RUN: yaml2obj %p/Inputs/main-nodbg.yaml -o %t/tmpstuff/main-nodbg.tmp
+# RUN: yaml2obj %p/Inputs/main-dbg.yaml -o %t/tmpstuff/main-dbg
+# RUN: llvm-objcopy %t/tmpstuff/main-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-dbg %t/output/main-nodbg
+# RUN: mv %t/tmpstuff/main-dbg %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/debuginfo
+# RUN: chmod a+x %t/output/main-nodbg
+
+# Verify that we find symbols from the Debuginfod service
+
+# 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/output/main-nodbg" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should have source file information:
+
+# CHECK: Breakpoint 1: where = main-nodbg`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/simple-dwp-negative.test b/lldb/test/Shell/Debuginfod/simple-dwp-negative.test
new file mode 100644
index 000000000000000..e1018a1181c2412
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/simple-dwp-negative.test
@@ -0,0 +1,32 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
+
+# Scenario 2
+#  A stripped binary, with an "-only-keep-debug" symbols file
+#  Debuginfo has the 'okd' file as the 'debuginfo' item
+# LLDB should ask Debuginfod for it's symbols
+
+# RUN: yaml2obj %p/Inputs/main-split.yaml -o %t/output/main-split
+# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
+# RUN: chmod a+x %t/output/main-split
+
+# Negative test (We don't find symbols without the Debuginfod service)
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/main-split" \
+# RUN:       -o "target modules dump separate-debug-info" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# CHECK: Symbol file: {{.*}}/main-split
+# CHECK-NEXT: Type: "dwo"
+# CHECK-NEXT: Dwo ID{{.*}}
+# CHECK-NEXT: {{^[- ]+$}}
+# CHECK-NEXT: 0x{{[0-9a-f]+.*}} unable to locate .dwo debug file {{.*}}main-split.dwo{{.*}} for skeleton DIE 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/simple-dwp-positive.test b/lldb/test/Shell/Debuginfod/simple-dwp-positive.test
new file mode 100644
index 000000000000000..acb647e83e008fb
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/simple-dwp-positive.test
@@ -0,0 +1,37 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
+
+# Scenario 2
+#  A stripped binary, with an "-only-keep-debug" symbols file
+#  Debuginfo has the 'okd' file as the 'debuginfo' item
+# LLDB should ask Debuginfod for it's symbols
+
+# RUN: yaml2obj %p/Inputs/main-split.yaml -o %t/output/main-split
+# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
+# RUN: chmod a+x %t/output/main-split
+
+# Positive test: We find the DWP file with the Debuginfod service
+
+# 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/output/main-split" \
+# RUN:       -o "target modules dump separate-debug-info" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# CHECK: Symbol file: {{.*}}/main-split
+# CHECK-NEXT: Type: "dwo"
+# CHECK-NEXT: Dwo ID{{.*}}
+# CHECK-NEXT: {{^[- ]+$}}
+# The cache key is stable, so we can mandate that we discover this thing from the cache
+# It's an implementation detail, so it could potentially change, but the ensures that
+# CHECK-NEXT: 0x{{[0-9a-f]+.*}} {{.*}}/cache/llvmcache-9657596136574283768
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-negative.test b/lldb/test/Shell/Debuginfod/simple-stripped-negative.test
new file mode 100644
index 000000000000000..62c7832da8fb36f
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/simple-stripped-negative.test
@@ -0,0 +1,32 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
+
+# Scenario 1
+#  A simple stripped binary
+#  Debuginfod has the unstripped binary as the 'executable'
+# LLDB should ask Debuginfod for it's unstripped binary
+
+# Put the unstripped binary in the Debuginfod server as 'executable'
+
+# RUN: yaml2obj %p/Inputs/main-full.yaml -o %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/executable
+# RUN: yaml2obj %p/Inputs/main-stripped.yaml -o %t/output/main-stripped
+# RUN: chmod a+x %t/output/main-stripped
+
+# Run a negative test (make sure we don't have symbols)
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/main-stripped" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should NOT have source file information:
+
+# CHECK: Breakpoint 1: where = main-stripped`func, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-positive.test b/lldb/test/Shell/Debuginfod/simple-stripped-positive.test
new file mode 100644
index 000000000000000..78671b6eb463aa3
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/simple-stripped-positive.test
@@ -0,0 +1,38 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/tmpstuff
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
+
+# Scenario 1
+#  A simple stripped binary
+#  Debuginfod has the unstripped binary as the 'executable'
+# LLDB should ask Debuginfod for it's unstripped binary
+
+# Put the unstripped binary in the Debuginfod server as 'executable'
+
+# RUN: yaml2obj %p/Inputs/main-full.yaml -o %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/executable
+# RUN: yaml2obj %p/Inputs/main-stripped.yaml -o %t/output/main-stripped
+# RUN: chmod a+x %t/output/main-stripped
+
+# First, run a negative test (make sure we don't have symbols)
+
+# Scenario 1, postive test: Can we pull the executable
+# from Debuginfod and get a breakpoint set properly?
+
+# 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/output/main-stripped" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should have source file info:
+
+# CHECK: Breakpoint 1: where = main-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/tests.md b/lldb/test/Shell/Debuginfod/tests.md
new file mode 100644
index 000000000000000..7fe3e9e68d4ed32
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/tests.md
@@ -0,0 +1,61 @@
+# 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.
+
+## Baseline capabilities
+
+Things to test:
+
+- Just for sanity, the `-no-locator` tests validate that lldb works as the test
+  expects if the files that Debuginfod _should_ provide are already there.
+- Validate that symbols _aren't_ found without Debuginfod, to ensure they
+  weren't cached from previous runs (`-negative` tests).
+- Validate that the Debuginfod symbol locator is providing the expected symbols
+  when the debugger doesn't already have them available.
+
+## Symbol "Configurations" to test
+
+There are 2 top level configurations, each of which then get some post-processing.
+- The 'normal' build: a simple binary built with debug information (`-g`)
+- The 'split' build: A binary built with `-gsplit-dwarf` that produces `.dwo` and `.dwp` files
+
+For the normal build there are 2 post-processing steps where Debuginfod may be used.
+- Strip the binary while hosting the full, unstripped binary on a Debuginfod server.
+- Strip the binary and produce a corresponding 'only-keep-debug' version of the binary to host on a Debuginfod server.
+
+For the split build, there are *3* post-processing outcomes where Debuginfod usage makes sense:
+- Stripped binary, hosting the full unstripped binary on a Debuginfod server, along with it's `.dwp` file.
+- Stripped binary, hosting the 'only-keep-debug' version of the binary *and* it's `.dwp` file.
+- Unstripped binary, hosting only the `.dwp` file on the Debuginfod server.
+
+For both normal and split builds, when using an 'only-keep-debug' symbol file, the original file
+also requires the addition of the `.gnu.debuglink` section (which can be added using `objcopy`)
+
+### Troubles
+
+The Debuginfod protocol is somewhat underspecified regarding what the 2 different callbacks actually return. The protocol itself is quite simple: query an HTTP server with the path `buildid/{.note.gnu.build-id hash}/debuginfo` and `buildid/{.note.gnu.build-id hash}/executable`. A keen reader may note that there's one configuration (split, only-keep-debug) where you need two different files to properly symbolicate, but the API only supports a single debuginfo file. For that scenario, I've chosen to simply treat the `.dwp` file as "debuginfo" and the "only-keep-debug" stripped binary as "executable". This scenario doesn't actually work at all in GDB. It seems more straightforward than trying to extend the protocol.
+
+### Stripped:
+
+- Should ask for symbols from the service; can be registered as 'executable' and
+  they should work!
+
+### Stripped "only-keep-debug":
+
+- Should get them from the debuginfo, not from the executable query
+
+### split-dwarf:
+
+- Should get dwp file from debuginfo
+
+### split-dwarf + stripped:
+
+- Should get dwp from debuginfo, and the unstripped binary from executable
+
+
+image
+lldb.target.ResolveLoadAddress
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 0dd8a7de1245b31..1244793dff20d87 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -252,27 +252,54 @@ static SmallVector<std::string, 0> getHeaders() {
   return Headers;
 }
 
-Expected<std::string> getCachedOrDownloadArtifact(
-    StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
-    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
+static SmallString<64> getCachedArtifactPath(StringRef UniqueKey,
+                                             StringRef CacheDirectoryPath) {
   SmallString<64> AbsCachedArtifactPath;
   sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
                     "llvmcache-" + UniqueKey);
+  return AbsCachedArtifactPath;
+}
+
+static Expected<AddStreamFn>
+getCachedArtifactHelper(StringRef UniqueKey, StringRef CacheDirectoryPath,
+                        unsigned &Task) {
+  SmallString<64> AbsCachedArtifactPath =
+      getCachedArtifactPath(UniqueKey, CacheDirectoryPath);
 
   Expected<FileCache> CacheOrErr =
       localCache("Debuginfod-client", ".debuginfod-client", CacheDirectoryPath);
   if (!CacheOrErr)
     return CacheOrErr.takeError();
+  return (*CacheOrErr)(Task, UniqueKey, "");
+}
+
+Expected<std::string> getCachedArtifact(StringRef UniqueKey,
+                                        StringRef CacheDirectoryPath) {
+  // We choose an arbitrary Task parameter as we do not make use of it.
+  unsigned Task = 0;
+  Expected<AddStreamFn> CacheAddStreamOrErr =
+      getCachedArtifactHelper(UniqueKey, CacheDirectoryPath, Task);
+  if (!CacheAddStreamOrErr)
+    return CacheAddStreamOrErr.takeError();
+  if (!*CacheAddStreamOrErr)
+    return std::string(getCachedArtifactPath(UniqueKey, CacheDirectoryPath));
+  return createStringError(errc::argument_out_of_domain,
+                           "build id not found in cache");
+}
 
-  FileCache Cache = *CacheOrErr;
+Expected<std::string> getCachedOrDownloadArtifact(
+    StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
+    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
   // We choose an arbitrary Task parameter as we do not make use of it.
   unsigned Task = 0;
-  Expected<AddStreamFn> CacheAddStreamOrErr = Cache(Task, UniqueKey, "");
+  Expected<AddStreamFn> CacheAddStreamOrErr =
+      getCachedArtifactHelper(UniqueKey, CacheDirectoryPath, Task);
   if (!CacheAddStreamOrErr)
     return CacheAddStreamOrErr.takeError();
   AddStreamFn &CacheAddStream = *CacheAddStreamOrErr;
   if (!CacheAddStream)
-    return std::string(AbsCachedArtifactPath);
+    return std::string(getCachedArtifactPath(UniqueKey, CacheDirectoryPath));
+
   // The artifact was not found in the local cache, query the debuginfod
   // servers.
   if (!HTTPClient::isAvailable())
@@ -315,7 +342,7 @@ Expected<std::string> getCachedOrDownloadArtifact(
     pruneCache(CacheDirectoryPath, *PruningPolicyOrErr);
 
     // Return the path to the artifact on disk.
-    return std::string(AbsCachedArtifactPath);
+    return std::string(getCachedArtifactPath(UniqueKey, CacheDirectoryPath));
   }
 
   return createStringError(errc::argument_out_of_domain, "build id not found");
diff --git a/llvm/utils/gn/build/write_library_dependencies.py b/llvm/utils/gn/build/write_library_dependencies.py
index ba1a8a0157314df..e88ed8d6411ec79 100644
--- a/llvm/utils/gn/build/write_library_dependencies.py
+++ b/llvm/utils/gn/build/write_library_dependencies.py
@@ -37,6 +37,7 @@
 { "coverage", "LLVMCoverage", true, {"core", "object", "profiledata", "support"} },
 { "debuginfocodeview", "LLVMDebugInfoCodeView", true, {"support", "debuginfomsf"} },
 { "debuginfodwarf", "LLVMDebugInfoDWARF", true, {"binaryformat", "object", "mc", "support"} },
+{ "debuginfod", "LLVMDebuginfod", true, {} },
 { "debuginfogsym", "LLVMDebugInfoGSYM", true, {"mc", "object", "support", "debuginfodwarf"} },
 { "debuginfomsf", "LLVMDebugInfoMSF", true, {"support"} },
 { "debuginfopdb", "LLVMDebugInfoPDB", true, {"binaryformat", "object", "support", "debuginfocodeview", "debuginfomsf"} },
diff --git a/llvm/utils/lldbDataFormatters.py b/llvm/utils/lldbDataFormatters.py
index de101abdabc8ecd..5acc02c9c8e8f4a 100644
--- a/llvm/utils/lldbDataFormatters.py
+++ b/llvm/utils/lldbDataFormatters.py
@@ -373,6 +373,7 @@ def DenseMapSummary(valobj: lldb.SBValue, _) -> str:
     return summary
 
 
+"""
 class DenseMapSynthetic:
     valobj: lldb.SBValue
 
@@ -431,3 +432,4 @@ def update(self):
         for indexes in key_buckets.values():
             if len(indexes) == 1:
                 self.child_buckets.append(indexes[0])
+"""

>From aa30eefe3d4570d6ef5a677e5ae156ba3a12e85c Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Mon, 22 Jan 2024 08:23:42 -0800
Subject: [PATCH 03/12] Getting all 5 variations documented and tests

---
 .../{main-full.yaml => bin-normal.yaml}       |   8 +-
 .../{main-dwp.yaml => bin-split-dwp.yaml}     |   2 +-
 ...lit-nodbg.yaml => bin-split-stripped.yaml} |   4 +-
 .../{main-split.yaml => bin-split.yaml}       |   8 +-
 .../{main-stripped.yaml => bin-stripped.yaml} |   4 +-
 .../Shell/Debuginfod/Inputs/main-nodbg.yaml   | 146 ------------------
 lldb/test/Shell/Debuginfod/Inputs/mk          | 119 +++++++++-----
 .../{main-split-dbg.yaml => sym-split.yaml}   |   8 +-
 .../{main-dbg.yaml => sym-stripped.yaml}      |   8 +-
 .../Debuginfod/simple-stripped-negative.test  |  21 +--
 .../simple-stripped-no-locator.test           |  24 +++
 .../simple-stripped-positive-a.test           |  35 +++++
 ...e.test => simple-stripped-positive-b.test} |  17 +-
 lldb/test/Shell/Debuginfod/tests.md           | 109 ++++++-------
 14 files changed, 226 insertions(+), 287 deletions(-)
 rename lldb/test/Shell/Debuginfod/Inputs/{main-full.yaml => bin-normal.yaml} (95%)
 rename lldb/test/Shell/Debuginfod/Inputs/{main-dwp.yaml => bin-split-dwp.yaml} (92%)
 rename lldb/test/Shell/Debuginfod/Inputs/{main-split-nodbg.yaml => bin-split-stripped.yaml} (96%)
 rename lldb/test/Shell/Debuginfod/Inputs/{main-split.yaml => bin-split.yaml} (95%)
 rename lldb/test/Shell/Debuginfod/Inputs/{main-stripped.yaml => bin-stripped.yaml} (96%)
 delete mode 100644 lldb/test/Shell/Debuginfod/Inputs/main-nodbg.yaml
 rename lldb/test/Shell/Debuginfod/Inputs/{main-split-dbg.yaml => sym-split.yaml} (95%)
 rename lldb/test/Shell/Debuginfod/Inputs/{main-dbg.yaml => sym-stripped.yaml} (95%)
 create mode 100644 lldb/test/Shell/Debuginfod/simple-stripped-no-locator.test
 create mode 100644 lldb/test/Shell/Debuginfod/simple-stripped-positive-a.test
 rename lldb/test/Shell/Debuginfod/{simple-stripped-positive.test => simple-stripped-positive-b.test} (62%)

diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-full.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml
similarity index 95%
rename from lldb/test/Shell/Debuginfod/Inputs/main-full.yaml
rename to lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml
index bcaa75028954268..1e8b8ffeee25e09 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main-full.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            B4927EA09A08EE63313299CF347043010D03CC5E
+        Desc:            725D47B7EE964F615C841A04712D6F43175F9D8D
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,7 +94,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -106,7 +106,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
@@ -191,7 +191,7 @@ Symbols:
     Value:           0x404000
 DWARF:
   debug_str:
-    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git 936cbb55363f8cc626d0a036fa840e87713572d9)'
+    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git f2b81cb569d0632a0eb0fd51722d725ab191af72)'
     - main.c
     - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs'
     - char
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-dwp.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml
similarity index 92%
rename from lldb/test/Shell/Debuginfod/Inputs/main-dwp.yaml
rename to lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml
index 60b086adf1d633f..1f18c04a4415add 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main-dwp.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml
@@ -21,7 +21,7 @@ Sections:
     Flags:           [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         63686172005F5F41525241595F53495A455F545950455F5F0066756E6300696E74005F7374617274006172676300617267760046616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E676974203933366362623535333633663863633632366430613033366661383430653837373133353732643929006D61696E2E630067656E2F6D61696E2D73706C69742E64776F00
+    Content:         63686172005F5F41525241595F53495A455F545950455F5F0066756E6300696E74005F7374617274006172676300617267760046616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E676974206632623831636235363964303633326130656230666435313732326437323561623139316166373229006D61696E2E630067656E2F62696E2D73706C69742E64776F00
   - Name:            .debug_str_offsets.dwo
     Type:            SHT_PROGBITS
     Flags:           [ SHF_EXCLUDE ]
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-split-nodbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml
similarity index 96%
rename from lldb/test/Shell/Debuginfod/Inputs/main-split-nodbg.yaml
rename to lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml
index 11798976f5c15ab..6501cda4a4f7e69 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main-split-nodbg.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            8B5B6416F61ADC140AE457E208F1699F89BFDA86
+        Desc:            82B2C35129DAB19AD58F3DD0F426BDB0CC8AA094
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,7 +94,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
 Symbols:
   - Name:            .note.gnu.build-id
     Type:            STT_SECTION
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-split.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml
similarity index 95%
rename from lldb/test/Shell/Debuginfod/Inputs/main-split.yaml
rename to lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml
index e03ff90187f40dd..b99d0ede47c21db 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main-split.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            8B5B6416F61ADC140AE457E208F1699F89BFDA86
+        Desc:            82B2C35129DAB19AD58F3DD0F426BDB0CC8AA094
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,7 +94,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -106,7 +106,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
@@ -206,7 +206,7 @@ Symbols:
 DWARF:
   debug_str:
     - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs'
-    - 'gen/main-split.dwo'
+    - 'gen/bin-split.dwo'
   debug_addr:
     - Length:          0x14
       Version:         0x5
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml
similarity index 96%
rename from lldb/test/Shell/Debuginfod/Inputs/main-stripped.yaml
rename to lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml
index a4465d75fa6dafa..6c8045e9a2068b4 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main-stripped.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            B4927EA09A08EE63313299CF347043010D03CC5E
+        Desc:            725D47B7EE964F615C841A04712D6F43175F9D8D
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,7 +94,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
 Symbols:
   - Name:            .note.gnu.build-id
     Type:            STT_SECTION
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-nodbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/main-nodbg.yaml
deleted file mode 100644
index a4465d75fa6dafa..000000000000000
--- a/lldb/test/Shell/Debuginfod/Inputs/main-nodbg.yaml
+++ /dev/null
@@ -1,146 +0,0 @@
---- !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:            B4927EA09A08EE63313299CF347043010D03CC5E
-        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:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
-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/mk b/lldb/test/Shell/Debuginfod/Inputs/mk
index a66f4a641b42752..b222b5c028a2a2e 100755
--- a/lldb/test/Shell/Debuginfod/Inputs/mk
+++ b/lldb/test/Shell/Debuginfod/Inputs/mk
@@ -1,51 +1,86 @@
 #!/bin/sh
 
-# I need 4 different scenarios:
+# I need 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
+# 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 binary itself
-${builddir}/bin/clang -g -o gen/main-full.o -O0 -c main.c
-ld -nostdlib gen/main-full.o --build-id=sha1 -o gen/main-full
-${builddir}/bin/clang -g -gsplit-dwarf -o gen/main-split.o -O0 -c main.c
-ld -nostdlib gen/main-split.o --build-id=sha1 -o gen/main-split
-${builddir}/bin/llvm-dwp -e gen/main-split -o gen/main-split.dwp
-
-# Scenario 1: main-strip -> main-full (both executable and debuginfo)
-${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-stripped
-${builddir}/bin/obj2yaml gen/main-full > main-full.yaml
-${builddir}/bin/obj2yaml gen/main-stripped > main-stripped.yaml
-# MAKE: ${builddir}/bin/yaml2obj main-full.yaml > run/main-full
-# MAKE: ${builddir}/bin/yaml2obj main-stripped.yaml > run/main-stripped
-
-# Scenario 2: main-nodbg -> main-dbg (debuginfo)
-${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-full gen/main-dbg
-${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-nodbg
-${builddir}/bin/obj2yaml gen/main-nodbg > main-nodbg.yaml
-${builddir}/bin/obj2yaml gen/main-dbg > main-dbg.yaml
-# MAKE: ${builddir}/bin/yaml2obj main-nodbg.yaml > gen/main-nodbg.tmp
-# MAKE: ${builddir}/bin/yaml2obj main-dbg.yaml > run/main-dbg
-# MAKE: ${builddir}/bin/llvm-objcopy gen/main-nodbg.tmp --add-gnu-debuglink=run/main-dbg run/main-nodbg
-
-# Scenario 3: main-split, main-split.dwp (debuginfo)
-${builddir}/bin/obj2yaml gen/main-split > main-split.yaml
-${builddir}/bin/obj2yaml gen/main-split.dwp > main-dwp.yaml
-# MAKE: ${builddir}/bin/yaml2obj main-split.yaml > run/main-split
-# MAKE: ${builddir}/bin/yaml2obj main-dwp.yaml > run/main-split.dwp
-
-# Scenario 4: main-split-nodbg, main-split-dbg (executable), main-split.dwp (debuginfo)
-${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-split gen/main-split-dbg
-${builddir}/bin/llvm-objcopy --strip-debug gen/main-split gen/main-split-nodbg
-${builddir}/bin/obj2yaml gen/main-split-nodbg > main-split-nodbg.yaml
-${builddir}/bin/obj2yaml gen/main-split-dbg > main-split-dbg.yaml
-# MAKE: ${builddir}/bin/yaml2obj main-split-nodbg.yaml > gen/main-split-nodbg.tmp
-# MAKE: ${builddir}/bin/yaml2obj main-split-dbg.yaml > run/main-split-dbg
-# MAKE: ${builddir}/bin/llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg
-# the main-dwp.yaml should be the same, I believe
-
-# MAKE: chmod a+x 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/main-split-dbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml
similarity index 95%
rename from lldb/test/Shell/Debuginfod/Inputs/main-split-dbg.yaml
rename to lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml
index 34d157b66c6b79a..f25e4c4abf5c24a 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main-split-dbg.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            8B5B6416F61ADC140AE457E208F1699F89BFDA86
+        Desc:            82B2C35129DAB19AD58F3DD0F426BDB0CC8AA094
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_NOBITS
@@ -93,7 +93,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -105,7 +105,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
@@ -205,7 +205,7 @@ Symbols:
 DWARF:
   debug_str:
     - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs'
-    - 'gen/main-split.dwo'
+    - 'gen/bin-split.dwo'
   debug_addr:
     - Length:          0x14
       Version:         0x5
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main-dbg.yaml b/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml
similarity index 95%
rename from lldb/test/Shell/Debuginfod/Inputs/main-dbg.yaml
rename to lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml
index 1cc8bffc59ce3a8..608e9d04b2ebf29 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main-dbg.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            B4927EA09A08EE63313299CF347043010D03CC5E
+        Desc:            725D47B7EE964F615C841A04712D6F43175F9D8D
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_NOBITS
@@ -93,7 +93,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420393336636262353533363366386363363236643061303336666138343065383737313335373264392900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -105,7 +105,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000004F0B089C0626CBD8AB443134CFE6DD950400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
@@ -190,7 +190,7 @@ Symbols:
     Value:           0x404000
 DWARF:
   debug_str:
-    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git 936cbb55363f8cc626d0a036fa840e87713572d9)'
+    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git f2b81cb569d0632a0eb0fd51722d725ab191af72)'
     - main.c
     - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs'
     - char
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-negative.test b/lldb/test/Shell/Debuginfod/simple-stripped-negative.test
index 62c7832da8fb36f..2c4128e0d04b680 100644
--- a/lldb/test/Shell/Debuginfod/simple-stripped-negative.test
+++ b/lldb/test/Shell/Debuginfod/simple-stripped-negative.test
@@ -1,32 +1,23 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# This is paranoia to make sure there's not a cached symbol file laying around
 
-# RUN: rm -rf %t || echo ok
 # RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
-# RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
 
 # Scenario 1
-#  A simple stripped binary
-#  Debuginfod has the unstripped binary as the 'executable'
-# LLDB should ask Debuginfod for it's unstripped binary
+#  A simple stripped binary, no symbols (negative test: nothing's been cached, right?)
 
-# Put the unstripped binary in the Debuginfod server as 'executable'
-
-# RUN: yaml2obj %p/Inputs/main-full.yaml -o %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/executable
-# RUN: yaml2obj %p/Inputs/main-stripped.yaml -o %t/output/main-stripped
-# RUN: chmod a+x %t/output/main-stripped
+# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
+# RUN: chmod a+x %t/output/bin-stripped
 
 # Run a negative test (make sure we don't have symbols)
 
 # RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
-# RUN:       -o "target create %t/output/main-stripped" \
+# RUN:       -o "target create %t/output/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
 # Should NOT have source file information:
 
-# CHECK: Breakpoint 1: where = main-stripped`func, address = 0x{{[0-9a-f]+}}
+# CHECK: Breakpoint 1: where = bin-stripped`func, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-no-locator.test b/lldb/test/Shell/Debuginfod/simple-stripped-no-locator.test
new file mode 100644
index 000000000000000..5ae9691d4939862
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/simple-stripped-no-locator.test
@@ -0,0 +1,24 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# RUN: mkdir -p %t/output
+
+# Scenario 1
+#  A simple stripped binary, add the unstripped binary as a symbol file
+#  (Sanity for comparison with Debuginfod-provided symbols)
+
+# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/output/bin-normal
+# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
+# RUN: chmod a+x %t/output/bin-stripped
+
+# Run a negative test (make sure we don't have symbols)
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/bin-stripped" \
+# RUN:       -o "target symbols add %t/output/bin-normal" \
+# 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 + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-positive-a.test b/lldb/test/Shell/Debuginfod/simple-stripped-positive-a.test
new file mode 100644
index 000000000000000..98df28b5c3232ba
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/simple-stripped-positive-a.test
@@ -0,0 +1,35 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
+
+# Scenario 1a
+#  A simple stripped binary
+#  Debuginfod has the unstripped binary as the 'debuginfo'
+
+# Put the unstripped binary in the Debuginfod server as 'debuginfo'
+
+# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/debuginfo
+# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
+# RUN: chmod a+x %t/output/bin-stripped
+
+# First, run a negative test (make sure we don't have symbols)
+
+# Scenario 1, postive test: Can we pull the executable
+# from Debuginfod and get a breakpoint set properly?
+
+# 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/output/bin-stripped" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should have source file info:
+
+# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-positive.test b/lldb/test/Shell/Debuginfod/simple-stripped-positive-b.test
similarity index 62%
rename from lldb/test/Shell/Debuginfod/simple-stripped-positive.test
rename to lldb/test/Shell/Debuginfod/simple-stripped-positive-b.test
index 78671b6eb463aa3..cc9aaee072b0f82 100644
--- a/lldb/test/Shell/Debuginfod/simple-stripped-positive.test
+++ b/lldb/test/Shell/Debuginfod/simple-stripped-positive-b.test
@@ -2,22 +2,19 @@
 
 # We set up a file-system 'hosted' Debuginfod server
 
-# RUN: rm -rf %t || echo ok
 # RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
+# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
 
-# Scenario 1
+# Scenario 1a
 #  A simple stripped binary
 #  Debuginfod has the unstripped binary as the 'executable'
-# LLDB should ask Debuginfod for it's unstripped binary
 
 # Put the unstripped binary in the Debuginfod server as 'executable'
 
-# RUN: yaml2obj %p/Inputs/main-full.yaml -o %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/executable
-# RUN: yaml2obj %p/Inputs/main-stripped.yaml -o %t/output/main-stripped
-# RUN: chmod a+x %t/output/main-stripped
+# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/executable
+# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
+# RUN: chmod a+x %t/output/bin-stripped
 
 # First, run a negative test (make sure we don't have symbols)
 
@@ -28,11 +25,11 @@
 # 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/output/main-stripped" \
+# RUN:       -o "target create %t/output/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
 # Should have source file info:
 
-# CHECK: Breakpoint 1: where = main-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
+# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/tests.md b/lldb/test/Shell/Debuginfod/tests.md
index 7fe3e9e68d4ed32..62cca92355b03ba 100644
--- a/lldb/test/Shell/Debuginfod/tests.md
+++ b/lldb/test/Shell/Debuginfod/tests.md
@@ -6,56 +6,59 @@ 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.
 
-## Baseline capabilities
-
-Things to test:
-
-- Just for sanity, the `-no-locator` tests validate that lldb works as the test
-  expects if the files that Debuginfod _should_ provide are already there.
-- Validate that symbols _aren't_ found without Debuginfod, to ensure they
-  weren't cached from previous runs (`-negative` tests).
-- Validate that the Debuginfod symbol locator is providing the expected symbols
-  when the debugger doesn't already have them available.
-
-## Symbol "Configurations" to test
-
-There are 2 top level configurations, each of which then get some post-processing.
-- The 'normal' build: a simple binary built with debug information (`-g`)
-- The 'split' build: A binary built with `-gsplit-dwarf` that produces `.dwo` and `.dwp` files
-
-For the normal build there are 2 post-processing steps where Debuginfod may be used.
-- Strip the binary while hosting the full, unstripped binary on a Debuginfod server.
-- Strip the binary and produce a corresponding 'only-keep-debug' version of the binary to host on a Debuginfod server.
-
-For the split build, there are *3* post-processing outcomes where Debuginfod usage makes sense:
-- Stripped binary, hosting the full unstripped binary on a Debuginfod server, along with it's `.dwp` file.
-- Stripped binary, hosting the 'only-keep-debug' version of the binary *and* it's `.dwp` file.
-- Unstripped binary, hosting only the `.dwp` file on the Debuginfod server.
-
-For both normal and split builds, when using an 'only-keep-debug' symbol file, the original file
-also requires the addition of the `.gnu.debuglink` section (which can be added using `objcopy`)
-
-### Troubles
-
-The Debuginfod protocol is somewhat underspecified regarding what the 2 different callbacks actually return. The protocol itself is quite simple: query an HTTP server with the path `buildid/{.note.gnu.build-id hash}/debuginfo` and `buildid/{.note.gnu.build-id hash}/executable`. A keen reader may note that there's one configuration (split, only-keep-debug) where you need two different files to properly symbolicate, but the API only supports a single debuginfo file. For that scenario, I've chosen to simply treat the `.dwp` file as "debuginfo" and the "only-keep-debug" stripped binary as "executable". This scenario doesn't actually work at all in GDB. It seems more straightforward than trying to extend the protocol.
-
-### Stripped:
-
-- Should ask for symbols from the service; can be registered as 'executable' and
-  they should work!
-
-### Stripped "only-keep-debug":
-
-- Should get them from the debuginfo, not from the executable query
-
-### split-dwarf:
-
-- Should get dwp file from debuginfo
-
-### split-dwarf + stripped:
-
-- Should get dwp from debuginfo, and the unstripped binary from executable
-
-
-image
-lldb.target.ResolveLoadAddress
+## 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) are _already_ there.
+- The `*-negative` tests validate that symbols _aren't_ found without
+  Debuginfod, to ensure they haven't been cached from previous runs.
+- 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 can provide value:
+
+1. The 'simple-stripped' build variation is a binary built with debug
+   information (`-g`), but stripped for deployment. A Debuginfod service can
+   then host the unstripped binary (as either `executable` or `debuginfo`).
+2. The 'okd-stripped' 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 'simple-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 should host the
+   `.dwp` file as `debuginfo`.
+4. The 'stripped-split' build variation is a binary built with `-gsplit-dwarf`,
+   then stripped in the same manner as variation #1. For this variation,
+   Debuginfod should host the unstripped binary as `executable` and the `.dwp`
+   file as `debuginfo`.
+5. The 'okd-stripped-split' build variation is the combination of variations 2
+   and 3, where Debuginfod hosts the `.gnu.debuglink`'ed file as `executable`
+   and the `.dwp` again 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, I prefer requesting `debuginfo`
+first, then falling back to `executable` (Scenarios #1 & #2). For Scenario #5,
+I've chosen to expect the stripped (i.e. not full) executable, which contains a
+number of sections necessary to correctly symbolicate will be 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.
+
+I've also chosen to simply treat the `.dwp` file as `debuginfo` and the
+"only-keep-debug" stripped binary as `executable`. This scenario doesn't appear
+to work at all in GDB. Supporting it how I did seems more straight forward than
+trying to extend the protocol. The protocol _does_ support querying for section
+contents by name for a given build ID, but adding support for that in LLDB
+looks...well beyond my current capability (and LLVM's Debuginfod library doesn't
+support it at this writing, anyway).

>From 67a9da227ca46af7bd3a6ec7993cb72ece5a385e Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Mon, 22 Jan 2024 17:17:07 -0800
Subject: [PATCH 04/12] One failling test that looks like a real bug...for
 tomorrow

---
 .../Shell/Debuginfod/okd-split-negative.test  | 31 --------------
 .../Shell/Debuginfod/okd-split-positive.test  | 40 -------------------
 .../Debuginfod/okd-stripped-negative.test     | 32 ---------------
 .../Debuginfod/okd-stripped-positive.test     | 35 ----------------
 .../Shell/Debuginfod/okdstrip-negative.test   | 28 +++++++++++++
 .../Shell/Debuginfod/okdstrip-no-locator.test | 26 ++++++++++++
 .../Shell/Debuginfod/okdstrip-positive-a.test | 33 +++++++++++++++
 .../Shell/Debuginfod/okdstrip-positive-b.test | 33 +++++++++++++++
 .../Shell/Debuginfod/simple-dwp-negative.test | 32 ---------------
 .../test/Shell/Debuginfod/split-negative.test | 25 ++++++++++++
 .../Shell/Debuginfod/split-no-locator.test    | 26 ++++++++++++
 .../Debuginfod/split-okdstrip-negative.test   | 24 +++++++++++
 .../Debuginfod/split-okdstrip-no-locator.test | 25 ++++++++++++
 .../Debuginfod/split-okdstrip-positive.test   | 31 ++++++++++++++
 ...-dwp-positive.test => split-positive.test} | 20 +++++-----
 .../Debuginfod/split-strip-negative.test      | 20 ++++++++++
 .../Debuginfod/split-strip-no-locator.test    | 26 ++++++++++++
 .../Debuginfod/split-strip-positive.test      | 31 ++++++++++++++
 ...pped-negative.test => strip-negative.test} |  0
 ...-no-locator.test => strip-no-locator.test} |  0
 ...-positive-a.test => strip-positive-a.test} |  0
 ...-positive-b.test => strip-positive-b.test} |  0
 lldb/test/Shell/Debuginfod/tests.md           |  4 +-
 23 files changed, 339 insertions(+), 183 deletions(-)
 delete mode 100644 lldb/test/Shell/Debuginfod/okd-split-negative.test
 delete mode 100644 lldb/test/Shell/Debuginfod/okd-split-positive.test
 delete mode 100644 lldb/test/Shell/Debuginfod/okd-stripped-negative.test
 delete mode 100644 lldb/test/Shell/Debuginfod/okd-stripped-positive.test
 create mode 100644 lldb/test/Shell/Debuginfod/okdstrip-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
 create mode 100644 lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
 create mode 100644 lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
 delete mode 100644 lldb/test/Shell/Debuginfod/simple-dwp-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/split-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/split-no-locator.test
 create mode 100644 lldb/test/Shell/Debuginfod/split-okdstrip-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/split-okdstrip-no-locator.test
 create mode 100644 lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
 rename lldb/test/Shell/Debuginfod/{simple-dwp-positive.test => split-positive.test} (61%)
 create mode 100644 lldb/test/Shell/Debuginfod/split-strip-negative.test
 create mode 100644 lldb/test/Shell/Debuginfod/split-strip-no-locator.test
 create mode 100644 lldb/test/Shell/Debuginfod/split-strip-positive.test
 rename lldb/test/Shell/Debuginfod/{simple-stripped-negative.test => strip-negative.test} (100%)
 rename lldb/test/Shell/Debuginfod/{simple-stripped-no-locator.test => strip-no-locator.test} (100%)
 rename lldb/test/Shell/Debuginfod/{simple-stripped-positive-a.test => strip-positive-a.test} (100%)
 rename lldb/test/Shell/Debuginfod/{simple-stripped-positive-b.test => strip-positive-b.test} (100%)

diff --git a/lldb/test/Shell/Debuginfod/okd-split-negative.test b/lldb/test/Shell/Debuginfod/okd-split-negative.test
deleted file mode 100644
index 5d5ed250c4cc1d3..000000000000000
--- a/lldb/test/Shell/Debuginfod/okd-split-negative.test
+++ /dev/null
@@ -1,31 +0,0 @@
-# REQUIRES: system-linux && native && target-x86_64
-
-# We set up a file-system 'hosted' Debuginfod server
-
-# RUN: rm -rf %t || echo ok
-# RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
-# RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
-
-# Scenario 4
-#  A stripped binary/split-dwarf combination
-# LLDB should ask Debuginfod for both it's executable AND it's symbols
-
-# RUN: yaml2obj %p/Inputs/main-split-nodbg.yaml -o %t/tmpstuff/main-split-nodbg.tmp
-# RUN: yaml2obj %p/Inputs/main-split-dbg.yaml -o %t/tmpstuff/main-split-dbg
-# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
-# RUN: llvm-objcopy %t/tmpstuff/main-split-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-split-dbg %t/output/main-split-nodbg
-# RUN: mv %t/tmpstuff/main-split-dbg %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/executable
-# RUN: chmod a+x %t/output/main-split-nodbg
-
-# Verify that we -don't- find symbols when not using the Debuginfod service
-
-# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
-# RUN:       -o "target create %t/output/main-split-nodbg" \
-# RUN:       -o "b func" \
-# RUN:       -o "quit" \
-# RUN:        2>&1 | FileCheck %s
-
-# Should NOT have source file information:
-# CHECK: Breakpoint 1: where = main-split-nodbg`func, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/okd-split-positive.test b/lldb/test/Shell/Debuginfod/okd-split-positive.test
deleted file mode 100644
index 3a3f20a5c82c4b1..000000000000000
--- a/lldb/test/Shell/Debuginfod/okd-split-positive.test
+++ /dev/null
@@ -1,40 +0,0 @@
-# REQUIRES: system-linux && native && target-x86_64
-
-# We set up a file-system 'hosted' Debuginfod server
-
-# RUN: rm -rf %t || echo ok
-# RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
-# RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
-
-# Scenario 4
-#  A stripped binary/split-dwarf combination
-# LLDB should ask Debuginfod for both it's executable AND it's symbols
-
-# RUN: yaml2obj %p/Inputs/main-split-nodbg.yaml -o %t/tmpstuff/main-split-nodbg.tmp
-# RUN: yaml2obj %p/Inputs/main-split-dbg.yaml -o %t/tmpstuff/main-split-dbg
-# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
-# RUN: llvm-objcopy %t/tmpstuff/main-split-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-split-dbg %t/output/main-split-nodbg
-# RUN: mv %t/tmpstuff/main-split-dbg %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/executable
-# RUN: chmod a+x %t/output/main-split-nodbg
-
-# Verify that we find symbols from the Debuginfod service
-
-# 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/output/main-split-nodbg" \
-# RUN:       -o "target modules dump separate-debug-info" \
-# RUN:       -o "b main.c:69" \
-# RUN:       -o "quit" \
-# RUN:        2>&1 | FileCheck %s
-
-# Should have source file information:
-# CHECK: Symbol file: {{.*}}/main-split-nodbg
-# CHECK-NEXT: Type: "dwo"
-# CHECK-NEXT: Dwo ID{{.*}}
-# CHECK-NEXT: {{^[- ]+$}}
-# CHECK-NEXT: 0x{{[0-9a-f]+.*}} {{.*}}/cache/llvmcache-9657596136574283768
-# CHECK: Breakpoint 1: address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/okd-stripped-negative.test b/lldb/test/Shell/Debuginfod/okd-stripped-negative.test
deleted file mode 100644
index f110db39c11ae75..000000000000000
--- a/lldb/test/Shell/Debuginfod/okd-stripped-negative.test
+++ /dev/null
@@ -1,32 +0,0 @@
-# REQUIRES: system-linux && native && target-x86_64
-
-# We set up a file-system 'hosted' Debuginfod server
-
-# RUN: rm -rf %t || echo ok
-# RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
-# RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
-
-# Scenario 2
-#  A stripped binary, with an "-only-keep-debug" symbols file
-#  Debuginfo has the 'okd' file as the 'debuginfo' item
-# LLDB should ask Debuginfod for it's symbols
-
-# RUN: yaml2obj %p/Inputs/main-nodbg.yaml -o %t/tmpstuff/main-nodbg.tmp
-# RUN: yaml2obj %p/Inputs/main-dbg.yaml -o %t/tmpstuff/main-dbg
-# RUN: llvm-objcopy %t/tmpstuff/main-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-dbg %t/output/main-nodbg
-# RUN: mv %t/tmpstuff/main-dbg %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/debuginfo
-# RUN: chmod a+x %t/output/main-nodbg
-
-# Negative test (We don't find symbols without the Debuginfod service)
-
-# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
-# RUN:       -o "target create %t/output/main-nodbg" \
-# RUN:       -o "b func" \
-# RUN:       -o "quit" \
-# RUN:        2>&1 | FileCheck %s
-
-# Should NOT have source file information:
-
-# CHECK: Breakpoint 1: where = main-nodbg`func, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/okd-stripped-positive.test b/lldb/test/Shell/Debuginfod/okd-stripped-positive.test
deleted file mode 100644
index 67d55a16041d341..000000000000000
--- a/lldb/test/Shell/Debuginfod/okd-stripped-positive.test
+++ /dev/null
@@ -1,35 +0,0 @@
-# REQUIRES: system-linux && native && target-x86_64
-
-# We set up a file-system 'hosted' Debuginfod server
-
-# RUN: rm -rf %t || echo ok
-# RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
-# RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e
-
-# Scenario 2
-#  A stripped binary, with an "-only-keep-debug" symbols file
-#  Debuginfo has the 'okd' file as the 'debuginfo' item
-# LLDB should ask Debuginfod for it's symbols
-
-# RUN: yaml2obj %p/Inputs/main-nodbg.yaml -o %t/tmpstuff/main-nodbg.tmp
-# RUN: yaml2obj %p/Inputs/main-dbg.yaml -o %t/tmpstuff/main-dbg
-# RUN: llvm-objcopy %t/tmpstuff/main-nodbg.tmp --add-gnu-debuglink=%t/tmpstuff/main-dbg %t/output/main-nodbg
-# RUN: mv %t/tmpstuff/main-dbg %t/buildid/b4927ea09a08ee63313299cf347043010d03cc5e/debuginfo
-# RUN: chmod a+x %t/output/main-nodbg
-
-# Verify that we find symbols from the Debuginfod service
-
-# 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/output/main-nodbg" \
-# RUN:       -o "b func" \
-# RUN:       -o "quit" \
-# RUN:        2>&1 | FileCheck %s
-
-# Should have source file information:
-
-# CHECK: Breakpoint 1: where = main-nodbg`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/okdstrip-negative.test b/lldb/test/Shell/Debuginfod/okdstrip-negative.test
new file mode 100644
index 000000000000000..a63beccd249b1f0
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okdstrip-negative.test
@@ -0,0 +1,28 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+
+# Scenario 2
+#  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: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
+# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
+# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
+# Don't leave the stripped .dbg file laying around for the debugger to discover
+# RUN: rm %t/output/bin-stripped.dbg
+# RUN: chmod a+x %t/output/bin-stripped
+
+# Verify that we find symbols from the Debuginfod service
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/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 000000000000000..f45477a8f037c0d
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
@@ -0,0 +1,26 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+
+# Scenario 2
+#  A stripped binary, with an "-only-keep-debug" symbols
+#  LLDB should find the OKD file automatically using .gnu.debuglink
+
+# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
+# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
+# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
+# RUN: chmod a+x %t/output/bin-stripped
+
+# Verify that we find symbols from the Debuginfod service
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/bin-stripped" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should have source file information:
+
+# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69: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 000000000000000..12cb9cf0282dda0
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
@@ -0,0 +1,33 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
+
+# Scenario 2a
+#  A stripped binary, with an "-only-keep-debug" symbols file
+#  LLDB should request the symbols from Debuginfod as 'debuginfo'
+
+# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
+# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
+# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
+# Move the stripped .dbg into the file:// hosted Debuginfod location
+# RUN: mv %t/output/bin-stripped.dbg %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/debuginfo
+# RUN: chmod a+x %t/output/bin-stripped
+
+# Verify that we find symbols from the Debuginfod service
+
+# 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/output/bin-stripped" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should have source file information:
+
+# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69: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 000000000000000..ace1cfc58e07177
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
@@ -0,0 +1,33 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
+
+# Scenario 2b
+#  A stripped binary, with an "-only-keep-debug" symbols file
+#  LLDB should request the symbols from Debuginfod as 'executable'
+
+# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
+# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
+# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
+# Move the stripped .dbg into the file:// hosted Debuginfod location
+# RUN: mv %t/output/bin-stripped.dbg %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/executable
+# RUN: chmod a+x %t/output/bin-stripped
+
+# Verify that we find symbols from the Debuginfod service
+
+# 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/output/bin-stripped" \
+# RUN:       -o "b func" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# Should have source file information:
+
+# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/simple-dwp-negative.test b/lldb/test/Shell/Debuginfod/simple-dwp-negative.test
deleted file mode 100644
index e1018a1181c2412..000000000000000
--- a/lldb/test/Shell/Debuginfod/simple-dwp-negative.test
+++ /dev/null
@@ -1,32 +0,0 @@
-# REQUIRES: system-linux && native && target-x86_64
-
-# We set up a file-system 'hosted' Debuginfod server
-
-# RUN: rm -rf %t || echo ok
-# RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
-# RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
-
-# Scenario 2
-#  A stripped binary, with an "-only-keep-debug" symbols file
-#  Debuginfo has the 'okd' file as the 'debuginfo' item
-# LLDB should ask Debuginfod for it's symbols
-
-# RUN: yaml2obj %p/Inputs/main-split.yaml -o %t/output/main-split
-# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
-# RUN: chmod a+x %t/output/main-split
-
-# Negative test (We don't find symbols without the Debuginfod service)
-
-# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
-# RUN:       -o "target create %t/output/main-split" \
-# RUN:       -o "target modules dump separate-debug-info" \
-# RUN:       -o "quit" \
-# RUN:        2>&1 | FileCheck %s
-
-# CHECK: Symbol file: {{.*}}/main-split
-# CHECK-NEXT: Type: "dwo"
-# CHECK-NEXT: Dwo ID{{.*}}
-# CHECK-NEXT: {{^[- ]+$}}
-# CHECK-NEXT: 0x{{[0-9a-f]+.*}} unable to locate .dwo debug file {{.*}}main-split.dwo{{.*}} for skeleton DIE 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 000000000000000..351bb0b3c44be92
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-negative.test
@@ -0,0 +1,25 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+
+# Scenario 3: No locator
+#  A split binary, with a *missing* .dwp file
+
+# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
+# RUN: chmod a+x %t/output/bin-split
+
+# Negative test (We don't find symbols without the Debuginfod service)
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/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: {{^[- ]+$}}
+# 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 000000000000000..bb60100b0e05478
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-no-locator.test
@@ -0,0 +1,26 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: rm -rf %t || echo ok
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
+
+# Scenario 3: No locator
+#  A split binary, with a .dwp file right next to the binary
+
+# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
+# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/output/bin-split.dwp
+# RUN: chmod a+x %t/output/bin-split
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/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: {{^[- ]+$}}
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 000000000000000..4bca2113d73ddb1
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-negative.test
@@ -0,0 +1,24 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+
+# Scenario 4: No locator
+#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
+
+# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped.tmp
+# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/output/sym-split
+# RUN: llvm-objcopy %t/output/bin-split-stripped.tmp --add-gnu-debuglink=%t/output/sym-split %t/output/bin-split-stripped
+# RUN: rm %t/output/sym-split
+# RUN: chmod a+x %t/output/bin-split-stripped
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/bin-split-stripped" \
+# RUN:       -o "target modules dump separate-debug-info" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# CHECK: Current executable set to {{.*}}.tmp/output/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 000000000000000..d210a1a7dd54b00
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-no-locator.test
@@ -0,0 +1,25 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+
+# Scenario 4: No locator
+#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
+
+# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped.tmp
+# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/output/sym-split
+# RUN: llvm-objcopy %t/output/bin-split-stripped.tmp --add-gnu-debuglink=%t/output/sym-split %t/output/bin-split-stripped
+# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/output/bin-split-stripped.dwp
+# RUN: chmod a+x %t/output/bin-split-stripped
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/bin-split-stripped" \
+# 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: {{0x[0-9a-f]+.* +.*}}/output/bin-split-stripped.dwp(gen/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 000000000000000..a60c1139a646046
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
@@ -0,0 +1,31 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
+
+# Scenario 4: No locator
+#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
+
+# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped.tmp
+# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/output/sym-split
+# RUN: llvm-objcopy %t/output/bin-split-stripped.tmp --add-gnu-debuglink=%t/output/sym-split %t/output/bin-split-stripped
+# RUN: mv %t/output/sym-split %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
+# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfod
+# RUN: chmod a+x %t/output/bin-split-stripped
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# 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/output/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: {{0x[0-9a-f]+.* +.*}}/output/bin-split-stripped.dwp(gen/bin-split.dwo){{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/simple-dwp-positive.test b/lldb/test/Shell/Debuginfod/split-positive.test
similarity index 61%
rename from lldb/test/Shell/Debuginfod/simple-dwp-positive.test
rename to lldb/test/Shell/Debuginfod/split-positive.test
index acb647e83e008fb..50b7082aac43c0f 100644
--- a/lldb/test/Shell/Debuginfod/simple-dwp-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-positive.test
@@ -2,20 +2,18 @@
 
 # We set up a file-system 'hosted' Debuginfod server
 
-# RUN: rm -rf %t || echo ok
 # RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/tmpstuff
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86
+# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
 
 # Scenario 2
 #  A stripped binary, with an "-only-keep-debug" symbols file
 #  Debuginfo has the 'okd' file as the 'debuginfo' item
 # LLDB should ask Debuginfod for it's symbols
 
-# RUN: yaml2obj %p/Inputs/main-split.yaml -o %t/output/main-split
-# RUN: yaml2obj %p/Inputs/main-dwp.yaml -o %t/buildid/8b5b6416f61adc140ae457e208f1699f89bfda86/debuginfo
-# RUN: chmod a+x %t/output/main-split
+# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
+# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
+# RUN: chmod a+x %t/output/bin-split
 
 # Positive test: We find the DWP file with the Debuginfod service
 
@@ -23,15 +21,15 @@
 # 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/output/main-split" \
+# RUN:       -o "target create %t/output/bin-split" \
 # RUN:       -o "target modules dump separate-debug-info" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
-# CHECK: Symbol file: {{.*}}/main-split
+# CHECK: Symbol file: {{.*}}/output/bin-split
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
-# CHECK-NEXT: {{^[- ]+$}}
+# CHECK: {{[- ]+}}
 # The cache key is stable, so we can mandate that we discover this thing from the cache
-# It's an implementation detail, so it could potentially change, but the ensures that
-# CHECK-NEXT: 0x{{[0-9a-f]+.*}} {{.*}}/cache/llvmcache-9657596136574283768
+# The '.tmp' (sort of) ensures the cache is our private cache, not the system cache
+# CHECK: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
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 000000000000000..163714cb20b77e4
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-strip-negative.test
@@ -0,0 +1,20 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+
+# Scenario 4: Negative
+#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
+
+# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped
+# RUN: chmod a+x %t/output/bin-split-stripped
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/bin-split-stripped" \
+# RUN:       -o "target modules dump separate-debug-info" \
+# RUN:       -o "quit" \
+# RUN:        2>&1 | FileCheck %s
+
+# CHECK: Current executable set to '{{.*}}/output/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 000000000000000..710313e84439857
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-strip-no-locator.test
@@ -0,0 +1,26 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+
+# Scenario 4: No locator
+#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
+
+# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped
+# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
+# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/output/bin-split-stripped.dwp
+# RUN: chmod a+x %t/output/bin-split-stripped
+# RUN: chmod a+x %t/output/bin-split
+
+# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# RUN:       -o "target create %t/output/bin-split-stripped" \
+# RUN:       -o "target symbols add %t/output/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: {{0x[0-9a-f]+.* +.*}}/output/bin-split-stripped.dwp(gen/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 000000000000000..9ebc74cb5bd3621
--- /dev/null
+++ b/lldb/test/Shell/Debuginfod/split-strip-positive.test
@@ -0,0 +1,31 @@
+# REQUIRES: system-linux && native && target-x86_64
+
+# We set up a file-system 'hosted' Debuginfod server
+
+# RUN: mkdir -p %t/output
+# RUN: mkdir -p %t/cache
+# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
+
+# Scenario 4:
+#  A stripped, split binary, symbols manually added and a .dwp file
+#  The unstripped binary should be picked up from /82...94/executable
+#  The .dwp file should be picke dup from /82...94/debuginfo
+
+# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped
+# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
+# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
+# RUN: chmod a+x %t/output/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/output/bin-split-stripped" \
+# 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: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-negative.test b/lldb/test/Shell/Debuginfod/strip-negative.test
similarity index 100%
rename from lldb/test/Shell/Debuginfod/simple-stripped-negative.test
rename to lldb/test/Shell/Debuginfod/strip-negative.test
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-no-locator.test b/lldb/test/Shell/Debuginfod/strip-no-locator.test
similarity index 100%
rename from lldb/test/Shell/Debuginfod/simple-stripped-no-locator.test
rename to lldb/test/Shell/Debuginfod/strip-no-locator.test
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-positive-a.test b/lldb/test/Shell/Debuginfod/strip-positive-a.test
similarity index 100%
rename from lldb/test/Shell/Debuginfod/simple-stripped-positive-a.test
rename to lldb/test/Shell/Debuginfod/strip-positive-a.test
diff --git a/lldb/test/Shell/Debuginfod/simple-stripped-positive-b.test b/lldb/test/Shell/Debuginfod/strip-positive-b.test
similarity index 100%
rename from lldb/test/Shell/Debuginfod/simple-stripped-positive-b.test
rename to lldb/test/Shell/Debuginfod/strip-positive-b.test
diff --git a/lldb/test/Shell/Debuginfod/tests.md b/lldb/test/Shell/Debuginfod/tests.md
index 62cca92355b03ba..cbde54d75af7a86 100644
--- a/lldb/test/Shell/Debuginfod/tests.md
+++ b/lldb/test/Shell/Debuginfod/tests.md
@@ -32,10 +32,10 @@ There are 5 variations of symbol data where Debuginfod can provide value:
    that produces `.dwo` which are subsequently linked together (using
    `llvm-dwp`) into a single `.dwp` file. The Debuginfod service should host the
    `.dwp` file as `debuginfo`.
-4. The 'stripped-split' build variation is a binary built with `-gsplit-dwarf`,
+4. **The 'stripped-split' build variation is a binary built with `-gsplit-dwarf`,
    then stripped in the same manner as variation #1. For this variation,
    Debuginfod should host the unstripped binary as `executable` and the `.dwp`
-   file as `debuginfo`.
+   file as `debuginfo`.**
 5. The 'okd-stripped-split' build variation is the combination of variations 2
    and 3, where Debuginfod hosts the `.gnu.debuglink`'ed file as `executable`
    and the `.dwp` again as `debuginfo`.

>From 148c7d7bad751d7c1ec69375b6de4b9fe4291cc5 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Mon, 22 Jan 2024 22:34:01 -0800
Subject: [PATCH 05/12] Fixed the last test. Looks like everything works.

---
 lldb/test/Shell/Debuginfod/split-okdstrip-positive.test | 6 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp                      | 5 -----
 llvm/utils/gn/build/write_library_dependencies.py       | 1 -
 llvm/utils/lldbDataFormatters.py                        | 2 --
 4 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
index a60c1139a646046..3261a78b22bb221 100644
--- a/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
@@ -13,10 +13,10 @@
 # RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/output/sym-split
 # RUN: llvm-objcopy %t/output/bin-split-stripped.tmp --add-gnu-debuglink=%t/output/sym-split %t/output/bin-split-stripped
 # RUN: mv %t/output/sym-split %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
-# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfod
+# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
 # RUN: chmod a+x %t/output/bin-split-stripped
 
-# RUN: %lldb -o "settings set symbols.enable-external-lookup false" \
+# 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" \
@@ -28,4 +28,4 @@
 # CHECK: Symbol file: {{.*}}/bin-split-stripped
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
-# CHECK: {{0x[0-9a-f]+.* +.*}}/output/bin-split-stripped.dwp(gen/bin-split.dwo){{ *$}}
+# CHECK: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 1244793dff20d87..ba1a3daebd2632f 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -154,11 +154,6 @@ std::string getDebuginfodDebuginfoUrlPath(BuildIDRef ID) {
   return std::string(UrlPath);
 }
 
-Expected<std::string> getCachedOrDownloadDebuginfo(BuildIDRef ID) {
-  std::string UrlPath = getDebuginfodDebuginfoUrlPath(ID);
-  return getCachedOrDownloadArtifact(getDebuginfodCacheKey(UrlPath), UrlPath);
-}
-
 Expected<std::string> getCachedOrDownloadDebuginfo(BuildIDRef ID) {
   std::string UrlPath = getDebuginfodDebuginfoUrlPath(ID);
   return getCachedOrDownloadArtifact(getDebuginfodCacheKey(UrlPath), UrlPath);
diff --git a/llvm/utils/gn/build/write_library_dependencies.py b/llvm/utils/gn/build/write_library_dependencies.py
index e88ed8d6411ec79..ba1a8a0157314df 100644
--- a/llvm/utils/gn/build/write_library_dependencies.py
+++ b/llvm/utils/gn/build/write_library_dependencies.py
@@ -37,7 +37,6 @@
 { "coverage", "LLVMCoverage", true, {"core", "object", "profiledata", "support"} },
 { "debuginfocodeview", "LLVMDebugInfoCodeView", true, {"support", "debuginfomsf"} },
 { "debuginfodwarf", "LLVMDebugInfoDWARF", true, {"binaryformat", "object", "mc", "support"} },
-{ "debuginfod", "LLVMDebuginfod", true, {} },
 { "debuginfogsym", "LLVMDebugInfoGSYM", true, {"mc", "object", "support", "debuginfodwarf"} },
 { "debuginfomsf", "LLVMDebugInfoMSF", true, {"support"} },
 { "debuginfopdb", "LLVMDebugInfoPDB", true, {"binaryformat", "object", "support", "debuginfocodeview", "debuginfomsf"} },
diff --git a/llvm/utils/lldbDataFormatters.py b/llvm/utils/lldbDataFormatters.py
index 5acc02c9c8e8f4a..de101abdabc8ecd 100644
--- a/llvm/utils/lldbDataFormatters.py
+++ b/llvm/utils/lldbDataFormatters.py
@@ -373,7 +373,6 @@ def DenseMapSummary(valobj: lldb.SBValue, _) -> str:
     return summary
 
 
-"""
 class DenseMapSynthetic:
     valobj: lldb.SBValue
 
@@ -432,4 +431,3 @@ def update(self):
         for indexes in key_buckets.values():
             if len(indexes) == 1:
                 self.child_buckets.append(indexes[0])
-"""

>From f39796f66e7d62db268872ddf484b0b3abe24c41 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Mon, 22 Jan 2024 22:43:16 -0800
Subject: [PATCH 06/12] Moved IsDwp to a local function for now

---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp      | 18 ---------------
 .../SymbolFile/DWARF/SymbolFileDWARF.h        |  3 ---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp    |  6 ++---
 .../SymbolVendor/ELF/SymbolVendorELF.cpp      | 22 ++++++++++++++++---
 .../Debuginfod/Inputs/{mk => make-inputs}     |  0
 5 files changed, 22 insertions(+), 27 deletions(-)
 rename lldb/test/Shell/Debuginfod/Inputs/{mk => make-inputs} (100%)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index e25a0dcd640b2ad..fed97858c83f8e2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -39,7 +39,6 @@
 #include "lldb/Interpreter/OptionValueProperties.h"
 
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
 #include "Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Symbol/Block.h"
@@ -4321,23 +4320,6 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {
   return m_debug_map_symfile;
 }
 
-bool SymbolFileDWARF::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 ObjectFileELF frorm the filespace
-  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;
-  static ConstString sect_name_debug_cu_index(".debug_cu_index");
-  if (!dwp_obj_file || !dwp_obj_file->GetSectionList()->FindSectionByName(
-                           sect_name_debug_cu_index))
-    return false;
-  return true;
-}
-
 const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
   llvm::call_once(m_dwp_symfile_once_flag, [this]() {
     ModuleSpec module_spec;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 1419604238d86c6..26a9502f90aa006 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -267,9 +267,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
 
   DWARFContext &GetDWARFContext() { return m_context; }
 
-  static bool IsDwpSymbolFile(const lldb::ModuleSP &module_sp,
-                              const FileSpec &file_spec);
-
   const std::shared_ptr<SymbolFileDWARFDwo> &GetDwpSymbolFile();
 
   FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
diff --git a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 81406654092b3c4..2cd7bbbb2449028 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -96,13 +96,13 @@ class PluginProperties : public Properties {
   Args m_server_urls;
 };
 
-PluginProperties &GetGlobalPluginProperties() {
+} // namespace
+
+static PluginProperties &GetGlobalPluginProperties() {
   static PluginProperties g_settings;
   return g_settings;
 }
 
-} // namespace
-
 SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {}
 
 void SymbolLocatorDebuginfod::Initialize() {
diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index aeacf9c78ea70fd..5f66de1ff67eeef 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -11,7 +11,6 @@
 #include <cstring>
 
 #include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
@@ -45,6 +44,24 @@ 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 ObjectFileELF frorm the filespace
+  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;
+  static ConstString sect_name_debug_cu_index(".debug_cu_index");
+  if (!dwp_obj_file || !dwp_obj_file->GetSectionList()->FindSectionByName(
+                           sect_name_debug_cu_index))
+    return false;
+  return true;
+}
+
 // CreateInstance
 //
 // Platforms can register a callback to use when creating symbol vendors to
@@ -88,8 +105,7 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
   FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
   FileSpec dsym_fspec =
       PluginManager::LocateExecutableSymbolFile(module_spec, search_paths);
-  if (!dsym_fspec ||
-      plugin::dwarf::SymbolFileDWARF::IsDwpSymbolFile(module_sp, dsym_fspec)) {
+  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 =
diff --git a/lldb/test/Shell/Debuginfod/Inputs/mk b/lldb/test/Shell/Debuginfod/Inputs/make-inputs
similarity index 100%
rename from lldb/test/Shell/Debuginfod/Inputs/mk
rename to lldb/test/Shell/Debuginfod/Inputs/make-inputs

>From bd02797017886f175019245c1b61a9affe847e32 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Tue, 23 Jan 2024 08:38:59 -0800
Subject: [PATCH 07/12] Switched to identifying DWP files by type instead of
 name.

---
 lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index 5f66de1ff67eeef..ec734b8bb64f871 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -49,15 +49,16 @@ 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 ObjectFileELF frorm the filespace
+  // 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;
-  static ConstString sect_name_debug_cu_index(".debug_cu_index");
-  if (!dwp_obj_file || !dwp_obj_file->GetSectionList()->FindSectionByName(
-                           sect_name_debug_cu_index))
+  // 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;
 }

>From c240e4904407d0d937863fe30c2ebe77dc693225 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Tue, 23 Jan 2024 09:36:07 -0800
Subject: [PATCH 08/12] Cleaned up tests comments-n-stuff

---
 .../{tests.md => Debuginfod-testing.md}       | 37 ++++++++++---------
 .../Shell/Debuginfod/okdstrip-negative.test   | 26 ++++++-------
 .../Shell/Debuginfod/okdstrip-no-locator.test | 26 ++++++-------
 .../Shell/Debuginfod/okdstrip-positive-a.test | 29 ++++++---------
 .../Shell/Debuginfod/okdstrip-positive-b.test | 29 ++++++---------
 .../test/Shell/Debuginfod/split-negative.test | 18 ++++-----
 .../Shell/Debuginfod/split-no-locator.test    | 22 +++++------
 .../Debuginfod/split-okdstrip-negative.test   | 24 ++++++------
 .../Debuginfod/split-okdstrip-no-locator.test | 28 +++++++-------
 .../Debuginfod/split-okdstrip-positive.test   | 25 +++++++------
 .../test/Shell/Debuginfod/split-positive.test | 27 ++++++--------
 .../Debuginfod/split-strip-negative.test      | 17 ++++-----
 .../Debuginfod/split-strip-no-locator.test    | 29 ++++++++-------
 .../Debuginfod/split-strip-positive.test      | 25 +++++++------
 .../test/Shell/Debuginfod/strip-negative.test | 19 ++++------
 .../Shell/Debuginfod/strip-no-locator.test    | 24 ++++++------
 .../Shell/Debuginfod/strip-positive-a.test    | 27 +++++---------
 .../Shell/Debuginfod/strip-positive-b.test    | 27 +++++---------
 18 files changed, 207 insertions(+), 252 deletions(-)
 rename lldb/test/Shell/Debuginfod/{tests.md => Debuginfod-testing.md} (68%)

diff --git a/lldb/test/Shell/Debuginfod/tests.md b/lldb/test/Shell/Debuginfod/Debuginfod-testing.md
similarity index 68%
rename from lldb/test/Shell/Debuginfod/tests.md
rename to lldb/test/Shell/Debuginfod/Debuginfod-testing.md
index cbde54d75af7a86..df335ca11ffa42e 100644
--- a/lldb/test/Shell/Debuginfod/tests.md
+++ b/lldb/test/Shell/Debuginfod/Debuginfod-testing.md
@@ -10,35 +10,36 @@ files we need for testing.
 
 - 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) are _already_ there.
+  `.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.
-- The `*-positive` tests check that the Debuginfod symbol locator is providing
+  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 can provide value:
+There are 5 variations of symbol data where Debuginfod provides value:
 
-1. The 'simple-stripped' build variation is a binary built with debug
-   information (`-g`), but stripped for deployment. A Debuginfod service can
-   then host the unstripped binary (as either `executable` or `debuginfo`).
-2. The 'okd-stripped' build variation is a binary build with `-g`, stripped for
+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 'simple-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 should host the
-   `.dwp` file as `debuginfo`.
-4. **The 'stripped-split' build variation is a binary built with `-gsplit-dwarf`,
+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 should host the unstripped binary as `executable` and the `.dwp`
-   file as `debuginfo`.**
-5. The 'okd-stripped-split' build variation is the combination of variations 2
-   and 3, where Debuginfod hosts the `.gnu.debuglink`'ed file as `executable`
-   and the `.dwp` again as `debuginfo`.
+   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
 
diff --git a/lldb/test/Shell/Debuginfod/okdstrip-negative.test b/lldb/test/Shell/Debuginfod/okdstrip-negative.test
index a63beccd249b1f0..8b0603e6f5860d5 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-negative.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-negative.test
@@ -1,24 +1,20 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# 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: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 2
-#  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: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
-# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
-# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
-# Don't leave the stripped .dbg file laying around for the debugger to discover
-# RUN: rm %t/output/bin-stripped.dbg
-# RUN: chmod a+x %t/output/bin-stripped
-
-# Verify that we find symbols from the Debuginfod service
+# 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/output/bin-stripped" \
+# RUN:       -o "target create %t/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
diff --git a/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test b/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
index f45477a8f037c0d..943ab100437c6c3 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
@@ -1,26 +1,22 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 2 baseline:
+# * A stripped binary, with an "-only-keep-debug" symbols file.
+# * LLDB should find the OKD file automatically using .gnu.debuglink.
 
-# RUN: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 2
-#  A stripped binary, with an "-only-keep-debug" symbols
-#  LLDB should find the OKD file automatically using .gnu.debuglink
-
-# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
-# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
-# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
-# RUN: chmod a+x %t/output/bin-stripped
-
-# Verify that we find symbols from the Debuginfod service
+# 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/output/bin-stripped" \
+# RUN:       -o "target create %t/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
-# Should have source file information:
-
+# Should have source file and line information:
 # CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69: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
index 12cb9cf0282dda0..77abcc7ca9d665b 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
@@ -1,33 +1,28 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 2a:
+#  A stripped binary, with an "-only-keep-debug" symbols file.
+#  LLDB should request the symbols from Debuginfod as 'debuginfo'.
 
-# RUN: mkdir -p %t/output
+# Set up a file-system 'hosted' Debuginfod server.
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
 # RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
 
-# Scenario 2a
-#  A stripped binary, with an "-only-keep-debug" symbols file
-#  LLDB should request the symbols from Debuginfod as 'debuginfo'
-
-# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
-# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
-# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
-# Move the stripped .dbg into the file:// hosted Debuginfod location
-# RUN: mv %t/output/bin-stripped.dbg %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/debuginfo
-# RUN: chmod a+x %t/output/bin-stripped
-
-# Verify that we find symbols from the Debuginfod service
+# 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/725d47b7ee964f615c841a04712d6f43175f9d8d/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/output/bin-stripped" \
+# RUN:       -o "target create %t/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
-# Should have source file information:
-
+# Should have source file and line information:
 # CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69: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
index ace1cfc58e07177..3555d4c2fc2874c 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
@@ -1,33 +1,28 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 2b:
+#  A stripped binary, with an "-only-keep-debug" symbols file.
+#  LLDB should request the symbols from Debuginfod as 'executable'.
 
-# RUN: mkdir -p %t/output
+# Set up a file-system 'hosted' Debuginfod server.
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
 # RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
 
-# Scenario 2b
-#  A stripped binary, with an "-only-keep-debug" symbols file
-#  LLDB should request the symbols from Debuginfod as 'executable'
-
-# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped.tmp
-# RUN: yaml2obj %p/Inputs/sym-stripped.yaml -o %t/output/bin-stripped.dbg
-# RUN: llvm-objcopy %t/output/bin-stripped.tmp --add-gnu-debuglink=%t/output/bin-stripped.dbg %t/output/bin-stripped
-# Move the stripped .dbg into the file:// hosted Debuginfod location
-# RUN: mv %t/output/bin-stripped.dbg %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/executable
-# RUN: chmod a+x %t/output/bin-stripped
-
-# Verify that we find symbols from the Debuginfod service
+# 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/725d47b7ee964f615c841a04712d6f43175f9d8d/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/output/bin-stripped" \
+# RUN:       -o "target create %t/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
-# Should have source file information:
-
+# Should have source file and line information:
 # CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
diff --git a/lldb/test/Shell/Debuginfod/split-negative.test b/lldb/test/Shell/Debuginfod/split-negative.test
index 351bb0b3c44be92..6458abd4485df65 100644
--- a/lldb/test/Shell/Debuginfod/split-negative.test
+++ b/lldb/test/Shell/Debuginfod/split-negative.test
@@ -1,19 +1,16 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 3 negative:
+# * A split-dwarf binary with a *missing* .dwp file (validate nothing's cached).
 
-# RUN: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 3: No locator
-#  A split binary, with a *missing* .dwp file
-
-# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
-# RUN: chmod a+x %t/output/bin-split
-
-# Negative test (We don't find symbols without the Debuginfod service)
+# 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/output/bin-split" \
+# RUN:       -o "target create %t/bin-split" \
 # RUN:       -o "target modules dump separate-debug-info" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
@@ -22,4 +19,5 @@
 # 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
index bb60100b0e05478..11ac3c60d5b87af 100644
--- a/lldb/test/Shell/Debuginfod/split-no-locator.test
+++ b/lldb/test/Shell/Debuginfod/split-no-locator.test
@@ -1,21 +1,17 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 3 baseline:
+# * A split-dwarf binary with the .dwp file right next to the binary.
 
-# RUN: rm -rf %t || echo ok
-# RUN: mkdir -p %t/output
-# RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 3: No locator
-#  A split binary, with a .dwp file right next to the binary
-
-# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
-# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/output/bin-split.dwp
-# RUN: chmod a+x %t/output/bin-split
+# 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/output/bin-split" \
+# RUN:       -o "target create %t/bin-split" \
 # RUN:       -o "target modules dump separate-debug-info" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
@@ -24,3 +20,5 @@
 # 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
index 4bca2113d73ddb1..0b2267329650a52 100644
--- a/lldb/test/Shell/Debuginfod/split-okdstrip-negative.test
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-negative.test
@@ -1,24 +1,24 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 5 negative:
+# * An "only-keep-debug" stripped, split binary with a _missing_
+# * --add-gnu-debuglink symbol file.
 
-# RUN: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 4: No locator
-#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
-
-# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped.tmp
-# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/output/sym-split
-# RUN: llvm-objcopy %t/output/bin-split-stripped.tmp --add-gnu-debuglink=%t/output/sym-split %t/output/bin-split-stripped
-# RUN: rm %t/output/sym-split
-# RUN: chmod a+x %t/output/bin-split-stripped
+# 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/output/bin-split-stripped" \
+# 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 {{.*}}.tmp/output/bin-split-stripped' (x86_64).
+# 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
index d210a1a7dd54b00..c4574257b5d07ce 100644
--- a/lldb/test/Shell/Debuginfod/split-okdstrip-no-locator.test
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-no-locator.test
@@ -1,25 +1,27 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 5 baseline:
+# * A stripped, split binary, with --add-gnu-debuglink symbols automatically
+# * found, with a .dwp file located next to the binary.
 
-# RUN: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 4: No locator
-#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
-
-# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped.tmp
-# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/output/sym-split
-# RUN: llvm-objcopy %t/output/bin-split-stripped.tmp --add-gnu-debuglink=%t/output/sym-split %t/output/bin-split-stripped
-# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/output/bin-split-stripped.dwp
-# RUN: chmod a+x %t/output/bin-split-stripped
+# 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/output/bin-split-stripped" \
+# 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
+# CHECK: Symbol file: {{.*}}/bin-split-stripped
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
-# CHECK: {{0x[0-9a-f]+.* +.*}}/output/bin-split-stripped.dwp(gen/bin-split.dwo){{ *$}}
+# 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
index 3261a78b22bb221..9d141b0f87abe4b 100644
--- a/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
@@ -1,26 +1,26 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 5:
+# * A stripped, split binary, with --add-gnu-debuglink symbol file where
+# * both files are *only* available through Debuginfod.
 
-# RUN: mkdir -p %t/output
+# Set up a file-system 'hosted' Debuginfod server
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
 # RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
 
-# Scenario 4: No locator
-#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
-
-# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped.tmp
-# RUN: yaml2obj %p/Inputs/sym-split.yaml -o %t/output/sym-split
-# RUN: llvm-objcopy %t/output/bin-split-stripped.tmp --add-gnu-debuglink=%t/output/sym-split %t/output/bin-split-stripped
-# RUN: mv %t/output/sym-split %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
+# 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/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
 # RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
-# RUN: chmod a+x %t/output/bin-split-stripped
+# 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/output/bin-split-stripped" \
+# RUN:       -o "target create %t/bin-split-stripped" \
 # RUN:       -o "target modules dump separate-debug-info" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
@@ -28,4 +28,5 @@
 # CHECK: Symbol file: {{.*}}/bin-split-stripped
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
-# CHECK: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
+# CHECK-NEXT: {{[- ]+}}
+# CHECK-NEXT: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/split-positive.test b/lldb/test/Shell/Debuginfod/split-positive.test
index 50b7082aac43c0f..572b36f505c1b9f 100644
--- a/lldb/test/Shell/Debuginfod/split-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-positive.test
@@ -1,35 +1,30 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 3:
+# * A split-dwarf binary with a Debuginfod-hosted .dwp file.
 
-# RUN: mkdir -p %t/output
+# Set up a file-system 'hosted' Debuginfod server
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
 # RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
 
-# Scenario 2
-#  A stripped binary, with an "-only-keep-debug" symbols file
-#  Debuginfo has the 'okd' file as the 'debuginfo' item
-# LLDB should ask Debuginfod for it's symbols
-
-# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
+# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/bin-split
 # RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
-# RUN: chmod a+x %t/output/bin-split
-
-# Positive test: We find the DWP file with the Debuginfod service
+# 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/output/bin-split" \
+# 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: {{.*}}/output/bin-split
+# CHECK: Symbol file: {{.*}}/bin-split
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
-# CHECK: {{[- ]+}}
-# The cache key is stable, so we can mandate that we discover this thing from the cache
+# 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: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
+# CHECK-NEXT: {{0x[0-9a-f]+.* +}}/{{.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/split-strip-negative.test b/lldb/test/Shell/Debuginfod/split-strip-negative.test
index 163714cb20b77e4..0359fdb0cfb7d45 100644
--- a/lldb/test/Shell/Debuginfod/split-strip-negative.test
+++ b/lldb/test/Shell/Debuginfod/split-strip-negative.test
@@ -1,20 +1,19 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 4 negative:
+# * A stripped, split binary with missing symbols and missing .dwp file.
 
-# RUN: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 4: Negative
-#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
-
-# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped
-# RUN: chmod a+x %t/output/bin-split-stripped
+# 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/output/bin-split-stripped" \
+# 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 '{{.*}}/output/bin-split-stripped'
+# 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
index 710313e84439857..a7638f918811dd5 100644
--- a/lldb/test/Shell/Debuginfod/split-strip-no-locator.test
+++ b/lldb/test/Shell/Debuginfod/split-strip-no-locator.test
@@ -1,26 +1,27 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 4 baseline:
+# * A stripped, split binary, with symbols manually added and the
+# * .dwp file located (automatically) sitting next to the binary.
 
-# RUN: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 4: No locator
-#  A stripped, split binary, symbols manually added and a .dwp file right next to the binary
-
-# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped
-# RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/output/bin-split
-# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/output/bin-split-stripped.dwp
-# RUN: chmod a+x %t/output/bin-split-stripped
-# RUN: chmod a+x %t/output/bin-split
+# 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/output/bin-split-stripped" \
-# RUN:       -o "target symbols add %t/output/bin-split" \
+# 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
+# CHECK: Symbol file: {{.*}}/bin-split-stripped
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
-# CHECK: {{0x[0-9a-f]+.* +.*}}/output/bin-split-stripped.dwp(gen/bin-split.dwo){{ *$}}
+# 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
index 9ebc74cb5bd3621..261319919bc94fd 100644
--- a/lldb/test/Shell/Debuginfod/split-strip-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-strip-positive.test
@@ -1,31 +1,32 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 4:
+# * A stripped, split binary, with the unstripped binary and .dwp file
+# * hosted by Debuginfod.
 
-# RUN: mkdir -p %t/output
+# Set up a file-system 'hosted' Debuginfod server.
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
 # RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
 
-# Scenario 4:
-#  A stripped, split binary, symbols manually added and a .dwp file
-#  The unstripped binary should be picked up from /82...94/executable
-#  The .dwp file should be picke dup from /82...94/debuginfo
-
-# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/output/bin-split-stripped
+# RUN: yaml2obj %p/Inputs/bin-split-stripped.yaml -o %t/bin-split-stripped
 # RUN: yaml2obj %p/Inputs/bin-split.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
 # RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
-# RUN: chmod a+x %t/output/bin-split-stripped
+# 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/output/bin-split-stripped" \
+# 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
+# CHECK: Symbol file: {{.*}}/bin-split-stripped
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
-# CHECK: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
+# 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-6559017670391320133{{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/strip-negative.test b/lldb/test/Shell/Debuginfod/strip-negative.test
index 2c4128e0d04b680..5aae7189678a114 100644
--- a/lldb/test/Shell/Debuginfod/strip-negative.test
+++ b/lldb/test/Shell/Debuginfod/strip-negative.test
@@ -1,23 +1,20 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# This is paranoia to make sure there's not a cached symbol file laying around
+# Scenario 1 negative:
+# * A plain stripped binary, no symbols available
+# * Negative test: make sure nothing's been cached
 
-# RUN: mkdir -p %t/output
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# Scenario 1
-#  A simple stripped binary, no symbols (negative test: nothing's been cached, right?)
-
-# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
-# RUN: chmod a+x %t/output/bin-stripped
-
-# Run a negative test (make sure we don't have symbols)
+# 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/output/bin-stripped" \
+# 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
index 5ae9691d4939862..ea4bb47648ecbdc 100644
--- a/lldb/test/Shell/Debuginfod/strip-no-locator.test
+++ b/lldb/test/Shell/Debuginfod/strip-no-locator.test
@@ -1,24 +1,22 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# RUN: mkdir -p %t/output
+# Scenario 1 baseline:
+# * A plain stripped binary, add the unstripped binary as a symbol file
+# * Sanity for functional parity with Debuginfod-provided symbols
 
-# Scenario 1
-#  A simple stripped binary, add the unstripped binary as a symbol file
-#  (Sanity for comparison with Debuginfod-provided symbols)
+# RUN: rm -rf %t
+# RUN: mkdir -p %t
 
-# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/output/bin-normal
-# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
-# RUN: chmod a+x %t/output/bin-stripped
-
-# Run a negative test (make sure we don't have symbols)
+# 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/output/bin-stripped" \
-# RUN:       -o "target symbols add %t/output/bin-normal" \
+# 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 NOT have source file information:
-
+# Should have correct source file and line information:
 # CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69: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
index 98df28b5c3232ba..baa63f068bbff8e 100644
--- a/lldb/test/Shell/Debuginfod/strip-positive-a.test
+++ b/lldb/test/Shell/Debuginfod/strip-positive-a.test
@@ -1,35 +1,26 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 1a:
+# * A plain stripped binary
+# * Debuginfod has the unstripped binary as the 'debuginfo'
 
-# RUN: mkdir -p %t/output
+# Set up a file-system 'hosted' Debuginfod server:
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
 # RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
 
-# Scenario 1a
-#  A simple stripped binary
-#  Debuginfod has the unstripped binary as the 'debuginfo'
-
-# Put the unstripped binary in the Debuginfod server as 'debuginfo'
-
 # RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/debuginfo
-# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
-# RUN: chmod a+x %t/output/bin-stripped
-
-# First, run a negative test (make sure we don't have symbols)
-
-# Scenario 1, postive test: Can we pull the executable
-# from Debuginfod and get a breakpoint set properly?
+# 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/output/bin-stripped" \
+# RUN:       -o "target create %t/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
-# Should have source file info:
-
+# Should have source file and line info:
 # CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69: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
index cc9aaee072b0f82..f1046bb8448f15c 100644
--- a/lldb/test/Shell/Debuginfod/strip-positive-b.test
+++ b/lldb/test/Shell/Debuginfod/strip-positive-b.test
@@ -1,35 +1,26 @@
 # REQUIRES: system-linux && native && target-x86_64
 
-# We set up a file-system 'hosted' Debuginfod server
+# Scenario 1b:
+# * A plain stripped binary
+# * Debuginfod has the unstripped binary as the 'executable'
 
-# RUN: mkdir -p %t/output
+# Set up a file-system 'hosted' Debuginfod server:
+# RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
 # RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
 
-# Scenario 1a
-#  A simple stripped binary
-#  Debuginfod has the unstripped binary as the 'executable'
-
-# Put the unstripped binary in the Debuginfod server as 'executable'
-
 # RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/executable
-# RUN: yaml2obj %p/Inputs/bin-stripped.yaml -o %t/output/bin-stripped
-# RUN: chmod a+x %t/output/bin-stripped
-
-# First, run a negative test (make sure we don't have symbols)
-
-# Scenario 1, postive test: Can we pull the executable
-# from Debuginfod and get a breakpoint set properly?
+# 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/output/bin-stripped" \
+# RUN:       -o "target create %t/bin-stripped" \
 # RUN:       -o "b func" \
 # RUN:       -o "quit" \
 # RUN:        2>&1 | FileCheck %s
 
-# Should have source file info:
-
+# Should have source file and line info:
 # CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}

>From 2e2494f8d7d1f84c6a19537d24b88b3021be4456 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Tue, 23 Jan 2024 09:52:50 -0800
Subject: [PATCH 09/12] Positive tests only run if we have libcurl

---
 lldb/test/Shell/Debuginfod/okdstrip-positive-a.test     | 2 +-
 lldb/test/Shell/Debuginfod/okdstrip-positive-b.test     | 2 +-
 lldb/test/Shell/Debuginfod/split-okdstrip-positive.test | 2 +-
 lldb/test/Shell/Debuginfod/split-positive.test          | 6 +++---
 lldb/test/Shell/Debuginfod/split-strip-positive.test    | 2 +-
 lldb/test/Shell/Debuginfod/strip-positive-a.test        | 2 +-
 lldb/test/Shell/Debuginfod/strip-positive-b.test        | 2 +-
 lldb/test/Shell/lit.cfg.py                              | 3 +++
 lldb/test/Shell/lit.site.cfg.py.in                      | 1 +
 llvm/lib/Debuginfod/Debuginfod.cpp                      | 1 +
 10 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test b/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
index 77abcc7ca9d665b..930a64e85187010 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-linux && native && target-x86_64
+# REQUIRES: curl && system-linux && native && target-x86_64
 
 # Scenario 2a:
 #  A stripped binary, with an "-only-keep-debug" symbols file.
diff --git a/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test b/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
index 3555d4c2fc2874c..05d9fa1ebbf36e9 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-linux && native && target-x86_64
+# REQUIRES: curl && system-linux && native && target-x86_64
 
 # Scenario 2b:
 #  A stripped binary, with an "-only-keep-debug" symbols file.
diff --git a/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
index 9d141b0f87abe4b..5f1eb18e21c7c50 100644
--- a/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-linux && native && target-x86_64
+# REQUIRES: curl && system-linux && native && target-x86_64
 
 # Scenario 5:
 # * A stripped, split binary, with --add-gnu-debuglink symbol file where
diff --git a/lldb/test/Shell/Debuginfod/split-positive.test b/lldb/test/Shell/Debuginfod/split-positive.test
index 572b36f505c1b9f..445b6b7eef96f6a 100644
--- a/lldb/test/Shell/Debuginfod/split-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-positive.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-linux && native && target-x86_64
+# REQUIRES: curl && system-linux && native && target-x86_64
 
 # Scenario 3:
 # * A split-dwarf binary with a Debuginfod-hosted .dwp file.
@@ -25,6 +25,6 @@
 # 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
+# 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-6559017670391320133{{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/split-strip-positive.test b/lldb/test/Shell/Debuginfod/split-strip-positive.test
index 261319919bc94fd..3c19382d2f6df61 100644
--- a/lldb/test/Shell/Debuginfod/split-strip-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-strip-positive.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-linux && native && target-x86_64
+# REQUIRES: curl && system-linux && native && target-x86_64
 
 # Scenario 4:
 # * A stripped, split binary, with the unstripped binary and .dwp file
diff --git a/lldb/test/Shell/Debuginfod/strip-positive-a.test b/lldb/test/Shell/Debuginfod/strip-positive-a.test
index baa63f068bbff8e..e8ca8584c2fbc49 100644
--- a/lldb/test/Shell/Debuginfod/strip-positive-a.test
+++ b/lldb/test/Shell/Debuginfod/strip-positive-a.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-linux && native && target-x86_64
+# REQUIRES: curl && system-linux && native && target-x86_64
 
 # Scenario 1a:
 # * A plain stripped binary
diff --git a/lldb/test/Shell/Debuginfod/strip-positive-b.test b/lldb/test/Shell/Debuginfod/strip-positive-b.test
index f1046bb8448f15c..a7af5bdbdfcf1ea 100644
--- a/lldb/test/Shell/Debuginfod/strip-positive-b.test
+++ b/lldb/test/Shell/Debuginfod/strip-positive-b.test
@@ -1,4 +1,4 @@
-# REQUIRES: system-linux && native && target-x86_64
+# REQUIRES: curl && system-linux && native && target-x86_64
 
 # Scenario 1b:
 # * A plain stripped binary
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index d75c1f532e147f6..9a596a40b29664e 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 736dfc335732b5a..5428691c129a1c8 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@
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index ba1a3daebd2632f..16368cb5d5c6b6e 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -158,6 +158,7 @@ Expected<std::string> getCachedOrDownloadDebuginfo(BuildIDRef ID) {
   std::string UrlPath = getDebuginfodDebuginfoUrlPath(ID);
   return getCachedOrDownloadArtifact(getDebuginfodCacheKey(UrlPath), UrlPath);
 }
+
 // General fetching function.
 Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey,
                                                   StringRef UrlPath) {

>From 0045111a4ea172c543dd10d72f4615791ba9cd61 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Tue, 23 Jan 2024 10:02:50 -0800
Subject: [PATCH 10/12] Cleaned up comment in the SymLocator cmake file

---
 lldb/source/Plugins/SymbolLocator/CMakeLists.txt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/SymbolLocator/CMakeLists.txt b/lldb/source/Plugins/SymbolLocator/CMakeLists.txt
index f536760d8feb0e8..3367022639ab85f 100644
--- a/lldb/source/Plugins/SymbolLocator/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolLocator/CMakeLists.txt
@@ -1,8 +1,8 @@
-# Order matters here, as the first symbol locator will prevent further
-# searching. For DWARF binaries that are both stripped & split, the Default
-# plugin will return the stripped binary when asked for the ObjectFile,
-# preventing an unstripped binary from being requested from the Debuginfod
-# provider
+# 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")

>From e74b2a2cc14b5ee86299a113a1cdffb30493f5c3 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Tue, 23 Jan 2024 13:00:57 -0800
Subject: [PATCH 11/12] Updated tests for smaller main.c

---
 .../Shell/Debuginfod/Inputs/bin-normal.yaml   | 10 +--
 .../Debuginfod/Inputs/bin-split-dwp.yaml      |  4 +-
 .../Debuginfod/Inputs/bin-split-stripped.yaml |  4 +-
 .../Shell/Debuginfod/Inputs/bin-split.yaml    |  6 +-
 .../Shell/Debuginfod/Inputs/bin-stripped.yaml |  4 +-
 lldb/test/Shell/Debuginfod/Inputs/main.c      | 72 +------------------
 lldb/test/Shell/Debuginfod/Inputs/make-inputs |  2 +-
 .../Shell/Debuginfod/Inputs/sym-split.yaml    |  6 +-
 .../Shell/Debuginfod/Inputs/sym-stripped.yaml | 10 +--
 .../Shell/Debuginfod/okdstrip-no-locator.test |  2 +-
 .../Shell/Debuginfod/okdstrip-positive-a.test |  6 +-
 .../Shell/Debuginfod/okdstrip-positive-b.test |  6 +-
 .../Debuginfod/split-okdstrip-positive.test   |  8 +--
 .../test/Shell/Debuginfod/split-positive.test |  6 +-
 .../Debuginfod/split-strip-positive.test      |  8 +--
 .../Shell/Debuginfod/strip-no-locator.test    |  2 +-
 .../Shell/Debuginfod/strip-positive-a.test    |  6 +-
 .../Shell/Debuginfod/strip-positive-b.test    |  6 +-
 llvm/lib/Debuginfod/Debuginfod.cpp            | 41 ++---------
 19 files changed, 58 insertions(+), 151 deletions(-)

diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml
index 1e8b8ffeee25e09..ed3fd4d949ea6c9 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-normal.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            725D47B7EE964F615C841A04712D6F43175F9D8D
+        Desc:            6E10CF17A4D84D5622C67A2FD38282BF121C67D5
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,11 +94,11 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000004C02A1000339000000043D0000000100050306010604080707012800000001560500447E0000000802917C0800447E00000008029170090044820000000009023400000001560700480A02770809004C9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000
+    Content:         9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000000B02A1000339000000043D0000000100050306010604080707012800000001560500037E0000000802917C0800037E00000008029170090003820000000009023400000001560700070A02770809000B9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000
   - Name:            .debug_abbrev
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -106,7 +106,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
@@ -191,7 +191,7 @@ Symbols:
     Value:           0x404000
 DWARF:
   debug_str:
-    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git f2b81cb569d0632a0eb0fd51722d725ab191af72)'
+    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git c240e4904407d0d937863fe30c2ebe77dc693225)'
     - main.c
     - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs'
     - char
diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml
index 1f18c04a4415add..b3bbff01a3689f1 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split-dwp.yaml
@@ -21,7 +21,7 @@ Sections:
     Flags:           [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         63686172005F5F41525241595F53495A455F545950455F5F0066756E6300696E74005F7374617274006172676300617267760046616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E676974206632623831636235363964303633326130656230666435313732326437323561623139316166373229006D61696E2E630067656E2F62696E2D73706C69742E64776F00
+    Content:         63686172005F5F41525241595F53495A455F545950455F5F0066756E6300696E74005F7374617274006172676300617267760046616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E676974206332343065343930343430376430643933373836336665333063326562653737646336393332323529006D61696E2E630067656E2F62696E2D73706C69742E64776F00
   - Name:            .debug_str_offsets.dwo
     Type:            SHT_PROGBITS
     Flags:           [ SHF_EXCLUDE ]
@@ -31,7 +31,7 @@ Sections:
     Type:            SHT_PROGBITS
     Flags:           [ SHF_EXCLUDE ]
     AddressAlign:    0x1
-    Content:         8D00000005000508000000008094E89A08DB62C101071D0008090224000000004C02A10003300000000434000000010005000601060108070701280000000156020044710000000802917C05004471000000080291700600447500000000090001560400480A02770806004C8400000000050305040B7A0000000B7F0000000C30000000037A0000000434000000010000
+    Content:         8D00000005000508000000008094E89A08DB62C101071D0008090224000000000B02A10003300000000434000000010005000601060108070701280000000156020003710000000802917C05000371000000080291700600037500000000090001560400070A02770806000B8400000000050305040B7A0000000B7F0000000C30000000037A0000000434000000010000
   - Name:            .debug_cu_index
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml
index 6501cda4a4f7e69..7c0c95d4d7bacea 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split-stripped.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            82B2C35129DAB19AD58F3DD0F426BDB0CC8AA094
+        Desc:            14FE1776C0055EA25EFD58D934BB305FBBACDAC3
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,7 +94,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900
 Symbols:
   - Name:            .note.gnu.build-id
     Type:            STT_SECTION
diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml
index b99d0ede47c21db..e3679b3ca5b635d 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-split.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            82B2C35129DAB19AD58F3DD0F426BDB0CC8AA094
+        Desc:            14FE1776C0055EA25EFD58D934BB305FBBACDAC3
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,7 +94,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -106,7 +106,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
diff --git a/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml
index 6c8045e9a2068b4..f81ce51e4de1bf8 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/bin-stripped.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            725D47B7EE964F615C841A04712D6F43175F9D8D
+        Desc:            6E10CF17A4D84D5622C67A2FD38282BF121C67D5
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_PROGBITS
@@ -94,7 +94,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900
 Symbols:
   - Name:            .note.gnu.build-id
     Type:            STT_SECTION
diff --git a/lldb/test/Shell/Debuginfod/Inputs/main.c b/lldb/test/Shell/Debuginfod/Inputs/main.c
index 661e5771fcbeeb7..6f2106034f45ab9 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/main.c
+++ b/lldb/test/Shell/Debuginfod/Inputs/main.c
@@ -1,73 +1,7 @@
-/*
+// 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
 
-script to (re)create the .yaml files:
----------------------------------------------------------------------------
-#!/bin/sh
-
-# I need 4 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
-
-# Note: gnu-debuglink has to be added from the yaml2obj output,
-# as the CRC's are slightly different from the original binary
-
-mkdir -p gen
-mkdir -p run
-
-# First, compile & link the binary itself
-${builddir}/bin/clang -g -o gen/main-full.o -O0 -c main.c
-ld -nostdlib gen/main-full.o --build-id=sha1 -o gen/main-full
-${builddir}/bin/clang -g -gsplit-dwarf -o gen/main-split.o -O0 -c main.c
-ld -nostdlib gen/main-split.o --build-id=sha1 -o gen/main-split
-${builddir}/bin/llvm-dwp -e gen/main-split -o gen/main-split.dwp
-
-# Scenario 1: main-strip -> main-full (both executable and debuginfo)
-${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-stripped
-${builddir}/bin/obj2yaml gen/main-full > main-full.yaml
-${builddir}/bin/obj2yaml gen/main-stripped > main-stripped.yaml
-${builddir}/bin/yaml2obj main-full.yaml > run/main-full
-${builddir}/bin/yaml2obj main-stripped.yaml > run/main-stripped
-
-# Scenario 2: main-nodbg -> main-dbg (debuginfo)
-${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-full gen/main-dbg
-${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-nodbg
-${builddir}/bin/obj2yaml gen/main-nodbg > main-nodbg.yaml
-${builddir}/bin/obj2yaml gen/main-dbg > main-dbg.yaml
-${builddir}/bin/yaml2obj main-nodbg.yaml > gen/main-nodbg.tmp
-${builddir}/bin/yaml2obj main-dbg.yaml > run/main-dbg
-${builddir}/bin/llvm-objcopy gen/main-nodbg.tmp --add-gnu-debuglink=run/main-dbg run/main-nodbg
-
-# Scenario 3: main-split, main-split.dwp (debuginfo)
-${builddir}/bin/obj2yaml gen/main-split > main-split.yaml
-${builddir}/bin/obj2yaml gen/main-split.dwp > main-dwp.yaml
-${builddir}/bin/yaml2obj main-split.yaml > run/main-split
-${builddir}/bin/yaml2obj main-dwp.yaml > run/main-split.dwp
-
-# Scenario 4: main-split-nodbg, main-split-dbg (executable), main-split.dwp (debuginfo)
-${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-split gen/main-split-dbg
-${builddir}/bin/llvm-objcopy --strip-debug gen/main-split gen/main-split-nodbg
-${builddir}/bin/obj2yaml gen/main-split-nodbg > main-split-nodbg.yaml
-${builddir}/bin/obj2yaml gen/main-split-dbg > main-split-dbg.yaml
-${builddir}/bin/yaml2obj main-split-nodbg.yaml > gen/main-split-nodbg.tmp
-${builddir}/bin/yaml2obj main-split-dbg.yaml > run/main-split-dbg
-${builddir}/bin/llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg
-# the main-dwp.yaml should be the same for both Scenario 3 and 4
-
-chmod a+x 'run/'*
-
----------------------------------------------------------------------------
-You need to re-generate the gnu-debuglinks after the yaml2obj step (in the test)
-
-You can find the build id's in the yaml files under "NT_PRPSINFO" from the YAML files
-(grep for 'Desc')
-
-*/
-
-int func(int argc, const char **argv) {
-  return (argc + 1) * (argv[argc][0] + 2);
-}
+int func(int argc, const char **argv) { return (argc + 1) * (argv[argc][0] + 2); }
 
 __attribute__((force_align_arg_pointer)) void _start(void) {
 
diff --git a/lldb/test/Shell/Debuginfod/Inputs/make-inputs b/lldb/test/Shell/Debuginfod/Inputs/make-inputs
index b222b5c028a2a2e..c1ec233d10d0b75 100755
--- a/lldb/test/Shell/Debuginfod/Inputs/make-inputs
+++ b/lldb/test/Shell/Debuginfod/Inputs/make-inputs
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# I need 5 different scenarios:
+# 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
diff --git a/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml b/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml
index f25e4c4abf5c24a..9cebffacac7478a 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/sym-split.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            82B2C35129DAB19AD58F3DD0F426BDB0CC8AA094
+        Desc:            14FE1776C0055EA25EFD58D934BB305FBBACDAC3
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_NOBITS
@@ -93,7 +93,7 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -105,7 +105,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
diff --git a/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml b/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml
index 608e9d04b2ebf29..b9118d1a1820a0a 100644
--- a/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml
+++ b/lldb/test/Shell/Debuginfod/Inputs/sym-stripped.yaml
@@ -59,7 +59,7 @@ Sections:
     AddressAlign:    0x4
     Notes:
       - Name:            GNU
-        Desc:            725D47B7EE964F615C841A04712D6F43175F9D8D
+        Desc:            6E10CF17A4D84D5622C67A2FD38282BF121C67D5
         Type:            NT_PRPSINFO
   - Name:            .text
     Type:            SHT_NOBITS
@@ -93,11 +93,11 @@ Sections:
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
     AddressAlign:    0x1
     EntSize:         0x1
-    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420663262383163623536396430363332613065623066643531373232643732356162313931616637322900
+    Content:         46616365626F6F6B20636C616E672076657273696F6E2031352E302E302028676974406769746875622E636F6D3A6B6576696E667265692F6C6C766D2E67697420633234306534393034343037643064393337383633666533306332656265373764633639333232352900
   - Name:            .debug_info
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000004C02A1000339000000043D0000000100050306010604080707012800000001560500447E0000000802917C0800447E00000008029170090044820000000009023400000001560700480A02770809004C9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000
+    Content:         9A000000050001080000000001001D0001080000000000000002016400000008000000022D000000000B02A1000339000000043D0000000100050306010604080707012800000001560500037E0000000802917C0800037E00000008029170090003820000000009023400000001560700070A02770809000B9100000000050605040B870000000B8C0000000C390000000387000000043D000000010000
   - Name:            .debug_abbrev
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
@@ -105,7 +105,7 @@ Sections:
   - Name:            .debug_line
     Type:            SHT_PROGBITS
     AddressAlign:    0x1
-    Content:         7B0000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D00000000AA7BC59AF617547916B47B73E78D55160400000902001040000000000003C30001050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
+    Content:         780000000500080037000000010101FB0E0D00010101010000000100000101011F010000000003011F020F051E013D000000002F0CB321CF64CEDC7E77B5861A0075A20400000902001040000000000014050B0AAD0510063C05183C0526E405153C05030B3C050006A1050F0ABE050BBB0503065806770210000101
   - Name:            .debug_line_str
     Type:            SHT_PROGBITS
     Flags:           [ SHF_MERGE, SHF_STRINGS ]
@@ -190,7 +190,7 @@ Symbols:
     Value:           0x404000
 DWARF:
   debug_str:
-    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git f2b81cb569d0632a0eb0fd51722d725ab191af72)'
+    - 'Facebook clang version 15.0.0 (git at github.com:kevinfrei/llvm.git c240e4904407d0d937863fe30c2ebe77dc693225)'
     - main.c
     - '/home/freik/llvm-sand/llvm/lldb/test/Shell/Debuginfod/Inputs'
     - char
diff --git a/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test b/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
index 943ab100437c6c3..4fd8463744d2cff 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-no-locator.test
@@ -19,4 +19,4 @@
 # RUN:        2>&1 | FileCheck %s
 
 # Should have source file and line information:
-# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
+# 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
index 930a64e85187010..00e1b7c5bc72c2d 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-a.test
@@ -7,12 +7,12 @@
 # Set up a file-system 'hosted' Debuginfod server.
 # RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
+# 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/725d47b7ee964f615c841a04712d6f43175f9d8d/debuginfo
+# 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" \
@@ -25,4 +25,4 @@
 # RUN:        2>&1 | FileCheck %s
 
 # Should have source file and line information:
-# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
+# 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
index 05d9fa1ebbf36e9..c4444ce166811c5 100644
--- a/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
+++ b/lldb/test/Shell/Debuginfod/okdstrip-positive-b.test
@@ -7,12 +7,12 @@
 # Set up a file-system 'hosted' Debuginfod server.
 # RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
+# 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/725d47b7ee964f615c841a04712d6f43175f9d8d/executable
+# 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" \
@@ -25,4 +25,4 @@
 # RUN:        2>&1 | FileCheck %s
 
 # Should have source file and line information:
-# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
+# 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-okdstrip-positive.test b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
index 5f1eb18e21c7c50..0197b0b5e4101d5 100644
--- a/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-okdstrip-positive.test
@@ -7,13 +7,13 @@
 # Set up a file-system 'hosted' Debuginfod server
 # RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
+# 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/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
-# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
+# 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" \
@@ -29,4 +29,4 @@
 # CHECK-NEXT: Type: "dwo"
 # CHECK-NEXT: Dwo ID{{.*}}
 # CHECK-NEXT: {{[- ]+}}
-# CHECK-NEXT: {{0x[0-9a-f]+.* +.*}}.tmp/cache/llvmcache-6559017670391320133{{ *$}}
+# 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
index 445b6b7eef96f6a..3621b3f8d211350 100644
--- a/lldb/test/Shell/Debuginfod/split-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-positive.test
@@ -6,10 +6,10 @@
 # Set up a file-system 'hosted' Debuginfod server
 # RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
+# 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/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
+# 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" \
@@ -27,4 +27,4 @@
 # 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-6559017670391320133{{ *$}}
+# CHECK-NEXT: {{0x[0-9a-f]+.* +}}/{{.*}}.tmp/cache/llvmcache-14969591668314937758{{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/split-strip-positive.test b/lldb/test/Shell/Debuginfod/split-strip-positive.test
index 3c19382d2f6df61..4c6510986913ff4 100644
--- a/lldb/test/Shell/Debuginfod/split-strip-positive.test
+++ b/lldb/test/Shell/Debuginfod/split-strip-positive.test
@@ -7,11 +7,11 @@
 # Set up a file-system 'hosted' Debuginfod server.
 # RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094
+# 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/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/executable
-# RUN: yaml2obj %p/Inputs/bin-split-dwp.yaml -o %t/buildid/82b2c35129dab19ad58f3dd0f426bdb0cc8aa094/debuginfo
+# 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" \
@@ -29,4 +29,4 @@
 # 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-6559017670391320133{{ *$}}
+# CHECK-NEXT: {{0x[0-9a-f]+.* +}}/{{.*}}.tmp/cache/llvmcache-14969591668314937758{{ *$}}
diff --git a/lldb/test/Shell/Debuginfod/strip-no-locator.test b/lldb/test/Shell/Debuginfod/strip-no-locator.test
index ea4bb47648ecbdc..562c8d8e620b41c 100644
--- a/lldb/test/Shell/Debuginfod/strip-no-locator.test
+++ b/lldb/test/Shell/Debuginfod/strip-no-locator.test
@@ -19,4 +19,4 @@
 # RUN:        2>&1 | FileCheck %s
 
 # Should have correct source file and line information:
-# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
+# 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
index e8ca8584c2fbc49..72e3c8801d74952 100644
--- a/lldb/test/Shell/Debuginfod/strip-positive-a.test
+++ b/lldb/test/Shell/Debuginfod/strip-positive-a.test
@@ -7,9 +7,9 @@
 # Set up a file-system 'hosted' Debuginfod server:
 # RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
+# RUN: mkdir -p %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5
 
-# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/debuginfo
+# 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
 
@@ -23,4 +23,4 @@
 # RUN:        2>&1 | FileCheck %s
 
 # Should have source file and line info:
-# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
+# 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
index a7af5bdbdfcf1ea..b3344228bcbb019 100644
--- a/lldb/test/Shell/Debuginfod/strip-positive-b.test
+++ b/lldb/test/Shell/Debuginfod/strip-positive-b.test
@@ -7,9 +7,9 @@
 # Set up a file-system 'hosted' Debuginfod server:
 # RUN: rm -rf %t
 # RUN: mkdir -p %t/cache
-# RUN: mkdir -p %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d
+# RUN: mkdir -p %t/buildid/6e10cf17a4d84d5622c67a2fd38282bf121c67d5
 
-# RUN: yaml2obj %p/Inputs/bin-normal.yaml -o %t/buildid/725d47b7ee964f615c841a04712d6f43175f9d8d/executable
+# 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
 
@@ -23,4 +23,4 @@
 # RUN:        2>&1 | FileCheck %s
 
 # Should have source file and line info:
-# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:69:11, address = 0x{{[0-9a-f]+}}
+# CHECK: Breakpoint 1: where = bin-stripped`func + 11 at main.c:4:11, address = 0x{{[0-9a-f]+}}
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp
index 16368cb5d5c6b6e..4928fcb3b3f8791 100644
--- a/llvm/lib/Debuginfod/Debuginfod.cpp
+++ b/llvm/lib/Debuginfod/Debuginfod.cpp
@@ -248,54 +248,27 @@ static SmallVector<std::string, 0> getHeaders() {
   return Headers;
 }
 
-static SmallString<64> getCachedArtifactPath(StringRef UniqueKey,
-                                             StringRef CacheDirectoryPath) {
+Expected<std::string> getCachedOrDownloadArtifact(
+    StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
+    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
   SmallString<64> AbsCachedArtifactPath;
   sys::path::append(AbsCachedArtifactPath, CacheDirectoryPath,
                     "llvmcache-" + UniqueKey);
-  return AbsCachedArtifactPath;
-}
-
-static Expected<AddStreamFn>
-getCachedArtifactHelper(StringRef UniqueKey, StringRef CacheDirectoryPath,
-                        unsigned &Task) {
-  SmallString<64> AbsCachedArtifactPath =
-      getCachedArtifactPath(UniqueKey, CacheDirectoryPath);
 
   Expected<FileCache> CacheOrErr =
       localCache("Debuginfod-client", ".debuginfod-client", CacheDirectoryPath);
   if (!CacheOrErr)
     return CacheOrErr.takeError();
-  return (*CacheOrErr)(Task, UniqueKey, "");
-}
-
-Expected<std::string> getCachedArtifact(StringRef UniqueKey,
-                                        StringRef CacheDirectoryPath) {
-  // We choose an arbitrary Task parameter as we do not make use of it.
-  unsigned Task = 0;
-  Expected<AddStreamFn> CacheAddStreamOrErr =
-      getCachedArtifactHelper(UniqueKey, CacheDirectoryPath, Task);
-  if (!CacheAddStreamOrErr)
-    return CacheAddStreamOrErr.takeError();
-  if (!*CacheAddStreamOrErr)
-    return std::string(getCachedArtifactPath(UniqueKey, CacheDirectoryPath));
-  return createStringError(errc::argument_out_of_domain,
-                           "build id not found in cache");
-}
 
-Expected<std::string> getCachedOrDownloadArtifact(
-    StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
-    ArrayRef<StringRef> DebuginfodUrls, std::chrono::milliseconds Timeout) {
+  FileCache Cache = *CacheOrErr;
   // We choose an arbitrary Task parameter as we do not make use of it.
   unsigned Task = 0;
-  Expected<AddStreamFn> CacheAddStreamOrErr =
-      getCachedArtifactHelper(UniqueKey, CacheDirectoryPath, Task);
+  Expected<AddStreamFn> CacheAddStreamOrErr = Cache(Task, UniqueKey, "");
   if (!CacheAddStreamOrErr)
     return CacheAddStreamOrErr.takeError();
   AddStreamFn &CacheAddStream = *CacheAddStreamOrErr;
   if (!CacheAddStream)
-    return std::string(getCachedArtifactPath(UniqueKey, CacheDirectoryPath));
-
+    return std::string(AbsCachedArtifactPath);
   // The artifact was not found in the local cache, query the debuginfod
   // servers.
   if (!HTTPClient::isAvailable())
@@ -338,7 +311,7 @@ Expected<std::string> getCachedOrDownloadArtifact(
     pruneCache(CacheDirectoryPath, *PruningPolicyOrErr);
 
     // Return the path to the artifact on disk.
-    return std::string(getCachedArtifactPath(UniqueKey, CacheDirectoryPath));
+    return std::string(AbsCachedArtifactPath);
   }
 
   return createStringError(errc::argument_out_of_domain, "build id not found");

>From 7b3dac4d507d9ef8294a141a3309525e43fd5636 Mon Sep 17 00:00:00 2001
From: Kevin Frei <freik at meta.com>
Date: Fri, 26 Jan 2024 09:37:37 -0800
Subject: [PATCH 12/12] Changed to consistent voice in testing markdown doc

---
 .../Shell/Debuginfod/Debuginfod-testing.md    | 27 +++++++++----------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/lldb/test/Shell/Debuginfod/Debuginfod-testing.md b/lldb/test/Shell/Debuginfod/Debuginfod-testing.md
index df335ca11ffa42e..116bcc5c0ed7a02 100644
--- a/lldb/test/Shell/Debuginfod/Debuginfod-testing.md
+++ b/lldb/test/Shell/Debuginfod/Debuginfod-testing.md
@@ -48,18 +48,17 @@ 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, I prefer requesting `debuginfo`
-first, then falling back to `executable` (Scenarios #1 & #2). For Scenario #5,
-I've chosen to expect the stripped (i.e. not full) executable, which contains a
-number of sections necessary to correctly symbolicate will be 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.
+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.
 
-I've also chosen to simply treat the `.dwp` file as `debuginfo` and the
-"only-keep-debug" stripped binary as `executable`. This scenario doesn't appear
-to work at all in GDB. Supporting it how I did seems more straight forward than
-trying to extend the protocol. The protocol _does_ support querying for section
-contents by name for a given build ID, but adding support for that in LLDB
-looks...well beyond my current capability (and LLVM's Debuginfod library doesn't
-support it at this writing, anyway).
+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).



More information about the cfe-commits mailing list