public static IEnumerable<Breakpoint> GetBreakpoints(this Response response) { if (response == null) throw new ArgumentNullException("response"); if (response.Command != "listbreakpoints") throw new ArgumentException("The specified response object was not a listbreakpoints response.", "response"); if (response.Success == false) throw new ArgumentException("The specified response object did not specify a success condition.", "response"); foreach (var breakpoint in response.Body.breakpoints) { var concreteBreakpoint = new Breakpoint { BreakPointNumber = breakpoint.number, ScriptId = breakpoint.script_id, ScriptName = breakpoint.script_name, LineNumber = breakpoint.line, Column = breakpoint.column, GroupId = breakpoint.groupId, HitCount = breakpoint.hit_count, Enabled = breakpoint.active, IgnoreCount = breakpoint.ignoreCount //ActualLocations }; yield return concreteBreakpoint; } }
private void HandleCompositeCommand(JdwpPacket packet) { var data = packet.Data; var suspendPolicy = (Jdwp.SuspendPolicy) data.GetByte(); var count = data.GetInt(); for (var i = 0; i < count; i++) { var eventKind = (Jdwp.EventKind) data.GetByte(); JdwpEvent evt; switch (eventKind) { case Jdwp.EventKind.VmInit: evt = new VmStart(data); break; case Jdwp.EventKind.SingleStep: evt = new SingleStep(data); break; case Jdwp.EventKind.BreakPoint: evt = new Breakpoint(data); break; case Jdwp.EventKind.MethodEntry: evt = new MethodEntry(data); break; case Jdwp.EventKind.MethodExit: evt = new MethodExit(data); break; case Jdwp.EventKind.Exception: evt = new Exception(data); break; case Jdwp.EventKind.ThreadStart: evt = new ThreadStart(data); break; case Jdwp.EventKind.ThreadEnd: evt = new ThreadDeath(data); break; case Jdwp.EventKind.ClassPrepare: evt = new ClassPrepare(data); break; case Jdwp.EventKind.ClassUnload: evt = new ClassUnload(data); break; case Jdwp.EventKind.FieldAccess: evt = new FieldAccess(data); break; case Jdwp.EventKind.FieldModification: evt = new FieldModification(data); break; case Jdwp.EventKind.VmDeath: evt = new VmDeath(data); break; default: throw new ArgumentException("Unknown event kind in compositive command " + (int)eventKind); } DLog.Debug(DContext.DebuggerLibDebugger, "JDWP event {0} {1}", eventKind, evt); Task.Factory.StartNew(() => { evt.Accept(compositeCommandProcessor, suspendPolicy); }); } }
/// <summary> /// Constructor /// </summary> /// <param name="breakpoint">Breakpoint data to prefill in the form (skipped if null)</param> public EditBreakpointDialog(Breakpoint breakpoint) { InitializeComponent(); Breakpoint = breakpoint; radBPX.CheckedChanged += new EventHandler(radioButtonChanged); radBPM.CheckedChanged += new EventHandler(radioButtonChanged); radByte.CheckedChanged += new EventHandler(radioButtonChanged); radWord.CheckedChanged += new EventHandler(radioButtonChanged); radDword.CheckedChanged += new EventHandler(radioButtonChanged); radRead.CheckedChanged += new EventHandler(radioButtonChanged); radWrite.CheckedChanged += new EventHandler(radioButtonChanged); radReadWrite.CheckedChanged += new EventHandler(radioButtonChanged); radExecute.CheckedChanged += new EventHandler(radioButtonChanged); // Prefill the form with the data from the given breakpoint if (breakpoint != null) { switch (breakpoint.BreakpointType) { case DebugProtocol.Breakpoint.BPType.Software: radBPX.Select(); break; case DebugProtocol.Breakpoint.BPType.Hardware: radBPM.Select(); radExecute.Select(); break; case DebugProtocol.Breakpoint.BPType.ReadWatch: radBPM.Select(); radRead.Select(); break; case DebugProtocol.Breakpoint.BPType.WriteWatch: radBPM.Select(); radWrite.Select(); break; case DebugProtocol.Breakpoint.BPType.AccessWatch: radBPM.Select(); radReadWrite.Select(); break; } if (breakpoint.BreakpointType != DebugProtocol.Breakpoint.BPType.Software) { switch (breakpoint.Length) { case 1: radByte.Select(); break; case 2: radWord.Select(); break; case 4: radDword.Select(); break; } } txtAddress.Text = breakpoint.Address.ToString("X8"); txtCondition.Text = breakpoint.Condition; } }
public BreakpointBoundEvent( Breakpoint pendingBreakpoint, Breakpoint boundBreakpoint ) { if ( pendingBreakpoint == null ) { throw new ArgumentNullException( "pendingBreakpoint" ); } if ( boundBreakpoint == null ) { throw new ArgumentNullException( "boundBreakpoint" ); } PendingBreakpoint = pendingBreakpoint; BoundBreakpoint = boundBreakpoint; }
private void picPicture_MouseMove(object sender, MouseEventArgs e) { int cycle = e.X * 341 / (picPicture.Width - 2); int scanline = e.Y * (int)_state.PPU.ScanlineCount / (picPicture.Height - 2) - 1; int[] offsets = new int[3] { 0, -1, 1 }; for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { int key = (scanline + offsets[y] + 1) * 341 + cycle + offsets[x]; List <DebugEventInfo> eventList; if (_debugEventsByCycle.TryGetValue(key, out eventList)) { foreach (DebugEventInfo debugEvent in eventList) { if (ShowEvent(debugEvent.Type)) { if (key != _lastKey) { ResetTooltip(); Dictionary <string, string> values = new Dictionary <string, string>() { { "Type", ResourceHelper.GetEnumText(debugEvent.Type) }, { "Scanline", debugEvent.Scanline.ToString() }, { "Cycle", debugEvent.Cycle.ToString() }, { "PC", "$" + debugEvent.ProgramCounter.ToString("X4") }, }; switch (debugEvent.Type) { case DebugEventType.MapperRegisterRead: case DebugEventType.MapperRegisterWrite: case DebugEventType.PpuRegisterRead: case DebugEventType.PpuRegisterWrite: values["Register"] = "$" + debugEvent.Address.ToString("X4"); values["Value"] = "$" + debugEvent.Value.ToString("X2"); if (debugEvent.PpuLatch >= 0) { values["2nd Write"] = debugEvent.PpuLatch == 0 ? "false" : "true"; } break; case DebugEventType.Breakpoint: ReadOnlyCollection <Breakpoint> breakpoints = BreakpointManager.Breakpoints; if (debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count) { Breakpoint bp = breakpoints[debugEvent.BreakpointId]; values["BP Type"] = bp.ToReadableType(); values["BP Addresses"] = bp.GetAddressString(true); if (bp.Condition.Length > 0) { values["BP Condition"] = bp.Condition; } } break; } UpdateOverlay(new Point(debugEvent.Cycle * 2, (debugEvent.Scanline + 1) * 2)); Form parentForm = this.FindForm(); _tooltip = new frmCodeTooltip(parentForm, values); _tooltip.FormClosed += (s, evt) => { _tooltip = null; }; Point location = PointToScreen(e.Location); location.Offset(10, 10); _tooltip.SetFormLocation(location, this); _lastKey = key; } //Found a matching write to display, stop processing return; } } } } } UpdateOverlay(e.Location); //No match found, make sure any existing tooltip is closed ResetTooltip(); }
private Instruction BreakpointToInstruction(Breakpoint bp) { return allbreakPoints.Where(x => x.debug.Location == bp.Location).ElementAt(0); }
public void SetBreakpoint(string filename, uint sourcepos) { var bp = new Breakpoint { Filename = filename, Sourcepos = sourcepos, }; if (!breakpoints.ContainsKey(bp)) { breakpoints.Add(bp, null); } }
public MyBreakpointHandle(Breakpoint bpt, MonoFunctionType function, int line, int column) : base(bpt, function, line, column) { this.function = function; }
private void EditBreakpoint(Breakpoint storedBreakpoint) { using (EditBreakpointDialog dialog = new EditBreakpointDialog(storedBreakpoint)) { dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.OK && dialog.Breakpoint != null) { Breakpoint bp = dialog.Breakpoint; if (storedBreakpoint.ID >= 0) mConnection.Debugger.RemoveBreakpoint(storedBreakpoint.ID); mConnection.Debugger.SetBreakpoint(bp); } } }
void OnBreakpoint(object sender, CorBreakpointEventArgs e) { lock (debugLock) { if (evaluating) { e.Continue = true; return; } } BreakEventInfo binfo; if (breakpoints.TryGetValue(e.Breakpoint, out binfo)) { e.Continue = true; Breakpoint bp = (Breakpoint)binfo.BreakEvent; if (bp.HitCount > 1) { // Just update the count and continue binfo.UpdateHitCount(bp.HitCount - 1); return; } if (!string.IsNullOrEmpty(bp.ConditionExpression)) { string res = EvaluateExpression(e.Thread, bp.ConditionExpression); if (bp.BreakIfConditionChanges) { if (res == bp.LastConditionValue) { return; } bp.LastConditionValue = res; } else { if (res != null && res.ToLower() == "false") { return; } } } switch (bp.HitAction) { case HitAction.CustomAction: // If custom action returns true, execution must continue if (binfo.RunCustomBreakpointAction(bp.CustomActionId)) { return; } break; case HitAction.PrintExpression: { string exp = EvaluateTrace(e.Thread, bp.TraceExpression); binfo.UpdateLastTraceValue(exp); return; } } } OnStopped(); e.Continue = false; // If a breakpoint is hit while stepping, cancel the stepping operation if (stepper != null && stepper.IsActive()) { stepper.Deactivate(); } SetActiveThread(e.Thread); TargetEventArgs args = new TargetEventArgs(TargetEventType.TargetHitBreakpoint); args.Process = GetProcess(process); args.Thread = GetThread(e.Thread); args.Backtrace = new Backtrace(new CorBacktrace(e.Thread, this)); OnTargetEvent(args); }
public bool IsWatcherBreakpoint(Breakpoint bp) { lock (watches) { return(liveWatches.ContainsKey(bp)); } }
public BreakpointSpan(Breakpoint breakpoint, SnapshotSpan span) { Breakpoint = breakpoint; Span = span; }
public void SetBreakpointChecker(Breakpoint breakpoint) { breakpoint.TrySetChecker(BreakpointChecker); }
void AddBreakpoint(BreakpointBookmark bookmark) { Breakpoint breakpoint = null; breakpoint = new ILBreakpoint( debugger, bookmark.MemberReference.DeclaringType.FullName, bookmark.LineNumber, bookmark.FunctionToken, bookmark.ILRange.From, bookmark.IsEnabled); debugger.Breakpoints.Add(breakpoint); // Action setBookmarkColor = delegate { // if (debugger.Processes.Count == 0) { // bookmark.IsHealthy = true; // bookmark.Tooltip = null; // } else if (!breakpoint.IsSet) { // bookmark.IsHealthy = false; // bookmark.Tooltip = "Breakpoint was not found in any loaded modules"; // } else if (breakpoint.OriginalLocation.CheckSum == null) { // bookmark.IsHealthy = true; // bookmark.Tooltip = null; // } else { // byte[] fileMD5; // IEditable file = FileService.GetOpenFile(bookmark.FileName) as IEditable; // if (file != null) { // byte[] fileContent = Encoding.UTF8.GetBytesWithPreamble(file.Text); // fileMD5 = new MD5CryptoServiceProvider().ComputeHash(fileContent); // } else { // fileMD5 = new MD5CryptoServiceProvider().ComputeHash(File.ReadAllBytes(bookmark.FileName)); // } // if (Compare(fileMD5, breakpoint.OriginalLocation.CheckSum)) { // bookmark.IsHealthy = true; // bookmark.Tooltip = null; // } else { // bookmark.IsHealthy = false; // bookmark.Tooltip = "Check sum or file does not match to the original"; // } // } // }; // event handlers on bookmark and breakpoint don't need deregistration bookmark.IsEnabledChanged += delegate { breakpoint.Enabled = bookmark.IsEnabled; }; breakpoint.Set += delegate { //setBookmarkColor(); }; //setBookmarkColor(); EventHandler <CollectionItemEventArgs <Process> > bp_debugger_ProcessStarted = (sender, e) => { //setBookmarkColor(); // User can change line number by inserting or deleting lines breakpoint.Line = bookmark.LineNumber; }; EventHandler <CollectionItemEventArgs <Process> > bp_debugger_ProcessExited = (sender, e) => { //setBookmarkColor(); }; EventHandler <BreakpointEventArgs> bp_debugger_BreakpointHit = new EventHandler <BreakpointEventArgs>( delegate(object sender, BreakpointEventArgs e) { //LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Condition); switch (bookmark.Action) { case BreakpointAction.Break: break; case BreakpointAction.Condition: // if (Evaluate(bookmark.Condition, bookmark.ScriptLanguage)) // DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber, bookmark.FileName, bookmark.Condition)); // else // this.debuggedProcess.AsyncContinue(); break; case BreakpointAction.Trace: //DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}") + "\n", bookmark.LineNumber, bookmark.FileName)); break; } }); BookmarkEventHandler bp_bookmarkManager_Removed = null; bp_bookmarkManager_Removed = (sender, e) => { if (bookmark == e.Bookmark) { debugger.Breakpoints.Remove(breakpoint); // unregister the events debugger.Processes.Added -= bp_debugger_ProcessStarted; debugger.Processes.Removed -= bp_debugger_ProcessExited; breakpoint.Hit -= bp_debugger_BreakpointHit; BookmarkManager.Removed -= bp_bookmarkManager_Removed; } }; // register the events debugger.Processes.Added += bp_debugger_ProcessStarted; debugger.Processes.Removed += bp_debugger_ProcessExited; breakpoint.Hit += bp_debugger_BreakpointHit; BookmarkManager.Removed += bp_bookmarkManager_Removed; }
public void InvokeBreakpoint() { Breakpoint?.Invoke(this, new EventArgs()); }
public string BarBreakpoint(Breakpoint breakpoint) => null;
public Breakpoint SetBreakpoint(Address address) { this.AssertPaused(); this.connector.SetBreakpoint(address); var bp = new Breakpoint(address); this.breakpoints.Add(bp); // Fire event if (this.BreakpointSet != null) { this.BreakpointSet(this, new BreakpointChangedEventArgs(bp)); } return bp; }
public virtual void OnBreakpoint(AppDomain appDomainRef, Thread threadRef, Breakpoint breakpointRef) { _handleEvent(ManagedCallbackType.OnBreakpoint, new BreakpointEventArgs(appDomainRef, threadRef, breakpointRef, ManagedCallbackType.OnBreakpoint)); }
public void AddBreakpoint(Breakpoint.BreakpointType type, ushort address) { accessBreakpoints.Add(new Breakpoint(type, address)); }
public virtual void OnBreakpointSetError(AppDomain appDomainRef, Thread threadRef, Breakpoint breakpointRef, int dwError) { _handleEvent(ManagedCallbackType.OnBreakpointSetError, new BreakpointSetErrorEventArgs(appDomainRef, threadRef, breakpointRef, dwError, ManagedCallbackType.OnBreakpointSetError)); }
private void mnuDisableBreakpoint_Click(object sender, EventArgs e) { Breakpoint bp = GetCurrentLineBreakpoint(); bp.SetEnabled(!bp.Enabled); }
internal BreakpointRecord(ISourceBreakpoint sbp) { Breakpoint = new Breakpoint(true, sbp.Line); }
public void SetBreakpoint(Breakpoint bp) { if (!mBreakpoints.ContainsKey(bp)) { mBreakpoints[bp] = bp; SendBPCommand('Z', bp); } }
public abstract string BarBreakpoint(Breakpoint breakpoint);
public void RegisterBreakpoint(Breakpoint bp) { RegisteredBreakpoints.Add(bp); }
public abstract string Col(ColumnWidth columnWidth, Breakpoint breakpoint, bool offset);
private void btnCancel_Click(object sender, EventArgs e) { Breakpoint = null; DialogResult = DialogResult.Cancel; Close(); }
/// <summary> /// Updates the breakpoint state or mutable fields. /// The entire Breakpoint message must be sent back to the controller service. /// /// Updates to active breakpoint fields are only allowed if the new value /// does not change the breakpoint specification. Updates to the `location`, /// `condition` and `expressions` fields should not alter the breakpoint /// semantics. These may only make changes such as canonicalizing a value /// or snapping the location to the correct line of code. /// </summary> /// <param name="debuggeeId"> /// Required. Identifies the debuggee being debugged. /// </param> /// <param name="breakpoint"> /// Required. Updated breakpoint information. /// The field `id` must be set. /// The agent must echo all Breakpoint specification fields in the update. /// </param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <UpdateActiveBreakpointResponse> UpdateActiveBreakpointAsync(string debuggeeId, Breakpoint breakpoint, gaxgrpc::CallSettings callSettings = null) => UpdateActiveBreakpointAsync(new UpdateActiveBreakpointRequest { DebuggeeId = gax::GaxPreconditions.CheckNotNullOrEmpty(debuggeeId, nameof(debuggeeId)), Breakpoint = gax::GaxPreconditions.CheckNotNull(breakpoint, nameof(breakpoint)), }, callSettings);
/// <summary> /// analyzes a node /// </summary> /// <param name="activeNode"> the active node </param> /// <param name="index"> indicates the index of the item </param> /// <param name="tolerance"> indicates the tolerance for badness </param> /// <param name="lineProvider"> the line provider </param> /// <returns> the next node </returns> private LinkedListNode<Breakpoint> AnalyzeNode( LinkedListNode<Breakpoint> activeNode, int index, double tolerance, ILineProvider lineProvider) { Contract.Requires(activeNode != null); Contract.Requires(index >= 0); Contract.Requires(Check.IsFinite(tolerance)); Contract.Requires(tolerance >= 1.0); Contract.Requires(lineProvider != null); LinkedListNode<Breakpoint> nextNode = activeNode.Next; int currentLine = activeNode.Value.Line; LineItem indexItem = _Items[index]; double ratio = ComputeRatio( ref indexItem, activeNode, currentLine, lineProvider); if(ratio < -1.0 || indexItem.IsForcedBreak) { _Active.Remove(activeNode); _LastDeactivated = activeNode.Value; } if(ratio >= -1.0 && ratio <= tolerance) { Demerits demerits = indexItem.ComputeDemerits(ratio / tolerance); demerits = indexItem.CombineFlaggedDemerits( _Items[activeNode.Value.Position], demerits); LineFitness fitness = LineFitness.FromLineRatio(ratio / tolerance); if(fitness.MeasureFitnessGap(activeNode.Value.Fitness) > 1) { demerits += Demerits.FitnessPenalty; } demerits += activeNode.Value.Demerits; if(demerits < _Candidates[fitness].Demerits) { double totalWidth; double totalShrink; double totalStretch; ComputeSum(index, out totalWidth, out totalShrink, out totalStretch); _Candidates[fitness] = new Breakpoint( index, currentLine + 1, fitness, totalWidth, totalStretch, totalShrink, demerits, ratio, activeNode.Value); _MinimumCandidate = Math.Min(_MinimumCandidate.Value, demerits.Value); } } return nextNode; }
/// <summary> /// Updates the breakpoint state or mutable fields. /// The entire Breakpoint message must be sent back to the controller service. /// /// Updates to active breakpoint fields are only allowed if the new value /// does not change the breakpoint specification. Updates to the `location`, /// `condition` and `expressions` fields should not alter the breakpoint /// semantics. These may only make changes such as canonicalizing a value /// or snapping the location to the correct line of code. /// </summary> /// <param name="debuggeeId"> /// Required. Identifies the debuggee being debugged. /// </param> /// <param name="breakpoint"> /// Required. Updated breakpoint information. /// The field `id` must be set. /// The agent must echo all Breakpoint specification fields in the update. /// </param> /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <UpdateActiveBreakpointResponse> UpdateActiveBreakpointAsync(string debuggeeId, Breakpoint breakpoint, st::CancellationToken cancellationToken) => UpdateActiveBreakpointAsync(debuggeeId, breakpoint, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
private void HandleCompositeCommand(JdwpPacket packet) { var data = packet.Data; var suspendPolicy = (Jdwp.SuspendPolicy) data.GetByte(); var count = data.GetInt(); for (var i = 0; i < count; i++) { var eventKind = (Jdwp.EventKind) data.GetByte(); JdwpEvent evt; switch (eventKind) { case Jdwp.EventKind.VmInit: evt = new VmStart(data); break; case Jdwp.EventKind.SingleStep: evt = new SingleStep(data); break; case Jdwp.EventKind.BreakPoint: evt = new Breakpoint(data); break; case Jdwp.EventKind.MethodEntry: evt = new MethodEntry(data); break; case Jdwp.EventKind.MethodExit: evt = new MethodExit(data); break; case Jdwp.EventKind.Exception: evt = new Exception(data); break; case Jdwp.EventKind.ThreadStart: evt = new ThreadStart(data); break; case Jdwp.EventKind.ThreadEnd: evt = new ThreadDeath(data); break; case Jdwp.EventKind.ClassPrepare: evt = new ClassPrepare(data); break; case Jdwp.EventKind.ClassUnload: evt = new ClassUnload(data); break; case Jdwp.EventKind.FieldAccess: evt = new FieldAccess(data); break; case Jdwp.EventKind.FieldModification: evt = new FieldModification(data); break; case Jdwp.EventKind.VmDeath: evt = new VmDeath(data); break; default: throw new ArgumentException("Unknown event kind in compositive command " + (int)eventKind); } DLog.Debug(DContext.DebuggerLibDebugger, "JDWP event {0} {1}", eventKind, evt); Task.Factory.StartNew(() => { evt.Accept(compositeCommandProcessor, suspendPolicy); }).ContinueWith(task => { DLog.Error(DContext.DebuggerLibJdwpConnection, "HandleCompositeCommand: Internal failure on event processing. SuspendPolicy was {1}; IsCancelled={0}. Exception={1}", suspendPolicy, task.IsCanceled, task.Exception); if (suspendPolicy != Jdwp.SuspendPolicy.None) { // we should better resume the VM, as the command handler may have failed to do so. if(Connected) VirtualMachine.ResumeAsync(); } }, TaskContinuationOptions.NotOnRanToCompletion); } }
public virtual void Remove(Breakpoint entry) { if (g.IsDebugging) { // Tell the program that we're clearing a breakpoint g.LogDebug("CPROJECT::BreakpointCollection::Remove: Clear breakpoint from debugger"); string filerelpath = CProject.Breakpoint.FixPath(CProject.PathGetRelative(Path.GetFullPath(entry.file.RelativePath), Path.GetDirectoryName(Path.GetFullPath(g.Project.DebugExe)))); frmMain.stc_DebugQueue.Add("BRKCLR " + filerelpath + " " + Convert.ToString(entry.LineNumber + 1) + "\n"); } this.List.Remove(entry); }
public Breakpoint SetBreakpoint(Address address) { if (address.Type == AddressType.Logical) { throw new InvalidOperationException("Logical addressing not supported"); } connector.SetBreakpoint(address.Value); var bp = new Breakpoint(address); this.breakpoints.Add(bp); // Fire event if (this.BreakpointSet != null) { this.BreakpointSet(this, new BreakpointChangedEventArgs(bp)); } return bp; }
public async Task SendAsync_ShouldRetryWithNewToken_WhenRefreshedWhileRequesting() { // Arrange BreakpointHandler breakpointHandler = new BreakpointHandler { InnerHandler = _innerHandler }; Breakpoint requestBreakpoint = breakpointHandler.Breakpoint; BreakpointTokenClient breakpointTokenClient = new BreakpointTokenClient(_tokenClient); Breakpoint tokenClientBreakpoint = breakpointTokenClient.Breakpoint; UnauthorizedResponseHandler handler = new UnauthorizedResponseHandler(breakpointTokenClient, _tokenStorage, _userStorage, _logger) { InnerHandler = breakpointHandler }; HttpClient client = new HttpClient(handler) { BaseAddress = _baseAddress }; _tokenClient.RefreshTokenAsync(Arg.Any <CancellationToken>()) .Returns(ApiResponseResult <RefreshTokenResponse> .Ok( new RefreshTokenResponse { AccessToken = "New access token", RefreshToken = "New refresh token" })); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); // Act Task task1 = Task.CompletedTask; Task task2 = Task.CompletedTask; try { // Sending first request and pausing it HttpRequestMessage request1 = new HttpRequestMessage(HttpMethod.Get, "/vpn"); task1 = client.SendAsync(request1); BreakpointHit request1Hit = await requestBreakpoint.WaitForHit().TimeoutAfter(TestTimeout); // Sending second request and pausing it HttpRequestMessage request2 = new HttpRequestMessage(HttpMethod.Get, "/profiles"); task2 = client.SendAsync(request2); BreakpointHit request2Hit = await requestBreakpoint.WaitForHit().TimeoutAfter(TestTimeout); // Continue first request and get Unauthorized _innerHandler.Expect(HttpMethod.Get, "https://api.protonvpn.ch/vpn") .Respond(HttpStatusCode.Unauthorized); request1Hit.Continue(); // First request initiated token refresh await tokenClientBreakpoint.WaitForHitAndContinue().TimeoutAfter(TestTimeout); // First request retried with new tokens request1Hit = await requestBreakpoint.WaitForHit().TimeoutAfter(TestTimeout); _innerHandler.Expect(HttpMethod.Get, "https://api.protonvpn.ch/vpn") .WithHeaders("Authorization", "Bearer New access token") .Respond(req => response); request1Hit.Continue(); await task1.TimeoutAfter(TestTimeout); // Second request continues and gets Unauthorized _innerHandler.Expect(HttpMethod.Get, "https://api.protonvpn.ch/profiles") .Respond(HttpStatusCode.Unauthorized); request2Hit.Continue(); // Second request retried with new access token request2Hit = await requestBreakpoint.WaitForHit().TimeoutAfter(TestTimeout); _innerHandler.Expect(HttpMethod.Get, "https://api.protonvpn.ch/profiles") .WithHeaders("Authorization", "Bearer New access token") .Respond(req => response); request2Hit.Continue(); } finally { await task1.TimeoutAfter(TestTimeout); await task2.TimeoutAfter(TestTimeout); } // Assert await _tokenClient.Received(1).RefreshTokenAsync(Arg.Any <CancellationToken>()); _innerHandler.VerifyNoOutstandingExpectation(); }
private void btnAddBreakpoint_Click(object sender, EventArgs e) { Breakpoint orig_bp = new Breakpoint(-1, Breakpoint.BPType.Software, last_EIP, 1, ""); EditBreakpoint(orig_bp); }
public BreakpointTokenClient(ITokenClient origin) { _origin = origin; Breakpoint = new Breakpoint(); }
internal override FunctionBreakpointHandle GetBreakpointHandle( Breakpoint breakpoint, int line, int column) { throw new InvalidOperationException (); }
public BreakpointHandler() { Breakpoint = new Breakpoint(); }
// <summary> // A breakpoint has been hit; now the sse needs to find out what do do: // either ignore the breakpoint and continue or keep the target stopped // and send out the notification. // // If @index is zero, we hit an "unknown" breakpoint - ie. a // breakpoint which we did not create. Normally, this means that there // is a breakpoint instruction (such as G_BREAKPOINT ()) in the code. // Such unknown breakpoints are handled by the Debugger; one of // the language backends may recognize the breakpoint's address, for // instance if this is the JIT's breakpoint trampoline. // // Returns true if the target should remain stopped and false to // continue stepping. // // If we can't find a handler for the breakpoint, the default is to stop // the target and let the user decide what to do. // </summary> bool child_breakpoint(Inferior.ChildEvent cevent, int index, out Breakpoint bpt) { // The inferior knows about breakpoints from all threads, so if this is // zero, then no other thread has set this breakpoint. if (index == 0) { bpt = null; return true; } Inferior.StackFrame iframe = inferior.GetCurrentFrame (); bpt = lookup_breakpoint (index); if (bpt == null) return false; if (bpt is MainMethodBreakpoint) { main_retaddr = iframe.StackPointer + inferior.TargetAddressSize; reached_main = true; } if (!bpt.Breaks (thread.ID) || !process.BreakpointManager.IsBreakpointEnabled (index)) return false; index = bpt.Index; bool remain_stopped; if (bpt.BreakpointHandler (inferior, out remain_stopped)) return remain_stopped; TargetAddress address = inferior.CurrentFrame; return bpt.CheckBreakpointHit (thread, address); }
public void AreAlignSelf_With_Breakpoints(string expected, FlexAlignSelf alignSelf, Breakpoint breakpoint) { var flex = new FluentFlex(); flex.WithAlignSelf(alignSelf); flex.WithBreakpoint(breakpoint); var classname = flex.Class(classProvider); Assert.Equal(expected, classname); }
internal void TestDebuggerSteps( NodeDebugger process, NodeThread thread, string filename, IEnumerable<TestStep> steps, ExceptionHitTreatment? defaultExceptionTreatment = null, ICollection<KeyValuePair<string, ExceptionHitTreatment>> exceptionTreatments = null, bool waitForExit = false ) { if (!Path.IsPathRooted(filename)) { filename = DebuggerTestPath + filename; } // Since Alpha does not support break on unhandled, and the commonly used Express module has handled SyntaxError exceptions, // for alpha we have SyntaxErrors set to BreakNever by default. Here we set it to BreakAlways so unit tests can run // assuming BreakAlways is the default. // TODO: Remove once exception treatment is updated for just my code support when it is added after Alpha process.SetExceptionTreatment(null, CollectExceptionTreatments(ExceptionHitTreatment.BreakAlways, "SyntaxError")); if (defaultExceptionTreatment != null || exceptionTreatments != null) { process.SetExceptionTreatment(defaultExceptionTreatment, exceptionTreatments); } Dictionary<Breakpoint, NodeBreakpoint> breakpoints = new Dictionary<Breakpoint, NodeBreakpoint>(); AutoResetEvent entryPointHit = new AutoResetEvent(false); process.EntryPointHit += (sender, e) => { Console.WriteLine("EntryPointHit"); Assert.AreEqual(e.Thread, thread); entryPointHit.Set(); }; AutoResetEvent breakpointBound = new AutoResetEvent(false); process.BreakpointBound += (sender, e) => { Console.WriteLine("BreakpointBound {0} {1}", e.BreakpointBinding.Position.FileName, e.BreakpointBinding.Position.Line); breakpointBound.Set(); }; AutoResetEvent breakpointUnbound = new AutoResetEvent(false); process.BreakpointUnbound += (sender, e) => { Console.WriteLine("BreakpointUnbound"); breakpointUnbound.Set(); }; AutoResetEvent breakpointBindFailure = new AutoResetEvent(false); process.BreakpointBindFailure += (sender, e) => { Console.WriteLine("BreakpointBindFailure"); breakpointBindFailure.Set(); }; AutoResetEvent breakpointHit = new AutoResetEvent(false); process.BreakpointHit += (sender, e) => { Console.WriteLine("BreakpointHit {0}", e.BreakpointBinding.Target.Line); Assert.AreEqual(e.Thread, thread); Assert.AreEqual(e.BreakpointBinding.Target.Line, thread.Frames.First().Line); breakpointHit.Set(); }; AutoResetEvent stepComplete = new AutoResetEvent(false); process.StepComplete += (sender, e) => { Console.WriteLine("StepComplete"); Assert.AreEqual(e.Thread, thread); stepComplete.Set(); }; AutoResetEvent exceptionRaised = new AutoResetEvent(false); NodeException exception = null; process.ExceptionRaised += (sender, e) => { Console.WriteLine("ExceptionRaised"); Assert.AreEqual(e.Thread, thread); exception = e.Exception; exceptionRaised.Set(); }; AutoResetEvent processExited = new AutoResetEvent(false); int exitCode = 0; process.ProcessExited += (sender, e) => { Console.WriteLine("ProcessExited {0}", e.ExitCode); exitCode = e.ExitCode; processExited.Set(); }; Console.WriteLine("-----------------------------------------"); Console.WriteLine("Begin debugger step test"); foreach (var step in steps) { Console.WriteLine("Step: {0}", step._action); Assert.IsFalse( ((step._expectedEntryPointHit != null ? 1 : 0) + (step._expectedBreakpointHit != null ? 1 : 0) + (step._expectedStepComplete != null ? 1 : 0) + (step._expectedExceptionRaised != null ? 1 : 0)) > 1); bool wait = false; NodeBreakpoint nodeBreakpoint; switch (step._action) { case TestAction.None: break; case TestAction.Wait: wait = true; break; case TestAction.ResumeThread: thread.Resume(); wait = true; break; case TestAction.ResumeProcess: process.Resume(); wait = true; break; case TestAction.StepOver: thread.StepOver(); wait = true; break; case TestAction.StepInto: thread.StepInto(); wait = true; break; case TestAction.StepOut: thread.StepOut(); wait = true; break; case TestAction.AddBreakpoint: string breakpointFileName = step._targetBreakpointFile; if (breakpointFileName != null) { if (!step._builtin && !Path.IsPathRooted(breakpointFileName)) { breakpointFileName = DebuggerTestPath + breakpointFileName; } } else { breakpointFileName = filename; } int breakpointLine = step._targetBreakpoint.Value; int breakpointColumn = step._targetBreakpointColumn.HasValue ? step._targetBreakpointColumn.Value : 0; Breakpoint breakpoint = new Breakpoint(breakpointFileName, breakpointLine, breakpointColumn); Assert.IsFalse(breakpoints.TryGetValue(breakpoint, out nodeBreakpoint)); breakpoints[breakpoint] = AddBreakPoint( process, breakpointFileName, breakpointLine, breakpointColumn, step._enabled ?? true, step._breakOn ?? new BreakOn(), step._condition ); if (step._expectFailure) { AssertWaited(breakpointBindFailure); AssertNotSet(breakpointBound); breakpointBindFailure.Reset(); } else { AssertWaited(breakpointBound); AssertNotSet(breakpointBindFailure); breakpointBound.Reset(); } break; case TestAction.RemoveBreakpoint: breakpointFileName = step._targetBreakpointFile ?? filename; breakpointLine = step._targetBreakpoint.Value; breakpointColumn = step._targetBreakpointColumn.HasValue ? step._targetBreakpointColumn.Value : 0; breakpoint = new Breakpoint(breakpointFileName, breakpointLine, breakpointColumn); breakpoints[breakpoint].Remove().WaitAndUnwrapExceptions(); breakpoints.Remove(breakpoint); AssertWaited(breakpointUnbound); breakpointUnbound.Reset(); break; case TestAction.UpdateBreakpoint: breakpointFileName = step._targetBreakpointFile ?? filename; breakpointLine = step._targetBreakpoint.Value; breakpointColumn = step._targetBreakpointColumn.HasValue ? step._targetBreakpointColumn.Value : 0; breakpoint = new Breakpoint(breakpointFileName, breakpointLine, breakpointColumn); nodeBreakpoint = breakpoints[breakpoint]; foreach (var breakpointBinding in nodeBreakpoint.GetBindings()) { if (step._hitCount != null) { Assert.IsTrue(breakpointBinding.SetHitCountAsync(step._hitCount.Value).WaitAndUnwrapExceptions()); } if (step._enabled != null) { Assert.IsTrue(breakpointBinding.SetEnabledAsync(step._enabled.Value).WaitAndUnwrapExceptions()); } if (step._breakOn != null) { Assert.IsTrue(breakpointBinding.SetBreakOnAsync(step._breakOn.Value).WaitAndUnwrapExceptions()); } if (step._condition != null) { Assert.IsTrue(breakpointBinding.SetConditionAsync(step._condition).WaitAndUnwrapExceptions()); } } break; case TestAction.KillProcess: process.Terminate(); break; case TestAction.Detach: process.Detach(); break; } if (wait) { if (step._expectedEntryPointHit != null) { AssertWaited(entryPointHit); AssertNotSet(breakpointHit); AssertNotSet(stepComplete); AssertNotSet(exceptionRaised); Assert.IsNull(exception); entryPointHit.Reset(); } else if (step._expectedBreakpointHit != null) { if (step._expectReBind) { AssertWaited(breakpointUnbound); AssertWaited(breakpointBound); breakpointUnbound.Reset(); breakpointBound.Reset(); } AssertWaited(breakpointHit); AssertNotSet(entryPointHit); AssertNotSet(stepComplete); AssertNotSet(exceptionRaised); Assert.IsNull(exception); breakpointHit.Reset(); } else if (step._expectedStepComplete != null) { AssertWaited(stepComplete); AssertNotSet(entryPointHit); AssertNotSet(breakpointHit); AssertNotSet(exceptionRaised); Assert.IsNull(exception); stepComplete.Reset(); } else if (step._expectedExceptionRaised != null) { AssertWaited(exceptionRaised); AssertNotSet(entryPointHit); AssertNotSet(breakpointHit); AssertNotSet(stepComplete); exceptionRaised.Reset(); } else { AssertNotSet(entryPointHit); AssertNotSet(breakpointHit); AssertNotSet(stepComplete); AssertNotSet(exceptionRaised); Assert.IsNull(exception); } } if (step._expectedEntryPointHit != null) { Assert.AreEqual(step._expectedEntryPointHit.Value, thread.Frames.First().Line); } else if (step._expectedBreakpointHit != null) { Assert.AreEqual(step._expectedBreakpointHit.Value, thread.Frames.First().Line); } else if (step._expectedStepComplete != null) { Assert.AreEqual(step._expectedStepComplete.Value, thread.Frames.First().Line); } else if (step._expectedExceptionRaised != null) { Assert.AreEqual(step._expectedExceptionRaised.TypeName, exception.TypeName); Assert.AreEqual(step._expectedExceptionRaised.Description, exception.Description); if (step._expectedExceptionRaised.LineNo != null) { Assert.AreEqual(step._expectedExceptionRaised.LineNo.Value, thread.Frames[0].Line); } exception = null; } var expectedBreakFile = step._expectedBreakFile; if (expectedBreakFile != null) { if (!step._builtin && !Path.IsPathRooted(expectedBreakFile)) { expectedBreakFile = DebuggerTestPath + expectedBreakFile; } Assert.AreEqual(expectedBreakFile, thread.Frames.First().FileName); } var expectedBreakFunction = step._expectedBreakFunction; if (expectedBreakFunction != null) { Assert.AreEqual(expectedBreakFunction, thread.Frames.First().FunctionName); } if (step._expectedHitCount != null) { string breakpointFileName = step._targetBreakpointFile ?? filename; if (!step._builtin && !Path.IsPathRooted(breakpointFileName)) { breakpointFileName = DebuggerTestPath + breakpointFileName; } int breakpointLine = step._targetBreakpoint.Value; int breakpointColumn = step._targetBreakpointColumn.HasValue ? step._targetBreakpointColumn.Value : 0; var breakpoint = new Breakpoint(breakpointFileName, breakpointLine, breakpointColumn); nodeBreakpoint = breakpoints[breakpoint]; foreach (var breakpointBinding in nodeBreakpoint.GetBindings()) { Assert.AreEqual(step._expectedHitCount.Value, breakpointBinding.GetHitCount()); } } if (step._validation != null) { step._validation(process, thread); } if (step._expectedExitCode != null) { AssertWaited(processExited); Assert.AreEqual(step._expectedExitCode.Value, exitCode); } } if (waitForExit) { process.WaitForExit(10000); } AssertNotSet(entryPointHit); AssertNotSet(breakpointHit); AssertNotSet(stepComplete); AssertNotSet(exceptionRaised); Assert.IsNull(exception); }
public void AreAlignContent_With_Breakpoints(string expected, FlexAlignContent alignContent, Breakpoint breakpoint) { var flex = new FluentFlex(); flex.WithFlexType(FlexType.Flex); flex.WithAlignContent(alignContent); flex.WithBreakpoint(breakpoint); var classname = flex.Class(classProvider); Assert.Equal(expected, classname); }
internal override FunctionBreakpointHandle GetBreakpointHandle( Breakpoint breakpoint, int line, int column) { return new MyBreakpointHandle (breakpoint, this, line, column); }
public void AreDirection_With_Breakpoints(string expected, FlexDirection direction, Breakpoint breakpoint) { var flex = new FluentFlex(); flex.WithFlexType(FlexType.Flex); flex.WithDirection(direction); flex.WithBreakpoint(breakpoint); var classname = flex.Class(classProvider); Assert.Equal(expected, classname); }
public void RemoveBreakpoint(Breakpoint bp) { mBreakpoints.Remove(bp); SendBPCommand('z', bp); }
/// <summary> /// Process the given breakpoint. /// </summary> protected abstract void ProcessBreakpoint(Breakpoint breakpoint);
void SendBPCommand(char ch, Breakpoint bp) { SendMessage (string.Format ("{0}{1},{2:X},{3:X}", ch, (int)bp.BreakpointType, bp.Address, bp.Length)); }
public void BuildCssClassSucceeds(OrderPosition position, Breakpoint breakpoint, string expectedCssClass) { new AbsoluteOrder(position).BuildCssClass(breakpoint).Should().Be(expectedCssClass); }
internal abstract FunctionBreakpointHandle GetBreakpointHandle( Breakpoint breakpoint, int line, int column);
private void fExtractBreakpoint(XmlNode _oNode) { Breakpoint _oBrk = new Breakpoint(); aBreakpoint.Add(_oBrk); DBGpClient.nBreakPointCurrID++; _oBrk.nID = DBGpClient.nBreakPointCurrID; foreach (XmlAttribute _oAtt in _oNode.Attributes) { switch (_oAtt.Name) { // case "id": //nope? // break; case "type": _oBrk.sType = _oAtt.Value; break; case "state": if (_oAtt.Value == "disabled") { _oBrk.bEnable = false; } else { _oBrk.bEnable = true; } break; case "resolved": if (_oAtt.Value == "unresolved") { _oBrk.bResolved = false; } else { _oBrk.bResolved = true; } break; case "filename": _oBrk.sPath = _oAtt.Value; break; case "lineno": Int32.TryParse(_oAtt.Value, out _oBrk.nLine); break; case "function": _oBrk.sFunction = _oAtt.Value; break; case "exception": _oBrk.sExeption = _oAtt.Value; break; case "expression": _oBrk.sExpression = _oAtt.Value; break; case "hit_value": Int32.TryParse(_oAtt.Value, out _oBrk.nHitValue); break; case "hit_condition": _oBrk.sHitCondition = _oAtt.Value; break; case "hit_count": Int32.TryParse(_oAtt.Value, out _oBrk.nHitCount); break; } // <expression>EXPRESSION</expression> </breakpoint> } }
public void UnRegisterBreakpoint(Breakpoint bp) { RegisteredBreakpoints.Remove(bp); }
public override string BarBreakpoint(Breakpoint breakpoint) => $"navbar-expand-{ToBreakpoint( breakpoint )}";
protected internal override void OnTrigger(Breakpoint @event) { TaskCompletionSource<object> task; while(_waiters.TryDequeue(out task)) task.SetResult(null); }
public void BuildCssClassSucceeds(FlexOrientation orientation, bool reversed, Breakpoint breakpoint, string expected) { new FlexDirection { Orientation = orientation, Reversed = reversed }.BuildCssClass(breakpoint).Should().Be(expected); }
private void btnOK_Click(object sender, EventArgs e) { try { if (Breakpoint == null) Breakpoint = new Breakpoint(-1); Breakpoint.Enabled = false; Breakpoint.Address = ulong.Parse(txtAddress.Text, NumberStyles.HexNumber); Breakpoint.Condition = txtCondition.Text; if (radBPX.Checked) { Breakpoint.BreakpointType = DebugProtocol.Breakpoint.BPType.Software; Breakpoint.Length = 1; } else if (radBPM.Checked) { if (radRead.Checked) Breakpoint.BreakpointType = DebugProtocol.Breakpoint.BPType.ReadWatch; else if (radWrite.Checked) Breakpoint.BreakpointType = DebugProtocol.Breakpoint.BPType.WriteWatch; else if (radReadWrite.Checked) Breakpoint.BreakpointType = DebugProtocol.Breakpoint.BPType.AccessWatch; else if (radExecute.Checked) Breakpoint.BreakpointType = DebugProtocol.Breakpoint.BPType.Hardware; if (radByte.Checked) Breakpoint.Length = 1; else if (radWord.Checked) Breakpoint.Length = 2; else if (radDword.Checked) Breakpoint.Length = 4; } DialogResult = DialogResult.OK; Close(); } catch (Exception) { } // If something goes wrong, don't close }
public virtual string BarBreakpoint(Breakpoint breakpoint) => $"navbar-expand-{ToBreakpoint( breakpoint )}";
public void SetBreakpointChecker(Breakpoint breakpoint) { breakpoint.TrySetChecker(BreakpointChecker); }
/// <summary> /// Removes the given breakpoint. /// </summary> protected override void ProcessBreakpoint(Breakpoint breakpoint) { Runspace.Debugger.RemoveBreakpoint(breakpoint); }
/// <summary> /// finds the optimal breakpoints in the item sequence /// </summary> /// <param name="tolerance"> indicates the tolerance for suboptimal lines </param> /// <param name="lineProvider"> the line provider </param> /// <param name="isOverfullAllowed"> indicates whether overfull lines are permitted </param> /// <returns> <c>true</c> if the sequence of items was successfully broken into lines; otherwise, <c>false</c> </returns> private bool FindBreakpointsInternal( double tolerance, ILineProvider lineProvider, bool isOverfullAllowed) { Contract.Requires(Check.IsFinite(tolerance)); Contract.Requires(tolerance >= 1.0); Contract.Requires(lineProvider != null); _Active.AddFirst(Breakpoint.Empty); _RunningWidthSum = 0.0; _RunningStretchSum = 0.0; _RunningShrinkSum = 0.0; for(int i = 0; i < _Items.Count; ++i) { LineItem item = _Items[i]; if(ExaminingItem != null) { ExaminingItem(ref item); } // analyze each possible breaking point if(IsFeasibleBreakpoint(i)) { AnalyzeBreakpoint(i, tolerance, lineProvider); } if(ItemExamined != null) { ItemExamined(ref item); } _RunningWidthSum += !item.IsPenalty ? item.Width : 0.0; _RunningStretchSum += item.IsGlue ? item.Stretch : 0.0; _RunningShrinkSum += item.IsGlue ? item.Shrink : 0.0; } Breakpoint breakpoint; if(_Active.Count == 0) { if(isOverfullAllowed) { // panic by using the last known breaking point breakpoint = _LastDeactivated; } else { // no possible breaking points with the given tolerance _Indices.Clear(); return false; } } else { LinkedListNode<Breakpoint> activeNode = _Active.First; for(var node = _Active.First; node != null; node = node.Next) { // select the tree-line having the least demerits if(node.Value.Demerits < activeNode.Value.Demerits) { activeNode = node; } } breakpoint = activeNode.Value; } _Active.Clear(); _Indices.Clear(); while(breakpoint != null) { // add each breaking point in the chain _Indices.Add(new BreakIndex(breakpoint.Position, breakpoint.Ratio)); breakpoint = breakpoint.Previous; } _Indices.Reverse(); _LastDeactivated = null; return true; }
public void BuildCssClassesSucceeds(Sides sides, Breakpoint breakpoint, string[] expectedCssClasses) { new AutoMarginSide { ImpactedSides = sides }.BuildCssClasses(breakpoint).Should().BeEquivalentTo(expectedCssClasses); }