diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs index 60a34fe522..7560d9be71 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs @@ -111,8 +111,7 @@ namespace Debugger this.thread = thread; this.chainIndex = chainIndex; this.frameIndex = frameIndex; - this.corILFrame = corILFrame; - this.corILFramePauseSession = debugger.PauseSession; + this.CorILFrame = corILFrame; corFunction = corILFrame.Function; module = debugger.GetModule(corFunction.Module); @@ -137,6 +136,7 @@ namespace Debugger return corILFrame; } set { + if (value == null) throw new DebuggerException("Can not set frame to null"); corILFrame = value; corILFramePauseSession = debugger.PauseSession; } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs index 66d8bdea1e..182055ff77 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs @@ -191,9 +191,11 @@ namespace Debugger foreach(ICorDebugFrame corFrame in corFrameEnum.Enumerator) { frameIndex--; - Function function = GetFunctionFromCache(chainIndex, frameIndex, corFrame); - if (function != null) { - yield return function; + if (corFrame.Is()) { + Function function = GetFunctionFromCache(chainIndex, frameIndex, corFrame.As()); + if (function != null) { + yield return function; + } } } } @@ -206,7 +208,7 @@ namespace Debugger public Dictionary Frames = new Dictionary(); } - Function GetFunctionFromCache(uint chainIndex, uint frameIndex, ICorDebugFrame corFrame) + Function GetFunctionFromCache(uint chainIndex, uint frameIndex, ICorDebugILFrame corFrame) { try { if (chainCache.ContainsKey(chainIndex) && @@ -214,18 +216,14 @@ namespace Debugger !chainCache[chainIndex].Frames[frameIndex].HasExpired) { Function function = chainCache[chainIndex].Frames[frameIndex]; - function.CorILFrame = corFrame.As(); + function.CorILFrame = corFrame; return function; } else { - if (corFrame.Is()) { - Function function = new Function(this, chainIndex, frameIndex, corFrame.CastTo()); - if (!chainCache.ContainsKey(chainIndex)) chainCache[chainIndex] = new Chain(); - chainCache[chainIndex].Frames[frameIndex] = function; - function.Expired += delegate { chainCache[chainIndex].Frames.Remove(frameIndex); }; - return function; - } else { - return null; - } + Function function = new Function(this, chainIndex, frameIndex, corFrame.CastTo()); + if (!chainCache.ContainsKey(chainIndex)) chainCache[chainIndex] = new Chain(); + chainCache[chainIndex].Frames[frameIndex] = function; + function.Expired += delegate { chainCache[chainIndex].Frames.Remove(frameIndex); }; + return function; } } catch (COMException) { // TODO return null;