Ejemplo n.º 1
0
 private void m_debuggerClient_BreakpointEvent(object sender, BreakpointEventArgs e)
 {
     if (ExceptionEvent != null)
     {
         BreakpointEvent(sender, new BreakpointEventArgs(e.BreakpointEvent));
     }
 }
 protected virtual void OnBreakpointHit(object sender, BreakpointEventArgs e)
 {
     if (BreakpointHit != null)
     {
         BreakpointHit(this, new BreakpointEventArgs(e.Breakpoint));
     }
 }
Ejemplo n.º 3
0
            } // end _ShouldOutput()

            public int Breakpoint(WDebugBreakpoint Bp)
            {
                try
                {
                    var bi = new DbgBreakpointInfo(m_debugger, Bp);
                    if (bi.IsOneShot)
                    {
                        // If we /hit/ a breakpoint, and it was "one-shot", then it's
                        // going to get deleted out from under us. Prevent AVs later by
                        // marking it invalid now.
                        bi.MarkInvalid();
                    }

                    var eventArgs = new BreakpointEventArgs(m_debugger, bi);
                    int retVal    = _RaiseEvent(m_debugger.BreakpointHit, eventArgs);
                    if (_ShouldOutput(retVal, eventArgs))
                    {
                        // Special case for "gu"/"step out" breakpoints: we're going to
                        // pretend they don't exist.
                        if (DbgBreakpointInfo.StepOutBreakpointId != bi.Id)
                        {
                            _PsPipe.WriteObject(eventArgs);
                        }
                    }
                    return(retVal);
                }
                catch (Exception e)
                {
                    Util.FailFast("Unexpected exception during event callback.", e);
                    return(0);
                }
            } // end Breakpoint()
 protected virtual void OnBreakpointStateChanged(object sender, BreakpointEventArgs e)
 {
     if (BreakpointStateChanged != null)
     {
         BreakpointStateChanged(this, new BreakpointEventArgs(e.Breakpoint));
     }
 }
Ejemplo n.º 5
0
        private void BreakpointService_Added(object sender, BreakpointEventArgs e)
        {
            var bpLine = GetLineByAddress(e.Address) as DisassemblyInstructionLineViewModel;

            if (bpLine != null)
            {
                bpLine.HasBreakpoint = true;
            }
        }
Ejemplo n.º 6
0
        private void HandleBp(object sender, BreakpointEventArgs args)
        {
            uint bpId = args.Breakpoint.Id;

            if (bpId == this.getVersionBp.Id)
            {
                this.getVersionRetBp.Offset  = this.ctrl.ReturnOffset;
                this.getVersionRetBp.Options = BreakpointOptions.Enabled;
            }
            else if (bpId == this.getVersionExBp.Id)
            {
                ulong[] ptrs = new ulong[1];
                this.data.ReadPointersVirtual(1, this.regs.StackOffset + 4, ptrs);
                this.osVerOffset = ptrs[0];

                this.getVersionExRetBp.Offset  = this.ctrl.ReturnOffset;
                this.getVersionExRetBp.Options = BreakpointOptions.Enabled;
            }
            else if (bpId == this.getVersionRetBp.Id)
            {
                this.getVersionRetBp.Options &= ~BreakpointOptions.Enabled;

                this.regs.SetValue(this.eaxIndex, this.versionNumber);

                Console.Out.WriteLine("HEALER: GetVersion returns {0}", this.versionNumber.ToString("x"));
            }
            else if (bpId == this.getVersionExRetBp.Id)
            {
                this.getVersionExRetBp.Options &= ~BreakpointOptions.Enabled;

                int sizeOfOsVer = Marshal.SizeOf(this.osVer);

                byte[] rawOsVer = new byte[sizeOfOsVer];

                GCHandle gchOsVer = GCHandle.Alloc(this.osVer, GCHandleType.Pinned);

                try
                {
                    Marshal.Copy((IntPtr)gchOsVer, rawOsVer, 0, sizeOfOsVer);
                    this.data.WriteVirtual(this.osVerOffset, rawOsVer);
                }
                finally
                {
                    gchOsVer.Free();
                }

                Console.Out.WriteLine("HEALER: GetVersionEx returns {0}", this.versionNumber.ToString("x"));
            }
            else
            {
                return;
            }

            args.EventStatus = DebugStatus.Go;
        }
Ejemplo n.º 7
0
        private void OnBreakpoint(object sender, BreakpointEventArgs e)
        {
            var result = MessageBox.Show($"Pause execution at 0x{e.PC:X4}?", "Breakpoint hit",
                                         MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                FocusHexBox?.Invoke(_console.Cpu.PC);
                _cancel = true;
            }
        }
Ejemplo n.º 8
0
        internal void HandleBreakpointEvent(BreakpointEventArgs e)
        {
            var context = e.Thread.GetThreadContext();
            var eip     = (Register <uint>)context.GetRegisterByName("eip");

            eip.Value--;
            context.Flush();

            RestoreOriginalCode();
            OnBreakpointHit(e);
        }
Ejemplo n.º 9
0
        private void OnChange(object sender, BreakpointEventArgs e)
        {
            switch (e.EventType)
            {
            case BreakpointEventType.Add:
                var lvi = new ListViewItem()
                {
                    Text = $"${e.Address:X4}", Tag = e.Address
                };
                lvi.SubItems.Add(new ListViewItem.ListViewSubItem()
                {
                    Text = "Yes"
                });
                BreakpointsListView.Items.Add(lvi);
                break;

            case BreakpointEventType.Remove:
            {
                var item = BreakpointsListView.Items.Cast <ListViewItem>().FirstOrDefault(x => (int)x.Tag == e.Address);
                if (item != null)
                {
                    BreakpointsListView.Items.Remove(item);
                }
            }
            break;

            case BreakpointEventType.Clear:
                BreakpointsListView.Items.Clear();
                break;

            case BreakpointEventType.Enable:
            {
                var item = BreakpointsListView.Items.Cast <ListViewItem>().FirstOrDefault(x => (int)x.Tag == e.Address);
                if (item != null)
                {
                    item.SubItems[1].Text = "Yes";
                }
            }
            break;

            case BreakpointEventType.Disable:
            {
                var item = BreakpointsListView.Items.Cast <ListViewItem>().FirstOrDefault(x => (int)x.Tag == e.Address);
                if (item != null)
                {
                    item.SubItems[1].Text = "No";
                }
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 10
0
        public bool HandlePageGuardViolationEvent(DEBUG_EVENT debugEvent, out DebuggerAction nextAction)
        {
            // Memory breakpoints are implemented using page guards. We need to check if the page guard
            // violation originated from a breakpoint or not, and pause or continue execution when appropriate.

            const int ExceptionInformationReadWrite = 0;
            const int ExceptionInformationAddress   = 1;

            var info    = debugEvent.InterpretDebugInfoAs <EXCEPTION_DEBUG_INFO>();
            var process = _session.GetProcessById((int)debugEvent.dwProcessId);
            var thread  = process.GetThreadById((int)debugEvent.dwThreadId);

            if (info.ExceptionRecord.NumberParameters >= 2)
            {
                bool   isWrite = info.ExceptionRecord.ExceptionInformation[ExceptionInformationReadWrite] == 1;
                IntPtr address = (IntPtr)info.ExceptionRecord.ExceptionInformation[ExceptionInformationAddress];

                var pageGuard = process.GetContainingPageGuard(address);
                if (pageGuard != null)
                {
                    // Restore page guard after continuing.
                    _pageGuardsToRestore.Add(pageGuard);

                    if (pageGuard.Breakpoints.TryGetValue(address, out var breakpoint) &&
                        (breakpoint.BreakOnRead == !isWrite || breakpoint.BreakOnWrite == isWrite))
                    {
                        // Violation originated from a breakpoint.
                        var eventArgs = new BreakpointEventArgs(thread, breakpoint)
                        {
                            NextAction = DebuggerAction.Stop
                        };

                        breakpoint.HandleBreakpointEvent(eventArgs);
                        OnBreakpointHit(eventArgs);
                        nextAction = eventArgs.NextAction;
                    }
                    else
                    {
                        // Violation did not originate from a breakpoint.
                        _isRestoringFromGuard = true;
                        PrepareContextForSingleStep(thread);
                        nextAction = DebuggerAction.Continue;
                    }

                    return(true);
                }
            }


            nextAction = DebuggerAction.ContinueWithException;
            return(false);
        }
Ejemplo n.º 11
0
        private void OnBreakpointBindSucceeded(object sender, BreakpointEventArgs e)
        {
            IDebugPendingBreakpoint2 pendingBreakpoint;
            var boundBreakpoint = _breakpointManager.GetBreakpoint(e.Breakpoint);

            ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint);

            Send(
                new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint),
                AD7BreakpointBoundEvent.IID,
                null
                );
        }
Ejemplo n.º 12
0
        private void SessionOnBreakpointHit(object sender, BreakpointEventArgs args)
        {
            string breakpointType = null;

            if (args.Breakpoint is ISoftwareBreakpoint)
            {
                breakpointType = "Software";
            }
            else if (args.Breakpoint is IMemoryBreakpoint)
            {
                breakpointType = "Memory";
            }

            _logger.WriteLine(LoggerMessageType.Breakpoint, "{0} breakpoint at address {1:X8} hit.",
                              breakpointType,
                              args.Breakpoint.Address.ToInt64());
        }
Ejemplo n.º 13
0
        private void OnBreakpointBindSucceeded(object sender, BreakpointEventArgs e)
        {
            IDebugPendingBreakpoint2 pendingBreakpoint;
            AD7BoundBreakpoint       boundBreakpoint = _breakpointManager.GetBreakpoint(e.Breakpoint);

            ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint);

            Send(
                new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint),
                AD7BreakpointBoundEvent.IID,
                null
                );

            EventHandler <AD7EngineEventArgs> breakpointHit = EngineBreakpointHit;

            if (breakpointHit != null)
            {
                breakpointHit(this, new AD7EngineEventArgs(this));
            }
        }
Ejemplo n.º 14
0
        public void RaiseBreakpointEventViaDebuggerClient()
        {
            // Arrange
            var    connectionMock    = new Mock <IDebuggerConnection>();
            var    messageEventArgs  = new MessageEventArgs(Resources.NodeBreakpointResponse);
            var    client            = new DebuggerClient(connectionMock.Object);
            object sender            = null;
            BreakpointEventArgs args = null;

            // Act
            client.BreakpointEvent += (s, a) => {
                sender = s;
                args   = a;
            };
            connectionMock.Raise(f => f.OutputMessage += null, messageEventArgs);

            // Assert
            Assert.AreEqual(client, sender);
            Assert.IsNotNull(args);
            Assert.IsNotNull(args.BreakpointEvent);
        }
        void OnBreakpointUpdated(object s, BreakpointEventArgs args)
        {
            TreeIter it;

            if (!store.GetIterFirst(out it))
            {
                return;
            }
            do
            {
                Breakpoint bp = (Breakpoint)store.GetValue(it, (int)Columns.Breakpoint);
                if (bp == args.Breakpoint)
                {
                    string traceVal = bp.HitAction == HitAction.PrintExpression ? bp.LastTraceValue : "";
                    string hitCount = bp.HitCount > 0 ? bp.HitCount.ToString() : "";
                    store.SetValue(it, (int)Columns.HitCount, hitCount);
                    store.SetValue(it, (int)Columns.LastTrace, traceVal);
                    break;
                }
            }while (store.IterNext(ref it));
        }
Ejemplo n.º 16
0
        public bool HandleBreakpointEvent(DEBUG_EVENT debugEvent, out DebuggerAction nextAction)
        {
            // If signalled by an int3, the exception was thrown after the execution of int3.
            // Find corresponding breakpoint and restore the instruction pointer so that it seems
            // it has paused execution before the int3.

            var process = _session.GetProcessById((int)debugEvent.dwProcessId);
            var thread  = process.GetThreadById((int)debugEvent.dwThreadId);

            uint eip        = (uint)thread.GetThreadContext().GetRegisterByName("eip").Value - 1;
            var  breakpoint = process.GetSoftwareBreakpointByAddress((IntPtr)eip);

            // Check if breakpoint originated from a step-over action.
            if (breakpoint == null && _stepOverBreakpoint?.Address == (IntPtr)eip)
            {
                _stepOverBreakpoint.HandleBreakpointEvent(new BreakpointEventArgs(thread, _stepOverBreakpoint));
                _stepOverBreakpoint = null;
                nextAction          = FinalizeStep(thread);
                return(true);
            }

            if (breakpoint != null)
            {
                _breakpointsToRestore.Add(breakpoint);
                var eventArgs = new BreakpointEventArgs(thread, breakpoint)
                {
                    NextAction = DebuggerAction.Stop
                };

                breakpoint.HandleBreakpointEvent(eventArgs);
                OnBreakpointHit(eventArgs);
                nextAction = eventArgs.NextAction;
                return(true);
            }

            nextAction = DebuggerAction.ContinueWithException;
            return(false);
        }
        // Token: 0x06000117 RID: 279 RVA: 0x000052C0 File Offset: 0x000034C0
        private void OnBreakpointStatusChanged(object sender, BreakpointEventArgs args)
        {
            Breakpoint        breakpoint = args.Breakpoint;
            PendingBreakpoint pendingBreakpoint;

            if (this.TryGetPendingBreakpoint(args.Breakpoint, out pendingBreakpoint))
            {
                BreakEventStatus   status = args.Breakpoint.GetStatus(this.session);
                AD7BoundBreakpoint bound;
                if (status == BreakEventStatus.Bound)
                {
                    if (!BreakpointsAdapter.TryGetBoundBreakpoint(breakpoint, pendingBreakpoint, out bound))
                    {
                        bound = new AD7BoundBreakpoint(pendingBreakpoint, args.Breakpoint, this.process);
                        pendingBreakpoint.OnBreakpointBound(bound);
                        return;
                    }
                }
                else if (BreakpointsAdapter.TryGetBoundBreakpoint(breakpoint, pendingBreakpoint, out bound))
                {
                    pendingBreakpoint.OnBreakpointUnbound(bound);
                }
            }
        }
Ejemplo n.º 18
0
        void OnBreakpointUpdated(object s, BreakpointEventArgs args)
        {
            Runtime.RunInMainThread(() => {
                TreeIter it;

                if (!store.GetIterFirst(out it))
                {
                    return;
                }

                do
                {
                    var bp = (BreakEvent)store.GetValue(it, (int)Columns.Breakpoint);
                    if (bp == args.Breakpoint)
                    {
                        string hitCount = bp.HitCountMode != HitCountMode.None ? bp.CurrentHitCount.ToString() : "";
                        string traceVal = (bp.HitAction & HitAction.PrintExpression) != HitAction.None ? bp.LastTraceValue : "";
                        store.SetValue(it, (int)Columns.HitCount, hitCount);
                        store.SetValue(it, (int)Columns.LastTrace, traceVal);
                        break;
                    }
                } while (store.IterNext(ref it));
            });
        }
Ejemplo n.º 19
0
 protected virtual void OnBreakpointHit(BreakpointEventArgs e)
 {
     BreakpointHit?.Invoke(this, e);
 }
        public void Breakpoint(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugBreakpoint pBreakpoint)
        {
            Log("Breakpoint hit.");

            var domain = GetProcessWrapper(pAppDomain).GetAppDomain(pAppDomain);
            var thread = domain.GetThread(pThread);
            var breakpoint = domain.GetBreakpoint(pBreakpoint);
            
            var eventArgs = new BreakpointEventArgs(domain, thread, breakpoint);
            domain.DispatchBreakpointEvent(eventArgs);
            FinalizeEvent(eventArgs);
        }
 private void BreakpointManager_Added(object sender, BreakpointEventArgs e)
 {
     WabbitcodeBreakpointManager.AddBreakpoint(new FilePath(FileName), e.Breakpoint.LineNumber);
 }
Ejemplo n.º 22
0
		private void DebuggerControlBreakpointToggled( object sender, BreakpointEventArgs e )
		{
			_codeCache.Invalidate( e.Breakpoint.Address );
		}
Ejemplo n.º 23
0
        private void OnBreakpointBindSucceeded(object sender, BreakpointEventArgs e)
        {
            IDebugPendingBreakpoint2 pendingBreakpoint;
            var boundBreakpoint = _breakpointManager.GetBreakpoint(e.Breakpoint);
            ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint);

            Send(
                new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint),
                AD7BreakpointBoundEvent.IID,
                null
            );
        }
Ejemplo n.º 24
0
 private void _debuggee_PreBreakpoint(object sender, BreakpointEventArgs e)
 {
     BreakIfHandled(DebugTrigger.Breakpoint, e);
 }
Ejemplo n.º 25
0
 private void OnBreakpointBindFailed(object sender, BreakpointEventArgs e)
 {
 }
Ejemplo n.º 26
0
 static DebugStatus HandleBp(object sender, BreakpointEventArgs e)
 {
     Console.WriteLine("Breakpoint hit");
     return(DebugStatus.Go);
 }
Ejemplo n.º 27
0
 private void debuggerClient_BreakpointEvent(object sender, BreakpointEventArgs e)
 {
     //TODO: Change this to notify only the connection associatd with the script engine. (or that group?!)
     Clients.All.breakpointHit(e.BreakpointEvent);
 }
Ejemplo n.º 28
0
 internal void HandleBreakpointEvent(BreakpointEventArgs e)
 {
     OnBreakpointHit(e);
 }
Ejemplo n.º 29
0
 private void Debugger_BreakpointHit(object sender, BreakpointEventArgs eventArgs)
 {
     m_bea = eventArgs;
 }
Ejemplo n.º 30
0
 private void _debuggee_Breakpoint(object sender, BreakpointEventArgs e)
 {
     HandleIfBroken(DebugTrigger.Breakpoint, e);
     e.Status = DebugStatus.Go;
 }
 internal void DispatchBreakpointEvent(BreakpointEventArgs e)
 {
     OnPaused(e);
     OnBreakpointHit(e);
 }
 protected virtual void OnBreakpointHit(BreakpointEventArgs e)
 {
     if (BreakpointHit != null)
         BreakpointHit(this, e);
 }
Ejemplo n.º 33
0
 private void OnBreakpointBindFailed(object sender, BreakpointEventArgs e)
 {
 }
Ejemplo n.º 34
0
        private void OnBreakpointBindSucceeded(object sender, BreakpointEventArgs e)
        {
            IDebugPendingBreakpoint2 pendingBreakpoint;
            var boundBreakpoint = _breakpointManager.GetBreakpoint(e.Breakpoint);
            ((IDebugBoundBreakpoint2)boundBreakpoint).GetPendingBreakpoint(out pendingBreakpoint);

            Send(
                new AD7BreakpointBoundEvent((AD7PendingBreakpoint)pendingBreakpoint, boundBreakpoint),
                AD7BreakpointBoundEvent.IID,
                null
            );

            var breakpointHit = EngineBreakpointHit;
            if (breakpointHit != null) {
                breakpointHit(this, new AD7EngineEventArgs(this));
            }
        }
Ejemplo n.º 35
0
 private void DebuggerControlBreakpointToggled(object sender, BreakpointEventArgs e)
 {
     _codeCache.Invalidate(e.Breakpoint.Address);
 }
 private void TargetObject_BreakpointHit(object sender, BreakpointEventArgs e)
 {
     OnBreakpointHit(e);
 }