-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb/Target] Delay image loading after corefile process creation #70351
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2639,19 +2639,6 @@ 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); | ||
|
@@ -2668,7 +2655,23 @@ Status Process::LoadCore() { | |
StateAsCString(state)); | ||
error.SetErrorString( | ||
"Did not get stopped event after loading the core file."); | ||
} else { | ||
DidLoadCore(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Call |
||
|
||
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; | ||
|
5 changes: 5 additions & 0 deletions
5
lldb/test/API/functionalities/script-resource-loading/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CXX_SOURCES := main.cpp | ||
|
||
override ARCH := $(shell uname -m) | ||
|
||
include Makefile.rules |
63 changes: 63 additions & 0 deletions
63
lldb/test/API/functionalities/script-resource-loading/TestScriptResourceLoading.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
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") |
5 changes: 5 additions & 0 deletions
5
lldb/test/API/functionalities/script-resource-loading/main.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
int foo() { | ||
return 42; // break | ||
} | ||
|
||
int main() { return foo(); } |
15 changes: 15 additions & 0 deletions
15
lldb/test/API/functionalities/script-resource-loading/my_scripting_resource.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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" | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.