14#ifndef MAXOS_RUNTIME_GDBSTUB_H
15#define MAXOS_RUNTIME_GDBSTUB_H
17#include <libcommon/string.h>
23namespace MaxOS::runtime {
78 void handle_interrupt()
override;
80 string current_command_buffer;
81 void try_handle_command();
82 void delegate_command(
const string& command);
84 string format_register(uint64_t value,
int num_bytes);
89 common::Map<void*, uint8_t> m_breakpoints;
98 bool check_checksum(
const string& payload,
const string& checksum);
108 void send_breakpoint_reached();
A driver for the serial output.
Base class for handing CPU expection interrupts.
Handles a certain interrupt number.
virtual void handle_interrupt()
Handles an interrupt.
The execution context of a sub-process thread.
Exception handler for a hardware breakpoint.
Handler for running a GDB server over serial.
processes::Thread * attached_thread()
Get the attached thread.
void handle_step_instruction()
Set the trap flag and allow the thread to run.
string build_message(const string &payload)
Converts a message into the form GDB expects, including and ACK package.
void send_message(const string &payload)
Converts a message to the required form and sends it over serial.
void handle_set_breakpoint(const string &message)
Set a software break point by replacing the instruction with a INT3.
string get_checksum(const string &payload)
Calculates the GDB checksum of a command.
bool check_checksum(const string &payload, const string &checksum)
Validates the checksum of a commnad.
void send_supported(const string &peer_supported)
Sends the features that this GDB stub supports to the GDB server.
void send_memory(const string &message)
Send a chunk of memory to the GDB server.
void handle_remove_breakpoint(const string &message)
Remove a software break point, and replace the original opcode.
void handle_continue()
Continues the exeuction of the thread, acknowledges the request and allows the thread to run.
void send_empty()
Send an empty message to the GDB server.
void send_registers()
Sends the registers of the thread to the GDB server.
void attach(processes::Thread *thread)
Begin debugging a thread, will start paused.
void handle_detach()
Detaches the thread from the GDB, removing all breakpoints and allowing it to be scheduled as usual.
Exception handler for a hardware mem watch.
struct PACKED MaxOS::system::CPUStatus cpu_status_t
Alias for CPUStatus struct.
constexpr bool DO_DEBUGGING
Whether to use the serial for GDB communcation or for logging.
constexpr char * DEBUG_TARGET
The userspace process to attach to.
Defines a InterruptManager and InterruptHandler for managing hardware and software interrupts.
Defines Process and Thread classes for managing processes and their execution contexts.
Defines a SerialConsole driver for serial output.