private void FormCPU_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.F3: // reset if (m_spectrum.IsRunning) { break; } m_spectrum.DoReset(); UpdateCPU(true); break; case Keys.F7: // StepInto if (m_spectrum.IsRunning) { break; } try { m_spectrum.DoStepInto(); } catch (Exception ex) { Logger.Error(ex); Locator.Resolve <IUserMessage>().ErrorDetails(ex); } UpdateCPU(true); break; case Keys.F8: // StepOver if (m_spectrum.IsRunning) { break; } try { m_spectrum.DoStepOver(); } catch (Exception ex) { Logger.Error(ex); Locator.Resolve <IUserMessage>().ErrorDetails(ex); } UpdateCPU(true); break; case Keys.F9: // Run m_spectrum.DoRun(); UpdateCPU(false); break; case Keys.F5: // Stop m_spectrum.DoStop(); UpdateCPU(true); break; } }
private void GDBClientConnected(object client) { TcpClient tcpClient = (TcpClient)client; NetworkStream clientStream = tcpClient.GetStream(); GDBSession session = new GDBSession(_emulator, _jtagDevice); byte[] message = new byte[0x1000]; int bytesRead; // log = new StreamWriter("c:\\temp\\log.txt"); // log.AutoFlush = true; _emulator.DoStop(); while (true) { bytesRead = 0; try { bytesRead = clientStream.Read(message, 0, 4096); } catch (IOException iex) { var sex = iex.InnerException as SocketException; if (sex == null || sex.ErrorCode != 10004) { Logger.Error(sex); } break; } catch (SocketException sex) { if (sex.ErrorCode != 10004) { Logger.Error(sex); } break; } catch (Exception ex) { Logger.Error(ex); break; } if (bytesRead == 0) { //the client has disconnected from the server break; } if (bytesRead > 0) { GDBPacket packet = new GDBPacket(message, bytesRead); if (_jtagDevice.Log) { Logger.Info("--> {0}", packet); } bool isSignal; string response = session.ParseRequest(packet, out isSignal); if (response != null) { if (isSignal) { SendGlobal(response); } else { SendResponse(clientStream, response); } } } } tcpClient.Close(); }
public string ParseRequest(GDBPacket packet, out bool isSignal) { var result = StandartAnswers.Empty; isSignal = false; // ctrl+c is SIGINT if (packet.GetBytes()[0] == 0x03) { _emulator.DoStop(); result = StandartAnswers.Interrupt; isSignal = true; } try { switch (packet.CommandName) { case '\0': // Command is empty ("+" in 99.99% cases) return(null); case 'q': result = GeneralQueryResponse(packet); break; case 'Q': result = GeneralQueryResponse(packet); break; case '?': result = GetTargetHaltedReason(packet); break; case '!': // extended connection break; case 'g': // read registers result = ReadRegisters(packet); break; case 'G': // write registers result = WriteRegisters(packet); break; case 'm': // read memory result = ReadMemory(packet); break; case 'M': // write memory result = WriteMemory(packet); break; case 'X': // write memory binary // Not implemented yet, client shoul use M instead //result = StandartAnswers.OK; break; case 'p': // get single register result = GetRegister(packet); break; case 'P': // set single register result = SetRegister(packet); break; case 'v': // some requests, mainly vCont result = ExecutionRequest(packet); break; case 's': //stepi _emulator.CPU.ExecCycle(); result = "T05"; break; case 'z': // remove bp result = RemoveBreakpoint(packet); break; case 'Z': // insert bp result = SetBreakpoint(packet); break; case 'k': // Kill the target break; case 'H': // set thread result = StandartAnswers.OK; // we do not have threads, so ignoring this command is OK break; case 'c': // continue _emulator.DoRun(); result = null; break; case 'D': // Detach from client _emulator.DoRun(); result = StandartAnswers.OK; break; } } catch (Exception ex) { Logger.Error(ex); result = GetErrorAnswer(Errno.EPERM); } if (result == null) { return("+"); } else { return(FormatResponse(result)); } }
private void FormCPU_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.F3: if (!m_spectrum.IsRunning) { m_spectrum.DoReset(); UpdateCPU(true); return; } return; case Keys.F4: case Keys.F6: break; case Keys.F5: m_spectrum.DoStop(); UpdateCPU(true); break; case Keys.F7: if (!m_spectrum.IsRunning) { try { m_spectrum.DoStepInto(); } catch (Exception exception) { Logger.Error(exception); Locator.Resolve <IUserMessage>().ErrorDetails(exception); } UpdateCPU(true); return; } return; case Keys.F8: if (!m_spectrum.IsRunning) { try { m_spectrum.DoStepOver(); } catch (Exception exception2) { Logger.Error(exception2); Locator.Resolve <IUserMessage>().ErrorDetails(exception2); } UpdateCPU(true); return; } return; case Keys.F9: m_spectrum.DoRun(); UpdateCPU(false); return; case Keys.F10: sprint_ula.UpdateFrame(); return; default: return; } }