StuBS
State Class Reference

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

#include <debug/gdb/state.h>

Collaboration diagram for State:
[legend]

Classes

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

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.
 
static Register get (uintptr_t reg, int8_t core=0)
 Access a previously saved register.
 
static void save (const DebugContext *context)
 Read register content from DebugContext and FPU.
 
static void restore (DebugContext *context)
 Write register contents back DebugContext and FPU.
 

Private Types

enum  Offset {
  OFFSET_GENERAL ,
  OFFSET_SEGMENT = REG_EFLAGS ,
  OFFSET_FPU_DATA = REG_ST0 ,
  OFFSET_FPU_STATUS = REG_FCTRL ,
  OFFSET_XMM_DATA = REG_XMM0 ,
  OFFSET_XMM_STATUS = REG_MXCSR
}
 
enum  Size {
  SIZE_GENERAL = OFFSET_SEGMENT - OFFSET_GENERAL ,
  SIZE_SEGMENT = OFFSET_FPU_DATA - OFFSET_SEGMENT ,
  SIZE_FPU_DATA = OFFSET_FPU_STATUS - OFFSET_FPU_DATA ,
  SIZE_FPU_STATUS = OFFSET_XMM_DATA - OFFSET_FPU_STATUS ,
  SIZE_XMM_DATA = OFFSET_XMM_STATUS - OFFSET_XMM_DATA ,
  SIZE_XMM_STATUS = REGISTERS - OFFSET_XMM_STATUS
}
 

Private Member Functions

 assert_size (Registers, 536)
 

Private Attributes

Registers registers
 

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.


Class Documentation

◆ State::Registers

struct State::Registers
Collaboration diagram for State::Registers:
[legend]
Class Members
uintptr_t general[SIZE_GENERAL]
uint32_t segment[SIZE_SEGMENT]
struct ST fpu_data[SIZE_FPU_DATA]
uint32_t fpu_status[SIZE_FPU_STATUS]
struct XMM xmm_data[SIZE_XMM_DATA]
uint32_t xmm_status[SIZE_XMM_STATUS]

Member Enumeration Documentation

◆ RegisterNumber

Enumerator
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 

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)

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 

Total number of registers.

◆ Offset

enum State::Offset
private
Enumerator
OFFSET_GENERAL 
OFFSET_SEGMENT 
OFFSET_FPU_DATA 
OFFSET_FPU_STATUS 
OFFSET_XMM_DATA 
OFFSET_XMM_STATUS 

◆ Size

enum State::Size
private
Enumerator
SIZE_GENERAL 
SIZE_SEGMENT 
SIZE_FPU_DATA 
SIZE_FPU_STATUS 
SIZE_XMM_DATA 
SIZE_XMM_STATUS 

Member Function Documentation

◆ assert_size()

State::assert_size ( Registers  ,
536   
)
private

◆ 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.

Member Data Documentation

◆ registers

Registers State::registers
private

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