public void RemoveBreakpoint(Breakpoint breakpoint) { if (breakpointCollection.Contains(breakpoint)) { breakpoint.Deactivate(); breakpointCollection.Remove(breakpoint); OnBreakpointRemoved(breakpoint); } }
public IBreakpoint AddBreakpoint(string file, int line) { file = typeProvider.MapFile (file); if (file == null) return null; var bp = new Breakpoint (new Location (file, line)); if (AddBreakpoint (bp)) return bp; return null; }
public Breakpoint AddBreakpoint(Breakpoint breakpoint) { breakpointCollection.Add(breakpoint); foreach(Process process in this.Processes) { foreach(Module module in process.Modules) { breakpoint.SetBreakpoint(module); } } OnBreakpointAdded(breakpoint); return breakpoint; }
internal Breakpoint AddBreakpoint(Breakpoint breakpoint) { breakpointCollection.Add(breakpoint); foreach(Process process in this.Processes) { foreach(Module module in process.Modules) { breakpoint.SetBreakpoint(module); } } breakpoint.Changed += new EventHandler<BreakpointEventArgs>(OnBreakpointStateChanged); breakpoint.Hit += new EventHandler<BreakpointEventArgs>(OnBreakpointHit); OnBreakpointAdded(breakpoint); return breakpoint; }
public void RemoveBreakpoint(Breakpoint bp, MethodMirror method, long ilOffset) { Contract.Requires(method != null, "method is null"); var resolved = new ResolvedBreakpoint(bp, method, ilOffset); lock (m_mutex) { BreakpointEventRequest request; if (m_breakpoints.TryGetValue(resolved, out request)) { Log.WriteLine(TraceLevel.Info, "Debugger", "Removing breakpoint from {0}:{1:X4}", method.FullName, ilOffset); request.Disable(); m_breakpoints.Remove(resolved); } } m_debugger.OnUnresolvedBreakpoint(bp); }
public void RunToCursor() { try { //cur_brpt = dbg.AddBreakpoint(new SourcecodeSegment((frm.CurrentTabPage.ag as CodeFileDocumentControl).FileName,(frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Line + 1,(frm.CurrentTabPage.Tag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column + 1, // (frm.CurrentTabPage.ag as CodeFileDocumentControl).TextEditor.ActiveTextAreaControl.Caret.Column+100), true); workbench.WidgetController.SetStartDebugDisabled(); currentBreakpoint = dbg.AddBreakpoint(WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.FileName, WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1); AddGoToBreakPoint(currentBreakpoint); Status = DebugStatus.None; dbg.Processes[0].Continue(); //dbg.RemoveBreakpoint(cur_brpt); CurrentLineBookmark.Remove(); } catch (System.Exception e) { } }
protected virtual void OnBreakpointRemoved(Breakpoint breakpoint) { if (BreakpointRemoved != null) { BreakpointRemoved(this, new BreakpointEventArgs(breakpoint)); } }
public void AddBreakpoint(Breakpoint bp, MethodMirror method, long ilOffset) { Contract.Requires(method != null, "method is null"); var resolved = new ResolvedBreakpoint(bp, method, ilOffset); lock (m_mutex) { if (!m_breakpoints.ContainsKey(resolved)) { Log.WriteLine(TraceLevel.Info, "Debugger", "Adding breakpoint to {0}:{1:X4}", method.FullName, ilOffset); BreakpointEventRequest request = m_debugger.VM.CreateBreakpointRequest(method, ilOffset); request.Enable(); m_breakpoints.Add(resolved, request); } } NSApplication.sharedApplication().BeginInvoke(() => m_debugger.OnResolvedBreakpoint(resolved)); }
public void SetFirstBreakpoint(string fileName, int line) { brPoint = dbg.AddBreakpoint(fileName, line); }
/// <summary> /// Перейти к следующей строке при отладке /// </summary> private void JumpToCurrentLine() { workbench.MainForm.Activate(); CurrentLineBookmark.Remove();//udalajem zheltyj kursor otladki //System.Threading.Thread.Sleep(70); if (debuggedProcess != null) { SourcecodeSegment nextStatement = debuggedProcess.NextStatement; //debuggedProcess.Modules[0].SymReader.GetMethod(debuggedProcess.SelectedFunction.Token); if (nextStatement != null) { string save_PrevFullFileName = PrevFullFileName; //CodeFileDocumentControl page = null; //DebuggerService.JumpToCurrentLine(nextStatement.SourceFullFilename, nextStatement.StartLine, nextStatement.StartColumn, nextStatement.EndLine, nextStatement.EndColumn); if (!show_debug_tabs)//esli eshe ne pokazany watch i lokal, pokazyvaem { show_debug_tabs = true; workbench.WidgetController.SetDebugTabsVisible(true); workbench.WidgetController.SetAddExprMenuVisible(true); } if (debuggedProcess.NextStatement.StartLine == 0xFFFFFF) { //sjuda popadem, esli vyzyvaem Test(arr), gde arr - massiv peredavaemyj po znacheniju //metod $Copy ne imeet sequence pointov, poetomu chtoby vojti v proceduru vyzovy $Copy my pomechaem 0xFFFFFFF //dolgo s etoj badjagoj muchalsja is_out = true; debuggedProcess.StepInto();//vhodim neposredstvenno v proceduru return; } else if (AssemblyHelper.IsDebuggerStepThrough(debuggedProcess.SelectedFunction)) { MustDebug = true; debuggedProcess.StepOut(); return; } else if (is_out == true) { is_out = false; if (stepin_stmt.SourceFullFilename == debuggedProcess.NextStatement.SourceFullFilename && stepin_stmt.StartLine != debuggedProcess.NextStatement.StartLine) stepin_stmt = debuggedProcess.NextStatement; else { debuggedProcess.StepInto(); return; } } if (debuggedProcess.NextStatement.SourceFullFilename != this.PrevFullFileName || !WorkbenchServiceFactory.DocumentService.ContainsTab(debuggedProcess.NextStatement.SourceFullFilename)) { tab_changed = true; curPage = WorkbenchServiceFactory.FileService.OpenFileForDebug(debuggedProcess.NextStatement.SourceFullFilename); if (curPage == null) { MustDebug = true; return; } PrevFullFileName = debuggedProcess.NextStatement.SourceFullFilename; } else if (curPage != WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument) WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument = curPage; bool remove_breakpoints = true; IDocument doc = curPage.TextEditor.Document; curTextArea = curPage.TextEditor.ActiveTextAreaControl.TextArea; LineSegment lseg = curPage.TextEditor.ActiveTextAreaControl.Document.GetLineSegment(debuggedProcess.NextStatement.StartLine - 1); int len = lseg.Length + 1; /*if (lseg.Words.Count == 1 && string.Compare(lseg.Words[0].Word,"begin",true)==0) { debuggedProcess.StepOver(); return; }*/ //eto badjaga prepjatstvuet popadaniju na begin //luchshego sposoba naverno net bool in_comm = false; bool beg = false; bool in_str = false; for (int i = 0; i < lseg.Words.Count; i++) { if (lseg.Words[i].Type == TextWordType.Word) { string word = lseg.Words[i].Word; if (string.Compare(word, "begin", true) == 0 && !in_str && !in_comm) beg = true; else if (string.Compare(word, "{") == 0) { if (!in_str) in_comm = true; } else if (string.Compare(word, "}") == 0) { if (!in_str && in_comm) in_comm = false; } else if (string.Compare(word, "'") == 0) in_str = !in_str; else if (string.Compare(word, "/") == 0) { if (i < lseg.Words.Count - 1 && string.Compare(lseg.Words[i + 1].Word, "/") == 0) break; } else if (string.Compare(word, "(") == 0) { if (i < lseg.Words.Count - 1 && string.Compare(lseg.Words[i + 1].Word, "*") == 0) { beg = false; break; } } else if (!in_str && !in_comm) { beg = false; break; } } } if (beg) { if (debuggedProcess.PausedReason != PausedReason.Exception) debuggedProcess.StepOver(); return; } if (debuggedProcess.PausedReason == PausedReason.Breakpoint) { Breakpoint br = dbg.GetBreakpoint(debuggedProcess.NextStatement.SourceFullFilename, nextStatement.StartLine); if (br != null && !BreakPointFactory.MustHit(br)) { if (Status == DebugStatus.StepOver || Status == DebugStatus.StepIn) { remove_breakpoints = false; } else { debuggedProcess.Continue(); return; } } } //for (int i=0; i<lseg.Words.Count; i++) CurrentLineBookmark.SetPosition(debuggedProcess.NextStatement.SourceFilename, curPage.TextEditor.Document, nextStatement.StartLine, 1, nextStatement.StartLine, len); curPage.TextEditor.ActiveTextAreaControl.JumpTo(nextStatement.StartLine - 1, 0); if ((Status == DebugStatus.StepOver || Status == DebugStatus.StepIn) && (CurrentLine == nextStatement.StartLine && save_PrevFullFileName == debuggedProcess.NextStatement.SourceFilename)) { if (curILOffset != nextStatement.ILOffset) { curILOffset = nextStatement.ILOffset; //debuggedProcess.StepOver(); MustDebug = true; } CurrentLine = nextStatement.StartLine; //return; } else { curILOffset = nextStatement.ILOffset; CurrentLine = nextStatement.StartLine; MustDebug = false; //MustDebug = ((nextStatement.ILOffset + 1) == nextStatement.ILEnd); } //MustDebug = false; //if (remove_breakpoints) { RemoveBreakpoints(); if (currentBreakpoint != null) { dbg.RemoveBreakpoint(currentBreakpoint); currentBreakpoint = null; //RemoveBreakpoints(); } } } } }
private void DoRemovingBreakpoint(Breakpoint bp) { MethodMirror method; int offset; if (DoTryGetMethod(bp, out method, out offset)) { m_thread.RemoveBreakpoint(bp, method, offset); } }
/// <summary> /// Запуск процесса на отладку /// </summary> /// <param name="fileName">Имя ехе-файла</param> /// <param name="sourceFileName">Имя исходного файла</param> /// <param name="workingDirectory">Каталог файла</param> /// <param name="arguments">Аргументы командной строки</param> /// <param name="need_first_brpt">Флаг, нужно ли устанавливать Breakpoint на первом операторе (F8, F7)</param> /// <param name="redirectOutput">Временно не используется</param> public void Start(string fileName, string sourceFileName, string workingDirectory, string arguments, bool need_first_brpt, bool redirectOutput) { if (Starting != null) Starting(fileName); //dbg = new NDebugger(); dbg.ProcessStarted += debugProcessStarted; dbg.ProcessExited += debugProcessExit; dbg.BreakpointHit += debugBreakpointHit; //if (brPoint != null) dbg.RemoveBreakpoint(brPoint); this.FileName = sourceFileName;//Path.GetFileNameWithoutExtension(fileName) + ".pas"; this.FullFileName = Path.Combine(Path.GetDirectoryName(fileName), this.FileName); this.ExeFileName = fileName; this.PrevFullFileName = FullFileName; if (need_first_brpt) brPoint = dbg.AddBreakpoint(FileName, workbench.VisualEnvironmentCompiler.Compiler.BeginOffset); AssemblyHelper.LoadAssembly(fileName); debuggedProcess = dbg.Start(fileName, workingDirectory, arguments); SelectProcess(debuggedProcess); }
internal void OnUnresolvedBreakpoint(Breakpoint bp) { Broadcaster.Invoke("debugger unresolved breakpoint", bp); }
private void DoAddedBreakpoint(Breakpoint bp) { MethodMirror method; int offset; if (DoTryGetMethod(bp, out method, out offset)) { m_thread.AddBreakpoint(bp, method, offset); } }
public BreakpointEventArgs(Breakpoint breakpoint) : base(breakpoint.Debugger) { this.breakpoint = breakpoint; }
public static bool MustHit(Breakpoint br) { BreakpointInfo bi = null; if (breakpoints_conditions.TryGetValue(br,out bi)) { if (!bi.enabled) return true; string cond = bi.condition.Trim(' ','\t'); if (string.IsNullOrEmpty(cond)) return true; try { RetValue res = WorkbenchServiceFactory.DebuggerManager.Evaluate(cond); if (bi.kind == hit_kind.is_true) { if (res.prim_val != null && res.prim_val is bool) { if ((bool)res.prim_val) return true; else return false; } else if (res.obj_val != null && res.obj_val.IsPrimitive && res.obj_val.PrimitiveValue is bool) { if ((bool)res.obj_val.PrimitiveValue) return true; else return false; } else return true; } else { if (res.obj_val != null && res.obj_val.IsPrimitive) { res.prim_val = res.obj_val.PrimitiveValue; res.obj_val = null; } if (!WorkbenchServiceFactory.DebuggerManager.evaluator.IsEqual(res,bi.val)) { bi.val = res; return true; } else return false; } } catch { return true; } } else return true; }
protected internal virtual void OnBreakpointHit(Breakpoint breakpoint) { if (BreakpointHit != null) { BreakpointHit(this, new BreakpointEventArgs(breakpoint)); } }
/// <summary> /// Добавляет Breakpoint по F4 /// </summary> public void AddGoToBreakPoint(Breakpoint br) { goto_brs.Push(br); }
// Adding breakpoints after the program is running should be relatively rare so // we'll save memory by keeping a table of file paths to types instead of file // paths to methods (TypeMirror doesn't store the methods either). private bool DoTryGetMethod(Breakpoint bp, out MethodMirror method, out int offset) { TypeMirror[] types = m_thread.GetTypesDefinedWithin(bp.File); if (types.Length > 0) { foreach (TypeMirror type in types) { foreach (MethodMirror candidate in type.GetMethods()) { if (candidate.SourceFile == bp.File) { Location loc = candidate.Locations.FirstOrDefault(l => l.LineNumber == bp.Line); if (loc != null) { Contract.Assert(loc.Method == candidate, "methods don't match"); Contract.Assert(loc.SourceFile == bp.File, "paths don't match"); method = candidate; offset = loc.ILOffset; return true; } } } } } method = null; offset = 0; return false; }
/// <summary> /// Удалить Breakpoint /// </summary> public void RemoveBreakpoint(Breakpoint br) { dbg.RemoveBreakpoint(br); }
private ITextAnnotation DoCreateBreakpoint(Boss boss, string file, int line) { var metrics = boss.Get<ITextMetrics>(); var range = new NSRange(metrics.GetLineOffset(line), 1); var bp = new Breakpoint(file, line); var editor = boss.Get<ITextEditor>(); ITextAnnotation annotation = editor.GetAnnotation(range, AnnotationAlignment.Center); annotation.BackColor = m_resolved.Contains(bp) ? ms_resolvedColor : ms_unresolvedColor; annotation.Text = "B"; annotation.Draggable = false; annotation.Visible = true; return annotation; }
void debuggedProcess_DebuggeeStateChanged(object sender, ProcessEventArgs e) { if (currentBreakpoint != null) { dbg.RemoveBreakpoint(currentBreakpoint); RemoveGotoBreakpoints(); currentBreakpoint = null; //RemoveBreakpoints(); } JumpToCurrentLine(); //ChangeLocalVars(e.Process); //if (e.Process.IsPaused) WorkbenchServiceFactory.DebuggerOperationsService.RefreshPad(new FunctionItem(e.Process.SelectedFunction).SubItems); workbench.WidgetController.SetStartDebugEnabled(); }
public BreakpointEventArgs(Breakpoint breakpoint): base(breakpoint.Debugger) { this.Breakpoint = breakpoint; }
void RemoveBreakpoints() { if (brPoint != null) { dbg.RemoveBreakpoint(brPoint); brPoint = null; } }
public void RemoveBreakpoint(Breakpoint breakpoint) { breakpoint.Changed -= new EventHandler<BreakpointEventArgs>(OnBreakpointStateChanged); breakpoint.Hit -= new EventHandler<BreakpointEventArgs>(OnBreakpointHit); breakpoint.Enabled = false; breakpointCollection.Remove( breakpoint ); OnBreakpointRemoved( breakpoint); }
public Breakpoint AddBreakpoint(string fileName, int line, int column = 0, bool enabled = true) { Breakpoint breakpoint = new Breakpoint(fileName, line, column, enabled); AddBreakpoint(breakpoint); return breakpoint; }
public static void ToggleBreakpointAtByOpen(IDocument document, string fileName, int lineNumber, Breakpoint br) { foreach (char ch in document.GetText(document.GetLineSegment(lineNumber))) { if (!char.IsWhiteSpace(ch)) { CurrentBreakpointBookmark cbb = new CurrentBreakpointBookmark(fileName, document, lineNumber); breakpoints.Add(cbb, br); document.BookmarkManager.AddMark(cbb); document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, lineNumber)); document.CommitUpdate(); break; } } }
private void DoUnresolvedBreakpoint(Breakpoint bp) { foreach (WindowedBreakpoint wbp in ms_windowedBreakpoints) { if (wbp.File == bp.File && wbp.GetLine() == bp.Line) { wbp.Annotation.BackColor = ms_unresolvedColor; } } m_resolved.Remove(bp); }
void AddBreakpoint(Breakpoint breakpoint) { this.breakpoints.Add(breakpoint); foreach (Process process in this.Processes) { foreach(Module module in process.Modules) { breakpoint.SetBreakpoint(module); } } }
private void OnModulesAdded(object sender, CollectionItemEventArgs<Module> e) { if (BreakAtBeginning) { if (e.Item.SymReader == null) return; // No symbols try { // create a BP at entry point uint entryPoint = e.Item.SymReader.GetUserEntryPoint(); if (entryPoint == 0) return; // no EP var mainFunction = e.Item.CorModule.GetFunctionFromToken(entryPoint); var corBreakpoint = mainFunction.CreateBreakpoint(); corBreakpoint.Activate(1); // create a SD BP var breakpoint = new Breakpoint(this.debugger, corBreakpoint); this.debugger.Breakpoints.Add(breakpoint); breakpoint.Hit += delegate { if (breakpoint != null) breakpoint.Remove(); breakpoint = null; }; } catch { // the app does not have an entry point - COM exception } BreakAtBeginning = false; } }
public void RemoveBreakpoint(Breakpoint breakpoint) { breakpoint.IsEnabled = false; this.breakpoints.Remove(breakpoint); }