Skip to content

Commit 97aa01b

Browse files
authored
[lldb] Call Target::ClearAllLoadedSections earlier (llvm#138892)
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 llvm#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 6b97a98 commit 97aa01b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

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

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

+4
Original file line numberDiff line numberDiff line change
@@ -2763,6 +2763,7 @@ Status Process::LaunchPrivate(ProcessLaunchInfo &launch_info, StateType &state,
27632763
}
27642764

27652765
if (state == eStateStopped || state == eStateCrashed) {
2766+
GetTarget().ClearAllLoadedSections();
27662767
DidLaunch();
27672768

27682769
// Now that we know the process type, update its signal responses from the
@@ -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(
@@ -3094,6 +3096,8 @@ void Process::CompleteAttach() {
30943096
Log *log(GetLog(LLDBLog::Process | LLDBLog::Target));
30953097
LLDB_LOGF(log, "Process::%s()", __FUNCTION__);
30963098

3099+
GetTarget().ClearAllLoadedSections();
3100+
30973101
// Let the process subclass figure out at much as it can about the process
30983102
// before we go looking for a dynamic loader plug-in.
30993103
ArchSpec process_arch;

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

-1
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)