[Lldb-commits] [lldb] 455098d - Revert "[lldb/Target] Delay image loading after corefile process creation (#70351)"
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 31 20:35:46 PDT 2023
Author: Med Ismail Bennani
Date: 2023-10-31T20:35:25-07:00
New Revision: 455098d8073483e0fa40557100cfb717ea466818
URL: https://github.com/llvm/llvm-project/commit/455098d8073483e0fa40557100cfb717ea466818
DIFF: https://github.com/llvm/llvm-project/commit/455098d8073483e0fa40557100cfb717ea466818.diff
LOG: Revert "[lldb/Target] Delay image loading after corefile process creation (#70351)"
This reverts commit 3c727a959d1c479ef284471701faa0e8ac6f427e because it
introduced some test failures:
https://lab.llvm.org/buildbot/#/builders/68/builds/62638
```
********************
Failed Tests (5):
lldb-api :: functionalities/postmortem/elf-core/TestLinuxCore.py
lldb-api :: functionalities/postmortem/mach-core/TestMachCore.py
lldb-api :: functionalities/postmortem/netbsd-core/TestNetBSDCore.py
lldb-api :: functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
lldb-api :: tools/lldb-dap/coreFile/TestDAP_coreFile.py
```
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
Added:
Modified:
lldb/include/lldb/Target/Process.h
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/source/Target/Process.cpp
Removed:
lldb/test/API/functionalities/script-resource-loading/Makefile
lldb/test/API/functionalities/script-resource-loading/TestScriptResourceLoading.py
lldb/test/API/functionalities/script-resource-loading/main.cpp
lldb/test/API/functionalities/script-resource-loading/my_scripting_resource.py
################################################################################
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index e25e82302a56dd9..a6d3e6c2d16926e 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -614,8 +614,6 @@ class Process : public std::enable_shared_from_this<Process>,
return error;
}
- virtual void DidLoadCore() {}
-
/// The "ShadowListener" for a process is just an ordinary Listener that
/// listens for all the Process event bits. It's convenient because you can
/// specify it in the LaunchInfo or AttachInfo, so it will get events from
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index 9b10a0b832915d3..b11062a0224abc2 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -570,6 +570,8 @@ Status ProcessMachCore::DoLoadCore() {
CreateMemoryRegions();
+ LoadBinariesAndSetDYLD();
+
CleanupMemoryRegionPermissions();
AddressableBits addressable_bits = core_objfile->GetAddressableBits();
@@ -578,8 +580,6 @@ Status ProcessMachCore::DoLoadCore() {
return error;
}
-void ProcessMachCore::DidLoadCore() { LoadBinariesAndSetDYLD(); }
-
lldb_private::DynamicLoader *ProcessMachCore::GetDynamicLoader() {
if (m_dyld_up.get() == nullptr)
m_dyld_up.reset(DynamicLoader::FindPlugin(this, m_dyld_plugin_name));
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
index 0e61daa625b53cc..c8820209e3f3830 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -46,8 +46,6 @@ class ProcessMachCore : public lldb_private::PostMortemProcess {
// Creating a new process, or attaching to an existing one
lldb_private::Status DoLoadCore() override;
- void DidLoadCore() override;
-
lldb_private::DynamicLoader *GetDynamicLoader() override;
// PluginInterface protocol
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index f4bacf314dd746a..f82ab05362fbee9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -2639,6 +2639,19 @@ Status Process::LoadCore() {
else
StartPrivateStateThread();
+ DynamicLoader *dyld = GetDynamicLoader();
+ if (dyld)
+ dyld->DidAttach();
+
+ GetJITLoaders().DidAttach();
+
+ SystemRuntime *system_runtime = GetSystemRuntime();
+ if (system_runtime)
+ system_runtime->DidAttach();
+
+ if (!m_os_up)
+ LoadOperatingSystemPlugin(false);
+
// We successfully loaded a core file, now pretend we stopped so we can
// show all of the threads in the core file and explore the crashed state.
SetPrivateState(eStateStopped);
@@ -2655,23 +2668,7 @@ Status Process::LoadCore() {
StateAsCString(state));
error.SetErrorString(
"Did not get stopped event after loading the core file.");
- } else {
- DidLoadCore();
-
- DynamicLoader *dyld = GetDynamicLoader();
- if (dyld)
- dyld->DidAttach();
-
- GetJITLoaders().DidAttach();
-
- SystemRuntime *system_runtime = GetSystemRuntime();
- if (system_runtime)
- system_runtime->DidAttach();
-
- if (!m_os_up)
- LoadOperatingSystemPlugin(false);
}
-
RestoreProcessEvents();
}
return error;
diff --git a/lldb/test/API/functionalities/script-resource-loading/Makefile b/lldb/test/API/functionalities/script-resource-loading/Makefile
deleted file mode 100644
index 98d4eb86e95bfc8..000000000000000
--- a/lldb/test/API/functionalities/script-resource-loading/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-CXX_SOURCES := main.cpp
-
-override ARCH := $(shell uname -m)
-
-include Makefile.rules
diff --git a/lldb/test/API/functionalities/script-resource-loading/TestScriptResourceLoading.py b/lldb/test/API/functionalities/script-resource-loading/TestScriptResourceLoading.py
deleted file mode 100644
index 6148ed09e20b005..000000000000000
--- a/lldb/test/API/functionalities/script-resource-loading/TestScriptResourceLoading.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""
-Test loading python scripting resource from corefile
-"""
-
-import os, tempfile
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-from lldbsuite.test import lldbtest
-
-
-class ScriptResourceLoadingTestCase(TestBase):
- NO_DEBUG_INFO_TESTCASE = True
-
- def create_stack_skinny_corefile(self, file):
- self.build()
- target, process, thread, _ = lldbutil.run_to_source_breakpoint(
- self, "// break", lldb.SBFileSpec("main.cpp")
- )
- self.assertTrue(process.IsValid(), "Process is invalid.")
- # FIXME: Use SBAPI to save the process corefile.
- self.runCmd("process save-core -s stack " + file)
- self.assertTrue(os.path.exists(file), "No stack-only corefile found.")
- self.assertTrue(self.dbg.DeleteTarget(target), "Couldn't delete target")
-
- def move_blueprint_to_dsym(self, blueprint_name):
- blueprint_origin_path = os.path.join(self.getSourceDir(), blueprint_name)
- dsym_bundle = self.getBuildArtifact("a.out.dSYM")
- blueprint_destination_path = os.path.join(
- dsym_bundle, "Contents", "Resources", "Python"
- )
- if not os.path.exists(blueprint_destination_path):
- os.mkdir(blueprint_destination_path)
-
- blueprint_destination_path = os.path.join(
- blueprint_destination_path, "a_out.py"
- )
- shutil.copy(blueprint_origin_path, blueprint_destination_path)
-
- @skipUnlessDarwin
- def test_script_resource_loading(self):
- """
- Test that we're able to load the python scripting resource from
- corefile dSYM bundle.
-
- """
- self.build()
-
- self.runCmd("settings set target.load-script-from-symbol-file true")
- self.move_blueprint_to_dsym("my_scripting_resource.py")
-
- corefile_process = None
- with tempfile.NamedTemporaryFile() as file:
- self.create_stack_skinny_corefile(file.name)
- corefile_target = self.dbg.CreateTarget(None)
- corefile_process = corefile_target.LoadCore(
- self.getBuildArtifact(file.name)
- )
- self.assertTrue(corefile_process, PROCESS_IS_VALID)
- self.expect("command script list", substrs=["test_script_resource_loading"])
- self.runCmd("test_script_resource_loading")
diff --git a/lldb/test/API/functionalities/script-resource-loading/main.cpp b/lldb/test/API/functionalities/script-resource-loading/main.cpp
deleted file mode 100644
index fb5f61d8ffcff76..000000000000000
--- a/lldb/test/API/functionalities/script-resource-loading/main.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-int foo() {
- return 42; // break
-}
-
-int main() { return foo(); }
diff --git a/lldb/test/API/functionalities/script-resource-loading/my_scripting_resource.py b/lldb/test/API/functionalities/script-resource-loading/my_scripting_resource.py
deleted file mode 100644
index d48ae5a8b59bd57..000000000000000
--- a/lldb/test/API/functionalities/script-resource-loading/my_scripting_resource.py
+++ /dev/null
@@ -1,15 +0,0 @@
-import sys, lldb
-
-
-def test_script_resource_loading(debugger, command, exe_ctx, result, dict):
- if not exe_ctx.target.process.IsValid():
- result.SetError("invalid process")
- process = exe_ctx.target.process
- if not len(process):
- result.SetError("invalid thread count")
-
-
-def __lldb_init_module(debugger, dict):
- debugger.HandleCommand(
- "command script add -o -f a_out.test_script_resource_loading test_script_resource_loading"
- )
More information about the lldb-commits
mailing list