internal void OnException(ExceptionEvent e) { var frames = new LiveStack(e.Thread); LiveStackFrame frame = frames[0]; Boss boss = ObjectModel.Create("Application"); var exceptions = boss.Get<IExceptions>(); if (!DoIsIgnoredException(e.Exception.Type, exceptions.Ignored, frame.Method.Name)) { m_currentThread = e.Thread; if (m_stepRequest != null) { m_stepRequest.Disable(); m_stepRequest = null; } if (DebuggerWindows.WriteEvents) m_transcript.WriteLine(Output.Normal, "{0} exception was thrown at {1}:{2:X4}", e.Exception.Type.FullName, frame.Method.FullName, frame.ILOffset); var context = new Context(e.Thread, frame.Method, frame.ILOffset); Broadcaster.Invoke("debugger thrown exception", context); } else { m_transcript.WriteLine(Output.Normal, "Ignoring {0} in {1}:{2}", e.Exception.Type.FullName, frame.Method.DeclaringType.Name, frame.Method.Name); m_thread.Resume(); } }
public void doubleClicked(NSObject sender) { int row = m_table.selectedRow(); if (!m_threads[row].IsCollected) { var stack = new LiveStack(m_threads[row]); if (stack.Length > 0) { m_selected = row; m_table.reloadData(); Broadcaster.Invoke("changed thread", stack); } else { Boss boss = ObjectModel.Create("Application"); var transcript = boss.Get<ITranscript>(); transcript.Show(); transcript.WriteLine(Output.Error, "{0}", "The thread has no stack frames."); } } }
internal void OnBreakpoint(BreakpointEvent e, ResolvedBreakpoint bp) { m_currentThread = e.Thread; var frames = new LiveStack(m_currentThread); Contract.Assert(BreakpointCondition != null, "BreakpointCondition is null"); DebuggerThread.HandlerAction action = BreakpointCondition(frames[0], bp.BreakPoint); if (action == DebuggerThread.HandlerAction.Suspend) { if (m_stepRequest != null) { m_stepRequest.Disable(); m_stepRequest = null; } Log.WriteLine(TraceLevel.Info, "Debugger", "Hit breakpoint at {0}:{1:X4}", e.Method.FullName, bp.Offset); var context = new Context(e.Thread, e.Method, bp.Offset); Broadcaster.Invoke("debugger processed breakpoint event", context); if (!NSApplication.sharedApplication().isActive()) NSApplication.sharedApplication().activateIgnoringOtherApps(true); } else { Log.WriteLine(TraceLevel.Info, "Debugger", "ignoring breakpoint at {0}:{1:X4} (condition evaluated to false)", e.Method.FullName, bp.Offset); m_thread.Resume(); } }
public void OnBroadcast(string name, object value) { switch (name) { case "debugger stopped": m_stack = null; m_table.reloadData(); break; case "debugger processed breakpoint event": case "debugger thrown exception": case "debugger processed step event": case "debugger break all": var context = (Context) value; var stack = new LiveStack(context.Thread); // Note that the new stack should almost always be different than the cached // stack so there isn't much point in comparing the two (and the equals operator // doesn't compare IL offsets (if it did then stepping would cause stacks to compare // different and the variables window would do a full refresh instead of a partial // refresh and we'd lose the ability to draw changes in red)). m_stack = stack; m_selected = 0; m_table.reloadData(); m_table.scrollRowToVisible(m_stack.Length - 1); break; case "changed thread": var stack2 = (LiveStack) value; if (stack2 != m_stack) { m_stack = stack2; m_selected = 0; m_table.reloadData(); m_table.scrollRowToVisible(m_stack.Length - 1); } break; case "debugger state changed": var state = (State) value; if (state != m_state) { m_state = state; if (state != State.Paused && state != State.Running && m_stack != null) { m_stack = null; m_table.reloadData(); } } break; default: Contract.Assert(false, "bad name: " + name); break; } }