public GdbStub(int port, ICpuSupportingGdb cpu, bool autostartEmulation)
        {
            this.cpu = cpu;
            Port     = port;

            pcktBuilder = new PacketBuilder();
            commands    = new CommandsManager(cpu);
            commands.ShouldAutoStart             = autostartEmulation;
            TypeManager.Instance.AutoLoadedType += commands.Register;

            terminal = new SocketServerProvider();
            terminal.DataReceived       += OnByteWritten;
            terminal.ConnectionAccepted += delegate
            {
                cpu.Halted       += OnHalted;
                cpu.ExecutionMode = ExecutionMode.SingleStep;
            };
            terminal.ConnectionClosed += delegate
            {
                cpu.Halted       -= OnHalted;
                cpu.ExecutionMode = ExecutionMode.Continuous;
            };
            terminal.Start(port);
            commHandler = new CommunicationHandler(this);
        }
 private void AccessWatchpointHook(ICpuSupportingGdb cpu, ulong address, SysbusAccessWidth width, uint value)
 {
     //? I See a possible problem here.
     //? Here we call `Halt` event with T05 argument, but in a second we will call it once again with S05 in HandleStepping@TranlationCPU.
     //? It seems to work fine with GDB, but... I don't know if it is fully correct.
     cpu.EnterSingleStepModeSafely(new HaltArguments(HaltReason.Breakpoint, cpu.Id, address, BreakpointType.AccessWatchpoint), manager.BlockOnStep);
 }
Example #3
0
 public void Invoke(ICpuSupportingGdb cpu, ulong currentAddress, SysbusAccessWidth currentWidth, uint value = 0)
 {
     if ((currentWidth & width) != 0)
     {
         action(cpu, currentAddress, currentWidth, value);
     }
 }
Example #4
0
 private bool TryAddManagedCPU(ICpuSupportingGdb cpu)
 {
     if (IsCPUAttached(cpu))
     {
         return(false);
     }
     ManagedCpus.Add(cpu.Id + 1, cpu);
     return(true);
 }
Example #5
0
        public CommandsManager(ICpuSupportingGdb cpu)
        {
            availableCommands = new HashSet<CommandDescriptor>();
            activeCommands = new HashSet<Command>();

            Machine machine;
            EmulationManager.Instance.CurrentEmulation.TryGetMachineForPeripheral(cpu, out machine);
            Cpu = cpu;
            Machine = machine;
        }
Example #6
0
 public void AttachCPU(ICpuSupportingGdb cpu)
 {
     if (!CanAttachCPU)
     {
         throw new RecoverableException("Cannot attach CPU because GDB is already connected.");
     }
     if (!TryAddManagedCPU(cpu))
     {
         throw new RecoverableException("CPU already attached to this GDB server.");
     }
 }
Example #7
0
        public CommandsManager(ICpuSupportingGdb cpu)
        {
            availableCommands = new HashSet <CommandDescriptor>();
            activeCommands    = new HashSet <Command>();

            Machine machine;

            EmulationManager.Instance.CurrentEmulation.TryGetMachineForPeripheral(cpu, out machine);
            Cpu     = cpu;
            Machine = machine;
        }
Example #8
0
        public GdbStub(int port, ICpuSupportingGdb cpu)
        {
            this.cpu = cpu;
            Port     = port;

            pcktBuilder = new PacketBuilder();

            commands = new CommandsManager(cpu);
            TypeManager.Instance.AutoLoadedType += commands.Register;

            cpu.Halted       += OnHalted;
            cpu.ExecutionMode = ExecutionMode.SingleStep;

            terminal = new SocketServerProvider();
            terminal.DataReceived += OnByteWritten;
            terminal.Start(port);
        }
Example #9
0
        public GdbStub(int port, ICpuSupportingGdb cpu)
        {
            this.cpu = cpu;
            Port = port;

            pcktBuilder = new PacketBuilder();

            commands = new CommandsManager(cpu);
            TypeManager.Instance.AutoLoadedType += commands.Register;

            cpu.Halted += OnHalted;
            cpu.ExecutionMode = ExecutionMode.SingleStep;

            terminal = new SocketServerProvider();
            terminal.DataReceived += OnByteWritten;
            terminal.Start(port);
        }
 private void ReadWatchpointHook(ICpuSupportingGdb cpu, ulong address, SysbusAccessWidth width, uint value)
 {
     cpu.EnterSingleStepModeSafely(new HaltArguments(HaltReason.Breakpoint, cpu.Id, address, BreakpointType.ReadWatchpoint), manager.BlockOnStep);
 }
 private void MemoryBreakpointHook(ICpuSupportingGdb cpu, ulong address)
 {
     cpu.EnterSingleStepModeSafely(new HaltArguments(HaltReason.Breakpoint, cpu.Id, breakpointType: BreakpointType.MemoryBreakpoint), manager.BlockOnStep);
 }
 private void HardwareBreakpointHook(ICpuSupportingGdb cpu, ulong address)
 {
     cpu.EnterSingleStepModeSafely(new HaltArguments(HaltReason.Breakpoint, cpu.Id, breakpointType: BreakpointType.HardwareBreakpoint));
 }
 private void WriteWatchpointHook(ICpuSupportingGdb cpu, ulong address, SysbusAccessWidth width)
 {
     cpu.EnterSingleStepModeSafely(new HaltArguments(HaltReason.Breakpoint, cpu.Id, address, BreakpointType.WriteWatchpoint));
 }
Example #14
0
 public bool IsCPUAttached(ICpuSupportingGdb cpu)
 {
     return(ManagedCpus.ContainsValue(cpu));
 }
Example #15
0
 public bool IsCPUAttached(ICpuSupportingGdb cpu)
 {
     return(commandsManager.IsCPUAttached(cpu));
 }
Example #16
0
 public void AttachCPU(ICpuSupportingGdb cpu)
 {
     commandsManager.AttachCPU(cpu);
 }