[Lldb-commits] [lldb] [lldb][split-dwarf] implement GetSeparateDebugInfo for SymbolFileOnDemand (PR #71230)

Tom Yang via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 3 13:54:27 PDT 2023


https://github.com/zhyty created https://github.com/llvm/llvm-project/pull/71230

Easy change to get `image dump separate-debug-info` working when using `symbols.load-on-demand`. Also added a line of space in the default table output.

Added tests
```
bin/lldb-dotest -p TestDumpDwo
```

It's easy to verify this manually by running 
```
lldb --one-line-before-file "settings set symbols.load-on-demand true" <some_target>
(lldb) image dump separate-debug-info
...
```

>From c009fadeaea30de58df22564cca685938a0746f9 Mon Sep 17 00:00:00 2001
From: Tom Yang <toyang at fb.com>
Date: Fri, 3 Nov 2023 13:45:37 -0700
Subject: [PATCH] [lldb][split-dwarf] implement GetSeparateDebugInfo for
 SymbolFileOnDemand

---
 lldb/include/lldb/Symbol/SymbolFileOnDemand.h |  5 ++++
 lldb/source/Commands/CommandObjectTarget.cpp  |  1 +
 .../dwo/TestDumpDwo.py                        | 26 +++++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
index adf1017ce73c11b..9cbcef2a111d320 100644
--- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -228,6 +228,11 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
     return m_sym_file_impl->SetDebugInfoHadFrameVariableErrors();
   }
 
+  bool GetSeparateDebugInfo(StructuredData::Dictionary &d,
+                            bool errors_only) override {
+    return m_sym_file_impl->GetSeparateDebugInfo(d, errors_only);
+  }
+
   lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name,
                         std::optional<uint64_t> byte_size,
                         SymbolContextScope *context,
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index ca8484cc79d4054..323b821f7ca6455 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -2691,6 +2691,7 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
                     "Found unsupported debug info type '%s'.\n",
                     type.str().c_str());
               }
+              strm.EOL();
               return true;
             });
       }
diff --git a/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py b/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py
index 163f5a112367693..881ee7b1dc71adf 100644
--- a/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py
+++ b/lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py
@@ -130,3 +130,29 @@ def test_dwos_not_loaded_table_output(self):
                 "0x[a-zA-Z0-9]{16}\s+E\s+.*foo\.dwo",
             ],
         )
+
+    @skipIfRemote
+    @skipIfDarwin
+    @skipIfWindows
+    def test_dwos_loaded_symbols_on_demand(self):
+        self.build()
+        exe = self.getBuildArtifact("a.out")
+        main_dwo = self.getBuildArtifact("main.dwo")
+        foo_dwo = self.getBuildArtifact("foo.dwo")
+
+        # Make sure dwo files exist
+        self.assertTrue(os.path.exists(main_dwo), f'Make sure "{main_dwo}" file exists')
+        self.assertTrue(os.path.exists(foo_dwo), f'Make sure "{foo_dwo}" file exists')
+
+        # Load symbols on-demand
+        self.runCmd("settings set symbols.load-on-demand true")
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, lldbtest.VALID_TARGET)
+
+        self.runCmd("target modules dump separate-debug-info --json")
+
+        # Check the output
+        output = self.get_dwos_from_json_output()
+        self.assertTrue(output[exe]["main.dwo"]["loaded"])
+        self.assertTrue(output[exe]["foo.dwo"]["loaded"])



More information about the lldb-commits mailing list