Exemplo n.º 1
0
        public void BreakpointBreakAndContinue() => ContinousTestExecutionWrapper(() =>
        {
            InitializeProcess(TestProcessPath, ProcessArguments, DefaultSymbolPath);

            BreakpointSpec bpSpec = new BreakpointSpec(GetFunctionAddress("InfiniteRecursionTestCase"));
            var bp = Debugger.AddBreakpoint(bpSpec);

            Debugger.ContinueExecution();
            bp.WaitForHit();

            int funcCallCount =
                FindThreadHostingMain()
                .StackTrace.Frames
                .Where(frame => frame.FunctionName.Contains("InfiniteRecursionTestCase")).Count();
            Assert.Equal(1, funcCallCount);

            Debugger.ContinueExecution();
            bp.WaitForHit();

            funcCallCount =
                FindThreadHostingMain()
                .StackTrace.Frames
                .Where(frame => frame.FunctionName.Contains("InfiniteRecursionTestCase")).Count();
            Assert.Equal(2, funcCallCount);
        }, DefaultTimeout);
Exemplo n.º 2
0
        public void BreakpointSanityTest() => ContinousTestExecutionWrapper(() =>
        {
            InitializeProcess(TestProcessPath, ProcessArguments, DefaultSymbolPath);

            BreakpointSpec bpSpec = new BreakpointSpec(GetFunctionAddress("InfiniteRecursionTestCase"));
            var bp = Debugger.AddBreakpoint(bpSpec);

            Debugger.ContinueExecution();
            bp.WaitForHit();
        }, DefaultTimeout);
Exemplo n.º 3
0
        /// <summary>
        /// Constructor for creating new breakpoints.
        /// </summary>
        /// <param name="breakpointSpec">Spec describing this breakpoint.</param>
        /// <param name="invalidateCache">Invalidate cache action.</param>
        /// <param name="dbgEngDll">DbgEngDll interface.</param>
        /// <remarks>
        /// This about adding some sort of factory pattern here.
        /// </remarks>
        public DbgEngBreakpoint(BreakpointSpec breakpointSpec, Action invalidateCache, DbgEngDll dbgEngDll)
        {
            this.breakpointAction = breakpointSpec.BreakpointAction;
            this.invalidateCache  = invalidateCache;

            unchecked
            {
                if (breakpointSpec.BreakpointType == BreakpointType.Code)
                {
                    breakpoint = dbgEngDll.Control.AddBreakpoint2((uint)Defines.DebugBreakpointCode, (uint)Defines.DebugAnyId);
                }
                else
                {
                    throw new NotImplementedException("Only supports Code breakpoints");
                }
            }

            breakpoint.SetOffset(breakpointSpec.BreakpointAddress);
            breakpoint.SetFlags((uint)Defines.DebugBreakpointEnabled);
            breakpointStatusEnabled = true;
        }
Exemplo n.º 4
0
        public void BreakpointWithBreakAfterHit() => ContinousTestExecutionWrapper(() =>
        {
            InitializeProcess(TestProcessPath, ProcessArguments, DefaultSymbolPath);
            Diagnostics.Debug.WriteLine($"Process {TestProcessPath} started.");

            System.Threading.AutoResetEvent are = new System.Threading.AutoResetEvent(false);
            int breakpointHitCount = 0;

            ulong bpAddress       = GetFunctionAddress("InfiniteRecursionTestCase");
            BreakpointSpec bpSpec = new BreakpointSpec(bpAddress)
            {
                BreakpointAction = () =>
                {
                    Thread mainThread       = FindThreadHostingMain();
                    int recursionDepthCount =
                        mainThread.StackTrace.Frames.
                        Where(frame => frame.FunctionName.Contains("InfiniteRecursionTestCase")).Count();

                    // Insure that top of main thread points to the same location as breakpoint address.
                    //
                    Assert.Equal(bpAddress, mainThread.StackTrace.Frames[0].InstructionOffset);

                    breakpointHitCount++;
                    Assert.Equal(breakpointHitCount, recursionDepthCount);

                    if (recursionDepthCount == 5)
                    {
                        are.Set();
                    }

                    return(BreakpointHitResult.Continue);
                }
            };

            Debugger.AddBreakpoint(bpSpec);

            Debugger.ContinueExecution();
            are.WaitOne();
            Debugger.BreakExecution();
        }, DefaultTimeout);
Exemplo n.º 5
0
 /// <summary>
 /// Adds new breakpoint to the given process.
 /// </summary>
 /// <param name="process">Process.</param>
 /// <param name="breakpointSpec">Description of this breakpoint.</param>
 /// <returns>New breakpoint.</returns>
 public IBreakpoint AddBreakpoint(Process process, BreakpointSpec breakpointSpec)
 {
     throw new NotImplementedException();
 }