Flush icache when using swbps and report to gdb.
[riscv-isa-sim.git] / riscv / gdbserver.h
index 8add2ad802dec4c5790547c8b2ba7aadf8e4499d..8f52a92e9566a4ba9d151077ccc433753ebea82b 100644 (file)
@@ -42,6 +42,18 @@ public:
   void append(const T *src, unsigned int count);
 };
 
+// Class to track software breakpoints that we set.
+class software_breakpoint_t
+{
+public:
+  reg_t address;
+  unsigned int size;
+  uint32_t instruction;
+
+  void insert(mmu_t* mmu);
+  void remove(mmu_t* mmu);
+};
+
 class gdbserver_t
 {
 public:
@@ -55,11 +67,17 @@ public:
   void handle_packet(const std::vector<uint8_t> &packet);
   void handle_interrupt();
 
-  void handle_halt_reason(const std::vector<uint8_t> &packet);
-  void handle_read_general_registers(const std::vector<uint8_t> &packet);
-  void handle_read_memory(const std::vector<uint8_t> &packet);
-  void handle_read_register(const std::vector<uint8_t> &packet);
+  void handle_breakpoint(const std::vector<uint8_t> &packet);
   void handle_continue(const std::vector<uint8_t> &packet);
+  void handle_extended(const std::vector<uint8_t> &packet);
+  void handle_general_registers_read(const std::vector<uint8_t> &packet);
+  void handle_halt_reason(const std::vector<uint8_t> &packet);
+  void handle_kill(const std::vector<uint8_t> &packet);
+  void handle_memory_binary_write(const std::vector<uint8_t> &packet);
+  void handle_memory_read(const std::vector<uint8_t> &packet);
+  void handle_query(const std::vector<uint8_t> &packet);
+  void handle_register_read(const std::vector<uint8_t> &packet);
+  void handle_step(const std::vector<uint8_t> &packet);
 
 private:
   sim_t *sim;
@@ -69,6 +87,12 @@ private:
   circular_buffer_t<uint8_t> send_buf;
 
   bool expect_ack;
+  bool extended_mode;
+  // Used to track whether we think the target is running. If we think it is
+  // but it isn't, we need to tell gdb about it.
+  bool running;
+
+  std::map <reg_t, software_breakpoint_t> breakpoints;
 
   // Read pending data from the client.
   void read();