Skip to content

Commit 53a5bea

Browse files
authored
[lldb] Call Target::ClearAllLoadedSections even earlier (#140228)
This reapplies #138892, which was reverted in 5fb9dca due to failures on windows. Windows loads modules from the Process class, and it does that quite early, and it kinda makes sense which is why I'm moving the clearing code even earlier. The original commit message was: Minidump files contain explicit information about load addresses of modules, so it can load them itself. This works on other platforms, but fails on darwin because DynamicLoaderDarwin nukes the loaded module list on initialization (which happens after the core file plugin has done its work). This used to work until #109477, which enabled the dynamic loader plugins for minidump files in order to get them to provide access to TLS. Clearing the load list makes sense, but I think we could do it earlier in the process, so that both Process and DynamicLoader plugins get a chance to load modules. This patch does that by calling the function early in the launch/attach/load core flows. This fixes TestDynamicValue.py:test_from_core_file on darwin.
1 parent bf6d24a commit 53a5bea

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,6 @@ void DynamicLoaderDarwin::PrivateInitialize(Process *process) {
872872
StateAsCString(m_process->GetState()));
873873
Clear(true);
874874
m_process = process;
875-
m_process->GetTarget().ClearAllLoadedSections();
876875
}
877876

878877
// Member function that gets called when the process state changes.

lldb/source/Target/Process.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,6 +2675,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
26752675
m_jit_loaders_up.reset();
26762676
m_system_runtime_up.reset();
26772677
m_os_up.reset();
2678+
GetTarget().ClearAllLoadedSections();
26782679

26792680
{
26802681
std::lock_guard<std::mutex> guard(m_process_input_reader_mutex);
@@ -2799,6 +2800,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
27992800
}
28002801

28012802
Status Process::LoadCore() {
2803+
GetTarget().ClearAllLoadedSections();
28022804
Status error = DoLoadCore();
28032805
if (error.Success()) {
28042806
ListenerSP listener_sp(
@@ -2984,6 +2986,7 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
29842986
m_jit_loaders_up.reset();
29852987
m_system_runtime_up.reset();
29862988
m_os_up.reset();
2989+
GetTarget().ClearAllLoadedSections();
29872990

29882991
lldb::pid_t attach_pid = attach_info.GetProcessID();
29892992
Status error;

lldb/test/API/lang/cpp/dynamic-value/TestDynamicValue.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ def test_from_forward_decl(self):
282282

283283
@no_debug_info_test
284284
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24663")
285-
@expectedFailureDarwin # dynamic loader unloads modules
286285
@expectedFailureAll(archs=["arm"]) # Minidump saving not implemented
287286
def test_from_core_file(self):
288287
"""Test fetching C++ dynamic values from core files. Specifically, test

0 commit comments

Comments
 (0)