Пример #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);
Пример #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);
Пример #3
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);