10000 Defer loading all DWOs by default when dumping separate_debug-info by qxy11 · Pull Request #146166 · llvm/llvm-project · GitHub
[go: up one dir, main page]

Skip to content

Defer loading all DWOs by default when dumping separate_debug-info #146166

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 4 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change default to loading all debug info
  • Loading branch information
qxy11 committed Jun 30, 2025
commit c14bf4b5ca976c2034ffc6a2ecdcba7f42b606a4
43 changes: 19 additions & 24 deletions lldb/source/Commands/CommandObjectTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2125,10 +2125,9 @@ class CommandObjectTargetModulesDumpSections
result.GetOutputStream().Format("Dumping sections for {0} modules.\n",
num_modules);
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
if (INTERRUPT_REQUESTED(
GetDebugger(),
"Interrupted in dump all sections with {0} of {1} dumped",
image_idx, num_modules))
if (INTERRUPT_REQUESTED(GetDebugger(),
"Interrupted in dump all sections with {0} of {1} dumped",
image_idx, num_modules))
break;

num_dumped++;
Expand All @@ -2147,10 +2146,9 @@ class CommandObjectTargetModulesDumpSections
FindModulesByName(&target, arg_cstr, module_list, true);
if (num_matches > 0) {
for (size_t i = 0; i < num_matches; ++i) {
if (INTERRUPT_REQUESTED(
GetDebugger(),
"Interrupted in dump section list with {0} of {1} dumped.",
i, num_matches))
if (INTERRUPT_REQUESTED(GetDebugger(),
"Interrupted in dump section list with {0} of {1} dumped.",
i, num_matches))
break;

Module *module = module_list.GetModulePointerAtIndex(i);
Expand Down Expand Up @@ -2301,10 +2299,9 @@ class CommandObjectTargetModulesDumpClangAST
}

for (size_t i = 0; i < num_matches; ++i) {
if (INTERRUPT_REQUESTED(
GetDebugger(),
"Interrupted in dump clang ast list with {0} of {1} dumped.", i,
num_matches))
if (INTERRUPT_REQUESTED(GetDebugger(),
"Interrupted in dump clang ast list with {0} of {1} dumped.",
i, num_matches))
break;

Module *m = module_list.GetModulePointerAtIndex(i);
Expand Down Expand Up @@ -2353,10 +2350,9 @@ class CommandObjectTargetModulesDumpSymfile
result.GetOutputStream().Format(
"Dumping debug symbols for {0} modules.\n", num_modules);
for (ModuleSP module_sp : target_modules.ModulesNoLocking()) {
if (INTERRUPT_REQUESTED(GetDebugger(),
"Interrupted in dumping all "
if (INTERRUPT_REQUESTED(GetDebugger(), "Interrupted in dumping all "
"debug symbols with {0} of {1} modules dumped",
num_dumped, num_modules))
num_dumped, num_modules))
break;

if (DumpModuleSymbolFile(result.GetOutputStream(), module_sp.get()))
Expand All @@ -2373,10 +2369,9 @@ class CommandObjectTargetModulesDumpSymfile
FindModulesByName(&target, arg_cstr, module_list, true);
if (num_matches > 0) {
for (size_t i = 0; i < num_matches; ++i) {
if (INTERRUPT_REQUESTED(GetDebugger(),
"Interrupted dumping {0} "
"of {1} requested modules",
i, num_matches))
if (INTERRUPT_REQUESTED(GetDebugger(), "Interrupted dumping {0} "
"of {1} requested modules",
i, num_matches))
break;
Module *module = module_list.GetModulePointerAtIndex(i);
if (module) {
Expand Down Expand Up @@ -2445,8 +2440,8 @@ class CommandObjectTargetModulesDumpLineTable
for (ModuleSP module_sp : target_modules.ModulesNoLocking()) {
if (INTERRUPT_REQUESTED(GetDebugger(),
"Interrupted in dump all line tables with "
"{0} of {1} dumped",
num_dumped, num_modules))
"{0} of {1} dumped", num_dumped,
num_modules))
break;

if (DumpCompileUnitLineTable(
Expand Down Expand Up @@ -2531,8 +2526,8 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
const int short_option = m_getopt_table[option_idx].val;

switch (short_option) {
case 'd':
m_load_all_debug_info.SetCurrentValue(false);
10000 case 'f':
m_load_all_debug_info.SetCurrentValue(true);
m_load_all_debug_info.SetOptionWasSet();
break;
case 'j':
Expand Down Expand Up @@ -2561,7 +2556,7 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles

OptionValueBoolean m_json = false;
OptionValueBoolean m_errors_only = false;
OptionValueBoolean m_load_all_debug_info = true;
OptionValueBoolean m_load_all_debug_info = false;
};

protected:
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Commands/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let Command = "target modules dump separate debug info" in {
Desc<"Output the details in JSON format.">;
def tm_errors_only : Option<"errors-only", "e">, Group<1>,
Desc<"Filter to show only debug info files with errors.">;
def tm_defer_load_all_debug_info : Option<"defer-load-all-debug-info", "d">,
def tm_force_load_all_debug_info : Option<"force-load-all-debug-info", "f">,
Group<1>,
Desc<"Load all debug info files.">;
}
Expand Down
FB63
Original file line number Diff line number Diff line change
Expand Up @@ -146,44 +146,57 @@ def test_dwos_loaded_symbols_on_demand(self):

# Check the output
output = self.get_dwos_from_json_output()
self.assertFalse(output[exe]["a.out-main.dwo"]["loaded"])
self.assertFalse(output[exe]["a.out-foo.dwo"]["loaded"])
# Set a breakpoint in main(). All DWO files should be loaded now
self.runCmd("b main")
self.runCmd(
"target modules dump separate-debug-info --json --force-load-all-debug-info"
)
output = self.get_dwos_from_json_output()
self.assertTrue(output[exe]["a.out-main.dwo"]["loaded"])
self.assertTrue(output[exe]["a.out-foo.dwo"]["loaded"])

def test_dwos_loaded_symbols_on_demand_defer_load_all(self):
self.build_and_skip_if_error()
def test_dwos_load_json_with_debug_names_default(self):
"""
Test that DWO files are lazily loaded, and target module dump gives the expected output.
"""
# Build with split DWARF, debug_names, and gpubnames
self.build_and_skip_if_error(debug_info=["debug_names"])
exe = self.getBuildArtifact("a.out")

main_dwo = self.getBuildArtifact("a.out-main.dwo")
foo_dwo = self.getBuildArtifact("a.out-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 --defer-load-all-debug-info"
)
self.runCmd("target modules dump separate-debug-info --j")

# Check the output
output = self.get_dwos_from_json_output()
self.assertFalse(output[exe]["a.out-main.dwo"]["loaded"])
self.assertFalse(output[exe]["a.out-foo.dwo"]["loaded"])

# Set a breakpoint in main(). All DWO files should be loaded now
# Set a breakpoint in main(). a.out-main.dwo should be loaded now
self.runCmd("b main")
self.runCmd(
"target modules dump separate-debug-info --json --defer-load-all-debug-info"
)
self.runCmd("target modules dump separate-debug-info --j")
output = self.get_dwos_from_json_output()
self.assertTrue(output[exe]["a.out-main.dwo"]["loaded"])
self.assertFalse(output[exe]["a.out-foo.dwo"]["loaded"])

# Set a breakpoint in foo(). a.out-foo.dwo should be loaded now
self.runCmd("b foo")
self.runCmd("target modules dump separate-debug-info --j")
output = self.get_dwos_from_json_output()
self.assertTrue(output[exe]["a.out-main.dwo"]["loaded"])
self.assertTrue(output[exe]["a.out-foo.dwo"]["loaded"])

def test_dwos_defer_loaded_json_with_debug_names(self):
def test_dwos_load_json_with_debug_names_force_load_all(self):
"""
Test that DWO files are lazily loaded, and target module dump gives the expected output.
"""
Expand All @@ -201,23 +214,8 @@ def test_dwos_defer_loaded_json_with_debug_names(self):
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, lldbtest.VALID_TARGET)

self.runCmd("target modules dump separate-debug-info --j --d")
self.runCmd("target modules dump separate-debug-info --j --f")

# Check the output
output = self.get_dwos_from_json_output()
self.assertFalse(output[exe]["a.out-main.dwo"]["loaded"])
self.assertFalse(output[exe]["a.out-foo.dwo"]["loaded"])

# Set a breakpoint in main(). a.out-main.dwo should be loaded now
self.runCmd("b main")
self.runCmd("target modules dump separate-debug-info --j --d")
output = self.get_dwos_from_json_output()
self.assertTrue(output[exe]["a.out-main.dwo"]["loaded"])
self.assertFalse(output[exe]["a.out-foo.dwo"]["loaded"])

# Set a breakpoint in foo(). a.out-foo.dwo should be loaded now
self.runCmd("b foo")
self.runCmd("target modules dump separate-debug-info --j --d")
output = self.get_dwos_from_json_output()
self.assertTrue(output[exe]["a.out-main.dwo"]["loaded"])
self.assertTrue(output[exe]["a.out-foo.dwo"]["loaded"])
0