// Token: 0x06000138 RID: 312 RVA: 0x00005888 File Offset: 0x00003A88 private Client.ExceptionInfo GetExceptionInfo(Backtrace backTrace, EvaluationOptions options = null, bool isUnhandled = false) { Client.ExceptionInfo exceptionInfo = null; if (backTrace != null && backTrace.FrameCount > 0) { for (int i = 0; i < backTrace.FrameCount; i++) { Mono.Debugging.Client.StackFrame frame = backTrace.GetFrame(i); if (isUnhandled || !frame.IsExternalCode) { try { exceptionInfo = ((options == null) ? frame.GetException() : frame.GetException(options)); } catch (AbsentInformationException) { goto IL_4A; } if (exceptionInfo != null) { this.ResolveFullException(exceptionInfo); break; } } IL_4A :; } } return(exceptionInfo); }
static void SetSourceCodeFrame() { Backtrace bt = DebuggingService.CurrentCallStack; if (bt != null) { for (int n = 0; n < bt.FrameCount; n++) { StackFrame sf = bt.GetFrame(n); if (!sf.IsExternalCode && sf.SourceLocation.Line != -1 && !string.IsNullOrEmpty(sf.SourceLocation.FileName) && //Uncomment condition below once logic for ProjectOnlyCode in runtime is fixed ( /*DebuggingService.CurrentSessionSupportsFeature (DebuggerFeatures.Disassembly) ||*/ sf.SourceLocation.SourceLink != null || File.Exists(sf.SourceLocation.FileName) || SourceCodeLookup.FindSourceFile(sf.SourceLocation.FileName, sf.SourceLocation.FileHash).IsNotNull)) { if (n != DebuggingService.CurrentFrameIndex) { DebuggingService.CurrentFrameIndex = n; } break; } } } }
static void SetSourceCodeFrame() { Backtrace bt = DebuggingService.CurrentCallStack; if (bt != null) { for (int n = 0; n < bt.FrameCount; n++) { StackFrame sf = bt.GetFrame(n); if (!sf.IsExternalCode && sf.SourceLocation.Line != -1) { bool found = !string.IsNullOrEmpty(sf.SourceLocation.FileName) && System.IO.File.Exists(sf.SourceLocation.FileName); if (found) { if (n != DebuggingService.CurrentFrameIndex) { DebuggingService.CurrentFrameIndex = n; } break; } else { LoggingService.LogWarning("Debugger could not find file '{0}'", sf.SourceLocation.FileName); } } } } }
/// <summary> /// Parses a Response from a raw JSON string /// </summary> public static Response ParseFrom(long token, string buf) { //we check here because it's possibly very expensive to ship this buf around in the call stack if (Log.IsTraceEnabled) { Log.Trace($"JSON Recv: Token: {token}, JSON: {buf}"); } var jsonResp = ParseJson(buf); var responseType = jsonResp[TypeKey].ToObject <ResponseType>(); var responseNotes = jsonResp[NotesKey]?.ToObject <List <ResponseNote> >() ?? new List <ResponseNote>(); ErrorType?et = jsonResp[ErrorKey]?.ToObject <ErrorType>(); var profile = Profile.FromJsonArray((JArray)jsonResp[ProfileKey]); var backtrace = Backtrace.FromJsonArray((JArray)jsonResp[BacktraceKey]); var res = new Response(token, responseType) { ErrorType = et, Profile = profile, Backtrace = backtrace, Data = (JArray)jsonResp[DataKey] ?? new JArray(), Notes = responseNotes }; return(res); }
public override Backtrace GetBacktrace(Backtrace.Mode mode, int max_frames) { current_backtrace = new Backtrace(CurrentFrame); current_backtrace.GetBacktrace( this, TargetAccess, mode, TargetAddress.Null, max_frames); return(current_backtrace); }
static void Cleanup() { currentBacktrace = null; if (!IsDebugging) { return; } if (busyStatusIcon != null) { busyStatusIcon.Dispose(); busyStatusIcon = null; } session.TargetEvent -= OnTargetEvent; session.TargetStarted -= OnStarted; session.OutputWriter = null; session.LogWriter = null; session.ExceptionHandler = null; session.BusyStateChanged -= OnBusyStateChanged; session.TypeResolverHandler = null; session.BreakpointTraceHandler = null; session.GetExpressionEvaluator = null; console.CancelRequested -= OnCancelRequested; // Dispose the session at the end, since it may take a while. DebuggerSession oldSession = session; session = null; if (StoppedEvent != null) { StoppedEvent(null, new EventArgs()); } if (console != null) { console.Dispose(); console = null; } DispatchService.GuiDispatch(delegate { NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); if (oldSession != null) { oldSession.BusyStateChanged -= OnBusyStateChanged; oldSession.Dispose(); } }
static void OnStarted(object s, EventArgs a) { currentBacktrace = null; DispatchService.GuiDispatch(delegate { if (ResumedEvent != null) { ResumedEvent(null, a); } NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); }
static void OnStarted(object s, EventArgs a) { nextStatementLocations.Clear(); currentBacktrace = null; DispatchService.GuiDispatch(delegate { HideExceptionCaughtDialog(); if (ResumedEvent != null) { ResumedEvent(null, a); } NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); }
static void OnStarted(object s, EventArgs a) { nextStatementLocations.Clear(); currentBacktrace = null; Runtime.RunInMainThread(delegate { HideExceptionCaughtDialog(); if (ResumedEvent != null) { ResumedEvent(null, a); } NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); }
// Token: 0x060000FE RID: 254 RVA: 0x00004E40 File Offset: 0x00003040 public StackFrame[] GetBacktrace() { ThreadInfo threadInfo = this.GetThreadInfo(); Backtrace backtrace = threadInfo.Backtrace; if (backtrace == null) { return(null); } StackFrame[] array = new StackFrame[backtrace.FrameCount]; for (int i = 0; i < array.Length; i++) { array[i] = new StackFrame(this, backtrace.GetFrame(i), this.eventSender); } return(array); }
static void SetCurrentBacktrace(Backtrace bt) { currentBacktrace = bt; if (currentBacktrace != null) { currentFrame = 0; } else { currentFrame = -1; } DispatchService.GuiDispatch(delegate { NotifyCallStackChanged(); NotifyCurrentFrameChanged(); }); }
// Token: 0x060000FD RID: 253 RVA: 0x00004E04 File Offset: 0x00003004 public StackFrame GetFrame() { ThreadInfo threadInfo = this.GetThreadInfo(); Backtrace backtrace = threadInfo.Backtrace; if (backtrace == null) { return(null); } var frame = backtrace.GetFrame(0); if (frame == null) { return(null); } return(new StackFrame(this, frame, this.eventSender)); }
public int EnumFrameInfo(uint dwFieldSpec, uint nRadix, out IEnumDebugFrameInfo2 ppEnum) { Backtrace trace = _engine.SoftDebugger.ActiveBacktrace; //_monoThread.Backtrace; FRAMEINFO[] frames = new FRAMEINFO[trace.FrameCount]; for (int x = 0; x < trace.FrameCount; x++) { MonoStackFrame frame = new MonoStackFrame(_engine, this, trace.GetFrame(x)); frames[x] = frame.GetFrameInfo(dwFieldSpec); } ppEnum = new MonoFrameInfoEnumerator(frames); return(S_OK); }
static void SetCurrentBacktrace(Backtrace bt) { currentBacktrace = bt; if (currentBacktrace != null) { currentFrame = 0; } else { currentFrame = -1; } Runtime.RunInMainThread(delegate { NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); }
static void SetSourceCodeFrame() { Backtrace bt = DebuggingService.CurrentCallStack; if (bt != null) { for (int n = 0; n < bt.FrameCount; n++) { StackFrame sf = bt.GetFrame(n); if (!sf.IsExternalCode && !string.IsNullOrEmpty(sf.SourceLocation.Filename) && System.IO.File.Exists(sf.SourceLocation.Filename) && sf.SourceLocation.Line != -1) { if (n != DebuggingService.CurrentFrameIndex) { DebuggingService.CurrentFrameIndex = n; } break; } } } }
public void AttachAgain() { Process process = Attach(child.Id); Assert.IsTrue(process.MainThread.IsStopped); AssertStopped(process.MainThread, null, -1); StackFrame frame = process.MainThread.CurrentFrame; Assert.IsNotNull(frame); Backtrace bt = process.MainThread.GetBacktrace(-1); if (bt.Count < 1) { Assert.Fail("Cannot get backtrace."); } process.Detach(); AssertTargetExited(process); }
/// <summary> /// Parses a Response from a raw JSON string /// </summary> public static Response ParseFrom(long token, string buf) { Log.Trace($"JSON Recv: Token: {token}, JSON: {buf}"); var jsonResp = JObject.Parse(buf); var responseType = jsonResp[TypeKey].ToObject <ResponseType>(); var responseNotes = jsonResp[NotesKey]?.ToObject <List <ResponseNote> >() ?? new List <ResponseNote>(); ErrorType?et = jsonResp[ErrorKey]?.ToObject <ErrorType>(); var profile = Profile.FromJsonArray((JArray)jsonResp[ProfileKey]); var backtrace = Backtrace.FromJsonArray((JArray)jsonResp[BacktraceKey]); var res = new Response(token, responseType) { ErrorType = et, Profile = profile, Backtrace = backtrace, Data = (JArray)jsonResp[DataKey] ?? new JArray(), Notes = responseNotes }; return(res); }
public StackFrame GetFrame(int number) { Thread thread = CurrentThread; if (!thread.IsStopped) { throw new TargetException(TargetError.NotStopped); } if (number == -1) { return(thread.CurrentFrame); } Backtrace bt = thread.GetBacktrace(); if (number >= bt.Count) { throw new ScriptingException("No such frame: {0}", number); } return(bt [number]); }
public StackTracePad() { this.ShadowType = ShadowType.None; ActionCommand gotoCmd = new ActionCommand("StackTracePad.ActivateFrame", GettextCatalog.GetString("Activate Stack Frame")); menuSet = new CommandEntrySet(); menuSet.Add(gotoCmd); menuSet.AddSeparator(); menuSet.AddItem(EditCommands.SelectAll); menuSet.AddItem(EditCommands.Copy); store = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Pango.Style)); tree = new MonoDevelop.Ide.Gui.Components.PadTreeView(store); tree.RulesHint = true; tree.HeadersVisible = true; tree.Selection.Mode = SelectionMode.Multiple; tree.DoPopupMenu = ShowPopup; TreeViewColumn col = new TreeViewColumn(); CellRenderer crp = new CellRendererIcon(); col.PackStart(crp, false); col.AddAttribute(crp, "stock_id", 0); tree.AppendColumn(col); TreeViewColumn FrameCol = new TreeViewColumn(); FrameCol.Title = GettextCatalog.GetString("Name"); FrameCol.PackStart(tree.TextRenderer, true); FrameCol.AddAttribute(tree.TextRenderer, "text", 1); FrameCol.AddAttribute(tree.TextRenderer, "foreground", 5); FrameCol.AddAttribute(tree.TextRenderer, "style", 6); FrameCol.Resizable = true; FrameCol.Alignment = 0.0f; tree.AppendColumn(FrameCol); col = new TreeViewColumn(); col.Title = GettextCatalog.GetString("File"); col.PackStart(tree.TextRenderer, false); col.AddAttribute(tree.TextRenderer, "text", 2); col.AddAttribute(tree.TextRenderer, "foreground", 5); tree.AppendColumn(col); col = new TreeViewColumn(); col.Title = GettextCatalog.GetString("Language"); col.PackStart(tree.TextRenderer, false); col.AddAttribute(tree.TextRenderer, "text", 3); col.AddAttribute(tree.TextRenderer, "foreground", 5); tree.AppendColumn(col); col = new TreeViewColumn(); col.Title = GettextCatalog.GetString("Address"); col.PackStart(tree.TextRenderer, false); col.AddAttribute(tree.TextRenderer, "text", 4); col.AddAttribute(tree.TextRenderer, "foreground", 5); tree.AppendColumn(col); Add(tree); ShowAll(); current_backtrace = DebuggingService.CurrentCallStack; UpdateDisplay(); DebuggingService.CallStackChanged += (EventHandler)DispatchService.GuiDispatch(new EventHandler(OnClassStackChanged)); DebuggingService.CurrentFrameChanged += (EventHandler)DispatchService.GuiDispatch(new EventHandler(OnFrameChanged)); tree.RowActivated += OnRowActivated; }
protected void OnClassStackChanged(object o, EventArgs args) { current_backtrace = DebuggingService.CurrentCallStack; UpdateDisplay(); }
protected override bool DoResolve(ScriptingContext context) { // set whole method in a try-catch block: if anything goes wrong, an invalid breakpoint // number is set and the semaphore is released. try { if (global) { if (local) { throw new ScriptingException( "Cannot use both -local and -global."); } if (Group != null) { throw new ScriptingException( "Cannot use both -group and -global."); } tgroup = ThreadGroup.Global; } else if (local) { if (Group != null) { throw new ScriptingException( "Cannot use both -group and -local."); } tgroup = context.Interpreter.GetThreadGroup(Group, false); } else if (Group != null) { tgroup = context.Interpreter.GetThreadGroup(Group, false); } else { tgroup = ThreadGroup.Global; } if (context.Interpreter.HasTarget) { context.CurrentProcess = context.Interpreter.GetProcess(p_index); context.CurrentThread = context.Interpreter.GetThread(t_index); Mono.Debugger.Thread thread = context.CurrentThread; if (!thread.IsStopped) { throw new Mono.Debugger.TargetException(TargetError.NotStopped); } Backtrace backtrace = thread.GetBacktrace(); StackFrame frame; if (f_index == -1) { frame = backtrace.CurrentFrame; } else { if (f_index >= backtrace.Count) { throw new ScriptingException( "No such frame: {0}", f_index); } frame = backtrace [f_index]; } context.CurrentFrame = frame; if (ExpressionParser.ParseLocation( thread, thread.CurrentFrame, Argument, out location)) { return(true); } } if (Argument.IndexOf(':') > 0) { return(true); } try { UInt32.Parse(Argument); return(true); } catch { } Expression expr = context.Interpreter.ExpressionParser.Parse(Argument); if (expr == null) { throw new ScriptingException("Cannot resolve expression `{0}'.", Argument); } if (expr is PointerExpression) { address = ((PointerExpression)expr).EvaluateAddress(context); return(true); } if (!context.Interpreter.HasTarget) { return(true); } MethodExpression mexpr; try { mexpr = expr.ResolveMethod(context, type); } catch { if (lazy) { return(true); } throw new ScriptingException("No such method: `{0}'.", Argument); } if (mexpr != null) { location = mexpr.EvaluateSource(context); } else { location = context.FindMethod(Argument); } if (lazy) { return(true); } if (location == null) { throw new ScriptingException("No such method: `{0}'.", Argument); } return(true); } catch { EmonicInterpreter.breakpointNumber = -1; EmonicInterpreter.breakpointSem.Release(); throw; } }
void DoAbortInvocation(long rti_id) { Report.Debug (DebugFlags.SSE, "{0} do abort invocation: {1}", this, rti_id); if (current_frame == null) throw new TargetException (TargetError.NoStack); process.UpdateSymbolTable (inferior); Inferior.CallbackFrame cframe = inferior.GetCallbackFrame (current_frame.StackPointer, false); bool found = false; foreach (OperationRuntimeInvoke rti in rti_stack) { if (rti.ID != rti_id) continue; found = true; if (!rti.RequestAbort ()) throw new TargetException (TargetError.NoInvocation); break; } if (!found) throw new TargetException (TargetError.NoInvocation); if (cframe == null) throw new TargetException (TargetError.InvalidReturn, "No invocation found."); else if (cframe.ID != rti_id) throw new TargetException (TargetError.InvalidReturn, "Requested to abort invocation {0}, but current invocation has id {1}.", rti_id, cframe.ID); CommandResult result = new ThreadCommandResult (thread); if (MonoDebuggerInfo.HasAbortRuntimeInvoke) { PushOperation (new OperationAbortRuntimeInvoke (this, result)); return; } Backtrace bt = new Backtrace (current_frame); bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, cframe.StackPointer, -1); if (bt.Count < 2) throw new TargetException (TargetError.NoStack); // // Walk the stack and check whether we can abort this invocation. // bool stack_ok = true; for (int i = 0; i < bt.Count; i++) { StackFrame frame = bt.Frames [i]; Report.Debug (DebugFlags.SSE, "{0} do abort invocation - frame {1} ({2}:{3}): {4}", this, i, frame.Type, frame.IsManaged, frame); if ((frame.Type == FrameType.Normal) && frame.IsManaged) { continue; } else if ((frame.Type == FrameType.RuntimeInvoke) && (i + 1 == bt.Count)) break; stack_ok = false; break; } if (!stack_ok) throw new TargetException (TargetError.InvalidReturn, "Cannot abort an invocation which contains non-managed frames."); // // We're all set - the stack only contains managed frames, so we can go ahead here. // PushOperation (new OperationReturn (this, bt, ReturnMode.Invocation, result)); }
static void Cleanup() { DebuggerSession currentSession; StatusBarIcon currentIcon; IConsole currentConsole; lock (cleanup_lock) { if (!IsDebugging) { return; } currentIcon = busyStatusIcon; currentSession = session; currentConsole = console; currentBacktrace = null; busyStatusIcon = null; session = null; console = null; pinnedWatches.InvalidateAll(); } if (oldLayout != null) { string layout = oldLayout; oldLayout = null; UnsetDebugLayout(layout); } currentSession.BusyStateChanged -= OnBusyStateChanged; currentSession.TargetEvent -= OnTargetEvent; currentSession.TargetStarted -= OnStarted; currentSession.BreakpointTraceHandler = null; currentSession.GetExpressionEvaluator = null; currentSession.TypeResolverHandler = null; currentSession.OutputWriter = null; currentSession.LogWriter = null; if (currentConsole != null) { currentConsole.CancelRequested -= OnCancelRequested; currentConsole.Dispose(); } DispatchService.GuiDispatch(delegate { HideExceptionCaughtDialog(); if (currentIcon != null) { currentIcon.Dispose(); currentIcon = null; } if (StoppedEvent != null) { StoppedEvent(null, new EventArgs()); } NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); currentSession.Dispose(); }
public OperationReturn(SingleSteppingEngine sse, Backtrace bt, ReturnMode mode, CommandResult result) : base(sse, result) { this.Backtrace = bt; this.Mode = mode; }
void frames_invalid() { current_frame = null; current_backtrace = null; registers = null; }
public override Backtrace GetBacktrace(Backtrace.Mode mode, int max_frames) { current_backtrace = new Backtrace (CurrentFrame); current_backtrace.GetBacktrace ( this, TargetAccess, mode, TargetAddress.Null, max_frames); return current_backtrace; }
void restore_stack(StackData stack) { if (inferior.CurrentFrame != stack.Address) { Report.Debug (DebugFlags.SSE, "{0} discarding saved stack: stopped " + "at {1}, but recorded {2}", this, inferior.CurrentFrame, stack.Frame.TargetAddress); frame_changed (inferior.CurrentFrame, null); return; } current_method = stack.Method; current_frame = stack.Frame; current_backtrace = stack.Backtrace; registers = stack.Registers; }
public override CommandResult Return(ReturnMode mode) { return (CommandResult) SendCommand (delegate { if (!engine_stopped) { Report.Debug (DebugFlags.Wait, "{0} not stopped", this); throw new TargetException (TargetError.NotStopped); } if (current_frame == null) throw new TargetException (TargetError.NoStack); process.UpdateSymbolTable (inferior); if (!process.IsManagedApplication) { if (mode == ReturnMode.Managed) mode = ReturnMode.Native; else if (mode == ReturnMode.Invocation) throw new TargetException (TargetError.InvalidReturn, "Not a managed application."); } CommandResult result = new ThreadCommandResult (thread); Backtrace bt = new Backtrace (current_frame); if (mode == ReturnMode.Invocation) { var cframe = inferior.GetCallbackFrame (current_frame.StackPointer, false); if (cframe == null) throw new TargetException (TargetError.NoInvocation); if (MonoDebuggerInfo.HasAbortRuntimeInvoke) { OperationRuntimeInvoke rti = rti_stack.Peek (); if (rti.ID != cframe.ID) throw new TargetException (TargetError.NoInvocation); return StartOperation (new OperationAbortRuntimeInvoke (this, result)); } bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, cframe.StackPointer, -1); for (int i = 0; i < bt.Count; i++) { if ((bt.Frames [i].Type == FrameType.Normal) && bt.Frames [i].IsManaged) continue; else if ((bt.Frames [i].Type == FrameType.RuntimeInvoke) && (i + 1 == bt.Count)) break; throw new TargetException (TargetError.InvalidReturn, "Cannot abort an invocation which contains non-managed frames."); } } else { bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, TargetAddress.Null, 2); } if (bt.Count < 2) throw new TargetException (TargetError.NoStack); StackFrame parent_frame = bt.Frames [1]; if (parent_frame == null) return null; Report.Debug (DebugFlags.SSE, "{0} return: {1} {2} {3}", this, mode, current_frame.Type, parent_frame.Type); if (mode == ReturnMode.Native) { if ((current_frame.Type == FrameType.Signal) || (parent_frame.Type == FrameType.Signal) || (current_frame.Type == FrameType.Callback) || (parent_frame.Type == FrameType.Callback)) throw new TargetException (TargetError.InvalidReturn, "Cannot return from a signal handler or mdb-internal callback."); if ((current_frame.Type != FrameType.Normal) || (parent_frame.Type != FrameType.Normal)) throw new TargetException (TargetError.InvalidReturn); } else if (mode == ReturnMode.Managed) { bool ok = true; if (current_frame.Type == FrameType.Normal) { if (!current_frame.IsManaged) ok = false; } else { if (current_frame.Type == FrameType.RuntimeInvoke) throw new TargetException (TargetError.InvalidReturn, "Cannot return from an invocation."); ok = false; } if (parent_frame.Type == FrameType.Normal) { if (!parent_frame.IsManaged) ok = false; } else { if (parent_frame.Type == FrameType.RuntimeInvoke) throw new TargetException (TargetError.InvalidReturn, "Cannot return from an invocation."); ok = false; } if (!ok) throw new TargetException (TargetError.InvalidReturn, "Cannot return from a non-managed frame."); } if (mode == ReturnMode.Native) { inferior.SetRegisters (parent_frame.Registers); frame_changed (inferior.CurrentFrame, null); TargetEventArgs args = new TargetEventArgs ( TargetEventType.TargetStopped, 0, current_frame); process.Debugger.OnTargetEvent (thread, args); return null; } return StartOperation (new OperationReturn (this, bt, mode, result)); }); }
public StackData(long id, Method method, TargetAddress address, StackFrame frame, Backtrace backtrace, Registers registers) { this.ID = id; this.Method = method; this.Address = address; this.Frame = frame; this.Backtrace = backtrace; this.Registers = registers; }
public override Backtrace GetBacktrace(Backtrace.Mode mode, int max_frames) { return (Backtrace) SendCommand (delegate { if (!engine_stopped) { Report.Debug (DebugFlags.Wait, "{0} not stopped", this); throw new TargetException (TargetError.NotStopped); } process.UpdateSymbolTable (inferior); if (current_frame == null) throw new TargetException (TargetError.NoStack); current_backtrace = new Backtrace (current_frame); current_backtrace.GetBacktrace ( this, inferior, mode, TargetAddress.Null, max_frames); return current_backtrace; }); }
protected override object DoExecute(ScriptingContext context) { Backtrace backtrace = null; if ((mode == Backtrace.Mode.Default) && (max_frames == -1)) { backtrace = CurrentThread.CurrentBacktrace; } if (backtrace == null) { backtrace = CurrentThread.GetBacktrace(mode, max_frames); } for (int i = 0; i < backtrace.Count; i++) { string prefix = i == backtrace.CurrentFrameIndex ? "(*)" : " "; context.Print("{0} {1}", prefix, backtrace [i]); EmonicInterpreter.backtraceData bt = new EmonicInterpreter.backtraceData(); bt.frameNumber = backtrace[i].Level; bt.currentFrame = i == backtrace.CurrentFrameIndex; if (backtrace[i].Method != null) { bt.method = backtrace[i].Method.Name; if (bt.method == null) { bt.method = ""; } } else { if (backtrace[i].Name == null) { bt.method = ""; } else { bt.method = backtrace[i].Name.ToString(); if (bt.method == null) { bt.method = ""; } } } if (backtrace[i].SourceAddress != null && backtrace[i].SourceAddress.SourceFile != null) { bt.file = backtrace[i].SourceAddress.SourceFile.FileName; } else { bt.file = ""; } if (backtrace[i].SourceAddress != null) { bt.lineNumber = backtrace[i].SourceAddress.Row; } else { bt.lineNumber = -1; } if (i + 1 < backtrace.Count) { bt.moreData = true; } else { bt.moreData = false; } EmonicInterpreter.backtraceList.Add(bt); } return(backtrace); }
public virtual ErrorBuilder SetBacktrace(Backtrace backtrace) { this.Backtrace = backtrace; return(this); }
StackData save_stack(long id) { // // Save current state. // StackData stack_data = new StackData ( id, current_method, inferior.CurrentFrame, current_frame, current_backtrace, registers); current_method = null; current_frame = null; current_backtrace = null; registers = null; return stack_data; }
static void Cleanup() { DebuggerSession currentSession; StatusBarIcon currentIcon; OperationConsole currentConsole; lock (cleanup_lock) { if (!IsDebugging) { return; } currentIcon = busyStatusIcon; currentSession = session; currentConsole = console; nextStatementLocations.Clear(); currentBacktrace = null; busyStatusIcon = null; session = null; console = null; pinnedWatches.InvalidateAll(); } UnsetDebugLayout(); currentSession.BusyStateChanged -= OnBusyStateChanged; currentSession.TargetEvent -= OnTargetEvent; currentSession.TargetStarted -= OnStarted; currentSession.BreakpointTraceHandler = null; currentSession.GetExpressionEvaluator = null; currentSession.TypeResolverHandler = null; currentSession.OutputWriter = null; currentSession.LogWriter = null; currentDebugOperation.Cleanup(); if (currentConsole != null) { cancelRegistration.Dispose(); currentConsole.Dispose(); } Runtime.RunInMainThread(delegate { HideExceptionCaughtDialog(); if (currentIcon != null) { currentIcon.Dispose(); currentIcon = null; } if (StoppedEvent != null) { StoppedEvent(null, new EventArgs()); } NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); currentSession.Dispose(); }
/// <summary> /// [time diff: uleb128] nanoseconds since last timing /// if exinfo.low3bits == TypeException.Throw /// [object: sleb128] the object that was thrown as a difference from obj_base /// If the TypeException.ExceptionBt flag is set, a backtrace follows. /// </summary> /// <param name="obj">the object that was thrown as a difference from obj_base If the TypeException.ExceptionBt flag is set, a backtrace follows.</param> /// <param name="backtrace">The backtrace</param> public virtual void HandleExceptionThrow(long obj, Backtrace backtrace) { }
public void Main() { Process process = Start(); Assert.IsTrue(process.IsManaged); Assert.IsTrue(process.MainThread.IsStopped); Thread thread = process.MainThread; const int line_main = 33; const int line_hello = 13; const int line_hello_2 = 20; const int line_hello_3 = 22; AssertStopped(thread, "X.Main()", line_main); AssertExecute("call Hello()"); AssertStopped(thread, "X.Hello()", line_hello); Backtrace bt = thread.GetBacktrace(-1); if (bt.Count != 3) { Assert.Fail("Backtrace has {0} frames, but expected {1}.", bt.Count, 5); } AssertFrame(bt [0], 0, "X.Hello()", line_hello); AssertRuntimeInvokeFrame(bt [1], 1, "X.Hello()"); AssertFrame(bt [2], 2, "X.Main()", line_main); AssertExecute("continue"); AssertTargetOutput("Hello World"); AssertRuntimeInvokeDone(thread, "X.Main()", line_main); AssertExecute("call Hello()"); AssertStopped(thread, "X.Hello()", line_hello); AssertExecute("return -yes"); AssertRuntimeInvokeDone(thread, "X.Main()", line_main); AssertExecute("call Hello (8)"); AssertStopped(thread, "X.Hello(int)", line_hello_2); AssertExecute("return -yes"); AssertRuntimeInvokeDone(thread, "X.Main()", line_main); AssertExecute("call Hello (9)"); AssertStopped(thread, "X.Hello(int)", line_hello_2); AssertExecute("step"); AssertStopped(thread, "X.Hello(int)", line_hello_3); AssertExecute("return -yes"); AssertTargetOutput("Done: 9 18 1"); AssertNoTargetOutput(); AssertRuntimeInvokeDone(thread, "X.Main()", line_main); bt = thread.GetBacktrace(-1); if (bt.Count != 1) { Assert.Fail("Backtrace has {0} frames, but expected {1}.", bt.Count, 1); } AssertFrame(bt [0], 0, "X.Main()", line_main); AssertExecute("call Hello (7)"); AssertStopped(thread, "X.Hello(int)", line_hello_2); AssertExecute("step"); AssertStopped(thread, "X.Hello(int)", line_hello_3); AssertExecute("step"); AssertStopped(thread, "X.Hello()", line_hello); bt = thread.GetBacktrace(-1); if (bt.Count != 4) { Assert.Fail("Backtrace has {0} frames, but expected {1}.", bt.Count, 6); } AssertFrame(bt [0], 0, "X.Hello()", line_hello); AssertFrame(bt [1], 1, "X.Hello(int)", line_hello_3); AssertRuntimeInvokeFrame(bt [2], 2, "X.Hello(int)"); AssertFrame(bt [3], 3, "X.Main()", line_main); AssertExecute("return -yes -invocation"); AssertTargetOutput("Done: 7 14 2"); AssertNoTargetOutput(); AssertRuntimeInvokeDone(thread, "X.Main()", line_main); bt = thread.GetBacktrace(-1); if (bt.Count != 1) { Assert.Fail("Backtrace has {0} frames, but expected {1}.", bt.Count, 1); } AssertFrame(bt [0], 0, "X.Main()", line_main); AssertExecute("continue"); AssertTargetOutput("Hello World"); AssertTargetOutput("Done: 5 10 3"); AssertTargetOutput("3"); AssertTargetExited(thread.Process); }
/// <summary> /// exinfo: flags: TYPE_ALLOC_BT /// [time diff: uleb128] nanoseconds since last timing /// [ptr: sleb128] class as a byte difference from ptr_base /// [obj: sleb128] object address as a byte difference from obj_base /// [size: uleb128] size of the object in the heap /// If the TYPE_ALLOC_BT flag is set, a backtrace follows. /// </summary> /// <param name="ptr">The class as a byte difference from ptr_base.</param> /// <param name="obj">The object address as a byte difference from obj_base.</param> /// <param name="size">The size of the object in the heap.</param> /// <param name="backtrace">The backtrace.</param> public virtual void HandleAlloc(long ptr, long obj, ulong size, Backtrace backtrace) { }
static void Cleanup() { DebuggerSession currentSession; StatusBarIcon currentIcon; IConsole currentConsole; lock (cleanup_lock) { if (!IsDebugging) { return; } currentIcon = busyStatusIcon; currentSession = session; currentConsole = console; currentBacktrace = null; busyStatusIcon = null; session = null; console = null; } if (oldLayout != null) { string layout = oldLayout; oldLayout = null; // Dispatch synchronously to avoid start/stop races DispatchService.GuiSyncDispatch(delegate { IdeApp.Workbench.HideCommandBar("Debug"); if (IdeApp.Workbench.CurrentLayout == "Debug") { IdeApp.Workbench.CurrentLayout = layout; } }); } currentSession.BusyStateChanged -= OnBusyStateChanged; currentSession.TargetEvent -= OnTargetEvent; currentSession.TargetStarted -= OnStarted; currentSession.BreakpointTraceHandler = null; currentSession.GetExpressionEvaluator = null; currentSession.TypeResolverHandler = null; currentSession.OutputWriter = null; currentSession.LogWriter = null; if (currentConsole != null) { currentConsole.CancelRequested -= OnCancelRequested; currentConsole.Dispose(); } DispatchService.GuiDispatch(delegate { HideExceptionCaughtDialog(); if (currentIcon != null) { currentIcon.Dispose(); currentIcon = null; } if (StoppedEvent != null) { StoppedEvent(null, new EventArgs()); } NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); currentSession.Dispose(); }
public void Main() { Process process = Start(); Assert.IsTrue(process.IsManaged); Assert.IsTrue(process.MainThread.IsStopped); Thread thread = process.MainThread; AssertStopped(thread, "X.Main()", GetLine("main")); int invalid_op_catchpoint = AssertCatchpoint("InvalidOperationException"); AssertExecute("continue"); AssertCaughtException(thread, "X.Test()", GetLine("exception")); AssertNoTargetOutput(); Backtrace bt = thread.GetBacktrace(-1); if (bt.Count != 2) { Assert.Fail("Backtrace has {0} frames, but expected {1}.", bt.Count, 2); } AssertFrame(bt [0], 0, "X.Test()", GetLine("exception")); AssertFrame(bt [1], 1, "X.Main()", GetLine("try") + 1); AssertExecute("continue"); AssertTargetOutput("EXCEPTION: System.InvalidOperationException"); AssertNoTargetOutput(); AssertHitBreakpoint(thread, "main2", "X.Main()"); AssertPrintException(thread, "x.Test()", "Invocation of `x.Test ()' raised an exception: " + "System.InvalidOperationException: Operation is not " + "valid due to the current state of the object\n" + " at X.Test () [0x00000] in " + FileName + ":" + GetLine("exception") + " "); AssertExecute("continue"); AssertTargetOutput("Done"); AssertHitBreakpoint(thread, "try my", "X.TestMy()"); // Stop when `MyException' is thrown. int my_exc_catchpoint = AssertCatchpoint("MyException"); AssertExecute("continue"); AssertCaughtException(thread, "X.ThrowMy()", GetLine("throw my")); AssertExecute("continue"); AssertTargetOutput("MY EXCEPTION: MyException"); AssertHitBreakpoint(thread, "main3", "X.Main()"); // Make it a catchpoint for unhandled `MyException' exceptions only. AssertExecute("delete " + my_exc_catchpoint); AssertExecute("delete " + invalid_op_catchpoint); my_exc_catchpoint = AssertUnhandledCatchpoint("MyException"); // `MyException' is thrown, but we don't stop since we're only interested // in unhandled instances of it. AssertExecute("continue"); AssertTargetOutput("True"); AssertHitBreakpoint(thread, "main4", "X.Main()"); AssertPrint(thread, "catched", "(bool) true"); AssertExecute("continue"); AssertCaughtUnhandledException(thread, "X.ThrowMy()", GetLine("throw my")); AssertExecute("continue"); AssertNoTargetOutput(); AssertTargetExited(thread.Process); }
static void Cleanup() { if (oldLayout != null) { string layout = oldLayout; oldLayout = null; // Dispatch asynchronously to avoid start/stop races DispatchService.GuiSyncDispatch(delegate { if (IdeApp.Workbench.CurrentLayout == "Debug") { IdeApp.Workbench.CurrentLayout = layout; } }); } currentBacktrace = null; if (!IsDebugging) { return; } if (busyStatusIcon != null) { busyStatusIcon.Dispose(); busyStatusIcon = null; } session.TargetEvent -= OnTargetEvent; session.TargetStarted -= OnStarted; session.OutputWriter = null; session.LogWriter = null; session.BusyStateChanged -= OnBusyStateChanged; session.TypeResolverHandler = null; session.BreakpointTraceHandler = null; session.GetExpressionEvaluator = null; console.CancelRequested -= OnCancelRequested; // Dispose the session at the end, since it may take a while. DebuggerSession oldSession = session; session = null; DispatchService.GuiDispatch(delegate { if (StoppedEvent != null) { StoppedEvent(null, new EventArgs()); } }); if (console != null) { console.Dispose(); console = null; } DispatchService.GuiDispatch(delegate { NotifyCallStackChanged(); NotifyCurrentFrameChanged(); NotifyLocationChanged(); }); if (oldSession != null) { oldSession.BusyStateChanged -= OnBusyStateChanged; oldSession.Dispose(); } }
public StackTracePad() { this.ShadowType = ShadowType.None; ActionCommand evalCmd = new ActionCommand("StackTracePad.EvaluateMethodParams", GettextCatalog.GetString("Evaluate Method Parameters")); ActionCommand gotoCmd = new ActionCommand("StackTracePad.ActivateFrame", GettextCatalog.GetString("Activate Stack Frame")); menuSet = new CommandEntrySet(); menuSet.Add(evalCmd); menuSet.Add(gotoCmd); menuSet.AddSeparator(); menuSet.AddItem(EditCommands.SelectAll); menuSet.AddItem(EditCommands.Copy); store = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Pango.Style), typeof(object), typeof(bool)); tree = new PadTreeView(store); tree.RulesHint = true; tree.HeadersVisible = true; tree.Selection.Mode = SelectionMode.Multiple; tree.SearchEqualFunc = Search; tree.EnableSearch = true; tree.SearchColumn = 1; tree.ButtonPressEvent += HandleButtonPressEvent; tree.DoPopupMenu = ShowPopup; TreeViewColumn col = new TreeViewColumn(); CellRenderer crp = new CellRendererIcon(); col.PackStart(crp, false); col.AddAttribute(crp, "stock_id", 0); tree.AppendColumn(col); TreeViewColumn FrameCol = new TreeViewColumn(); FrameCol.Title = GettextCatalog.GetString("Name"); refresh = new CellRendererIcon(); refresh.Pixbuf = ImageService.GetPixbuf(Gtk.Stock.Refresh).ScaleSimple(12, 12, Gdk.InterpType.Hyper); FrameCol.PackStart(refresh, false); FrameCol.AddAttribute(refresh, "visible", 8); FrameCol.PackStart(tree.TextRenderer, true); FrameCol.AddAttribute(tree.TextRenderer, "text", 1); FrameCol.AddAttribute(tree.TextRenderer, "foreground", 5); FrameCol.AddAttribute(tree.TextRenderer, "style", 6); FrameCol.Resizable = true; FrameCol.Alignment = 0.0f; tree.AppendColumn(FrameCol); col = new TreeViewColumn(); col.Title = GettextCatalog.GetString("File"); col.PackStart(tree.TextRenderer, false); col.AddAttribute(tree.TextRenderer, "text", 2); col.AddAttribute(tree.TextRenderer, "foreground", 5); tree.AppendColumn(col); col = new TreeViewColumn(); col.Title = GettextCatalog.GetString("Language"); col.PackStart(tree.TextRenderer, false); col.AddAttribute(tree.TextRenderer, "text", 3); col.AddAttribute(tree.TextRenderer, "foreground", 5); tree.AppendColumn(col); col = new TreeViewColumn(); col.Title = GettextCatalog.GetString("Address"); col.PackStart(tree.TextRenderer, false); col.AddAttribute(tree.TextRenderer, "text", 4); col.AddAttribute(tree.TextRenderer, "foreground", 5); tree.AppendColumn(col); Add(tree); ShowAll(); current_backtrace = DebuggingService.CurrentCallStack; UpdateDisplay(); DebuggingService.CallStackChanged += (EventHandler)DispatchService.GuiDispatch(new EventHandler(OnClassStackChanged)); DebuggingService.CurrentFrameChanged += (EventHandler)DispatchService.GuiDispatch(new EventHandler(OnFrameChanged)); tree.RowActivated += OnRowActivated; }
public abstract Backtrace GetBacktrace(Backtrace.Mode mode, int max_frames);
/// <summary> /// exinfo: TYPE_MONITOR_BT flag and one of: MONO_PROFILER_MONITOR_(CONTENTION|FAIL|DONE) /// [time diff: uleb128] nanoseconds since last timing /// [object: sleb128] the lock object as a difference from obj_base /// if exinfo.low3bits == MONO_PROFILER_MONITOR_CONTENTION /// If the TYPE_MONITOR_BT flag is set, a backtrace follows. /// </summary> /// <param name="obj">the lock object as a difference from obj_base</param> /// <param name="backtrace">The backtrace</param> public virtual void HandleMonitor(long obj, Backtrace backtrace) { }