protected override BreakEventInfo OnInsertBreakEvent(BreakEvent breakEvent) { BreakEventInfo breakEventInfo; if (breakpoints.TryGetValue(breakEvent, out breakEventInfo)) { return(breakEventInfo); } breakEventInfo = new BreakEventInfo(); if (breakEvent is Mono.Debugging.Client.Breakpoint) { breakpoints.Add(breakEvent, breakEventInfo); UpdateBreakpoints(); } else if (breakEvent is Catchpoint) { breakpoints.Add(breakEvent, breakEventInfo); UpdateExceptions(); } else { throw new NotImplementedException(breakEvent.GetType().FullName); } return(breakEventInfo); }
protected override void OnUpdateBreakEvent(BreakEventInfo binfo) { Breakpoint bp = binfo.BreakEvent as Breakpoint; if (bp == null) { throw new NotSupportedException(); } bool ss = InternalStop(); try { if (bp.HitCount > 0) { RunCommand("-break-after", binfo.Handle.ToString(), bp.HitCount.ToString()); breakpointsWithHitCount.Add(binfo); } else { breakpointsWithHitCount.Remove(binfo); } if (!string.IsNullOrEmpty(bp.ConditionExpression) && !bp.BreakIfConditionChanges) { RunCommand("-break-condition", binfo.Handle.ToString(), bp.ConditionExpression); } else { RunCommand("-break-condition", binfo.Handle.ToString()); } } finally { InternalResume(ss); } }
protected override void OnRemoveBreakEvent(BreakEventInfo binfo) { if (LogWriter != null) { LogWriter(false, "Break removed " + binfo.ToString()); } }
protected override BreakEventInfo OnInsertBreakEvent(BreakEvent be) { Breakpoint bp = be as Breakpoint; if (bp == null) { throw new NotSupportedException(); } BreakEventInfo breakEventInfo = new BreakEventInfo(); if (bp.HitCount > 0) { breakpointsWithHitCount.Add(breakEventInfo); } ulong address = this.SymbolResolver.GetAddressFromCodeLine(bp.FileName, (ushort)bp.Line); if (address != 0) { breakpointcounter++; debuggee.SetBreakPoint(address); breakpoints[address] = new BreakPointWrapper(breakpointcounter, breakEventInfo); breakEventInfo.Handle = address; breakEventInfo.SetStatus(BreakEventStatus.Bound, null); } else { breakEventInfo.SetStatus(BreakEventStatus.BindError, null); } return(breakEventInfo); }
protected override void OnEnableBreakEvent(BreakEventInfo binfo, bool enable) { lock (gdbLock) { if (binfo.Handle == null) { return; } bool dres = InternalStop(); try { if (enable) { RunCommand("-break-enable", binfo.Handle.ToString()); } else { RunCommand("-break-disable", binfo.Handle.ToString()); } } finally { InternalResume(dres); } } }
protected override BreakEventInfo OnInsertBreakEvent(BreakEvent be) { Breakpoint bp = be as Breakpoint; if (bp == null) { throw new NotSupportedException(); } BreakEventInfo breakEventInfo = new BreakEventInfo(); //bool dres = InternalStop (); try { string extraCmd = string.Empty; if (bp.HitCount > 0) { extraCmd += "-i " + bp.HitCount; breakpointsWithHitCount.Add(breakEventInfo); } if (!string.IsNullOrEmpty(bp.ConditionExpression)) { if (!bp.BreakIfConditionChanges) { extraCmd += " -c " + bp.ConditionExpression; } } ulong bh = 0; DebugEngineWrapper.BreakPoint engineBreakPoint = null; ulong off = 0; if (Engine.Symbols.GetOffsetByLine(bp.FileName, (uint)bp.Line, out off)) { engineBreakPoint = Engine.AddBreakPoint(BreakPointOptions.Enabled); engineBreakPoint.Offset = off; bh = engineBreakPoint.Offset; breakpoints[bh] = new BreakPointWrapper(breakEventInfo, engineBreakPoint); breakEventInfo.Handle = bh; breakEventInfo.SetStatus(BreakEventStatus.Bound, null); //if (!be.Enabled) //ToDo: tell debugger engine that breakpoint is disabled } else { breakEventInfo.SetStatus(BreakEventStatus.BindError, null); } return(breakEventInfo); } finally { //InternalResume (dres); } }
protected override BreakEventInfo OnInsertBreakEvent(BreakEvent be) { BreakEventInfo binfo = new BreakEventInfo(); lock (documents) { Breakpoint bp = be as Breakpoint; if (bp != null) { DocInfo doc; if (!documents.TryGetValue(System.IO.Path.GetFullPath(bp.FileName), out doc)) { binfo.SetStatus(BreakEventStatus.NotBound, null); return(binfo); } int line; try { line = doc.Document.FindClosestLine(bp.Line); } catch { // Invalid line binfo.SetStatus(BreakEventStatus.Invalid, null); return(binfo); } ISymbolMethod met = doc.Reader.GetMethodFromDocumentPosition(doc.Document, line, 0); if (met == null) { binfo.SetStatus(BreakEventStatus.Invalid, null); return(binfo); } int offset = -1; foreach (SequencePoint sp in met.GetSequencePoints()) { if (sp.Line == line && sp.Document.URL == doc.Document.URL) { offset = sp.Offset; break; } } if (offset == -1) { binfo.SetStatus(BreakEventStatus.Invalid, null); return(binfo); } CorFunction func = doc.Module.GetFunctionFromToken(met.Token.GetToken()); CorFunctionBreakpoint corBp = func.ILCode.CreateBreakpoint(offset); corBp.Activate(bp.Enabled); breakpoints[corBp] = binfo; binfo.Handle = corBp; binfo.SetStatus(BreakEventStatus.Bound, null); return(binfo); } } return(null); }
private BreakEventInfo OnInsertWatchPoint(BreakEvent be) { var bi = new BreakEventInfo(); var wp = be as WatchPoint; lock (gdbLock) { bool dres = InternalStop(); try { string errorMsg = string.Empty; GdbCommandResult res = null; try { if (wp.TriggerOnRead && wp.TriggerOnWrite) { res = RunCommand("-break-watch", wp.Expression, "-a"); } else if (wp.TriggerOnRead && !wp.TriggerOnWrite) { res = RunCommand("-break-watch", wp.Expression, "-r"); } else { res = RunCommand("-break-watch", wp.Expression); } } catch (Exception ex) { errorMsg = ex.Message; } if (res == null || res.Status != CommandStatus.Done) { bi.SetStatus(BreakEventStatus.Invalid, errorMsg); return(bi); } int bh = res.GetObject("wpt").GetInt("number"); if (!be.Enabled) { RunCommand("-break-disable", bh.ToString()); } breakpoints[bh] = bi; bi.Handle = bh; bi.SetStatus(BreakEventStatus.Bound, null); return(bi); } finally { InternalResume(dres); } } }
protected override void OnEnableBreakEvent(BreakEventInfo binfo, bool enable) { CorBreakpoint bp = binfo.Handle as CorFunctionBreakpoint; if (bp != null) { bp.Activate(enable); } }
private void NotifyBreakEventUpdate(BreakEventInfo binfo, int hitCount, string lastTrace) { bool notify = false; WaitCallback nc = delegate { if (hitCount != -1) { binfo.IncrementHitCount(); } if (lastTrace != null) { binfo.UpdateLastTraceValue(lastTrace); } }; lock (breakUpdates) { int span = (int)(DateTime.Now - lastBreakEventUpdate).TotalMilliseconds; if (span >= BreakEventUpdateNotifyDelay && !breakUpdateEventsQueued) { // Last update was more than 0.5s ago. The update can be sent. lastBreakEventUpdate = DateTime.Now; notify = true; } else { // Queue the event notifications to avoid wasting too much time breakUpdates[(int)binfo.Handle] = nc; if (!breakUpdateEventsQueued) { breakUpdateEventsQueued = true; ThreadPool.QueueUserWorkItem(delegate { Thread.Sleep(BreakEventUpdateNotifyDelay - span); List <WaitCallback> copy; lock (breakUpdates) { copy = new List <WaitCallback>(breakUpdates.Values); breakUpdates.Clear(); breakUpdateEventsQueued = false; lastBreakEventUpdate = DateTime.Now; } foreach (WaitCallback wc in copy) { wc(null); } }); } } } if (notify) { nc(null); } }
protected override void OnRemoveBreakEvent(BreakEventInfo bi) { if (terminated) { return; } CorFunctionBreakpoint corBp = (CorFunctionBreakpoint)bi.Handle; corBp.Activate(false); }
protected override void OnEnableBreakEvent(BreakEventInfo binfo, bool enable) { if (binfo.Handle == null) { return; } breakpoints[(ulong)binfo.Handle].Breakpoint.Flags = enable ? BreakPointOptions.Enabled : BreakPointOptions.Deferred; //ToDo: tell engine we enabled a break point }
protected override void OnRemoveBreakEvent(BreakEventInfo binfo) { lock (gdbLock) { bool dres = InternalStop(); breakpointsWithHitCount.Remove(binfo); breakpoints.Remove((int)binfo.Handle); try { RunCommand("-break-delete", binfo.Handle.ToString()); } finally { InternalResume(dres); } } }
protected override void OnRemoveBreakEvent(BreakEventInfo binfo) { if (binfo == null) { return; } breakpointsWithHitCount.Remove(binfo); if (breakpoints.ContainsKey((ulong)binfo.Handle)) { ulong key = breakpoints[(ulong)binfo.Handle].Key; breakpoints.Remove((ulong)binfo.Handle); debuggee.RemoveBreakPoint((ulong)binfo.Handle); } }
protected override void OnRemoveBreakEvent(BreakEventInfo eventInfo) { if (process == null) { return; } if (eventInfo.Status != BreakEventStatus.Bound || eventInfo.Handle == null) { return; } var corBp = (CorDebugFunctionBreakpoint)eventInfo.Handle; corBp.Active = false; }
protected override void OnRemoveBreakEvent(BreakEventInfo bi) { if (terminated) { return; } if (bi.Status != BreakEventStatus.Bound || bi.Handle == null) { return; } CorFunctionBreakpoint corBp = (CorFunctionBreakpoint)bi.Handle; corBp.Activate(false); }
protected override BreakEventInfo OnInsertBreakEvent(BreakEvent breakEvent) { var bp = breakEvent as Breakpoint; if (bp == null) { throw new NotImplementedException(); } unityDebugProtocol.AddBreakpoint(bp.FileName, bp.Line); var eventInfo = new BreakEventInfo(); eventInfo.SetStatus(BreakEventStatus.Bound, null); return(eventInfo); }
void FireBreakPoint(ulong offset) { TargetEventArgs args = new TargetEventArgs(TargetEventType.TargetHitBreakpoint); ulong tempoff = (ulong)offset; if (breakpoints.ContainsKey(tempoff)) { breakpoints[(ulong)tempoff].EventInfo.BreakEvent.HitCount = (int)breakpoints[(ulong)tempoff].Breakpoint.HitCount; args.BreakEvent = breakpoints[(ulong)tempoff].EventInfo.BreakEvent; } else { args = new TargetEventArgs(TargetEventType.TargetStopped); BreakEventInfo breakInfo = new BreakEventInfo(); breakInfo.Handle = tempoff; breakInfo.SetStatus(BreakEventStatus.Bound, null); string fn; uint ln; if (Engine.Symbols.GetLineByOffset(offset, out fn, out ln)) { //breakInfo.BreakEvent = new Breakpoint(fn, (int)ln); args.BreakEvent = breakInfo.BreakEvent; } } ProcessInfo process = OnGetProcesses()[0]; args.Process = new ProcessInfo(process.Id, process.Name); args.Backtrace = new Backtrace(new PlainDbgEngBasedBacktrace(this, activeThread, Engine)); ThreadPool.QueueUserWorkItem(delegate(object data) { try { OnTargetEvent((TargetEventArgs)data); } catch (Exception ex) { Console.WriteLine(ex); } }, args); }
protected override void OnRemoveBreakEvent(BreakEventInfo binfo) { if (binfo == null) { return; } breakpointsWithHitCount.Remove(binfo); DebugEngineWrapper.BreakPoint breakpoint = breakpoints[(ulong)binfo.Handle].Breakpoint; if (IsDebugging /*&& bpw.IsExisting*/) { Engine.RemoveBreakPoint(breakpoint); } breakpointsWithHitCount.Remove(binfo); breakpoints.Remove((ulong)binfo.Handle); }
protected override BreakEventInfo OnInsertBreakEvent(BreakEvent be) { if (be is Breakpoint) { return(OnInsertBreakPoint(be as Breakpoint)); } else if (be is WatchPoint) { return(OnInsertWatchPoint(be as WatchPoint)); } else { var bi = new BreakEventInfo(); bi.SetStatus(BreakEventStatus.NotBound, "BreakEvent type not supported."); return(bi); } }
void FireBreakPoint(ulong address) { TargetEventArgs args = new TargetEventArgs(TargetEventType.TargetHitBreakpoint); ulong tempAddress = address; if (breakpoints.ContainsKey(tempAddress)) { //breakpoints[(ulong)tempoff].EventInfo.UpdateHitCount((int)breakpoints[(ulong)tempoff].Breakpoint.HitCount); args.BreakEvent = breakpoints[tempAddress].EventInfo.BreakEvent; } else { args = new TargetEventArgs(TargetEventType.TargetStopped); BreakEventInfo breakInfo = new BreakEventInfo(); breakInfo.Handle = tempAddress; breakInfo.SetStatus(BreakEventStatus.Bound, null); string filename; uint line; if (this.SymbolResolver.GetCodeLineFromAddress(address, out filename, out line)) { args.BreakEvent = breakInfo.BreakEvent; } } ProcessInfo process = OnGetProcesses()[0]; args.Process = new ProcessInfo(process.Id, process.Name); args.Backtrace = new Backtrace(new DDebugBacktrace(this, activeThread, this.debuggee));//, Engine)); args.Thread = GetThread(activeThread); ThreadPool.QueueUserWorkItem(delegate(object data) { try { OnTargetEvent((TargetEventArgs)data); } catch (Exception ex) { Console.WriteLine(ex); } }, args); }
protected override BreakEventInfo OnInsertBreakEvent(BreakEvent breakEvent) { if (breakEvent is Mono.Debugging.Client.Breakpoint) { var breakEventInfo = new BreakEventInfo(); breakpoints.Add((Mono.Debugging.Client.Breakpoint)breakEvent, breakEventInfo); UpdateBreakpoints(); return(breakEventInfo); } else if (breakEvent is Catchpoint) { var catchpoint = (Catchpoint)breakEvent; var breakEventInfo = new BreakEventInfo(); breakpoints.Add(breakEvent, breakEventInfo); UpdateExceptions(); return(breakEventInfo); } throw new NotImplementedException(breakEvent.GetType().FullName); }
protected override BreakEventInfo OnInsertBreakEvent(BreakEvent be) { LogWriter(false, "Break inserted\n"); Breakpoint bp = be as Breakpoint; if (bp == null) { throw new NotSupportedException(); } BreakEventInfo bi = new BreakEventInfo(); //lock (debuggerLock) { LogWriter(false, "Location is " + PathHelper.CutOffClassPath(classPathes, bp.FileName) + ":" + bp.Line + '\n'); breaks.Add(new Break(PathHelper.CutOffClassPath(classPathes, bp.FileName), bp.Line)); //} //bi.Handle = TODO: add returned success value (break count etc) bi.SetStatus(BreakEventStatus.Bound, null); return(bi); }
private BreakEventInfo OnInsertBreakPoint(BreakEvent be) { var bi = new BreakEventInfo(); var bp = be as Breakpoint; lock (gdbLock) { bool dres = InternalStop(); try { string extraCmd = string.Empty; if (bp.HitCount > 0) { extraCmd += "-i " + bp.HitCount; breakpointsWithHitCount.Add(bi); } if (!string.IsNullOrEmpty(bp.ConditionExpression)) { if (!bp.BreakIfConditionChanges) { extraCmd += " -c " + bp.ConditionExpression; } } GdbCommandResult res = null; string errorMsg = null; if (bp is FunctionBreakpoint) { try { res = RunCommand("-break-insert", extraCmd.Trim(), ((FunctionBreakpoint)bp).FunctionName); } catch (Exception ex) { errorMsg = ex.Message; } } else { // Breakpoint locations must be double-quoted if files contain spaces. // For example: -break-insert "\"C:/Documents and Settings/foo.c\":17" RunCommand("-environment-directory", Escape(Path.GetDirectoryName(bp.FileName).ToAvalonPath())); try { res = RunCommand("-break-insert", extraCmd.Trim(), Escape(Escape(bp.FileName.ToAvalonPath()) + ":" + bp.Line)); } catch (Exception ex) { errorMsg = ex.Message; } if (res == null) { try { res = RunCommand("-break-insert", extraCmd.Trim(), Escape(Escape(Path.GetFileName(bp.FileName)) + ":" + bp.Line)); } catch { // Ignore } } } if (res == null || res.Status != CommandStatus.Done) { bi.SetStatus(BreakEventStatus.Invalid, errorMsg); return(bi); } int bh = res.GetObject("bkpt").GetInt("number"); if (!be.Enabled) { RunCommand("-break-disable", bh.ToString()); } breakpoints[bh] = bi; bi.Handle = bh; bi.SetStatus(BreakEventStatus.Bound, null); return(bi); } finally { InternalResume(dres); } } }
protected override void OnUpdateBreakEvent(BreakEventInfo eventInfo) { breakpoints [breakpoints.Single(b => b.Value == eventInfo).Key] = eventInfo; UpdateBreakpoints(); UpdateExceptions(); }
protected override void OnEnableBreakEvent(BreakEventInfo eventInfo, bool enable) { UpdateExceptions(); UpdateBreakpoints(); }
protected override void OnRemoveBreakEvent(BreakEventInfo eventInfo) { }
protected override void OnEnableBreakEvent(BreakEventInfo eventInfo, bool enable) { }
protected override void OnUpdateBreakEvent(BreakEventInfo eventInfo) { }
protected override void OnUpdateBreakEvent(BreakEventInfo binfo) { return; }