From 85dc142e3bbb5986139031831d63f9a1900c51ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Mon, 7 Dec 2009 13:34:18 +0000 Subject: [PATCH] Fixed a bug that could cause the debugger to freeze. (ie. all debugee threads suspended) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5303 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/AddIns/Debugger/Debugger.Core/Process.cs | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.Core/Process.cs b/src/AddIns/Debugger/Debugger.Core/Process.cs index 430819d80c..5d2610d8a8 100644 --- a/src/AddIns/Debugger/Debugger.Core/Process.cs +++ b/src/AddIns/Debugger/Debugger.Core/Process.cs @@ -447,19 +447,18 @@ namespace Debugger // It is not corProcess.GetHelperThreadID // ICorDebugThread[] ts = new ICorDebugThread[corProcess.EnumerateThreads().GetCount()]; // corProcess.EnumerateThreads().Next((uint)ts.Length, ts); - try { - foreach(Thread t in this.Threads) { - t.CorThread.SetDebugState(CorDebugThreadState.THREAD_SUSPEND); - } - foreach(Thread t in threadsToRun) { - t.CorThread.SetDebugState(CorDebugThreadState.THREAD_RUN); - } - } catch (COMException e) { - // The state of the thread is invalid. (Exception from HRESULT: 0x8013132D) - // It can happen for threads that have not started yet - if ((uint)e.ErrorCode == 0x8013132D) { - } else { - throw; + foreach(Thread t in this.Threads) { + CorDebugThreadState state = Array.IndexOf(threadsToRun, t) == -1 ? CorDebugThreadState.THREAD_SUSPEND : CorDebugThreadState.THREAD_RUN; + try { + t.CorThread.SetDebugState(state); + } catch (COMException e) { + // The state of the thread is invalid. (Exception from HRESULT: 0x8013132D) + // It can happen for example when thread has not started yet + if ((uint)e.ErrorCode == 0x8013132D) { + // TraceMessage("Can not suspend thread - The state of the thread is invalid. Thread ID = " + t.CorThread.GetID()); + } else { + throw; + } } } }