Max OS 0.3
Loading...
Searching...
No Matches
MaxOS::runtime::BreakPointException Class Reference

Exception handler for a hardware breakpoint. More...

#include <gdbstub.h>

Inheritance diagram for MaxOS::runtime::BreakPointException:
MaxOS::hardwarecommunication::ExceptionHandler MaxOS::hardwarecommunication::InterruptHandler

Public Member Functions

 BreakPointException (GDBServer *server)
 Registers a handler for the BreakPointException (interrupt 0x1)
 
system::cpu_status_t * handle_interrupt (system::cpu_status_t *status) override
 Handles the interrupt 0x3 by pausing the thread.
 
- Public Member Functions inherited from MaxOS::hardwarecommunication::ExceptionHandler
 ExceptionHandler (uint8_t interrupt_number)
 Create a new base exception handler for an interrupt.
 
 ~ExceptionHandler ()
 
virtual string get_message (system::cpu_status_t *status)
 Get an human readable error message explaining this exception.
 
- Public Member Functions inherited from MaxOS::hardwarecommunication::InterruptHandler
virtual void handle_interrupt ()
 Handles an interrupt.
 

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.
 

Detailed Description

Exception handler for a hardware breakpoint.

Definition at line 54 of file gdbstub.h.

Constructor & Destructor Documentation

◆ BreakPointException()

BreakPointException::BreakPointException ( GDBServer *  server)

Registers a handler for the BreakPointException (interrupt 0x1)

Parameters
serverThe GDB stub that will handle the exception

Definition at line 585 of file gdbstub.cpp.

586: ExceptionHandler(0x3),
587 m_gdb_handler(server)
588{
589
590}
Base class for handing CPU expection interrupts.
Definition interrupts.h:61

Member Function Documentation

◆ handle_interrupt()

cpu_status_t * BreakPointException::handle_interrupt ( system::cpu_status_t *  status)
overridevirtual

Handles the interrupt 0x3 by pausing the thread.

Parameters
statusThe registers at time of exception
Returns
The state to return to

Reimplemented from MaxOS::hardwarecommunication::ExceptionHandler.

Definition at line 600 of file gdbstub.cpp.

600 {
601
602 // Move back
603 status->rip -= 1;
604 m_gdb_handler->thread_regs = *status;
605 m_gdb_handler->attached_thread()->thread_state = ThreadState::WAITING;
606
607 // Notify the server that it stopped
608 m_gdb_handler->send_message("S05");
609
610 // Dont execute further until instructed by GDB
612
613 // Copy the registers back as they may have been modified elsewhere
614 *status = m_gdb_handler->thread_regs;
615 return status;
616}
static Thread * current_thread()
Gets the thread on the currently executing core.
void yield()
Pass execution to the next ready thread.
Definition process.cpp:103
volatile thread_state_t thread_state
The current state of the thread.
Definition process.h:72
processes::Thread * attached_thread()
Get the attached thread.
Definition gdbstub.cpp:536
void send_message(const string &payload)
Converts a message to the required form and sends it over serial.
Definition gdbstub.cpp:267

References MaxOS::runtime::GDBServer::attached_thread(), MaxOS::processes::GlobalScheduler::current_thread(), MaxOS::runtime::GDBServer::send_message(), MaxOS::processes::Thread::thread_state, and MaxOS::processes::Thread::yield().


The documentation for this class was generated from the following files: