ICorDebugValue GetThisCorValue() { if (this.MethodInfo.IsStatic) { throw new GetValueException("Static method does not have 'this'."); } ICorDebugValue corValue; try { corValue = CorILFrame.GetArgument(0); } catch (COMException e) { // System.Runtime.InteropServices.COMException (0x80131304): An IL variable is not available at the current native IP. (See Forum-8640) if ((uint)e.ErrorCode == 0x80131304) { throw new GetValueException("Not available in the current state"); } throw; } // This can be 'by ref' for value types if (corValue.GetTheType() == (uint)CorElementType.BYREF) { corValue = ((ICorDebugReferenceValue)corValue).Dereference(); } return(corValue); }
ICorDebugValue GetArgumentCorValue(int index) { ICorDebugValue corValue; try { // Non-static methods include 'this' as first argument corValue = CorILFrame.GetArgument((uint)(this.MethodInfo.IsStatic? index : (index + 1))); } catch (COMException e) { if ((uint)e.ErrorCode == 0x80131304) { throw new GetValueException("Unavailable in optimized code"); } throw; } // Method arguments can be passed 'by ref' if (corValue.GetTheType() == (uint)CorElementType.BYREF) { try { corValue = ((ICorDebugReferenceValue)corValue).Dereference(); } catch (COMException e) { if ((uint)e.ErrorCode == 0x80131305) { // A reference value was found to be bad during dereferencing. // This can sometimes happen after a stack overflow throw new GetValueException("Bad reference"); } else { throw; } } } return(corValue); }
public bool SetIP(string filename, int line, int column, bool dryRun) { this.Process.AssertPaused(); foreach (var symbolSource in this.Process.Debugger.SymbolSources) { foreach (var seq in symbolSource.GetSequencePoints(this.Module, filename, line, column)) { if (seq.MethodDefToken == this.MethodInfo.GetMetadataToken()) { try { if (dryRun) { CorILFrame.CanSetIP((uint)seq.ILOffset); } else { CorILFrame.SetIP((uint)seq.ILOffset); // Invalidates all frames and chains for the current thread this.Process.NotifyResumed(DebuggeeStateAction.Keep); this.Process.NotifyPaused(); } } catch { return(false); } return(true); } } } return(false); }
SourcecodeSegment SetIP(bool simulate, string filename, int line, int column) { process.AssertPaused(); SourcecodeSegment segment = SourcecodeSegment.Resolve(this.MethodInfo.DebugModule, filename, null, line, column); if (segment != null && segment.CorFunction.GetToken() == this.MethodInfo.MetadataToken) { try { if (simulate) { CorILFrame.CanSetIP((uint)segment.ILStart); } else { // Invalidates all frames and chains for the current thread CorILFrame.SetIP((uint)segment.ILStart); process.NotifyResumed(DebuggeeStateAction.Keep); process.NotifyPaused(PausedReason.SetIP); process.RaisePausedEvents(); } } catch { return(null); } return(segment); } return(null); }
ICorDebugValue GetLocalVariableCorValue(ISymUnmanagedVariable symVar) { try { return(CorILFrame.GetLocalVariable((uint)symVar.AddressField1)); } catch (COMException e) { if ((uint)e.ErrorCode == 0x80131304) { throw new GetValueException("Unavailable in optimized code"); } throw; } }
ICorDebugValue GetCorValueOfLocalVariable(ISymUnmanagedVariable symVar) { if (this.HasExpired) { throw new CannotGetValueException("FUNCTION_HAS_EXPIRED"); } try { return(CorILFrame.GetLocalVariable((uint)symVar.AddressField1)); } catch (COMException e) { if ((uint)e.ErrorCode == 0x80131304) { throw new CannotGetValueException("Unavailable in optimized code"); } throw; } }
ICorDebugValue GetArgumentCorValue(int index) { if (this.HasExpired) { throw new CannotGetValueException("FUNCTION_HAS_EXPIRED"); } try { // Non-static functions include 'this' as first argument return(CorILFrame.GetArgument((uint)(IsStatic? index : (index + 1)))); } catch (COMException e) { if ((uint)e.ErrorCode == 0x80131304) { throw new CannotGetValueException("Unavailable in optimized code"); } throw; } }
SourcecodeSegment SetIP(bool simulate, string filename, int line, int column) { process.AssertPaused(); SourcecodeSegment suggestion = new SourcecodeSegment(filename, line, column, column); ICorDebugFunction corFunction; int ilOffset; if (!suggestion.GetFunctionAndOffset(this.Module, false, out corFunction, out ilOffset)) { return(null); } else { if (corFunction.Token != methodProps.Token) { return(null); } else { try { if (simulate) { CorILFrame.CanSetIP((uint)ilOffset); } else { // invalidates all frames and chains for the current thread CorILFrame.SetIP((uint)ilOffset); process.NotifyPaused(new PauseSession(PausedReason.SetIP)); process.Pause(false); } } catch { return(null); } return(GetSegmentForOffet((uint)ilOffset)); } } }
bool SetIP(int ilOffset, bool simulate) { process.AssertPaused(); try { if (simulate) { CorILFrame.CanSetIP((uint)ilOffset); } else { // Invalidates all frames and chains for the current thread CorILFrame.SetIP((uint)ilOffset); process.NotifyResumed(DebuggeeStateAction.Keep); process.NotifyPaused(PausedReason.SetIP); process.RaisePausedEvents(); } } catch { return(false); } return(true); }