public override void CopyFrom (BreakEvent ev) { base.CopyFrom (ev); Catchpoint cp = (Catchpoint) ev; exceptionName = cp.exceptionName; includeSubclasses = cp.includeSubclasses; }
public override void CopyFrom (BreakEvent ev) { base.CopyFrom (ev); FunctionBreakpoint bp = (FunctionBreakpoint) ev; FunctionName = bp.FunctionName; }
internal void AttachSession (DebuggerSession s, BreakEvent ev) { session = s; BreakEvent = ev; session.NotifyBreakEventStatusChanged (BreakEvent); if (adjustedLine != -1) session.AdjustBreakpointLocation ((Breakpoint)BreakEvent, adjustedLine); }
protected override object OnInsertBreakEvent (BreakEvent be, bool activate) { lock (documents) { Breakpoint bp = be as Breakpoint; if (bp != null) { DocInfo doc; if (!documents.TryGetValue (System.IO.Path.GetFullPath (bp.FileName), out doc)) return null; int line; try { line = doc.Document.FindClosestLine(bp.Line); } catch { // Invalid line return null; } ISymbolMethod met = doc.Reader.GetMethodFromDocumentPosition (doc.Document, line, 0); if (met == null) return null; 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) return null; CorFunction func = doc.Module.GetFunctionFromToken (met.Token.GetToken ()); CorFunctionBreakpoint corBp = func.ILCode.CreateBreakpoint (offset); corBp.Activate (activate); return corBp; } } return null; }
BreakInfo GetBreakInfo (BreakEvent be) { object bi; if (GetBreakpointHandle (be, out bi)) return (BreakInfo) bi; else return null; }
public BreakpointPropertiesDialog (BreakEvent be, BreakpointType breakpointType) { this.be = be; LoadExceptionList (); Initialize (); SetInitialData (); SetLayout (); if (be == null) { switch (breakpointType) { case BreakpointType.Location: stopOnLocation.Active = true; entryLocationFile.SetFocus (); break; case BreakpointType.Function: stopOnFunction.Active = true; entryFunctionName.SetFocus (); break; case BreakpointType.Catchpoint: stopOnException.Active = true; entryExceptionType.SetFocus (); break; } } }
void UpdateBreakEvent (BreakEvent be) { lock (breakpoints) { BreakEventInfo binfo; if (breakpoints.TryGetValue (be, out binfo)) OnUpdateBreakEvent (binfo); } }
bool RemoveBreakEvent (BreakEvent be) { lock (breakpoints) { BreakEventInfo binfo; if (breakpoints.TryGetValue (be, out binfo)) { try { OnRemoveBreakEvent (binfo); } catch (Exception ex) { if (started) OnDebuggerOutput (false, ex.Message); HandleException (ex); return false; } breakpoints.Remove (be); } return true; } }
/// <summary> /// Returns a status message of a breakpoint for this debugger session. /// </summary> public string GetBreakEventStatusMessage (BreakEvent be) { if (started) { BreakEventInfo binfo; lock (breakpoints) { if (breakpoints.TryGetValue (be, out binfo)) { if (binfo.StatusMessage != null) return binfo.StatusMessage; switch (binfo.Status) { case BreakEventStatus.BindError: return "The breakpoint could not be bound"; case BreakEventStatus.Bound: return ""; case BreakEventStatus.Disconnected: return ""; case BreakEventStatus.Invalid: return "The breakpoint location is invalid. Perhaps the source line does " + "not contain any statements, or the source does not correspond to the current binary"; case BreakEventStatus.NotBound: return "The breakpoint could not yet be bound to a valid location"; } } } } return "The breakpoint will not currently be hit"; }
//breakpoints etc /// <summary> /// Called to insert a new breakpoint or catchpoint /// </summary> /// <param name='breakEvent'> /// The break event. /// </param> /// <remarks> /// Implementations of this method must: (1) create (and return) an instance of BreakEventInfo /// (or a subclass of it). (2) Attempt to activate a breakpoint at the location /// specified in breakEvent. If the breakpoint cannot be activated at the time this /// method is called, it is the responsibility of the DebuggerSession subclass /// to attempt it later on. /// The BreakEventInfo object can be used to change the status of the breakpoint, /// update the hit point, etc. /// </remarks> protected abstract BreakEventInfo OnInsertBreakEvent (BreakEvent breakEvent);
public int InsertBreakEvent(DL.BreakEvent be, bool enable) { CancelRuntimeInvokes(); DL.Breakpoint bp = be as DL.Breakpoint; MD.Event ev = null; if (bp != null) { MD.SourceLocation location = new MD.SourceLocation(bp.FileName, bp.Line); MD.SourceBreakpoint sbp = new MD.SourceBreakpoint(session, ThreadGroup.Global, location); mdbAdaptor.InitializeBreakpoint(sbp); session.AddEvent(sbp); ev = sbp; } else if (be is Catchpoint) { lock (pendingCatchpoints) { Catchpoint cp = (Catchpoint)be; ML.TargetType exc = null; if (process != null) { foreach (Module mod in process.Modules) { exc = mod.Language.LookupType(cp.ExceptionName); if (exc != null) { break; } } } if (exc != null) { ev = session.InsertExceptionCatchPoint(process.MainThread, ThreadGroup.Global, exc); } else { pendingCatchpoints.Add(cp); return(-1); } } } ev.IsEnabled = enable; if (!initializing) { lock (debugger) { mdbAdaptor.ActivateEvent(ev); } } if (bp != null && !running && !initializing && activeThread.CurrentFrame != null && !string.IsNullOrEmpty(bp.ConditionExpression) && bp.BreakIfConditionChanges) { // Initial expression evaluation MdbEvaluationContext ctx = new MdbEvaluationContext(activeThread, activeThread.CurrentFrame, null, SessionOptions.EvaluationOptions); ML.TargetObject ob = EvaluateExp(ctx, bp.ConditionExpression); if (ob != null) { lastConditionValue [ev.Index] = evaluator.TargetObjectToExpression(ctx, ob).Value; } } events [ev.Index] = be; return(ev.Index); }
protected bool GetBreakpointHandle (BreakEvent be, out object handle) { BreakEventInfo binfo; if (!breakpoints.TryGetValue (be, out binfo)) { handle = null; return false; } handle = binfo.Handle; return true; }
void UpdateBreakEvent (BreakEvent be) { lock (breakpoints) { object handle; if (GetBreakpointHandle (be, out handle)) { if (handle != null) { object newHandle = OnUpdateBreakEvent (handle, be); if (newHandle != handle && (newHandle == null || !newHandle.Equals (handle))) { // Update the handle if it has changed, and notify the status change SetBreakEventHandle (be, newHandle); } Breakpoints.NotifyStatusChanged (be); } else { // Try inserting the breakpoint again try { handle = OnInsertBreakEvent (be, be.Enabled); if (handle != null) { // This time worked SetBreakEventHandle (be, handle); Breakpoints.NotifyStatusChanged (be); } } catch (Exception ex) { Breakpoint bp = be as Breakpoint; if (bp != null) OnDebuggerOutput (false, "Could not set breakpoint at location '" + bp.FileName + ":" + bp.Line + " (" + ex.Message + ")\n"); else OnDebuggerOutput (false, "Could not set catchpoint for exception '" + ((Catchpoint)be).ExceptionName + "' (" + ex.Message + ")\n"); HandleException (ex); } } } } }
void UpdateBreakEventStatus (BreakEvent be) { lock (breakpoints) { object handle; if (GetBreakpointHandle (be, out handle) && handle != null) { try { OnEnableBreakEvent (handle, be.Enabled); } catch (Exception ex) { if (started) OnDebuggerOutput (false, ex.Message); HandleException (ex); } } } }
public override void CopyFrom (BreakEvent ev) { base.CopyFrom (ev); Breakpoint bp = (Breakpoint) ev; breakIfConditionChanges = bp.breakIfConditionChanges; conditionExpression = bp.conditionExpression; fileName = bp.fileName; column = bp.column; line = bp.line; }
public object UpdateBreakEvent(object handle, DL.BreakEvent bp) { events [(int)handle] = bp; return(handle); }
public void UpdateHitCount(int count) { BreakEvent.HitCount = count; BreakEvent.NotifyUpdate(); }
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; }
/// <summary> /// Returns the status of a breakpoint for this debugger session. /// </summary> public BreakEventStatus GetBreakEventStatus (BreakEvent be) { if (started) { BreakEventInfo binfo; lock (breakpoints) { if (breakpoints.TryGetValue (be, out binfo)) return binfo.Status; } } return BreakEventStatus.NotBound; }
//breakpoints etc // returns a handle protected override object OnInsertBreakEvent (BreakEvent be, bool activate) { return controller.DebuggerServer.InsertBreakEvent (be, activate); }
void AddBreakEvent (BreakEvent be) { try { var eventInfo = OnInsertBreakEvent (be); if (eventInfo == null) throw new InvalidOperationException ("OnInsertBreakEvent can't return a null value. If the breakpoint can't be bound or is invalid, a BreakEventInfo with the corresponding status must be returned"); lock (breakpoints) { breakpoints [be] = eventInfo; } eventInfo.AttachSession (this, be); } catch (Exception ex) { Breakpoint bp = be as Breakpoint; string msg; if (bp != null) msg = "Could not set breakpoint at location '" + bp.FileName + ":" + bp.Line + "'"; else msg = "Could not set catchpoint for exception '" + ((Catchpoint)be).ExceptionName + "'"; msg += " (" + ex.Message + ")"; OnDebuggerOutput (false, msg + "\n"); HandleException (ex); return; } }
protected override object OnUpdateBreakEvent (object handle, BreakEvent be) { return controller.DebuggerServer.UpdateBreakEvent (handle, be); }
void UpdateBreakEventStatus (BreakEvent be) { lock (breakpoints) { BreakEventInfo binfo; if (breakpoints.TryGetValue (be, out binfo)) { try { OnEnableBreakEvent (binfo, be.Enabled); } catch (Exception ex) { if (started) OnDebuggerOutput (false, ex.Message); HandleException (ex); } } } }
public override void CopyFrom (BreakEvent ev) { base.CopyFrom (ev); Breakpoint bp = (Breakpoint) ev; fileName = bp.fileName; column = bp.column; line = bp.line; }
protected override BreakEventInfo OnInsertBreakEvent (BreakEvent ev) { if (exited) return null; var bi = new BreakInfo (); if (ev is FunctionBreakpoint) { var fb = (FunctionBreakpoint) ev; bool generic; bi.Location = FindLocationByFunction (fb.FunctionName, fb.ParamTypes, fb.Line, out generic); if (bi.Location != null) { fb.SetResolvedFileName (bi.Location.SourceFile); bi.FileName = fb.FileName; InsertBreakpoint (fb, bi); bi.SetStatus (BreakEventStatus.Bound, null); // Note: if the type or method is generic, there may be more instances so don't assume we are done resolving the breakpoint if (generic) pending_bes.Add (bi); } else { int dot = fb.FunctionName.LastIndexOf ('.'); if (dot != -1) bi.TypeName = fb.FunctionName.Substring (0, dot); pending_bes.Add (bi); bi.SetStatus (BreakEventStatus.NotBound, null); } } else if (ev is Breakpoint) { var bp = (Breakpoint) ev; bool insideLoadedRange; bool generic; bi.Location = FindLocationByFile (bp.FileName, bp.Line, out generic, out insideLoadedRange); bi.FileName = bp.FileName; if (bi.Location != null) { InsertBreakpoint (bp, bi); bi.SetStatus (BreakEventStatus.Bound, null); // Note: if the type or method is generic, there may be more instances so don't assume we are done resolving the breakpoint if (generic) pending_bes.Add (bi); } else { pending_bes.Add (bi); if (insideLoadedRange) bi.SetStatus (BreakEventStatus.Invalid, null); else bi.SetStatus (BreakEventStatus.NotBound, null); } } else if (ev is Catchpoint) { var cp = (Catchpoint) ev; TypeMirror type; if (!types.TryGetValue (cp.ExceptionName, out type)) { // // Same as in FindLocationByFile (), fetch types matching the type name if (vm.Version.AtLeast (2, 9)) { foreach (TypeMirror t in vm.GetTypes (cp.ExceptionName, false)) ProcessType (t); } } if (types.TryGetValue (cp.ExceptionName, out type)) { InsertCatchpoint (cp, bi, type); bi.SetStatus (BreakEventStatus.Bound, null); } else { bi.TypeName = cp.ExceptionName; pending_bes.Add (bi); bi.SetStatus (BreakEventStatus.NotBound, null); } } /* * TypeLoad events lead to too much wire traffic + suspend/resume work, so * filter them using the file names used by pending breakpoints. */ if (vm.Version.AtLeast (2, 9)) { var sourceFileList = pending_bes.Where (b => b.FileName != null).Select (b => b.FileName).ToArray (); if (sourceFileList.Length > 0) { //HACK: explicitly try lowercased drivename on windows, since csc (when not hosted in VS) lowercases //the drivename in the pdb files that get converted to mdbs as-is //FIXME: we should really do a case-insensitive request on Win/Mac, when sdb supports that if (IsWindows) { int originalCount = sourceFileList.Length; Array.Resize (ref sourceFileList, originalCount * 2); for (int i = 0; i < originalCount; i++) { string n = sourceFileList[i]; sourceFileList[originalCount + i] = char.ToLower (n[0]) + n.Substring (1); } } if (typeLoadReq == null) { typeLoadReq = vm.CreateTypeLoadRequest (); } typeLoadReq.Enabled = false; typeLoadReq.SourceFileFilter = sourceFileList; typeLoadReq.Enabled = true; } var typeNameList = pending_bes.Where (b => b.TypeName != null).Select (b => b.TypeName).ToArray (); if (typeNameList.Length > 0) { // Use a separate request since the filters are ANDed together if (typeLoadTypeNameReq == null) { typeLoadTypeNameReq = vm.CreateTypeLoadRequest (); } typeLoadTypeNameReq.Enabled = false; typeLoadTypeNameReq.TypeNameFilter = typeNameList; typeLoadTypeNameReq.Enabled = true; } } return bi; }
protected override BreakEventInfo OnInsertBreakEvent (BreakEvent be) { BreakEventInfo binfo = new BreakEventInfo (); lock (documents) { Breakpoint bp = be 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, 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; }
void OnSave (object sender, EventArgs e) { if (be == null) { if (stopOnFunction.Active) be = new FunctionBreakpoint ("", "C#"); else if (stopOnLocation.Active) be = breakpointLocation.ToBreakpoint (); else if (stopOnException.Active) be = new Catchpoint (entryExceptionType.Text, checkIncludeSubclass.Active); else return; } var fb = be as FunctionBreakpoint; if (fb != null) SaveFunctionBreakpoint (fb); var bp = be as Breakpoint; if (bp != null) SaveBreakpoint (bp); if ((HitCountMode)ignoreHitType.SelectedItem == HitCountMode.GreaterThanOrEqualTo && (int)ignoreHitCount.Value == 0) { be.HitCountMode = HitCountMode.None; } else { be.HitCountMode = (HitCountMode)ignoreHitType.SelectedItem; } be.HitCount = be.HitCountMode != HitCountMode.None ? (int)ignoreHitCount.Value : 0; if (!string.IsNullOrWhiteSpace (entryConditionalExpression.Text)) { be.ConditionExpression = entryConditionalExpression.Text; be.BreakIfConditionChanges = conditionalHitType.SelectedItem.Equals (ConditionalHitWhen.ExpressionChanges); } else { be.ConditionExpression = null; } if (breakpointActionPrint.Active) { be.HitAction = HitAction.PrintExpression; be.TraceExpression = entryPrintExpression.Text; } else { be.HitAction = HitAction.Break; } be.CommitChanges (); }
protected override BreakEventInfo OnInsertBreakEvent (BreakEvent ev) { if (exited) return null; BreakInfo bi = new BreakInfo (); if (ev is Breakpoint) { Breakpoint bp = (Breakpoint) ev; bool inisideLoadedRange; bi.Location = FindLocation (bp.FileName, bp.Line, out inisideLoadedRange); if (bi.Location != null) { InsertBreakpoint (bp, bi); bi.SetStatus (BreakEventStatus.Bound, null); } else { pending_bes.Add (bi); if (inisideLoadedRange) bi.SetStatus (BreakEventStatus.Invalid, null); else bi.SetStatus (BreakEventStatus.NotBound, null); } } else if (ev is Catchpoint) { var cp = (Catchpoint) ev; TypeMirror type; if (types.TryGetValue (cp.ExceptionName, out type)) { InsertCatchpoint (cp, bi, type); bi.SetStatus (BreakEventStatus.Bound, null); } else { pending_bes.Add (bi); bi.SetStatus (BreakEventStatus.NotBound, null); } } return bi; }
protected override object OnInsertBreakEvent (BreakEvent be, bool activate) { if (exited) return null; BreakInfo bi = new BreakInfo (); bi.Enabled = activate; bi.BreakEvent = be; if (be is Breakpoint) { Breakpoint bp = (Breakpoint) be; bi.Location = FindLocation (bp.FileName, bp.Line); if (bi.Location != null) InsertBreakpoint (bp, bi); else { pending_bes.Add (bp); SetBreakEventStatus (be, false, null); } } else if (be is Catchpoint) { var cp = (Catchpoint) be; TypeMirror type; if (types.TryGetValue (cp.ExceptionName, out type)) { InsertCatchpoint (cp, bi, type); } else { pending_bes.Add (be); SetBreakEventStatus (be, false, null); } } return bi; }
internal void NotifyBreakEventStatusChanged (BreakEvent be) { var s = GetBreakEventStatus (be); if (s == BreakEventStatus.BindError || s == BreakEventStatus.Invalid) OnDebuggerOutput (true, GetBreakEventErrorMessage (be) + ": " + GetBreakEventStatusMessage (be) + "\n"); Breakpoints.NotifyStatusChanged (be); }
protected override object OnUpdateBreakEvent (object handle, BreakEvent be) { return null; }
string GetBreakEventErrorMessage (BreakEvent be) { Breakpoint bp = be as Breakpoint; if (bp != null) return string.Format ("Could not insert breakpoint at '{0}:{1}'", bp.FileName, bp.Line); Catchpoint cp = (Catchpoint) be; return string.Format ("Could not enable catchpoint for exception '{0}'", cp.ExceptionName); }
static void BreakpointTraceHandler (BreakEvent be, string trace) { if (be is Breakpoint) { if (pinnedWatches.UpdateLiveWatch ((Breakpoint) be, trace)) return; // No need to log the value. It is shown in the watch. } console.Log.Write (trace + "\n"); }
public BreakEventArgs(BreakEvent be) { BreakEvent = be; }