aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectTarget.cpp
diff options
context:
space:
mode:
authorqxy11 <qxy11@meta.com>2025-07-07 12:01:22 -0700
committerGitHub <noreply@github.com>2025-07-07 12:01:22 -0700
commit7bd06c41a344fd107a3a300c8c20d78cbc34db35 (patch)
tree6a64938521c3eb391d7fc4166d56fabc3d97a5dd /lldb/source/Commands/CommandObjectTarget.cpp
parent6512ca7ddb0a462362aaedb18844e2993c5ae336 (diff)
downloadllvm-7bd06c41a344fd107a3a300c8c20d78cbc34db35.zip
llvm-7bd06c41a344fd107a3a300c8c20d78cbc34db35.tar.gz
llvm-7bd06c41a344fd107a3a300c8c20d78cbc34db35.tar.bz2
Defer loading all DWOs by default when dumping separate_debug-info (#146166)
### Summary Currently `target modules dump separate separate-debug-info` automatically loads up all DWO files, even if deferred loading is enabled through debug_names. Then, as expected all DWO files (assuming there is no error loading it), get marked as "loaded". This change adds the option `--force-load-all-debug-info` or `-f` for short to force loading all debug_info up, if it hasn't been loaded yet. Otherwise, it will change default behavior to not load all debug info so that the correct DWO files will show up for each modules as "loaded" or not "loaded", which could be helpful in cases where we want to know which particular DWO files were loaded. ### Testing #### Unit Tests Added additional unit tests `test_dwos_load_json_with_debug_names_default` and `test_dwos_load_json_with_debug_names_force_load_all` to test both default behavior and loading with the new flag `--force-load-all-debug-info`, and changed expected behavior in `test_dwos_loaded_symbols_on_demand`. ``` bin/lldb-dotest -p TestDumpDwo ~/llvm-project/lldb/test/API/commands/target/dump-separate-debug-info/dwo ``` #### Manual Testing Compiled a simple binary w/ `--gsplit-dwarf --gpubnames` and loaded it up: ``` (lldb) target create "./a.out" Current executable set to '/home/qxy11/hello-world/a.out' (x86_64). (lldb) help target modules dump separate-debug-info List the separate debug info symbol files for one or more target modules. Syntax: target modules dump separate-debug-info <cmd-options> [<filename> [<filename> [...]]] Command Options Usage: target modules dump separate-debug-info [-efj] [<filename> [<filename> [...]]] -e ( --errors-only ) Filter to show only debug info files with errors. -f ( --force-load-all-debug-info ) Load all debug info files. -j ( --json ) Output the details in JSON format. This command takes options and free-form arguments. If your arguments resemble option specifiers (i.e., they start with a - or --), you must use ' -- ' between the end of the command options and the beginning of the arguments. (lldb) target modules dump separate-debug-info --j [ { "separate-debug-info-files": [ { ... "dwo_name": "main.dwo", "loaded": false }, { ... "dwo_name": "foo.dwo", "loaded": false }, { ... "dwo_name": "bar.dwo", "loaded": false } ], } ] (lldb) b main Breakpoint 1: where = a.out`main + 15 at main.cc:3:12, address = 0x00000000000011ff (lldb) target modules dump separate-debug-info --j [ { "separate-debug-info-files": [ { ... "dwo_name": "main.dwo", "loaded": true, "resolved_dwo_path": "/home/qxy11/hello-world/main.dwo" }, { ... "dwo_name": "foo.dwo", "loaded": false }, { ... "dwo_name": "bar.dwo", "loaded": false } ], } ] (lldb) b foo Breakpoint 2: where = a.out`foo(int) + 11 at foo.cc:12:11, address = 0x000000000000121b (lldb) target modules dump separate-debug-info --j [ { "separate-debug-info-files": [ { ... "dwo_name": "main.dwo", "loaded": true, "resolved_dwo_path": "/home/qxy11/hello-world/main.dwo" }, { ... "dwo_name": "foo.dwo", "loaded": true, "resolved_dwo_path": "/home/qxy11/hello-world/foo.dwo" }, { ... "dwo_name": "bar.dwo", "loaded": false } ], } ] (lldb) b bar Breakpoint 3: where = a.out`bar(int) + 11 at bar.cc:10:9, address = 0x000000000000126b (lldb) target modules dump separate-debug-info --j [ { "separate-debug-info-files": [ { ... "dwo_name": "main.dwo", "loaded": true, "resolved_dwo_path": "/home/qxy11/hello-world/main.dwo" }, { ... "dwo_name": "foo.dwo", "loaded": true, "resolved_dwo_path": "/home/qxy11/hello-world/foo.dwo" }, { ... "dwo_name": "bar.dwo", "loaded": true, "resolved_dwo_path": "/home/qxy11/hello-world/bar.dwo" } ], } ] ```
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index fe421ad..dbebbbd 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1412,11 +1412,13 @@ static bool DumpModuleSymbolFile(Stream &strm, Module *module) {
}
static bool GetSeparateDebugInfoList(StructuredData::Array &list,
- Module *module, bool errors_only) {
+ Module *module, bool errors_only,
+ bool load_all_debug_info) {
if (module) {
if (SymbolFile *symbol_file = module->GetSymbolFile(/*can_create=*/true)) {
StructuredData::Dictionary d;
- if (symbol_file->GetSeparateDebugInfo(d, errors_only)) {
+ if (symbol_file->GetSeparateDebugInfo(d, errors_only,
+ load_all_debug_info)) {
list.AddItem(
std::make_shared<StructuredData::Dictionary>(std::move(d)));
return true;
@@ -2522,6 +2524,10 @@ public:
const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
+ case 'f':
+ m_load_all_debug_info.SetCurrentValue(true);
+ m_load_all_debug_info.SetOptionWasSet();
+ break;
case 'j':
m_json.SetCurrentValue(true);
m_json.SetOptionWasSet();
@@ -2539,6 +2545,7 @@ public:
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_json.Clear();
m_errors_only.Clear();
+ m_load_all_debug_info.Clear();
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -2547,6 +2554,7 @@ public:
OptionValueBoolean m_json = false;
OptionValueBoolean m_errors_only = false;
+ OptionValueBoolean m_load_all_debug_info = false;
};
protected:
@@ -2578,7 +2586,8 @@ protected:
if (GetSeparateDebugInfoList(separate_debug_info_lists_by_module,
module_sp.get(),
- bool(m_options.m_errors_only)))
+ bool(m_options.m_errors_only),
+ bool(m_options.m_load_all_debug_info)))
num_dumped++;
}
} else {
@@ -2599,7 +2608,8 @@ protected:
break;
Module *module = module_list.GetModulePointerAtIndex(i);
if (GetSeparateDebugInfoList(separate_debug_info_lists_by_module,
- module, bool(m_options.m_errors_only)))
+ module, bool(m_options.m_errors_only),
+ bool(m_options.m_load_all_debug_info)))
num_dumped++;
}
} else