Fixed threads enumerate command issue
authorAnton Zhukov <a.zhukov@samsung.com>
Wed, 22 Apr 2020 10:41:33 +0000 (06:41 -0400)
committerAlexander Soldatov/AI Compiler Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Thu, 30 Apr 2020 10:44:52 +0000 (13:44 +0300)
VSCode `threads' command failed periodically for multithread apps,
because `GetUserState()' retutns failed code for running Thread.
Any user/debug status is not available for running thread.

Issue: https://github.sec.samsung.net/dotnet/netcoredbg/issues/195

src/debug/netcoredbg/frames.cpp

index caecdf329d082d77da9bf29993b7f77f573e8971..7e29417c436cdf3e8cfcb2ae10e7975b8350593b 100644 (file)
@@ -26,6 +26,7 @@ HRESULT GetThreadsState(ICorDebugController *controller, std::vector<Thread> &th
     ToRelease<ICorDebugThreadEnum> pThreads;
     IfFailRet(controller->EnumerateThreads(&pThreads));
 
+    const std::string threadName = "<No name>";
     ICorDebugThread *handle = nullptr;
     ULONG fetched = 0;
 
@@ -42,18 +43,9 @@ HRESULT GetThreadsState(ICorDebugController *controller, std::vector<Thread> &th
         BOOL running = FALSE;
         IfFailRet(pProcess->IsRunning(&running));
 
-        CorDebugUserState corUserState;
-        IfFailRet(pThread->GetUserState(&corUserState));
-
-        if (!(corUserState & USER_BACKGROUND)) {
-            std::string name = "<No name>";
-            // TODO: Need label for Main Thread. This is bad approach.
-            // Because not garantee the thread sequences.
-            //if (threads.empty()) {
-              //  name = "Main Thread";
-            //}
-            threads.emplace_back(threadId, name, running);
-        }
+        // Baground threads also included. GetUserState() not available for running thread.
+        threads.emplace_back(threadId, threadName, running);
+
         fetched = 0;
         handle = nullptr;
     }