[lldb] Move ScriptedProcess private state update to implementation
While debugging a Scripted Process, in order to update its state and work nicely with lldb's execution model, it needs to toggle its private state from running to stopped, which will result in broadcasting a process state changed event to the debugger listener. Originally, this state update was done systematically in the Scripted Process C++ plugin, however in order to make scripted process interactive, we need to be able to update their state dynamically. This patch makes use of the recent addition of the SBProcess::ForceScriptedState to programatically, and moves the process private state update to the python implementation of the resume method instead of doing it in ScriptedProcess::DoResume. This patch also removes the unused ShouldStop & Stop scripted process APIs, and adds new ScriptedInterface transform methods for boolean arguments. This allow the user to programmatically decide if after running the process, we should stop it (which is the default setting). Differential Revision: https://reviews.llvm.org/D145295 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
@@ -150,22 +150,15 @@ Status ScriptedProcess::DoLoadCore() {
|
||||
|
||||
Status ScriptedProcess::DoLaunch(Module *exe_module,
|
||||
ProcessLaunchInfo &launch_info) {
|
||||
/* FIXME: This doesn't reflect how lldb actually launches a process.
|
||||
In reality, it attaches to debugserver, then resume the process. */
|
||||
LLDB_LOGF(GetLog(LLDBLog::Process), "ScriptedProcess::%s launching process", __FUNCTION__);
|
||||
|
||||
/* MARK: This doesn't reflect how lldb actually launches a process.
|
||||
In reality, it attaches to debugserver, then resume the process.
|
||||
That's not true in all cases. If debugserver is remote, lldb
|
||||
asks debugserver to launch the process for it. */
|
||||
Status error = GetInterface().Launch();
|
||||
SetPrivateState(eStateRunning);
|
||||
|
||||
if (error.Fail())
|
||||
return error;
|
||||
|
||||
// TODO: Fetch next state from stopped event queue then send stop event
|
||||
// const StateType state = SetThreadStopInfo(response);
|
||||
// if (state != eStateInvalid) {
|
||||
// SetPrivateState(state);
|
||||
|
||||
SetPrivateState(eStateStopped);
|
||||
|
||||
return {};
|
||||
return error;
|
||||
}
|
||||
|
||||
void ScriptedProcess::DidLaunch() { m_pid = GetInterface().GetProcessID(); }
|
||||
@@ -177,25 +170,9 @@ void ScriptedProcess::DidResume() {
|
||||
}
|
||||
|
||||
Status ScriptedProcess::DoResume() {
|
||||
Log *log = GetLog(LLDBLog::Process);
|
||||
// FIXME: Fetch data from thread.
|
||||
const StateType thread_resume_state = eStateRunning;
|
||||
LLDB_LOGF(log, "ScriptedProcess::%s thread_resume_state = %s", __FUNCTION__,
|
||||
StateAsCString(thread_resume_state));
|
||||
LLDB_LOGF(GetLog(LLDBLog::Process), "ScriptedProcess::%s resuming process", __FUNCTION__);
|
||||
|
||||
bool resume = (thread_resume_state == eStateRunning);
|
||||
assert(thread_resume_state == eStateRunning && "invalid thread resume state");
|
||||
|
||||
Status error;
|
||||
if (resume) {
|
||||
LLDB_LOGF(log, "ScriptedProcess::%s sending resume", __FUNCTION__);
|
||||
|
||||
SetPrivateState(eStateRunning);
|
||||
SetPrivateState(eStateStopped);
|
||||
error = GetInterface().Resume();
|
||||
}
|
||||
|
||||
return error;
|
||||
return GetInterface().Resume();
|
||||
}
|
||||
|
||||
Status ScriptedProcess::DoAttach(const ProcessAttachInfo &attach_info) {
|
||||
@@ -226,19 +203,6 @@ void ScriptedProcess::DidAttach(ArchSpec &process_arch) {
|
||||
process_arch = GetArchitecture();
|
||||
}
|
||||
|
||||
Status ScriptedProcess::DoStop() {
|
||||
Log *log = GetLog(LLDBLog::Process);
|
||||
|
||||
if (GetInterface().ShouldStop()) {
|
||||
SetPrivateState(eStateStopped);
|
||||
LLDB_LOGF(log, "ScriptedProcess::%s Immediate stop", __FUNCTION__);
|
||||
return {};
|
||||
}
|
||||
|
||||
LLDB_LOGF(log, "ScriptedProcess::%s Delayed stop", __FUNCTION__);
|
||||
return GetInterface().Stop();
|
||||
}
|
||||
|
||||
Status ScriptedProcess::DoDestroy() { return Status(); }
|
||||
|
||||
bool ScriptedProcess::IsAlive() { return GetInterface().IsAlive(); }
|
||||
|
||||
Reference in New Issue
Block a user