StuBS
State Class Reference

Structure for the core state after a trap. More...

#include <debug/gdb/state.h>

Classes

struct  Register
 Structure to access a register. More...
 

Public Types

enum  RegisterNumber {
  REG_RAX ,
  REG_RBX ,
  REG_RCX ,
  REG_RDX ,
  REG_RSI ,
  REG_RDI ,
  REG_RBP ,
  REG_RSP ,
  REG_8 ,
  REG_9 ,
  REG_10 ,
  REG_11 ,
  REG_12 ,
  REG_13 ,
  REG_14 ,
  REG_15 ,
  REG_RIP ,
  REG_EFLAGS ,
  REG_CS ,
  REG_SS ,
  REG_DS ,
  REG_ES ,
  REG_FS ,
  REG_GS ,
  REG_ST0 ,
  REG_ST1 ,
  REG_ST2 ,
  REG_ST3 ,
  REG_ST4 ,
  REG_ST5 ,
  REG_ST6 ,
  REG_ST7 ,
  REG_FCTRL ,
  REG_FSTAT ,
  REG_FTAG ,
  REG_FISEG ,
  REG_FIOFF ,
  REG_FOSEG ,
  REG_FOOFF ,
  REG_FOP ,
  REG_XMM0 ,
  REG_XMM1 ,
  REG_XMM2 ,
  REG_XMM3 ,
  REG_XMM4 ,
  REG_XMM5 ,
  REG_XMM6 ,
  REG_XMM7 ,
  REG_XMM8 ,
  REG_XMM9 ,
  REG_XMM10 ,
  REG_XMM11 ,
  REG_XMM12 ,
  REG_XMM13 ,
  REG_XMM14 ,
  REG_XMM15 ,
  REG_MXCSR ,
  REGISTERS
}
 

Static Public Member Functions

static Register get (enum RegisterNumber reg=REGISTERS, int8_t core=0)
 Access a previously saved register. More...
 
static Register get (uintptr_t reg, int8_t core=0)
 Access a previously saved register. More...
 
static void save (const DebugContext *context)
 Read register content from DebugContext and FPU. More...
 
static void restore (DebugContext *context)
 Write register contents back DebugContext and FPU. More...
 

Detailed Description

Structure for the core state after a trap.

GDB allows both reading and changing of registers. These registers are saved at the entry function of a trap (before the actual GDB_Stub::handle is executed) and then converted into this structure – and usually also directly transferred to the connected GDB host. Changes done by the GDB host are first saved in this structure and then written back into the registers right before continuing the actual operating system code.

Member Enumeration Documentation

◆ RegisterNumber

Enumerator
REG_FCTRL 

FPU Control Word (fcw)

REG_FSTAT 

FPU Status Word (fsw)

REG_FTAG 

FPU Tag Word (ftw)

REG_FISEG 

FPU IP Selector (fcs)

REG_FIOFF 

FPU IP Offset (fip)

REG_FOSEG 

FPU Operand Pointer Selector (fos)

REG_FOOFF 

FPU Operand Pointer Offset (foo)

REG_FOP 

Last Instruction Opcode (fop)

REGISTERS 

Total number of registers.

Member Function Documentation

◆ get() [1/2]

State::Register State::get ( enum RegisterNumber  reg = REGISTERS,
int8_t  core = 0 
)
static

Access a previously saved register.

Parameters
regRegister identifier. If State::REGISTERS is used, all registers will be returned
core1-indexed Core ID (≤ 0 for current core)
Returns
Pointer to a structure with address and size of the stored contents

◆ get() [2/2]

State::Register State::get ( uintptr_t  reg,
int8_t  core = 0 
)
static

Access a previously saved register.

Parameters
regRegister identifier. If State::REGISTERS is used, all registers will be returned
core1-indexed Core ID (≤ 0 for current core)
Returns
Pointer to a structure with address and size of the stored contents

◆ save()

void State::save ( const DebugContext context)
static

Read register content from DebugContext and FPU.

Parameters
contextPointer to context of gdb_interrupt_handler

◆ restore()

void State::restore ( DebugContext context)
static

Write register contents back DebugContext and FPU.

Parameters
contextPointer to context of gdb_interrupt_handler, which will finally be restored after returning from the handler.

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