gdbstub.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2013 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. // Originally written by Sven Peter <sven@fail0verflow.com> for anergistic.
  5. #pragma once
  6. #include "common/common_types.h"
  7. namespace GDBStub {
  8. /// Breakpoint Method
  9. enum class BreakpointType {
  10. None, ///< None
  11. Execute, ///< Execution Breakpoint
  12. Read, ///< Read Breakpoint
  13. Write, ///< Write Breakpoint
  14. Access ///< Access (R/W) Breakpoint
  15. };
  16. struct BreakpointAddress {
  17. PAddr address;
  18. BreakpointType type;
  19. };
  20. /**
  21. * Set the port the gdbstub should use to listen for connections.
  22. *
  23. * @param port Port to listen for connection
  24. */
  25. void SetServerPort(u16 port);
  26. /**
  27. * Starts or stops the server if possible.
  28. *
  29. * @param status Set the server to enabled or disabled.
  30. */
  31. void ToggleServer(bool status);
  32. /// Start the gdbstub server.
  33. void Init();
  34. /// Stop gdbstub server.
  35. void Shutdown();
  36. /// Checks if the gdbstub server is enabled.
  37. bool IsServerEnabled();
  38. /// Returns true if there is an active socket connection.
  39. bool IsConnected();
  40. /**
  41. * Signal to the gdbstub server that it should halt CPU execution.
  42. *
  43. * @param is_memory_break If true, the break resulted from a memory breakpoint.
  44. */
  45. void Break(bool is_memory_break = false);
  46. /// Determine if there was a memory breakpoint.
  47. bool IsMemoryBreak();
  48. /// Read and handle packet from gdb client.
  49. void HandlePacket();
  50. /**
  51. * Get the nearest breakpoint of the specified type at the given address.
  52. *
  53. * @param addr Address to search from.
  54. * @param type Type of breakpoint.
  55. */
  56. BreakpointAddress GetNextBreakpointFromAddress(PAddr addr, GDBStub::BreakpointType type);
  57. /**
  58. * Check if a breakpoint of the specified type exists at the given address.
  59. *
  60. * @param addr Address of breakpoint.
  61. * @param type Type of breakpoint.
  62. */
  63. bool CheckBreakpoint(PAddr addr, GDBStub::BreakpointType type);
  64. // If set to true, the CPU will halt at the beginning of the next CPU loop.
  65. bool GetCpuHaltFlag();
  66. // If set to true and the CPU is halted, the CPU will step one instruction.
  67. bool GetCpuStepFlag();
  68. /**
  69. * When set to true, the CPU will step one instruction when the CPU is halted next.
  70. *
  71. * @param is_step
  72. */
  73. void SetCpuStepFlag(bool is_step);
  74. } // namespace GDBStub