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 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 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 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 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 BreakEventInfo OnInsertBreakEvent(BreakEvent breakEvent) { var binfo = new BreakEventInfo(); var bp = breakEvent as Breakpoint; if (bp != null) { if (bp is FunctionBreakpoint) { // FIXME: implement breaking on function name binfo.SetStatus(BreakEventStatus.Invalid, null); return(binfo); } else { DocInfo doc; if (!documents.TryGetValue(System.IO.Path.GetFullPath(bp.FileName), out doc)) { binfo.SetStatus(BreakEventStatus.NotBound, "Cannot find source file in pdb/mdb debugging database."); return(binfo); } MethodSymbols met = doc.GetClosestMethod(bp.Line); int offset = -1; foreach (var sp in met.Instructions) { if (sp.SequencePoint.StartLine == bp.Line) { offset = sp.Offset; break; } } if (offset == -1) { if (bp.Line < met.Instructions.First().SequencePoint.StartLine) { offset = met.Instructions.First().Offset; } else { offset = met.Instructions.Last().Offset; } } CorDebugFunction func = doc.Assembly.GetFunctionFromTokenCLR(met.MethodToken.ToUInt32()); CorDebugFunctionBreakpoint corBp = func.ILCode.CreateBreakpoint((uint)offset); corBp.Active = bp.Enabled; binfo.Handle = corBp; binfo.SetStatus(BreakEventStatus.Bound, null); return(binfo); } } // var cp = breakEvent as Catchpoint; // if (cp != null) { // foreach (ModuleInfo mod in modules.Values) { // CorMetadataImport mi = mod.Importer; // if (mi != null) { // foreach (Type t in mi.DefinedTypes) // if (t.FullName == cp.ExceptionName) { // binfo.SetStatus (BreakEventStatus.Bound, null); // return binfo; // } // } // } // } binfo.SetStatus(BreakEventStatus.Invalid, null); return(binfo); }