Index: lldb/include/lldb/API/SBProcess.h =================================================================== --- lldb/include/lldb/API/SBProcess.h +++ lldb/include/lldb/API/SBProcess.h @@ -187,6 +187,14 @@ /// The stop event corresponding to stop ID. lldb::SBEvent GetStopEventForStopID(uint32_t stop_id); + /// If the process is a scripted process, changes its private state. + /// No-op otherwise. + /// + /// \param [in] new_state + /// The new private state that the scripted process should be set to. + /// + void ForceScriptedState(StateType new_state); + size_t ReadMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error); size_t WriteMemory(addr_t addr, const void *buf, size_t size, Index: lldb/include/lldb/Target/Process.h =================================================================== --- lldb/include/lldb/Target/Process.h +++ lldb/include/lldb/Target/Process.h @@ -2544,6 +2544,8 @@ virtual void *GetImplementation() { return nullptr; } + virtual void ForceScriptedState(lldb::StateType state) {} + protected: friend class Trace; Index: lldb/source/API/SBProcess.cpp =================================================================== --- lldb/source/API/SBProcess.cpp +++ lldb/source/API/SBProcess.cpp @@ -466,6 +466,16 @@ return sb_event; } +void SBProcess::ForceScriptedState(StateType new_state) { + LLDB_INSTRUMENT_VA(this, new_state); + + if (ProcessSP process_sp = GetSP()) { + std::lock_guard guard( + process_sp->GetTarget().GetAPIMutex()); + process_sp->ForceScriptedState(new_state); + } +} + StateType SBProcess::GetState() { LLDB_INSTRUMENT_VA(this); Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h =================================================================== --- lldb/source/Plugins/Process/scripted/ScriptedProcess.h +++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h @@ -88,6 +88,10 @@ void *GetImplementation() override; + void ForceScriptedState(lldb::StateType state) override { + SetPrivateState(state); + } + protected: ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const ScriptedMetadata &scripted_metadata, Status &error);