Skip to content

[lldb][DynamicLoader] Fix lldb unable to stop at _dl_debug_state if user set it before the process launched. #88792

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
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,17 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() {
FileSpec file(info.GetName().GetCString());
ModuleSpec module_spec(file, target.GetArchitecture());

if (ModuleSP module_sp = target.GetOrCreateModule(module_spec,
true /* notify */)) {
// Don't notify that module is added here because its loading section
// addresses are not updated yet. We manually notify it below.
if (ModuleSP module_sp =
target.GetOrCreateModule(module_spec, /*notify=*/false)) {
UpdateLoadedSections(module_sp, LLDB_INVALID_ADDRESS, m_interpreter_base,
false);
// Manually notify that dynamic linker is loaded after updating load section
// addersses so that breakpoints can be resolved.
ModuleList module_list;
module_list.Append(module_sp);
target.ModulesDidLoad(module_list);
m_interpreter_module = module_sp;
return module_sp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,20 @@ def test_breakpoint_statistics_hitcount(self):
self.assertNotEqual(breakpoints_stats, None)
for breakpoint_stats in breakpoints_stats:
self.assertIn("hitCount", breakpoint_stats)

@skipIf(oslist=no_match(["linux"]))
def test_break_at__dl_debug_state(self):
"""
Test lldb is able to stop at _dl_debug_state if it is set before the
process is launched.
"""
self.build()
exe = self.getBuildArtifact("a.out")
self.runCmd("target create %s" % exe)
bpid = lldbutil.run_break_set_by_symbol(
self, "_dl_debug_state", num_expected_locations=0
)
self.runCmd("run")
self.assertIsNotNone(
lldbutil.get_one_thread_stopped_at_breakpoint_id(self.process(), bpid)
)