public StackFrame(Debugger debugger, CorFrame frame, int frameNo) { debugger.Dispatcher.VerifyAccess(); this.debugger = debugger; this.frame = frame; this.frameNo = frameNo; this.hashCode = frame.GetHashCode(); this.ilFrameIP = new Contracts.Scripting.Debugger.ILFrameIP(frame.ILFrameIP.Offset, (MappingResult)frame.ILFrameIP.Mapping); this.nativeFrameIP = frame.NativeFrameIP; this.token = frame.Token; this.stackStart = frame.StackStart; this.stackEnd = frame.StackEnd; this.sfFlags = 0; if (frame.IsILFrame) { this.sfFlags |= SFFlags.ILFrame; } if (frame.IsInternalFrame) { this.sfFlags |= SFFlags.InternalFrame; } if (frame.IsNativeFrame) { this.sfFlags |= SFFlags.NativeFrame; } if (frame.IsRuntimeUnwindableFrame) { this.sfFlags |= SFFlags.RuntimeUnwindableFrame; } }
public static uint GetILOffset(this CorFrame frame) { var ip = frame.ILFrameIP; if (ip.IsExact || ip.IsApproximate) { return(ip.Offset); } if (ip.IsProlog) { return(0); } if (ip.IsEpilog) { var asm = frame.GetSerializedDnModuleWithAssembly(); if (asm != null) { var loadedAsm = MainWindow.Instance.LoadAssembly(asm.Value.Assembly, asm.Value.Module); var mod = loadedAsm == null ? null : loadedAsm.ModuleDefinition as ModuleDefMD; var md = mod == null ? null : mod.ResolveToken(frame.Token) as MethodDef; if (md != null && md.Body != null && md.Body.Instructions.Count > 0) { return(md.Body.Instructions[md.Body.Instructions.Count - 1].Offset); } } } return(uint.MaxValue); }
KeyValuePair <ModuleTokenId, uint>?GetModuleTokenId(CorFrame frame) { if (!frame.IsILFrame) { return(null); } var ip = frame.ILFrameIP; if (!ip.IsExact && !ip.IsApproximate && !ip.IsProlog && !ip.IsEpilog) { return(null); } uint token = frame.Token; if (token == 0) { return(null); } var mod = frame.DnModuleId; if (mod == null) { return(null); } return(new KeyValuePair <ModuleTokenId, uint>(new ModuleTokenId(mod.Value.ToModuleId(), frame.Token), ip.Offset)); }
public static uint GetILOffset(this CorFrame frame, IModuleLoader moduleLoader) { var ip = frame.ILFrameIP; if (ip.IsExact || ip.IsApproximate) { return(ip.Offset); } if (ip.IsProlog) { return(0); } if (ip.IsEpilog) { var func = frame.Function; var file = func == null ? null : moduleLoader.LoadModule(func.Module, true); var mod = file == null ? null : file.ModuleDef; var md = mod == null ? null : mod.ResolveToken(frame.Token) as MethodDef; if (md != null && md.Body != null && md.Body.Instructions.Count > 0) { return(md.Body.Instructions[md.Body.Instructions.Count - 1].Offset); } } return(uint.MaxValue); }
public static uint GetILOffset(this CorFrame frame, IModuleLoader moduleLoader) { var ip = frame.ILFrameIP; if (ip.IsExact || ip.IsApproximate) { return(ip.Offset); } if (ip.IsProlog) { return(0); } if (ip.IsEpilog) { var mod = moduleLoader.LoadModule(frame.Function?.Module, canLoadDynFile: true, isAutoLoaded: true)?.ModuleDef; var md = mod?.ResolveToken(frame.Token) as MethodDef; if (md != null && md.Body != null && md.Body.Instructions.Count > 0) { return(md.Body.Instructions[md.Body.Instructions.Count - 1].Offset); } } return(uint.MaxValue); }
public static CachedOutput Create(CorFrame frame, TypePrinterFlags flags) { var output = new TypeOutput(); frame.Write(output, flags); return(output.cachedOutput); }
public CallStackFrameVM(ICallStackFrameContext context, int index, CorFrame frame, DnProcess process) { this.context = context; this.index = index; this.frame = frame; this.process = process; }
private void AddLocalVariablesToList(CorFrame frame, int ip, ArrayList listToAdd, ISymbolScope scope) { Debug.Assert(frame.FunctionToken == m_function.Token); foreach (ISymbolVariable isv in scope.GetLocals()) { Debug.Assert(isv.AddressKind == SymAddressKind.ILOffset); CorValue v = null; try { v = frame.GetLocalVariable(isv.AddressField1); } catch (System.Runtime.InteropServices.COMException e) { if (e.ErrorCode != (int)Microsoft.Samples.Debugging.CorDebug.HResult.CORDBG_E_IL_VAR_NOT_AVAILABLE) { throw; } } listToAdd.Add(new MDbgValue(m_module.Process, isv.Name, v)); } foreach (ISymbolScope s in scope.GetChildren()) { if (s.StartOffset <= ip && s.EndOffset >= ip) { AddLocalVariablesToList(frame, ip, listToAdd, s); } } }
DbgEngineStackFrame CreateEngineStackFrame(CorFrame corFrame) { engine.DebuggerThread.VerifyAccess(); if (corFrame.IsILFrame) { var func = corFrame.Function; if (func is null) { return(CreateErrorStackFrame()); } var module = engine.TryGetModule(func.Module); if (module is null) { return(CreateErrorStackFrame()); } return(new ILDbgEngineStackFrame(engine, module, corFrame, dnThread, func, dbgDotNetNativeCodeLocationFactory, dbgDotNetCodeLocationFactory)); } if (corFrame.IsInternalFrame) { return(engine.ObjectFactory.CreateSpecialStackFrame(GetInternalFrameTypeName(corFrame))); } if (corFrame.IsNativeFrame) { var name = string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_NativeFrame, "0x" + corFrame.NativeFrameIP.ToString("X8")); return(engine.ObjectFactory.CreateSpecialStackFrame(name)); } return(CreateErrorStackFrame()); }
void GotStepRanges(CorFrame frame, uint offset, object tag, bool isStepInto, GetCodeRangeResult result, uint continueCounter) { engine.VerifyCorDebugThread(); if (IsClosed) { return; } if (stepData != null) { return; } if (continueCounter != dnThread.Debugger.ContinueCounter || frame.IsNeutered) { RaiseStepComplete(thread, tag, "Internal error"); return; } // If we failed to find the statement ranges (result.Success == false), step anyway. // We'll just step until the next sequence point instead of not doing anything. var ranges = result.Success ? ToStepRanges(result.StatementRanges) : new StepRange[] { new StepRange(offset, offset + 1) }; CorStepper newCorStepper = null; var dbg = dnThread.Debugger; if (isStepInto) { newCorStepper = dbg.StepInto(frame, ranges, (_, e) => StepCompleted(e, newCorStepper, tag)); } else { newCorStepper = dbg.StepOver(frame, ranges, (_, e) => StepCompleted(e, newCorStepper, tag)); } SaveStepper(newCorStepper, tag); }
public static bool CanGoToDisasm(CorFrame frame) { if (frame == null) return false; if (!frame.IsNativeFrame) return false; return false;//TODO: }
public static bool GoTo(IModuleIdProvider moduleIdProvider, IDocumentTabService documentTabService, IModuleLoader moduleLoader, CorFrame frame, bool newTab) { if (GoToIL(moduleIdProvider, documentTabService, moduleLoader, frame, newTab)) return true; //TODO: eg. native frame or internal frame return false; }
public static bool GoTo(IFileTabManager fileTabManager, IModuleLoader moduleLoader, CorFrame frame, bool newTab) { if (GoToIL(fileTabManager, moduleLoader, frame, newTab)) return true; //TODO: eg. native frame or internal frame return false; }
public static bool GoTo(CorFrame frame, bool newTab) { if (GoToIL(frame, newTab)) return true; //TODO: eg. native frame or internal frame return false; }
DbgModule TryGetModule(CorFrame frame, CorThread thread) { if (frame == null) { frame = thread?.ActiveFrame ?? thread?.AllFrames.FirstOrDefault(); } return(TryGetModule(frame?.Function?.Module)); }
public static bool GoToDisasm(CorFrame frame) { if (!CanGoToDisasm(frame)) { return(false); } return(false); //TODO: }
void CheckTimestamp( ) { if (evalTimestamp != CorDebuggerSession.EvaluationTimestamp) { thread = null; frame = null; corEval = null; } }
public override void CopyFrom(EvaluationContext ctx) { base.CopyFrom(ctx); frame = ((CorEvaluationContext)ctx).frame; frameIndex = ((CorEvaluationContext)ctx).frameIndex; evalTimestamp = ((CorEvaluationContext)ctx).evalTimestamp; Thread = ((CorEvaluationContext)ctx).Thread; Session = ((CorEvaluationContext)ctx).Session; }
public static bool GoToIL(IFileTabManager fileTabManager, IModuleLoader moduleLoader, CorFrame frame, bool newTab) { if (!CanGoToIL(frame)) return false; var func = frame.Function; if (func == null) return false; return DebugUtils.GoToIL(fileTabManager, moduleLoader.LoadModule(func.Module, true), frame.Token, frame.GetILOffset(moduleLoader), newTab); }
public ValueContext(ILocalsOwner localsOwner, CorFrame frame, DnThread thread) { this.LocalsOwner = localsOwner; this.Thread = thread; this.Process = thread.Process; // Read everything immediately since the frame will be neutered when Continue() is called this.FrameCouldBeNeutered = frame; frame.GetTypeAndMethodGenericParameters(out genericTypeArguments, out genericMethodArguments); this.Function = frame.Function; }
public ExceptionThrownStopReason(CorAppDomain appDomain, CorThread thread, CorFrame frame, int offset, CorDebugExceptionCallbackType eventType, int flags) { m_appDomain = appDomain; m_thread = thread; m_frame = frame; m_offset = offset; m_eventtype = eventType; m_flags = flags; }
public static bool GoToIL(CorFrame frame, bool newTab) { if (!CanGoToIL(frame)) return false; var func = frame.Function; if (func == null) return false; return DebugUtils.GoToIL(ModuleLoader.Instance.LoadModule(func.Module, true), frame.Token, frame.GetILOffset(), newTab); }
public static bool GoToIL(IModuleIdProvider moduleIdProvider, IDocumentTabService documentTabService, IModuleLoader moduleLoader, CorFrame frame, bool newTab) { if (!CanGoToIL(frame)) return false; var func = frame.Function; if (func == null) return false; return DebugUtils.GoToIL(moduleIdProvider, documentTabService, moduleLoader.LoadModule(func.Module, canLoadDynFile: true, isAutoLoaded: true), frame.Token, frame.GetILOffset(moduleLoader), newTab); }
public ValueContext(ILocalsOwner localsOwner, CorFrame frame, DnThread thread, IList<CorType> genericTypeArguments) { this.LocalsOwner = localsOwner; this.Thread = thread; this.Process = thread.Process; // Read everything immediately since the frame will be neutered when Continue() is called this.FrameCouldBeNeutered = frame; this.genericTypeArguments = genericTypeArguments; this.genericMethodArguments = new CorType[0]; this.Function = frame == null ? null : frame.Function; }
public static bool GoTo(CorFrame frame, bool newTab) { if (GoToIL(frame, newTab)) { return(true); } //TODO: eg. native frame or internal frame return(false); }
CorFrame?FindFrame(CorFrame frame) { foreach (var f in dnThread.AllFrames) { if (f.StackStart == frame.StackStart && f.StackEnd == frame.StackEnd) { return(f); } } return(null); }
/// <summary> /// Constructor /// </summary> /// <param name="frame">The CorFrame frame object</param> /// <param name="importer">The meta data importer for the module this frame is contained within</param> internal FrameInfo(CorFrame frame, CorMetadataImport importer) { if (frame == null) { throw new ArgumentNullException("frame"); } if (importer == null) { throw new ArgumentNullException("importer"); } thisFrame = frame; metaImporter = importer; functionShortName = ""; functionFullName = ""; moduleShortName = ""; moduleFullName = ""; functionFileName = null; functionLineNumber = -1; //-1 is set by deafult which means no line number SourcePosition functionPos = null; //position in this function where we are //make binder and reader for the metadata if (thisFrame.FrameType == CorFrameType.InternalFrame) { functionFullName = functionShortName = InternalFrameToString(); } else { try { functionPos = GetMetaDataInfo(importer); } catch (Exception e) { // We are not able to find information about the source code functionFileName = "unknown method: " + e.Message; } } if (functionPos != null) { functionLineNumber = functionPos.Line; functionFileName = Path.GetFileName(functionPos.Path); } else { functionLineNumber = -1; //no line number available functionFileName = functionFileName ?? "source unavailable"; } }
public ValueContext(ILocalsOwner localsOwner, CorFrame frame, DnThread thread, List <CorType> genericTypeArguments) { this.LocalsOwner = localsOwner; this.Thread = thread; this.Process = thread.Process; // Read everything immediately since the frame will be neutered when Continue() is called this.FrameCouldBeNeutered = frame; this.genericTypeArguments = genericTypeArguments; this.genericMethodArguments = new List <CorType>(); this.Function = frame?.Function; }
public static bool CanGoToDisasm(CorFrame frame) { if (frame == null) { return(false); } if (!frame.IsNativeFrame) { return(false); } return(false); //TODO: }
/// <summary> /// Returns the caller of the frame. /// </summary> /// <param name="frame">frame to return the caller of</param> /// <returns>the caller of the frame or null if the frame is the last frame in the chain</returns> protected virtual MDbgFrame GetFrameCaller(MDbgFrame frame) { Debug.Assert(frame != null); CorFrame f = frame.CorFrame.Caller; if (f == null) { return(null); } return(new MDbgILFrame(Thread, f)); }
public static bool CanGoToIL(CorFrame frame) { if (frame == null) return false; if (!frame.IsILFrame) return false; var ip = frame.ILFrameIP; if (!ip.IsExact && !ip.IsApproximate && !ip.IsProlog && !ip.IsEpilog) return false; if (frame.Token == 0) return false; return true; }
/// <summary> /// Creates a new V2 StackWalker. /// </summary> /// <param name="thread">a thread object associated with the stackwalker</param> /// <returns>object implementing MDbgStackWalker interface</returns> public IEnumerable <MDbgFrame> EnumerateFrames(MDbgThread thread) { // To do stackwalking using V2 ICorDebug, we enumerate through the chains, // and then enumerate each frame in every chain CorChain chain = null; try { chain = thread.CorThread.ActiveChain; } catch (System.Runtime.InteropServices.COMException ce) { // Sometimes we cannot get the callstack. For example, the thread // may not be scheduled yet (CORDBG_E_THREAD_NOT_SCHEDULED), // or the debuggee may be corrupt (CORDBG_E_BAD_THREAD_STATE). // In either case, we'll ignore the problem and return an empty callstack. Debug.Assert(ce.ErrorCode == (int)HResult.CORDBG_E_BAD_THREAD_STATE || ce.ErrorCode == (int)HResult.CORDBG_E_THREAD_NOT_SCHEDULED); } while (chain != null) { if (chain.IsManaged) { // Enumerate managed frames // A chain may have 0 managed frames. CorFrame f = chain.ActiveFrame; while (f != null) { MDbgFrame frame = new MDbgILFrame(thread, f); f = f.Caller; yield return(frame); } } else { // ICorDebug doesn't unwind unmanaged frames. Need to let a native-debug component handle that. foreach (MDbgFrame frame in UnwindNativeFrames(thread, chain)) { yield return(frame); } } // Move to next chain chain = chain.Caller; } }
public static bool GoToIL(CorFrame frame, bool newTab) { if (!CanGoToIL(frame)) { return(false); } var func = frame.Function; if (func == null) { return(false); } return(DebugUtils.GoToIL(ModuleLoader.Instance.LoadModule(func.Module, true), frame.Token, frame.GetILOffset(), newTab)); }
void GetStepRanges(CorFrame frame, object tag, bool isStepInto) { engine.VerifyCorDebugThread(); var module = engine.TryGetModule(frame.Function?.Module); var offset = GetILOffset(frame); if (module == null || offset == null) { SaveStepper(null, tag); } else { uint continueCounter = dnThread.Debugger.ContinueCounter; dbgDotNetCodeRangeService.GetCodeRanges(module, frame.Token, offset.Value, result => engine.CorDebugThread(() => GotStepRanges(frame, tag, isStepInto, result, continueCounter))); } }
public static bool GoToIL(CorFrame frame, bool newTab) { if (!CanGoToIL(frame)) { return(false); } var serAsm = frame.GetSerializedDnModuleWithAssembly(); if (serAsm == null) { return(false); } return(DebugUtils.GoToIL(serAsm.Value, frame.Token, frame.GetILOffset(), newTab)); }
/// <summary> /// Constructor /// </summary> /// <param name="frame">The CorFrame frame object</param> /// <param name="importer">The meta data importer for the module this frame is contained within</param> internal FrameInfo(CorFrame frame, CorMetadataImport importer) { if (frame == null) { throw new ArgumentNullException("frame"); } if (importer == null) { throw new ArgumentNullException("importer"); } thisFrame = frame; metaImporter = importer; functionShortName = ""; functionFullName = ""; moduleShortName = ""; moduleFullName = ""; functionFileName = ""; functionLineNumber = -1; //-1 is set by deafult which means no line number SourcePosition functionPos = null; //position in this function where we are //make binder and reader for the metadata if (thisFrame.FrameType == CorFrameType.InternalFrame) { functionFullName = functionShortName = InternalFrameToString(); } else { functionPos = GetMetaDataInfo(importer); } if (functionPos != null) { functionLineNumber = functionPos.Line; functionFileName = Path.GetFileName(functionPos.Path); } else { ResourceManager stackStrings = new ResourceManager(typeof(Resources)); functionLineNumber = -1; //no line number available functionFileName = stackStrings.GetString("sourceUnavailable"); } }
public ValueContext(ILocalsOwner localsOwner, CorFrame frame, DnThread thread, DnProcess process) { this.LocalsOwner = localsOwner; this.Thread = thread; this.Process = process; Debug.Assert(thread == null || thread.Process == process); // Read everything immediately since the frame will be neutered when Continue() is called this.FrameCouldBeNeutered = frame; if (frame == null) { genericTypeArguments = genericMethodArguments = new List<CorType>(); this.Function = null; } else { frame.GetTypeAndMethodGenericParameters(out genericTypeArguments, out genericMethodArguments); this.Function = frame.Function; } }
static uint?GetILOffset(CorFrame frame) { var ip = frame.ILFrameIP; if (ip.IsExact || ip.IsApproximate) { return(ip.Offset); } if (ip.IsProlog) { return(DbgDotNetCodeRangeService.PROLOG); } if (ip.IsEpilog) { return(DbgDotNetCodeRangeService.EPILOG); } return(null); }
static string GetInternalFrameTypeName(CorFrame corFrame) { Debug.Assert(corFrame.IsInternalFrame); switch (corFrame.InternalFrameType) { case CorDebugInternalFrameType.STUBFRAME_M2U: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_ManagedToNativeTransition); case CorDebugInternalFrameType.STUBFRAME_U2M: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_NativeToManagedTransition); case CorDebugInternalFrameType.STUBFRAME_APPDOMAIN_TRANSITION: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_AppdomainTransition); case CorDebugInternalFrameType.STUBFRAME_LIGHTWEIGHT_FUNCTION: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_LightweightFunction); case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_FunctionEvaluation); case CorDebugInternalFrameType.STUBFRAME_INTERNALCALL: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_InternalCall); case CorDebugInternalFrameType.STUBFRAME_CLASS_INIT: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_ClassInit); case CorDebugInternalFrameType.STUBFRAME_EXCEPTION: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_Exception); case CorDebugInternalFrameType.STUBFRAME_SECURITY: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_Security); case CorDebugInternalFrameType.STUBFRAME_JIT_COMPILATION: return(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_JITCompilation); case CorDebugInternalFrameType.STUBFRAME_NONE: Debug.Fail("Shouldn't be here"); goto default; default: return(string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.StackFrame_InternalFrame, "0x" + ((int)corFrame.InternalFrameType).ToString("X8"))); } }
public ValueContext(ILocalsOwner localsOwner, CorFrame frame, DnThread thread, DnProcess process) { this.LocalsOwner = localsOwner; this.Thread = thread; this.Process = process; Debug.Assert(thread == null || thread.Process == process); // Read everything immediately since the frame will be neutered when Continue() is called this.FrameCouldBeNeutered = frame; if (frame == null) { genericTypeArguments = genericMethodArguments = new List <CorType>(); this.Function = null; } else { frame.GetTypeAndMethodGenericParameters(out genericTypeArguments, out genericMethodArguments); this.Function = frame.Function; } }
public void SetFrame(CorFrame frame, DnProcess process) { this.frame = frame; this.process = process; if (cachedOutput == null || !HasPropertyChangedHandlers) { cachedOutput = null; OnPropertyChanged("NameObject"); } else { var newCachedOutput = CachedOutput.Create(frame, Context.TypePrinterFlags); if (newCachedOutput.Equals(cachedOutput.Value)) { return; } cachedOutput = newCachedOutput; OnPropertyChanged("NameObject"); } }
/// <summary> /// Step into /// </summary> /// <param name="frame">Frame</param> /// <param name="action">Delegate to call when completed or null</param> /// <returns></returns> public bool StepInto(CorFrame frame, Action<DnDebugger, StepCompleteDebugCallbackEventArgs> action = null) { DebugVerifyThread(); return StepIntoOver(frame, true, action); }
public bool RunTo(CorFrame frame) { DebugVerifyThread(); var callee = GetRunToCallee(frame); if (callee == null) return false; return StepOutInternal(callee, null); }
/// <summary> /// true if we can step into, step out or step over /// </summary> /// <param name="frame">Frame</param> public bool CanStep(CorFrame frame) { DebugVerifyThread(); return ProcessState == DebuggerProcessState.Stopped && frame != null; }
public bool CanRunTo(CorFrame frame) { DebugVerifyThread(); return GetRunToCallee(frame) != null; }
bool StepOutInternal(CorFrame frame, Action<DnDebugger, StepCompleteDebugCallbackEventArgs> action) { if (!CanStep(frame)) return false; var stepper = CreateStepper(frame); if (stepper == null) return false; if (!stepper.StepOut()) return false; stepInfos.Add(stepper, new StepInfo(action)); Continue(); return true; }
public bool CanRunTo(CorFrame frame) { return ProcessState == DebuggerProcessState.Stopped && Debugger.CanRunTo(frame); }
CorStepper CreateStepper(CorFrame frame) { if (frame == null) return null; var stepper = frame.CreateStepper(); if (stepper == null) return null; if (!stepper.SetInterceptMask(debugOptions.StepperInterceptMask)) return null; if (!stepper.SetUnmappedStopMask(debugOptions.StepperUnmappedStopMask)) return null; if (!stepper.SetJMC(debugOptions.StepperJMC)) return null; return stepper; }
public static bool GoToDisasm(CorFrame frame) { if (!CanGoToDisasm(frame)) return false; return false;//TODO: }
public CallStackFrameVM(CallStackVM owner, int index, CorFrame frame) { this.owner = owner; this.index = index; this.frame = frame; }
static MethodKey? CreateMethodKey(DnDebugger debugger, CorFrame frame) { var sma = frame.GetSerializedDnModuleWithAssembly(); if (sma == null) return null; return MethodKey.Create(frame.Token, sma.Value.Module); }
internal void UpdateCurrentLocation(CorFrame frame) { var newLoc = GetCodeLocation(frame); if (currentLocation == null || newLoc == null) { currentLocation = newLoc; UpdateCurrentMethod(); return; } if (!CodeLocation.SameMethod(currentLocation.Value, newLoc.Value)) { currentLocation = newLoc; UpdateCurrentMethod(); return; } currentLocation = newLoc; }
public void RunTo(CorFrame frame) { if (!CanRunTo(frame)) return; Debugger.RunTo(frame); }
/// <summary> /// Step out of current method in the selected frame /// </summary> /// <param name="frame">Frame</param> /// <param name="action">Delegate to call when completed or null</param> /// <returns></returns> public bool StepOut(CorFrame frame, Action<DnDebugger, StepCompleteDebugCallbackEventArgs> action = null) { DebugVerifyThread(); return StepOutInternal(frame, action); }
CorFrame GetRunToCallee(CorFrame frame) { if (!CanStep(frame)) return null; if (frame == null) return null; if (!frame.IsILFrame) return null; var callee = frame.Callee; if (callee == null) return null; if (!callee.IsILFrame) return null; return callee; }
/// <summary> /// Step over /// </summary> /// <param name="frame">Frame</param> /// <param name="ranges">Ranges to step over</param> /// <param name="action">Delegate to call when completed or null</param> /// <returns></returns> public bool StepOver(CorFrame frame, StepRange[] ranges, Action<DnDebugger, StepCompleteDebugCallbackEventArgs> action = null) { DebugVerifyThread(); return StepIntoOver(frame, ranges, false, action); }
bool StepIntoOver(CorFrame frame, StepRange[] ranges, bool stepInto, Action<DnDebugger, StepCompleteDebugCallbackEventArgs> action = null) { if (ranges == null) return StepIntoOver(frame, stepInto, action); if (!CanStep(frame)) return false; var stepper = CreateStepper(frame); if (stepper == null) return false; if (!stepper.StepRange(stepInto, ranges)) return false; stepInfos.Add(stepper, new StepInfo(action)); Continue(); return true; }
CodeLocation? GetCodeLocation(CorFrame frame) { if (ProcessState != DebuggerProcessState.Stopped) return null; if (frame == null) return null; var sma = frame.GetSerializedDnModuleWithAssembly(); if (sma == null) return null; uint token = frame.Token; if (token == 0) return null; return new CodeLocation(sma.Value, token, frame.GetILOffset(), frame.ILFrameIP.Mapping); }
StepRange[] GetStepRanges(DnDebugger debugger, CorFrame frame, bool isStepInto) { if (frame == null) return null; if (!frame.IsILFrame) return null; if (frame.ILFrameIP.IsUnmappedAddress) return null; var key = CreateMethodKey(debugger, frame); if (key == null) return null; MemberMapping mapping; var textView = MainWindow.Instance.SafeActiveTextView; var cm = textView.CodeMappings; if (cm == null || !cm.TryGetValue(key.Value, out mapping)) { // User has decompiled some other code or switched to another tab UpdateCurrentMethod(); JumpToCurrentStatement(textView); // It could be cached and immediately available. Check again cm = textView.CodeMappings; if (cm == null || !cm.TryGetValue(key.Value, out mapping)) return null; } bool isMatch; var scm = mapping.GetInstructionByOffset(frame.GetILOffset(), out isMatch); uint[] ilRanges; if (scm == null) ilRanges = mapping.ToArray(null, false); else ilRanges = scm.ToArray(isMatch); if (ilRanges.Length == 0) return null; return CreateStepRanges(ilRanges); }