Skip to content

[lldb][split-dwarf] implement GetSeparateDebugInfo for SymbolFileOnDemand #71230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 20, 2023

Conversation

zhyty
Copy link
Contributor

@zhyty zhyty commented Nov 3, 2023

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.

Updated the testing in response to comments.

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
...

@zhyty zhyty requested a review from JDevlieghere as a code owner November 3, 2023 20:54
@llvmbot llvmbot added the lldb label Nov 3, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2023

@llvm/pr-subscribers-lldb

Author: Tom Yang (zhyty)

Changes

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" &lt;some_target&gt;
(lldb) image dump separate-debug-info
...

Full diff: https://github.com/llvm/llvm-project/pull/71230.diff

3 Files Affected:

  • (modified) lldb/include/lldb/Symbol/SymbolFileOnDemand.h (+5)
  • (modified) lldb/source/Commands/CommandObjectTarget.cpp (+1)
  • (modified) lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py (+26)
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"])

@GeorgeHuyubo GeorgeHuyubo reopened this Nov 4, 2023
Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

FYI: here is how you might be able to try cross compiling by editing the Makefile and removing the @skipIf*. The compile command for cross compiling looks like:

clang++ -target x86_64-pc-linux-elf -g -gsplit-dwarf -c main.cpp

You will want to try adding a bogus -target x86_64--carp and make sure the test stops or can handle not compiling correctly. This will help you figure out what will happen if -target x86_64-pc-linux-elf doesn't work because ELF or linux support isn't compiled into clang. If you can't gracefully handle this case, then just leave the @skip decorators as is

@zhyty zhyty force-pushed the separate-debug-info-on-demand branch from 14fbf21 to da7cf85 Compare November 19, 2023 23:59
Copy link

github-actions bot commented Nov 20, 2023

✅ With the latest revision this PR passed the Python code formatter.

@zhyty
Copy link
Contributor Author

zhyty commented Nov 20, 2023

@bulbazord @clayborg I updated the DWO tests so that we try to compile for x86_64-pc-linux-elf on all platforms, and if we fail to build the tests are skipped. I've verified that the tests pass on my Linux machine and that they're skipped on my Mac, though it would be nice if I could make sure the build bots will pass.

Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@zhyty zhyty merged commit 69a5869 into llvm:main Nov 20, 2023
@zhyty zhyty deleted the separate-debug-info-on-demand branch November 20, 2023 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants