Example #1
0
        private void OnBreakpointHit(object sender, BreakpointHitEventArgs e)
        {
            var boundBreakpoints = new[] { _breakpointManager.GetBreakpoint(e.Breakpoint) };

            // 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.

            Send(new AD7BreakpointEvent(new AD7BoundBreakpointsEnum(boundBreakpoints)), AD7BreakpointEvent.IID, _threads.Item2);
        }
Example #2
0
        private static void DebuggerThread()
        {
            //
            // Wait for the display to be ready.
            //
            _console.WaitForSync();

            ConsoleExecutor debuggerPrompt = new ConsoleExecutor(_imlacSystem);

            if (_startupArgs.Length > 0)
            {
                //
                // Assume arg 0 is a script file to be executed.
                //
                Console.WriteLine("Executing startup script '{0}'", _startupArgs[0]);

                try
                {
                    _state = debuggerPrompt.ExecuteScript(_imlacSystem, _startupArgs[0]);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error parsing script: {0}", e.Message);
                }
            }

            while (_state != SystemExecutionState.Quit)
            {
                try
                {
                    switch (_state)
                    {
                    case SystemExecutionState.Halted:
                    case SystemExecutionState.Debugging:
                        _state = debuggerPrompt.Prompt(_imlacSystem);
                        break;

                    case SystemExecutionState.SingleStep:
                        _imlacSystem.SingleStep();
                        _imlacSystem.Display.RenderCurrent(false);
                        _state = SystemExecutionState.Debugging;
                        break;

                    case SystemExecutionState.SingleFrame:
                        _imlacSystem.SingleStep();

                        if (_imlacSystem.DisplayProcessor.FrameLatch)
                        {
                            Console.WriteLine("Frame completed.");
                            _state = SystemExecutionState.Debugging;
                        }
                        break;

                    case SystemExecutionState.UntilDisplayStart:
                        _imlacSystem.SingleStep();

                        if (_imlacSystem.DisplayProcessor.State == ProcessorState.Running)
                        {
                            Console.WriteLine("Display started.");
                            _state = SystemExecutionState.Debugging;
                        }
                        break;

                    case SystemExecutionState.Running:
                        _imlacSystem.SingleStep();

                        if (_imlacSystem.Processor.State == ProcessorState.Halted)
                        {
                            Console.WriteLine("Main processor halted at {0}", Helpers.ToOctal(_imlacSystem.Processor.PC));
                            _state = SystemExecutionState.Debugging;
                        }
                        else if (_imlacSystem.Processor.State == ProcessorState.BreakpointHalt)
                        {
                            Console.WriteLine(
                                "Breakpoint hit: {0} at address {1}",
                                BreakpointManager.GetBreakpoint(_imlacSystem.Processor.BreakpointAddress),
                                Helpers.ToOctal(_imlacSystem.Processor.BreakpointAddress));
                            _state = SystemExecutionState.Debugging;
                        }
                        break;
                    }
                }
                catch (Exception e)
                {
                    if (!(e is System.Threading.ThreadAbortException))
                    {
                        Console.WriteLine("Internal error during execution: {0}", e.Message);
                        _state = SystemExecutionState.Debugging;
                    }
                }
            }

            // We are exiting, shut things down.
            //
            _imlacSystem.Shutdown();
        }