diff options
| author | Jim Ingham <jingham@apple.com> | 2023-02-28 17:14:46 -0800 |
|---|---|---|
| committer | Jim Ingham <jingham@apple.com> | 2023-02-28 17:34:49 -0800 |
| commit | a92f7832f35c6c4792d8693e724c19802da75b36 (patch) | |
| tree | 5f5923b4d91e2be659aa6bf4ca739947dd6618ab /lldb/source/API/SBTarget.cpp | |
| parent | 740e2e908ca49118a6e1f27e380dbb3665a99cc8 (diff) | |
Fix the run locker setting for async launches that don't stop at the
initial stop. The code was using PrivateResume when it should have
used Resume.
This was allowing expression evaluation while the target was running,
and though that was caught a litle later on, we should never have gotten
that far. To make sure that this is caught immediately I made an error
SBValue when this happens, and test that we get this error.
Differential Revision: https://reviews.llvm.org/D144665
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
| -rw-r--r-- | lldb/source/API/SBTarget.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index cadaeb472e28..6e5942904db7 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -2219,12 +2219,25 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); ExecutionContext exe_ctx(m_opaque_sp.get()); - frame = exe_ctx.GetFramePtr(); Target *target = exe_ctx.GetTargetPtr(); + Process *process = exe_ctx.GetProcessPtr(); if (target) { - target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); + // If we have a process, make sure to lock the runlock: + if (process) { + Process::StopLocker stop_locker; + if (stop_locker.TryLock(&process->GetRunLock())) { + target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); + } else { + Status error; + error.SetErrorString("can't evaluate expressions when the " + "process is running."); + expr_value_sp = ValueObjectConstResult::Create(nullptr, error); + } + } else { + target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); + } expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); } |
