/// <summary> /// Fills an ExceptionInformation object with information about the /// current exception in the active thread. /// </summary> /// <param name="debuggedProc">The Process to extract exception from.</param> /// <returns>A filled ExceptionInformation object, or null if there is no current exception.</returns> private ExceptionInformation GetExceptionInformation(MDbgProcess debuggedProc) { ExceptionInformation ei = new ExceptionInformation(); //ei.StackTrace = GetStackTrace(debuggedProc.Threads.Active); ExceptionInformation inner = ei; MDbgValue ex = debuggedProc.ResolveVariable("$exception", debuggedProc.Threads.Active.CurrentFrame); if (ex == null) return null; do { MDbgValue messageValue = ResolveFunction(debuggedProc, ex, "System.Exception.get_Message"); if (messageValue != null) { inner.Message = messageValue.GetStringValue(true); } else { inner.Message = "Could not retrieve the exception message"; } MDbgValue stackTrace = ResolveFunction(debuggedProc, ex, "System.Exception.get_StackTrace"); if (stackTrace != null) { inner.StackTraceString = stackTrace.GetStringValue(true); } else { inner.StackTraceString = "Could not retrieve stack trace"; } ex = ResolveFunction(debuggedProc, ex, "System.Exception.get_InnerException"); if (ex != null && ex.IsNull != true) { inner.InnerExceptionInfo = new ExceptionInformation(); inner = inner.InnerExceptionInfo; } } while (ex != null && ex.IsNull != true); return ei; }
public MDbgValue ParseExpression(string variableName, MDbgProcess process, MDbgFrame scope) { Debug.Assert(process != null); return process.ResolveVariable(variableName, scope); }
/// <summary> /// Gets the current output of the template function. /// </summary> /// <remarks> /// Assumes that debuggedProc can be examined safely, and that the current output is stored in a static /// variable called __CurrentOutput in the class containing the template function. /// Alternatively, if the </remarks> /// <param name="debuggedProc">The Process that is being debugged.</param> /// <returns>The current output of the template function.</returns> private string GetCurrentOutput(MDbgProcess debuggedProc) { MDbgValue val = null; int lineNumber = (debuggedProc.Threads.HaveActive && debuggedProc.Threads.Active.HaveCurrentFrame && debuggedProc.Threads.Active.CurrentFrame.SourcePosition != null) ? debuggedProc.Threads.Active.CurrentFrame.SourcePosition.Line : 0; if (lineNumber == LAST_LINE_IN_MAIN) { val = debuggedProc.ResolveVariable("obj", debuggedProc.Threads.Active.CurrentFrame); } else if (debuggedProc.Threads.Active.CurrentFrame.SourcePosition != null) { if (debuggedProc.Threads.Active.CurrentFrame.SourcePosition.Path.Contains(Path.Combine("ArchAngel.Debugger.DebugProcess", "Commands.cs"))) { return ""; } val = debuggedProc.ResolveVariable("instance", debuggedProc.Threads.Active.CurrentFrame) ?? debuggedProc.ResolveVariable("this", debuggedProc.Threads.Active.CurrentFrame); if (val == null) return "Could not get value of current output"; string funcName = TestNamespace + "." + TestClassname + ".GetCurrentStringBuilder"; val = ResolveFunction(debuggedProc, val, funcName); val = ResolveFunction(debuggedProc, val, "System.Text.StringBuilder.ToString"); } if (val == null) return "Could not get value of current output"; string currentOutput = val.GetStringValue(1); currentOutput = currentOutput.Remove(0, 1); currentOutput = currentOutput.Remove(currentOutput.Length - 1, 1); return currentOutput; }
public CorValue ParseExpression2(string value, MDbgProcess process, MDbgFrame scope) { if (value.Length == 0) { return null; } CorGenericValue result; if (TryCreatePrimitiveValue(value, out result)) { //value is a primitive type return result; } if (value[0] == '"' && value[value.Length - 1] == '"') { //value is a string return CreateString(value); } //value is some variable Debug.Assert(process != null); MDbgValue var = process.ResolveVariable(value, scope); return (var == null ? null : var.CorValue); }