Skip to content

Commit

Permalink
Fix eval interop related logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
viewizard authored and gbalykov committed Sep 26, 2023
1 parent 8c5975b commit 3195f4f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/debugger/evalwaiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ HRESULT EvalWaiter::WaitEvalResult(ICorDebugThread *pThread,

#ifdef INTEROP_DEBUGGING
assert(!!m_sharedInteropDebugger);
if (m_sharedInteropDebugger->IsNativeThreadStopped((pid_t)evalThreadId))
if (m_sharedInteropDebugger->IsManagedThreadWasStoppedInNativeCode((pid_t)evalThreadId))
return COR_E_THREADSTATE;
#endif // INTEROP_DEBUGGING

Expand Down
11 changes: 7 additions & 4 deletions src/debugger/interop_debugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1668,18 +1668,21 @@ HRESULT InteropDebugger::GetFrameForAddr(std::uintptr_t addr, StackFrame &frame)
return S_OK;
}

bool InteropDebugger::IsNativeThreadStopped(pid_t pid)
bool InteropDebugger::IsManagedThreadWasStoppedInNativeCode(pid_t pid)
{
std::lock_guard<std::mutex> lock(m_waitpidMutex);

if (m_TIDs.empty())
return S_OK;
return false;

auto tid = m_TIDs.find(pid);
if (tid == m_TIDs.end())
return E_INVALIDARG;
{
LOGE("Requested native thread not found in process, TID: %i\n", pid);
// Note, in this case "not found" mean "not stopped" (same logic as we have for `m_TIDs.empty()`).
return false;
}

assert(tid->second.stat != thread_stat_e::stopped);
return tid->second.stat != thread_stat_e::running;
}

Expand Down
2 changes: 1 addition & 1 deletion src/debugger/interop_debugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class InteropDebugger final : InteropDebuggerHelpers
HRESULT UnwindNativeFrames(pid_t pid, bool firstFrame, std::uintptr_t endAddr, CONTEXT *pStartContext,
std::function<HRESULT(NativeFrame &nativeFrame)> nativeFramesCallback);

bool IsNativeThreadStopped(pid_t pid);
bool IsManagedThreadWasStoppedInNativeCode(pid_t pid);
void WalkAllThreads(std::function<void(pid_t, bool)> cb);
};

Expand Down

0 comments on commit 3195f4f

Please sign in to comment.