debugger.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. MSP430 Emulator
  3. Copyright (C) 2020 Rudolf Geosits (rgeosits@live.esu.edu)
  4. "MSP430 Emulator" is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. "MSP430 Emulator" is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef _DEBUGGER_H_
  16. #define _DEBUGGER_H_
  17. #include "../main.h"
  18. #include "../devices/cpu/registers.h"
  19. #include "../devices/memory/memspace.h"
  20. typedef enum { BYTE_STRIDE, WORD_STRIDE, DWORD_STRIDE } Stride;
  21. enum { MAX_BREAKPOINTS = 100 };
  22. typedef struct Debugger
  23. {
  24. bool disassemble_mode;
  25. bool debug_mode;
  26. bool web_interface;
  27. bool console_interface;
  28. bool quit;
  29. unsigned int ws_port;
  30. pthread_t web_server_thread;
  31. bool web_server_ready;
  32. bool web_firmware_uploaded;
  33. pthread_t gui_thread;
  34. char mnemonic[50];
  35. uint16_t bp_addresses[MAX_BREAKPOINTS];
  36. uint16_t current_bp;
  37. uint32_t num_bps;
  38. // debug server for web interface
  39. Server *server;
  40. } Debugger;
  41. void setup_debugger(Emulator *emu);
  42. void dump_memory(Emulator *emu, uint8_t *MEM, uint32_t size,
  43. uint32_t start_addr, uint8_t stride);
  44. void handle_sigint(int signal);
  45. bool command_loop(Emulator *emu, char *buf, int len);
  46. bool exec_cmd (Emulator *emu, char *buf, int len);
  47. void handle_breakpoints (Emulator *emu);
  48. #endif