コード例 #1
0
ファイル: AD7Events.cs プロジェクト: happylancer/node-tools
 int IDebugBreakpointBoundEvent2.EnumBoundBreakpoints(out IEnumDebugBoundBreakpoints2 ppEnum)
 {
     var boundBreakpoints = new IDebugBoundBreakpoint2[1];
     boundBreakpoints[0] = m_boundBreakpoint;
     ppEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);
     return VSConstants.S_OK;
 }
コード例 #2
0
 int IDebugBreakpointBoundEvent2.EnumBoundBreakpoints(out IEnumDebugBoundBreakpoints2 ppEnum)
 {
     IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[1];
     boundBreakpoints[0] = _boundBreakpoint;
     ppEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);
     return(Constants.S_OK);
 }
コード例 #3
0
 /// <summary>
 /// Creates an enumerator of breakpoints that were bound on this event.
 /// </summary>
 /// <param name="ppEnum">Returns an IEnumDebugBoundBreakpoints2 object that enumerates all the breakpoints bound from this event.</param>
 /// <returns>If successful, returns S_OK. Returns S_FALSE if there are no bound breakpoints; otherwise, returns an error code.</returns>
 /// <remarks>The list of bound breakpoints is for those bound to this event and might not be the entire list of breakpoints bound from a pending breakpoint. To get a list of all breakpoints bound to a pending breakpoint, call the IDebugBreakpointBoundEvent2::GetPendingBreakpoint method to get the associated IDebugPendingBreakpoint2 object and then call the IDebugPendingBreakpoint2::EnumBoundBreakpoints method to get an IEnumDebugBoundBreakpoints2 object which contains all the bound breakpoints for the pending breakpoint.</remarks>
 public int EnumBoundBreakpoints( out IEnumDebugBoundBreakpoints2 ppEnum )
 {
     var boundBreakpoints = new IDebugBoundBreakpoint2[1];
     boundBreakpoints[0] = BoundBreakpoint;
     ppEnum = new BoundBreakpointsEnumerator( boundBreakpoints );
     return VSConstants.S_OK;
 }
コード例 #4
0
        List <IDebugBoundBreakpoint2> GetBoundBreakpoints()
        {
            IEnumDebugBoundBreakpoints2 boundBreakpointsEnum;

            pendingBreakpoint.EnumBoundBreakpoints(out boundBreakpointsEnum);

            if (boundBreakpointsEnum == null)
            {
                return(new List <IDebugBoundBreakpoint2>());
            }

            uint numBreakpoints;

            Assert.AreEqual(VSConstants.S_OK, boundBreakpointsEnum.GetCount(out numBreakpoints));
            if (numBreakpoints == 0)
            {
                return(new List <IDebugBoundBreakpoint2>());
            }
            uint count, actualCount = 0;

            boundBreakpointsEnum.GetCount(out count);
            IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[count];
            boundBreakpointsEnum.Next(count, boundBreakpoints, ref actualCount);
            return(boundBreakpoints.ToList <IDebugBoundBreakpoint2>());
        }
コード例 #5
0
        IEnumerable <IDebugBoundBreakpoint2> GetBoundBreakpointsFired()
        {
            var breakpointEvent = evnt as IDebugBreakpointEvent2;

            if (breakpointEvent == null)
            {
                return(Enumerable.Empty <IDebugBoundBreakpoint2>());
            }

            IEnumDebugBoundBreakpoints2 boundBreakpointsEnum;

            HResultChecker.Check(breakpointEvent.EnumBreakpoints(out boundBreakpointsEnum));
            HResultChecker.Check(boundBreakpointsEnum.Reset());
            uint count;

            HResultChecker.Check(boundBreakpointsEnum.GetCount(out count));
            var  boundBreakpoints = new IDebugBoundBreakpoint2[count];
            uint actual           = 0;

            HResultChecker.Check(boundBreakpointsEnum.Next(count, boundBreakpoints, ref actual));
            if (actual != count)
            {
                throw new VSFakeException("Could not fetch all bound breakpoints. " +
                                          $"Expected: {count}, got: {actual}");
            }
            return(boundBreakpoints);
        }
コード例 #6
0
        public static enum_BP_STATE GetState(this IDebugBoundBreakpoint2 boundBreakpoint)
        {
            Contract.Requires <ArgumentNullException>(boundBreakpoint != null, "boundBreakpoint");

            enum_BP_STATE[] state = new enum_BP_STATE[1];
            ErrorHandler.ThrowOnFailure(boundBreakpoint.GetState(state));
            return(state[0]);
        }
コード例 #7
0
        int IDebugBreakpointBoundEvent2.EnumBoundBreakpoints(out IEnumDebugBoundBreakpoints2 ppEnum)
        {
            var boundBreakpoints = new IDebugBoundBreakpoint2[1];

            boundBreakpoints[0] = boundBreakpoint;
            ppEnum = new MonoBoundBreakpointsEnum(boundBreakpoints);
            return(VSConstants.S_OK);
        }
コード例 #8
0
        /// <summary>
        /// Creates an enumerator of breakpoints that were bound on this event.
        /// </summary>
        /// <param name="ppEnum">Returns an IEnumDebugBoundBreakpoints2 object that enumerates all the breakpoints bound from this event.</param>
        /// <returns>If successful, returns S_OK. Returns S_FALSE if there are no bound breakpoints; otherwise, returns an error code.</returns>
        /// <remarks>The list of bound breakpoints is for those bound to this event and might not be the entire list of breakpoints bound from a pending breakpoint. To get a list of all breakpoints bound to a pending breakpoint, call the IDebugBreakpointBoundEvent2::GetPendingBreakpoint method to get the associated IDebugPendingBreakpoint2 object and then call the IDebugPendingBreakpoint2::EnumBoundBreakpoints method to get an IEnumDebugBoundBreakpoints2 object which contains all the bound breakpoints for the pending breakpoint.</remarks>
        public int EnumBoundBreakpoints(out IEnumDebugBoundBreakpoints2 ppEnum)
        {
            var boundBreakpoints = new IDebugBoundBreakpoint2[1];

            boundBreakpoints[0] = BoundBreakpoint;
            ppEnum = new BoundBreakpointsEnumerator(boundBreakpoints);
            return(VSConstants.S_OK);
        }
コード例 #9
0
        public DebugBreakpointUnboundEvent(enum_EVENTATTRIBUTES attributes, IDebugBoundBreakpoint2 breakpoint, enum_BP_UNBOUND_REASON reason)
            : base(attributes)
        {
            Contract.Requires <ArgumentNullException>(breakpoint != null, "breakpoint");

            _breakpoint = breakpoint;
            _reason     = reason;
        }
コード例 #10
0
            int IDebugBreakpointBoundEvent2.EnumBoundBreakpoints(out IEnumDebugBoundBreakpoints2 ppEnum)
            {
                IDebugBoundBreakpoint2 [] breakpoints = new IDebugBoundBreakpoint2 [] { m_boundBreakpoint };

                ppEnum = new DebuggeeBreakpointBound.Enumerator(breakpoints);

                return(Constants.S_OK);
            }
コード例 #11
0
        public DebugBreakpointUnboundEvent(enum_EVENTATTRIBUTES attributes, IDebugBoundBreakpoint2 breakpoint, enum_BP_UNBOUND_REASON reason)
            : base(attributes)
        {
            Contract.Requires<ArgumentNullException>(breakpoint != null, "breakpoint");

            _breakpoint = breakpoint;
            _reason = reason;
        }
コード例 #12
0
        public static IDebugBreakpointResolution2 GetBreakpointResolution(this IDebugBoundBreakpoint2 boundBreakpoint)
        {
            Contract.Requires <ArgumentNullException>(boundBreakpoint != null, "boundBreakpoint");

            IDebugBreakpointResolution2 resolution;

            ErrorHandler.ThrowOnFailure(boundBreakpoint.GetBreakpointResolution(out resolution));
            return(resolution);
        }
コード例 #13
0
        public static uint GetHitCount(this IDebugBoundBreakpoint2 boundBreakpoint)
        {
            Contract.Requires <ArgumentNullException>(boundBreakpoint != null, "boundBreakpoint");

            uint hitCount;

            ErrorHandler.ThrowOnFailure(boundBreakpoint.GetHitCount(out hitCount));
            return(hitCount);
        }
コード例 #14
0
ファイル: BreakpointManager.cs プロジェクト: texbois/vsbasm
 public IDebugBoundBreakpoint2 MaybeGetBreakpoint(uint address)
 {
     foreach (PendingBreakpoint pendingBreakpoint in _pendingBreakpoints)
     {
         IDebugBoundBreakpoint2 bp = pendingBreakpoint.GetIfBoundAtAddress(address);
         if (bp != null)
         {
             return(bp);
         }
     }
     return(null);
 }
コード例 #15
0
        public void OnProgramStop(uint address)
        {
            IDebugBoundBreakpoint2 breakpoint = _breakpointManager.MaybeGetBreakpoint(address);

            if (breakpoint != null)
            {
                _callbacks.OnBreakpointHit(breakpoint);
            }
            else
            {
                Debug.WriteLine("OnProgramStop: non-synthetic HLT instruction reached, terminating.");
                _callbacks.OnProgramTerminated();
            }
        }
コード例 #16
0
ファイル: EngineCallback.cs プロジェクト: blackberry/VSPlugin
        /// <summary>
        /// Send an event to SDM with the breakpoint that was hit.
        /// </summary>
        /// <param name="thread"> The thread running in a program. </param>
        /// <param name="clients"> List of bound breakpoints. At this moment, this list has only one element. </param>
        public void OnBreakpoint(AD7Thread thread, IList<IDebugBoundBreakpoint2> clients)
        {
            IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[clients.Count];

            int i = 0;
            foreach (object objCurrentBreakpoint in clients)
            {
                boundBreakpoints[i] = (IDebugBoundBreakpoint2)objCurrentBreakpoint;
                i++;
            }

            AD7BoundBreakpointsEnum boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);
            AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpointsEnum);

            Send(eventObject, AD7BreakpointEvent.IID, thread);
        }
コード例 #17
0
        public void GetBreakpointResolutionNullAddress()
        {
            SbBreakpointLocation breakpointLocationNullAddress =
                Substitute.For <SbBreakpointLocation>();
            const SbAddress NULL_ADDRESS = null;

            breakpointLocationNullAddress.GetAddress().Returns(NULL_ADDRESS);
            IDebugBoundBreakpoint2 boundBreakpointNullAddress = boundBreakpointFactory.Create(
                mockPendingBreakpoint, breakpointLocationNullAddress, mockprogram, Guid.Empty);
            IDebugBreakpointResolution2 breakpointResolutionNullAddress;

            Assert.AreEqual(VSConstants.E_FAIL,
                            boundBreakpointNullAddress.GetBreakpointResolution(
                                out breakpointResolutionNullAddress));
            Assert.AreEqual(null, breakpointResolutionNullAddress);
        }
コード例 #18
0
        public static IEnumerable<IDebugBoundBreakpoint2> EnumBoundBreakpoints(this IDebugPendingBreakpoint2 breakpoint)
        {
            Contract.Requires<ArgumentNullException>(breakpoint != null, "breakpoint");

            IEnumDebugBoundBreakpoints2 boundBreakpoints;
            ErrorHandler.ThrowOnFailure(breakpoint.EnumBoundBreakpoints(out boundBreakpoints));

            uint count;
            ErrorHandler.ThrowOnFailure(boundBreakpoints.GetCount(out count));

            IDebugBoundBreakpoint2[] breakpoints = new IDebugBoundBreakpoint2[count];
            uint fetched = 0;
            ErrorHandler.ThrowOnFailure(boundBreakpoints.Next(count, breakpoints, ref fetched));

            return breakpoints.Take((int)fetched);
        }
コード例 #19
0
        /// <summary>
        /// Send an event to SDM with the breakpoint that was hit.
        /// </summary>
        /// <param name="thread"> The thread running in a program. </param>
        /// <param name="clients"> List of bound breakpoints. At this moment, this list has only one element. </param>
        public void OnBreakpoint(AD7Thread thread, IList <IDebugBoundBreakpoint2> clients)
        {
            IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[clients.Count];

            int i = 0;

            foreach (object objCurrentBreakpoint in clients)
            {
                boundBreakpoints[i] = (IDebugBoundBreakpoint2)objCurrentBreakpoint;
                i++;
            }

            AD7BoundBreakpointsEnum boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);
            AD7BreakpointEvent      eventObject          = new AD7BreakpointEvent(boundBreakpointsEnum);

            Send(eventObject, AD7BreakpointEvent.IID, thread);
        }
コード例 #20
0
        public static IEnumerable <IDebugBoundBreakpoint2> EnumBoundBreakpoints(this IDebugPendingBreakpoint2 breakpoint)
        {
            Contract.Requires <ArgumentNullException>(breakpoint != null, "breakpoint");

            IEnumDebugBoundBreakpoints2 boundBreakpoints;

            ErrorHandler.ThrowOnFailure(breakpoint.EnumBoundBreakpoints(out boundBreakpoints));

            uint count;

            ErrorHandler.ThrowOnFailure(boundBreakpoints.GetCount(out count));

            IDebugBoundBreakpoint2[] breakpoints = new IDebugBoundBreakpoint2[count];
            uint fetched = 0;

            ErrorHandler.ThrowOnFailure(boundBreakpoints.Next(count, breakpoints, ref fetched));

            return(breakpoints.Take((int)fetched));
        }
コード例 #21
0
        void AssertBreakpointEvent(BreakpointEvent breakpointEvent,
                                   List <IDebugBoundBreakpoint2> expectedBoundBreakpoints)
        {
            int numberBreakpoints = expectedBoundBreakpoints.Count;

            Assert.AreNotEqual(null, breakpointEvent);
            breakpointEvent.EnumBreakpoints(out IEnumDebugBoundBreakpoints2 enumBoundBreakpoints);
            enumBoundBreakpoints.GetCount(out uint count);
            Assert.AreEqual(numberBreakpoints, count);
            var  boundBreakpoints = new IDebugBoundBreakpoint2[numberBreakpoints];
            uint numberReturned   = 0;

            enumBoundBreakpoints.Next((uint)numberBreakpoints, boundBreakpoints,
                                      ref numberReturned);
            Assert.AreEqual(numberBreakpoints, numberReturned);
            var difference = expectedBoundBreakpoints.Except(boundBreakpoints).ToList();

            Assert.IsEmpty(difference);
        }
コード例 #22
0
        public void OnBreakpoint(AD7Thread thread, IList <IDebugBoundBreakpoint2> clients)
        {
            var boundBreakpoints = new IDebugBoundBreakpoint2[clients.Count];
            int i = 0;

            foreach (var objCurrentBreakpoint in clients)
            {
                boundBreakpoints[i] = objCurrentBreakpoint;
                i++;
            }

            // An engine that supports more advanced breakpoint features such as hit counts, conditions and filters
            // should notify each bound breakpoint that it has been hit and evaluate conditions here.
            // The sample engine does not support these features.
            var boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);
            var eventObject          = new AD7BreakpointEvent(boundBreakpointsEnum);

            Send(eventObject, AD7BreakpointEvent.IID, thread);
        }
コード例 #23
0
ファイル: EngineCallback.cs プロジェクト: hkopparru/VSPlugin
        /*public void OnThreadStart(DebuggedThread debuggedThread)
        {
            // This will get called when the entrypoint breakpoint is fired because the engine sends a thread start event
            // for the main thread of the application.
            //if (m_engine.DebuggedProcess != null)
            //{
            //    Debug.Assert(GDBParser.CurrentThreadId == m_engine.DebuggedProcess.PollThreadId);
            //}

            // AD7Thread ad7Thread = new AD7Thread(m_engine, debuggedThread);
            // debuggedThread.Client = ad7Thread;

            AD7ThreadCreateEvent eventObject = new AD7ThreadCreateEvent();
            // Send(eventObject, AD7ThreadCreateEvent.IID, ad7Thread);
            Send(eventObject, AD7ThreadCreateEvent.IID, debuggedThread);
        }*/
        public void OnBreakpoint(AD7Thread thread, IList<IDebugBoundBreakpoint2> clients)
        {
            IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[clients.Count];

            int i = 0;
            foreach (object objCurrentBreakpoint in clients)
            {
                boundBreakpoints[i] = (IDebugBoundBreakpoint2)objCurrentBreakpoint;
                i++;
            }

            // An engine that supports more advanced breakpoint features such as hit counts, conditions and filters
            // should notify each bound breakpoint that it has been hit and evaluate conditions here.
            // The sample engine does not support these features.

            AD7BoundBreakpointsEnum boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);
            AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpointsEnum);

            Send(eventObject, AD7BreakpointEvent.IID, thread);
        }
コード例 #24
0
        public void BindWatchpoint()
        {
            SbError error;

            Assert.AreEqual(VSConstants.S_OK, watchpoint.Bind());
            mockLldbWatchpoint.Received(1).SetEnabled(true);
            mockTarget.Received(1).WatchAddress(TEST_ADDRESS, WATCH_SIZE, false, true, out error);
            mockBreakpointManager.Received(1).RegisterWatchpoint(watchpoint);
            IEnumDebugBoundBreakpoints2 enumBoundBreakpoints;

            watchpoint.EnumBoundBreakpoints(out enumBoundBreakpoints);
            uint countBoundBreakpoint;

            enumBoundBreakpoints.GetCount(out countBoundBreakpoint);
            Assert.AreEqual(1, countBoundBreakpoint);
            IDebugBoundBreakpoint2[] boundBreakpoint = new IDebugBoundBreakpoint2[1];
            uint actualCount = 0;

            enumBoundBreakpoints.Next(1, boundBreakpoint, ref actualCount);
            Assert.AreEqual(watchpoint, boundBreakpoint[0]);
        }
コード例 #25
0
        public void OnBreakpoint(DebuggedThread thread, IDebugBoundBreakpoint2 bp, uint address)
        {
            IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[1];
            boundBreakpoints[0] = bp;

            /*int i = 0;
             * foreach (object objCurrentBreakpoint in clients)
             * {
             *  boundBreakpoints[i] = (IDebugBoundBreakpoint2)objCurrentBreakpoint;
             *  i++;
             * }*/

            // An engine that supports more advanced breakpoint features such as hit counts, conditions and filters
            // should notify each bound breakpoint that it has been hit and evaluate conditions here.
            // The sample engine does not support these features.

            AD7BoundBreakpointsEnum boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);

            AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpointsEnum);

            //AD7Thread ad7Thread = (AD7Thread)thread.Client;
            Send(eventObject, AD7BreakpointEvent.IID, (IDebugThread2)thread);
        }
コード例 #26
0
ファイル: EngineCallback.cs プロジェクト: aonorin/MIEngine
        public void OnBreakpoint(DebuggedThread thread, ReadOnlyCollection <object> clients)
        {
            IDebugBoundBreakpoint2[] boundBreakpoints = new IDebugBoundBreakpoint2[clients.Count];

            int i = 0;

            foreach (object objCurrentBreakpoint in clients)
            {
                boundBreakpoints[i] = (IDebugBoundBreakpoint2)objCurrentBreakpoint;
                i++;
            }

            // An engine that supports more advanced breakpoint features such as hit counts, conditions and filters
            // should notify each bound breakpoint that it has been hit and evaluate conditions here.
            // The sample engine does not support these features.

            AD7BoundBreakpointsEnum boundBreakpointsEnum = new AD7BoundBreakpointsEnum(boundBreakpoints);

            AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpointsEnum);

            AD7Thread ad7Thread = (AD7Thread)thread.Client;

            Send(eventObject, AD7BreakpointEvent.IID, ad7Thread);
        }
コード例 #27
0
ファイル: EngineCallback.cs プロジェクト: texbois/vsbasm
        public void OnBreakpointHit(IDebugBoundBreakpoint2 breakpoint)
        {
            var boundBreakpoints = new AD7BoundBreakpointsEnum(new IDebugBoundBreakpoint2[] { breakpoint });

            Send(new AD7BreakpointEvent(boundBreakpoints), AD7BreakpointEvent.IID);
        }
コード例 #28
0
 // Token: 0x06000099 RID: 153 RVA: 0x00003901 File Offset: 0x00001B01
 public int GetBreakpoint(out IDebugBoundBreakpoint2 ppBP)
 {
     ppBP = this.boundBreakpoint;
     return(0);
 }
コード例 #29
0
 public int GetBreakpoint(out IDebugBoundBreakpoint2 ppBP)
 {
     ppBP = _bp;
     return(Constants.S_OK);
 }
コード例 #30
0
ファイル: AD7Events.cs プロジェクト: zxckiller/VSLua
 public AD7BreakpointEvent(IDebugBoundBreakpoint2 boundBreakpoint)
 {
     // m_boundBreakpoints = boundBreakpoints;
     this.m_boundBreakpoints = new AD7BoundBreakpointsEnum(new IDebugBoundBreakpoint2[] { boundBreakpoint });
 }
コード例 #31
0
ファイル: Events.cs プロジェクト: yuva2achieve/dot42
 /// <summary>
 /// Default ctor
 /// </summary>
 public BreakpointEvent(IDebugBoundBreakpoint2 breakpoint)
 {
     this.breakpoint = breakpoint;
 }
コード例 #32
0
 public int Next(uint celt, IDebugBoundBreakpoint2[] rgelt, ref uint pceltFetched)
 {
     Log.Debug("ScriptBreakpoint: Next");
     rgelt[0] = this;
     pceltFetched = 1;
     return VSConstants.S_OK;
 }
コード例 #33
0
 public BreakpointUnbound (IDebugBoundBreakpoint2 boundBreakpoint)
 {
   m_boundBreakpoint = boundBreakpoint;
 }
コード例 #34
0
      int IDebugBreakpointUnboundEvent2.GetBreakpoint (out IDebugBoundBreakpoint2 ppBP)
      {
        LoggingUtils.PrintFunction ();

        ppBP = m_boundBreakpoint;

        return Constants.S_OK;
      }
コード例 #35
0
ファイル: AD7Events.cs プロジェクト: lioaphy/nodejstools
 int IDebugBreakpointUnboundEvent2.GetBreakpoint(out IDebugBoundBreakpoint2 ppBP)
 {
     ppBP = m_boundBreakpoint;
     return VSConstants.S_OK;
 }
コード例 #36
0
ファイル: AD7Events.cs プロジェクト: Strongc/VSLua
 public AD7BreakpointEvent(IDebugBoundBreakpoint2 boundBreakpoint)
 {
     // m_boundBreakpoints = boundBreakpoints;
     this.m_boundBreakpoints = new AD7BoundBreakpointsEnum(new IDebugBoundBreakpoint2[] { boundBreakpoint });
 }
コード例 #37
0
ファイル: AD7Events.cs プロジェクト: Strongc/VSLua
 internal static void Send(AD7Engine engine, IDebugBoundBreakpoint2 boundBreakpoint)
 {
     AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpoint);
     engine.Send(eventObject, IID, null);
 }
コード例 #38
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    private void OnClientAsyncRecord (MiAsyncRecord asyncRecord)
    {
      LoggingUtils.PrintFunction ();

      switch (asyncRecord.Type)
      {
        case MiAsyncRecord.AsyncType.Exec: 
        {
          // 
          // Records prefixed '*'.
          // 

          switch (asyncRecord.Class)
          {
            case "running":
            {
              // 
              // The target is now running. The thread field tells which specific thread is now running, can be 'all' if every thread is running.
              // 

              lock (NativeProgram)
              {
                NativeProgram.SetRunning (true);

                string threadId = asyncRecord ["thread-id"] [0].GetString ();

                if (threadId.Equals ("all"))
                {
                  Dictionary<uint, DebuggeeThread> programThreads = NativeProgram.GetThreads ();

                  lock (programThreads)
                  {
                    foreach (DebuggeeThread thread in programThreads.Values)
                    {
                      thread.SetRunning (true);
                    }
                  }
                }
                else
                {
                  uint numericThreadId = uint.Parse (threadId);

                  NativeProgram.CurrentThreadId = numericThreadId;

                  CLangDebuggeeThread thread = NativeProgram.GetThread (numericThreadId);

                  if (thread != null)
                  {
                    thread.SetRunning (true);
                  }
                }
              }

              break;
            }

            case "stopped":
            {
              // 
              // The target has stopped.
              // 

              CLangDebuggeeThread stoppedThread = null;

              lock (NativeProgram)
              {
                NativeProgram.SetRunning (false);

                if (asyncRecord.HasField ("thread-id"))
                {
                  uint threadId = asyncRecord ["thread-id"] [0].GetUnsignedInt ();

                  NativeProgram.CurrentThreadId = threadId;
                }

                if (stoppedThread == null)
                {
                  stoppedThread = NativeProgram.GetThread (NativeProgram.CurrentThreadId);
                }

                if (stoppedThread != null)
                {
                  stoppedThread.SetRunning (false);
                }
                else
                {
                  throw new InvalidOperationException ("Could not evaluate a thread on which we stopped");
                }

                // 
                // Flag some or all of the program's threads as stopped, directed by 'stopped-threads' field.
                // 

                bool hasStoppedThreads = asyncRecord.HasField ("stopped-threads");

                if (hasStoppedThreads)
                {
                  // 
                  // If all threads are stopped, the stopped field will have the value of "all". 
                  // Otherwise, the value of the stopped field will be a list of thread identifiers.
                  // 

                  MiResultValue stoppedThreadsRecord = asyncRecord ["stopped-threads"] [0];

                  if (stoppedThreadsRecord is MiResultValueList)
                  {
                    MiResultValueList stoppedThreads = stoppedThreadsRecord as MiResultValueList;

                    foreach (MiResultValue stoppedThreadValue in stoppedThreads.List)
                    {
                      uint stoppedThreadId = stoppedThreadValue.GetUnsignedInt ();

                      CLangDebuggeeThread thread = NativeProgram.GetThread (stoppedThreadId);

                      if (thread != null)
                      {
                        thread.SetRunning (false);
                      }
                    }
                  }
                  else
                  {
                    Dictionary<uint, DebuggeeThread> programThreads = NativeProgram.GetThreads ();

                    lock (programThreads)
                    {
                      foreach (DebuggeeThread thread in programThreads.Values)
                      {
                        thread.SetRunning (false);
                      }
                    }
                  }
                }
              }

              // 
              // Unblocks waiting for 'stopped' to be processed. Skipping event handling during interrupt requests as it confuses VS debugger flow.
              // 

              bool ignoreInterruptSignal = false;

              if (m_interruptOperationCompleted != null)
              {
                m_interruptOperationCompleted.Set ();

                ignoreInterruptSignal = true;
              }

              // 
              // Process any pending requests to refresh registered breakpoints.
              // 

#if false
              RefreshSharedLibraries ();
#endif


#if false
              NativeProgram.RefreshAllThreads ();
#endif

              if (!GdbClient.GetClientFeatureSupported ("breakpoint-notifications"))
              {
                Engine.BreakpointManager.RefreshBreakpoints ();
              }

              // 
              // This behaviour seems at odds with the GDB/MI spec, but a *stopped event can contain
              // multiple 'reason' fields. This seems to occur mainly when signals have been ignored prior 
              // to a non-ignored triggering, i.e:
              // 
              //   Signal        Stop\tPrint\tPass to program\tDescription\n
              //   SIGSEGV       No\tYes\tYes\t\tSegmentation fault\n
              // 
              // *stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmentation fault",reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmentation fault",reason="exited-signalled",signal-name="SIGSEGV",signal-meaning="Segmentation fault"
              // 

              if (asyncRecord.HasField ("reason"))
              {
                // 
                // Here we pick the most recent (unhandled) signal.
                // 

                int stoppedIndex = asyncRecord ["reason"].Count - 1;

                MiResultValue stoppedReason = asyncRecord ["reason"] [stoppedIndex];

                // 
                // The reason field can have one of the following values:
                // 

                switch (stoppedReason.GetString ())
                {
                  case "breakpoint-hit":
                  case "watchpoint-trigger":
                  {
                    bool canContinue = true;

                    uint breakpointId = asyncRecord ["bkptno"] [0].GetUnsignedInt ();

                    string breakpointMode = asyncRecord ["disp"] [0].GetString ();

                    if (breakpointMode.Equals ("del"))
                    {
                      // 
                      // For temporary breakpoints, we won't have a valid managed object - so will just enforce a break event.
                      // 

                      //Engine.Broadcast (new DebugEngineEvent.Break (), NativeProgram.DebugProgram, stoppedThread);

                      Engine.Broadcast (new DebugEngineEvent.BreakpointHit (null), NativeProgram.DebugProgram, stoppedThread);
                    }
                    else
                    {
                      DebuggeeBreakpointBound boundBreakpoint = Engine.BreakpointManager.FindBoundBreakpoint (breakpointId);

                      if (boundBreakpoint == null)
                      {
                        // 
                        // Could not find the breakpoint we're looking for. Refresh everything and try again.
                        // 

                        Engine.BreakpointManager.SetDirty (true);

                        Engine.BreakpointManager.RefreshBreakpoints ();

                        boundBreakpoint = Engine.BreakpointManager.FindBoundBreakpoint (breakpointId);
                      }

                      if (boundBreakpoint == null)
                      {
                        // 
                        // Could not locate a registered breakpoint with matching id.
                        // 

                        DebugEngineEvent.Exception exception = new DebugEngineEvent.Exception (NativeProgram.DebugProgram, stoppedReason.GetString (), "Breakpoint #" + breakpointId + "hit", 0x00000000, canContinue);

                        Engine.Broadcast (exception, NativeProgram.DebugProgram, stoppedThread);
                      }
                      else
                      {
                        enum_BP_STATE [] breakpointState = new enum_BP_STATE [1];

                        LoggingUtils.RequireOk (boundBreakpoint.GetState (breakpointState));

                        if (breakpointState [0] == enum_BP_STATE.BPS_DELETED)
                        {
                          // 
                          // Hit a breakpoint which internally is flagged as deleted. Oh noes!
                          // 

                          DebugEngineEvent.Exception exception = new DebugEngineEvent.Exception (NativeProgram.DebugProgram, stoppedReason.GetString (), "Breakpoint #" + breakpointId + " hit [deleted]", 0x00000000, canContinue);

                          Engine.Broadcast (exception, NativeProgram.DebugProgram, stoppedThread);
                        }
                        else
                        {
                          // 
                          // Hit a breakpoint which is known about. Issue break event.
                          // 

                          IDebugBoundBreakpoint2 [] boundBreakpoints = new IDebugBoundBreakpoint2 [] { boundBreakpoint };

                          IEnumDebugBoundBreakpoints2 enumeratedBoundBreakpoint = new DebuggeeBreakpointBound.Enumerator (boundBreakpoints);

                          Engine.Broadcast (new DebugEngineEvent.BreakpointHit (enumeratedBoundBreakpoint), NativeProgram.DebugProgram, stoppedThread);
                        }
                      }
                    }

                    break;
                  }

                  case "end-stepping-range":
                  case "function-finished":
                  {
                    Engine.Broadcast (new DebugEngineEvent.StepComplete (), NativeProgram.DebugProgram, stoppedThread);

                    break;
                  }

                  case "signal-received":
                  {
                    string signalName = asyncRecord ["signal-name"] [stoppedIndex].GetString ();

                    string signalMeaning = asyncRecord ["signal-meaning"] [stoppedIndex].GetString ();

                    switch (signalName)
                    {
                      case null:
                      case "SIGINT":
                      {
                        if (!ignoreInterruptSignal)
                        {
                          Engine.Broadcast (new DebugEngineEvent.Break (), NativeProgram.DebugProgram, stoppedThread);
                        }

                        break;
                      }

                      default:
                      {
                        StringBuilder signalDescription = new StringBuilder ();

                        signalDescription.AppendFormat ("{0} ({1})", signalName, signalMeaning);

                        if (asyncRecord.HasField ("frame"))
                        {
                          MiResultValueTuple frameTuple = asyncRecord ["frame"] [0] as MiResultValueTuple;

                          if (frameTuple.HasField ("addr"))
                          {
                            string address = frameTuple ["addr"] [0].GetString ();

                            signalDescription.AppendFormat (" at {0}", address);
                          }

                          if (frameTuple.HasField ("func"))
                          {
                            string function = frameTuple ["func"] [0].GetString ();

                            signalDescription.AppendFormat (" ({0})", function);
                          }
                        }

                        bool canContinue = true;

                        DebugEngineEvent.Exception exception = new DebugEngineEvent.Exception (NativeProgram.DebugProgram, signalName, signalDescription.ToString (), 0x80000000, canContinue);

                        Engine.Broadcast (exception, NativeProgram.DebugProgram, stoppedThread);

                        break;
                      }
                    }

                    break;
                  }

                  case "read-watchpoint-trigger":
                  case "access-watchpoint-trigger":
                  case "location-reached":
                  case "watchpoint-scope":
                  case "solib-event":
                  case "fork":
                  case "vfork":
                  case "syscall-entry":
                  case "exec":
                  {
                    Engine.Broadcast (new DebugEngineEvent.Break (), NativeProgram.DebugProgram, stoppedThread);

                    break;
                  }

                  case "exited":
                  case "exited-normally":
                  case "exited-signalled":
                  {
                    // 
                    // React to program termination, but defer this so it doesn't consume the async output thread.
                    // 

                    ThreadPool.QueueUserWorkItem (delegate (object state)
                    {
                      try
                      {
                        LoggingUtils.RequireOk (Engine.Detach (NativeProgram.DebugProgram));
                      }
                      catch (Exception e)
                      {
                        LoggingUtils.HandleException (e);
                      }
                    });

                    break;
                  }
                }
              }

              break;
            }
          }

          break;
        }

        case MiAsyncRecord.AsyncType.Status:
        {
          // 
          // Records prefixed '+'.
          // 

          break;
        }


        case MiAsyncRecord.AsyncType.Notify:
        {
          // 
          // Records prefixed '='.
          // 

          switch (asyncRecord.Class)
          {
            case "thread-group-added":
            case "thread-group-started":
            {
              // 
              // A thread group became associated with a running program, either because the program was just started or the thread group was attached to a program.
              // 

              try
              {
                string threadGroupId = asyncRecord ["id"] [0].GetString ();

                m_threadGroupStatus [threadGroupId] = 0;
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }

            case "thread-group-removed":
            case "thread-group-exited":
            {
              // 
              // A thread group is no longer associated with a running program, either because the program has exited, or because it was detached from.
              // 

              try
              {
                string threadGroupId = asyncRecord ["id"] [0].GetString ();

                if (asyncRecord.HasField ("exit-code"))
                {
                  m_threadGroupStatus [threadGroupId] = asyncRecord ["exit-code"] [0].GetUnsignedInt ();
                }
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }

            case "thread-created":
            {
              // 
              // A thread either was created. The id field contains the gdb identifier of the thread. The gid field identifies the thread group this thread belongs to. 
              // 

              try
              {
                uint threadId = asyncRecord ["id"] [0].GetUnsignedInt ();

                string threadGroupId = asyncRecord ["group-id"] [0].GetString ();

                CLangDebuggeeThread thread = NativeProgram.GetThread (threadId);

                if (thread == null)
                {
                  NativeProgram.AddThread (threadId);
                }
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }

            case "thread-exited":
            {
              // 
              // A thread has exited. The 'id' field contains the GDB identifier of the thread. The 'group-id' field identifies the thread group this thread belongs to. 
              // 

              try
              {
                uint threadId = asyncRecord ["id"] [0].GetUnsignedInt ();

                string threadGroupId = asyncRecord ["group-id"] [0].GetString ();

                uint exitCode = m_threadGroupStatus [threadGroupId];

                NativeProgram.RemoveThread (threadId, exitCode);
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }

            case "thread-selected":
            {
              // 
              // Informs that the selected thread was changed as result of the last command.
              // 

              try
              {
                uint threadId = asyncRecord ["id"] [0].GetUnsignedInt ();

                NativeProgram.CurrentThreadId = threadId;
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }

            case "library-loaded":
            {
              // 
              // Reports that a new library file was loaded by the program.
              // 

              try
              {
                string moduleName = asyncRecord ["id"] [0].GetString ();

                CLangDebuggeeModule module = NativeProgram.GetModule (moduleName);

                if (module == null)
                {
                  module = NativeProgram.AddModule (moduleName, asyncRecord);
                }

                if (!GdbClient.GetClientFeatureSupported ("breakpoint-notifications"))
                {
                  Engine.BreakpointManager.SetDirty (true);
                }
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }

            case "library-unloaded":
            {
              // 
              // Reports that a library was unloaded by the program.
              // 

              try
              {
                string moduleName = asyncRecord ["id"] [0].GetString ();

                NativeProgram.RemoveModule (moduleName);

                if (!GdbClient.GetClientFeatureSupported ("breakpoint-notifications"))
                {
                  Engine.BreakpointManager.SetDirty (true);
                }
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }

            case "breakpoint-created":
            case "breakpoint-modified":
            case "breakpoint-deleted":
            {
              try
              {
                IDebugPendingBreakpoint2 pendingBreakpoint = null;

                if (asyncRecord.HasField ("bkpt"))
                {
                  MiResultValue breakpointData = asyncRecord ["bkpt"] [0];

                  MiBreakpoint currentGdbBreakpoint = new MiBreakpoint (breakpointData.Values);

                  pendingBreakpoint = Engine.BreakpointManager.FindPendingBreakpoint (currentGdbBreakpoint.ID);

                  // If the breakpoint is unknown, this usually means it was bound externally to the IDE.
                  /*if (pendingBreakpoint == null)
                  {
                    // 
                    // CreatePendingBreakpoint always sets the dirty flag, so we need to reset this if it's handled immediately.
                    // 

                    DebugBreakpointRequest breakpointRequest = new DebugBreakpointRequest (currentGdbBreakpoint.Address);

                    LoggingUtils.RequireOk (Engine.BreakpointManager.CreatePendingBreakpoint (breakpointRequest, out pendingBreakpoint));
                  }*/
                }
                else if (asyncRecord.HasField ("id"))
                {
                  pendingBreakpoint = Engine.BreakpointManager.FindPendingBreakpoint (asyncRecord ["id"] [0].GetUnsignedInt ());
                }

                bool wasDirty = Engine.BreakpointManager.IsDirty ();

                if (pendingBreakpoint != null)
                {
                  DebuggeeBreakpointPending thisBreakpoint = pendingBreakpoint as DebuggeeBreakpointPending;

                  thisBreakpoint.RefreshBoundBreakpoints ();

                  thisBreakpoint.RefreshErrorBreakpoints ();
                }

                if (wasDirty)
                {
                  Engine.BreakpointManager.SetDirty (true);
                }
              }
              catch (Exception e)
              {
                LoggingUtils.HandleException (e);
              }

              break;
            }
          }

          break;
        }
      }
    }
コード例 #39
0
ファイル: AD7Events.cs プロジェクト: rajkumar42/MIEngine
 public int GetBreakpoint(out IDebugBoundBreakpoint2 ppBP)
 {
     ppBP = _bp;
     return Constants.S_OK;
 }
コード例 #40
0
      public BreakpointBound (IDebugPendingBreakpoint2 pendingBreakpoint, IDebugBoundBreakpoint2 boundBreakpoint)
      {
        m_pendingBreakpoint = pendingBreakpoint;

        m_boundBreakpoint = boundBreakpoint;
      }
コード例 #41
0
 int IEnumDebugBoundBreakpoints2.Next(uint celt, IDebugBoundBreakpoint2[] rgelt, ref uint pceltFetched)
 {
   Debug.WriteLine("AD7Breakpoint: Next");
   if (enumError == null)
   {
     rgelt[0] = this;
     pceltFetched = 1;
   }
   else
   {
     pceltFetched = 0;
   }
   return VSConstants.S_OK;
 }
コード例 #42
0
 public static void SetHitCount(this IDebugBoundBreakpoint2 boundBreakpoint, uint value)
 {
     Contract.Requires <ArgumentNullException>(boundBreakpoint != null, "boundBreakpoint");
     ErrorHandler.ThrowOnFailure(boundBreakpoint.SetHitCount(value));
 }
コード例 #43
0
            public Event(IDebugPendingBreakpoint2 pendingBreakpoint, IDebugBoundBreakpoint2 boundBreakpoint)
            {
                m_pendingBreakpoint = pendingBreakpoint;

                m_boundBreakpoint = boundBreakpoint;
            }
コード例 #44
0
ファイル: AD7Events.cs プロジェクト: zxckiller/VSLua
        internal static void Send(AD7Engine engine, IDebugBoundBreakpoint2 boundBreakpoint)
        {
            AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpoint);

            engine.Send(eventObject, IID, null);
        }
コード例 #45
0
 int IDebugBreakpointUnboundEvent2.GetBreakpoint(out IDebugBoundBreakpoint2 ppBP)
 {
     ppBP = this.m_boundBreakpoint;
     return(VSConstants.S_OK);
 }
コード例 #46
0
ファイル: Breakpoint.cs プロジェクト: IntelliTect/PowerStudio
 /// <summary>
 /// Returns the next set of elements from the enumeration.
 /// </summary>
 /// <param name="celt">The number of elements to retrieve. Also specifies the maximum size of the rgelt array.</param>
 /// <param name="rgelt">Array of IDebugBoundBreakpoint2 elements to be filled in.</param>
 /// <param name="pceltFetched">Returns the number of elements actually returned in rgelt.</param>
 /// <returns>If successful, returns S_OK. Returns S_FALSE if fewer than the requested number of elements could be returned; otherwise, returns an error code.</returns>
 public virtual int Next( uint celt, IDebugBoundBreakpoint2[] rgelt, ref uint pceltFetched )
 {
     Logger.Debug( string.Empty );
     return VSConstants.E_NOTIMPL;
 }