Fix not user code stack and scopes related work.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Tue, 7 Dec 2021 14:21:58 +0000 (06:21 -0800)
committerAlexander Soldatov/Platform Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Fri, 10 Dec 2021 13:57:59 +0000 (16:57 +0300)
Fix thread ID related logic in stop event at debuggee process pause.
Fix arguments and local scope variables evaluation logic in not user code.
Fix static members and methods evaluation in not user code.

src/debugger/evaluator.cpp
src/debugger/managedcallback.cpp
src/protocols/vscodeprotocol.cpp

index e9698bb3e014bbb9078c5bc977bba955728eab80..f416e7dc0dd184d09cc68fb1253e7693d4e575ad 100644 (file)
@@ -1323,6 +1323,14 @@ HRESULT Evaluator::WalkStackVars(ICorDebugThread *pThread, FrameLevel frameLevel
     if (pFrame == nullptr)
         return E_FAIL;
 
+    ULONG32 currentIlOffset;
+    Modules::SequencePoint sp;
+    // GetFrameILAndSequencePoint() return "success" code only in case it found sequence point
+    // for current IP, that mean we stop inside user code.
+    // Note, we could have request for not user code, we ignore it and this is OK.
+    if (FAILED(m_sharedModules->GetFrameILAndSequencePoint(pFrame, currentIlOffset, sp)))
+        return S_OK;
+
     ToRelease<ICorDebugFunction> pFunction;
     IfFailRet(pFrame->GetFunction(&pFunction));
 
@@ -1340,10 +1348,6 @@ HRESULT Evaluator::WalkStackVars(ICorDebugThread *pThread, FrameLevel frameLevel
     ToRelease<ICorDebugILFrame> pILFrame;
     IfFailRet(pFrame->QueryInterface(IID_ICorDebugILFrame, (LPVOID*) &pILFrame));
 
-    ULONG32 currentIlOffset;
-    CorDebugMappingResult mappingResult;
-    IfFailRet(pILFrame->GetIP(&currentIlOffset, &mappingResult));
-
     ToRelease<ICorDebugValueEnum> pLocalsEnum;
     IfFailRet(pILFrame->EnumerateLocalVariables(&pLocalsEnum));
 
index f029a32ad64bd69d4e039f18b830b7e57307a5f5..d24e7d44d1ef6bc72fe55d4a0fc27633d390785a 100644 (file)
@@ -346,7 +346,10 @@ HRESULT ManagedCallback::Pause(ICorDebugProcess *pProcess)
         }
     }
 
-    m_debugger.m_sharedProtocol->EmitStoppedEvent(StoppedEvent(StopPause, ThreadId::Invalid));
+    assert(threads.size() > 0);
+    // Event must provide thread (VSCode and MI/GDB protocols count on this), even if this thread don't have user code.
+    // Note, provide thread without user code also legit for this event.
+    m_debugger.m_sharedProtocol->EmitStoppedEvent(StoppedEvent(StopPause, threads[0].id));
     m_debugger.m_ioredirect.async_cancel();
     return S_OK;
 }
index 692978d947a1d71f48c658309accb0719ae36d05..ede0b35af678c433735daba7b9c6fc4c9ec76f6a 100644 (file)
@@ -614,6 +614,7 @@ HRESULT VSCodeProtocol::HandleCommand(const std::string &command, const json &ar
         return m_sharedDebugger->Continue(threadId);
     } },
     { "pause", [this](const json &arguments, json &body){
+        // Ignore `threadId` argument, since only pause for all threads are supported now.
         return m_sharedDebugger->Pause();
     } },
     { "next", [this](const json &arguments, json &body){