![]() |
Max OS 0.3
|
Handler for running a GDB server over serial. More...
#include <gdbstub.h>
Public Member Functions | |
| GDBServer (console::SerialConsole *serial) | |
| Constructs a handler for remote debugging using GDB, also sets up interrupt handlers for traps and breakpoints. | |
| void | attach (processes::Thread *thread) |
| Begin debugging a thread, will start paused. | |
| 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. | |
| 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 | send_empty () |
| Send an empty message to the GDB server. | |
| void | send_supported (const string &peer_supported) |
| Sends the features that this GDB stub supports to the GDB server. | |
| void | send_registers () |
| Sends the registers of the thread to the GDB server. | |
| void | send_memory (const string &message) |
| Send a chunk of memory to the GDB server. | |
| void | send_memory (void *address, size_t length) |
| Send a chunk of memory to the GDB server. | |
| void | send_breakpoint_reached () |
| void | handle_step_instruction () |
| Set the trap flag and allow the thread to run. | |
| void | handle_set_breakpoint (const string &message) |
| Set a software break point by replacing the instruction with a INT3. | |
| void | handle_set_breakpoint (void *address) |
| Set a software break point by replacing the instruction with a INT3. | |
| void | handle_remove_breakpoint (const string &message) |
| Remove a software break point, and replace the original opcode. | |
| void | handle_remove_breakpoint (void *address) |
| 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 | handle_detach () |
| Detaches the thread from the GDB, removing all breakpoints and allowing it to be scheduled as usual. | |
| processes::Thread * | attached_thread () |
| Get the attached thread. | |
Public Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler | |
| virtual system::cpu_status_t * | handle_interrupt (system::cpu_status_t *status) |
| Handles an interrupt and returns the status. | |
Public Attributes | |
| system::cpu_status_t | thread_regs |
Additional Inherited Members | |
Protected Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler | |
| InterruptHandler (uint8_t interrupt_number, int64_t redirect=-1, uint64_t redirect_index=0) | |
| Creates a new interrupt handler and registers it with the interrupt manager. | |
| virtual | ~InterruptHandler () |
| Destroys the interrupt handler and unregisters it from the interrupt manager. | |
Protected Attributes inherited from MaxOS::hardwarecommunication::InterruptHandler | |
| uint8_t | m_interrupt_number |
| The interrupt number this handler handles. | |
| GDBServer::GDBServer | ( | console::SerialConsole * | serial | ) |
Constructs a handler for remote debugging using GDB, also sets up interrupt handlers for traps and breakpoints.
| serial | The serial port where GDB will listen/send packets on |
Definition at line 28 of file gdbstub.cpp.
| void GDBServer::attach | ( | processes::Thread * | thread | ) |
Begin debugging a thread, will start paused.
| thread | The thread to debug |
Definition at line 43 of file gdbstub.cpp.
References MaxOS::processes::Thread::execution_state, and MaxOS::processes::Thread::thread_state.
| Thread * GDBServer::attached_thread | ( | ) |
Get the attached thread.
Definition at line 536 of file gdbstub.cpp.
Referenced by MaxOS::runtime::TrapFlagExcpetion::handle_interrupt(), and MaxOS::runtime::BreakPointException::handle_interrupt().
| string GDBServer::build_message | ( | const string & | payload | ) |
Converts a message into the form GDB expects, including and ACK package.
| payload | The message to convert |
Definition at line 258 of file gdbstub.cpp.
References get_checksum().
Referenced by send_message().
| bool GDBServer::check_checksum | ( | const string & | payload, |
| const string & | checksum | ||
| ) |
Validates the checksum of a commnad.
| payload | The command to validate |
| checksum | The expected checksum |
Definition at line 248 of file gdbstub.cpp.
References get_checksum().
| string GDBServer::get_checksum | ( | const string & | payload | ) |
Calculates the GDB checksum of a command.
| payload | The command to get the checksum of |
Definition at line 222 of file gdbstub.cpp.
Referenced by build_message(), and check_checksum().
| void GDBServer::handle_continue | ( | ) |
Continues the exeuction of the thread, acknowledges the request and allows the thread to run.
Definition at line 508 of file gdbstub.cpp.
References MaxOS::processes::Thread::thread_state, and MaxOS::console::SerialConsole::write_char().
| void GDBServer::handle_detach | ( | ) |
Detaches the thread from the GDB, removing all breakpoints and allowing it to be scheduled as usual.
Definition at line 520 of file gdbstub.cpp.
References handle_remove_breakpoint(), and MaxOS::processes::Thread::thread_state.
| void GDBServer::handle_remove_breakpoint | ( | const string & | message | ) |
Remove a software break point, and replace the original opcode.
| message | The GDB command requesting the breakpoint removal |
Definition at line 457 of file gdbstub.cpp.
References handle_remove_breakpoint().
Referenced by handle_detach(), and handle_remove_breakpoint().
| void GDBServer::handle_remove_breakpoint | ( | void * | address | ) |
Remove a software break point, and replace the original opcode.
| address | The address to break on |
Definition at line 472 of file gdbstub.cpp.
References MaxOS::processes::GlobalScheduler::current_process(), MaxOS::processes::GlobalScheduler::get_process(), MaxOS::processes::Process::memory_manager, MaxOS::processes::Thread::parent_pid, and send_message().
| void GDBServer::handle_set_breakpoint | ( | const string & | message | ) |
Set a software break point by replacing the instruction with a INT3.
| message | The GDB command requesting the breakpoint |
Definition at line 405 of file gdbstub.cpp.
References handle_set_breakpoint().
Referenced by handle_set_breakpoint().
| void GDBServer::handle_set_breakpoint | ( | void * | address | ) |
Set a software break point by replacing the instruction with a INT3.
| address | The address to break on |
Definition at line 420 of file gdbstub.cpp.
References MaxOS::processes::GlobalScheduler::current_process(), MaxOS::processes::GlobalScheduler::get_process(), MaxOS::processes::Process::memory_manager, MaxOS::processes::Thread::parent_pid, and send_message().
| void GDBServer::handle_step_instruction | ( | ) |
Set the trap flag and allow the thread to run.
Definition at line 383 of file gdbstub.cpp.
References MaxOS::processes::Thread::execution_state, MaxOS::processes::Thread::thread_state, and MaxOS::console::SerialConsole::write_char().
| void GDBServer::send_empty | ( | ) |
Send an empty message to the GDB server.
Definition at line 275 of file gdbstub.cpp.
References send_message().
| void GDBServer::send_memory | ( | const string & | message | ) |
Send a chunk of memory to the GDB server.
| message | The GDB command requesting the chunk |
Definition at line 343 of file gdbstub.cpp.
References send_memory().
Referenced by send_memory().
| void GDBServer::send_memory | ( | void * | address, |
| size_t | length | ||
| ) |
Send a chunk of memory to the GDB server.
| address | The start address of the chunk |
| length | How large the chunk is (in bytes) |
Definition at line 359 of file gdbstub.cpp.
References MaxOS::processes::GlobalScheduler::current_process(), MaxOS::processes::GlobalScheduler::get_process(), MaxOS::processes::Process::memory_manager, MaxOS::processes::Thread::parent_pid, and send_message().
| void GDBServer::send_message | ( | const string & | payload | ) |
Converts a message to the required form and sends it over serial.
| payload | The message to send |
Definition at line 267 of file gdbstub.cpp.
References build_message().
Referenced by MaxOS::runtime::TrapFlagExcpetion::handle_interrupt(), MaxOS::runtime::BreakPointException::handle_interrupt(), handle_remove_breakpoint(), handle_set_breakpoint(), send_empty(), send_memory(), send_registers(), and send_supported().
| void GDBServer::send_registers | ( | ) |
Sends the registers of the thread to the GDB server.
Definition at line 300 of file gdbstub.cpp.
References send_message().
| void GDBServer::send_supported | ( | const string & | peer_supported | ) |
Sends the features that this GDB stub supports to the GDB server.
| peer_supported | The features that the server has indicated that it supports |
Definition at line 284 of file gdbstub.cpp.
References send_message().
| system::cpu_status_t MaxOS::runtime::GDBServer::thread_regs |