The Pedigree Project  0.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DwarfCfiAutomaton Class Reference

#include <DwarfCfiAutomaton.h>

+ Collaboration diagram for DwarfCfiAutomaton:

Public Member Functions

 DwarfCfiAutomaton ()
 
 ~DwarfCfiAutomaton ()
 
void initialise (const DwarfState &startingState, uintptr_t nCodeLocation, size_t nCodeLen, int32_t nCodeAlignmentFactor, int32_t nDataAlignmentFactor, uintptr_t nStartingPc)
 
DwarfStateexecute (uintptr_t nCodeLocation, size_t nCodeLen, uintptr_t nBreakAt)
 

Private Member Functions

void executeInstruction (uintptr_t &nLocation, uintptr_t &nPc)
 

Private Attributes

DwarfState m_InitialState
 
DwarfState m_CurrentState
 
int32_t m_nCodeAlignmentFactor
 
int32_t m_nDataAlignmentFactor
 
uintptr_t m_nStartingPc
 

Detailed Description

The DWARF debugging standard uses a table for unwinding of the stack. This table has a column for each register and a row for each possible value of the program counter. Obviously, this table would be huge, so instead they encode it using instructions for an imaginary machine.

For each function, a new table is made and initialised. Opcodes cause sequential creation of the table. An extra column is added for the CFA (current frame address - how to find the current frame base) and (possibly) the return address.

Definition at line 73 of file DwarfCfiAutomaton.h.

Constructor & Destructor Documentation

DwarfCfiAutomaton::DwarfCfiAutomaton ( )

Constructor - Creates the initial starting state with all registers 'undefined'.

Definition at line 24 of file DwarfCfiAutomaton.cc.

DwarfCfiAutomaton::~DwarfCfiAutomaton ( )

Destructor - Doesn't do much, as we don't use dynamic memory.

Definition at line 30 of file DwarfCfiAutomaton.cc.

Member Function Documentation

DwarfState * DwarfCfiAutomaton::execute ( uintptr_t  nCodeLocation,
size_t  nCodeLen,
uintptr_t  nBreakAt 
)

Executes code at the location given until the instruction pointer passes nCodeLocation+nCodeLen or the instruction pointer equals nBreakAt.

Parameters
nCodeLocationLocation of the CFA instruction stream to execute.
nCodeLenMaximum length (in bytes) of code to execute.
nBreakAtExecution should stop when the table row for this instruction has been constructed.
Returns
The ending state on success, zero on failure.

Definition at line 55 of file DwarfCfiAutomaton.cc.

References executeInstruction(), m_CurrentState, and m_nStartingPc.

Referenced by initialise(), and DwarfUnwinder::unwind().

+ Here is the caller graph for this function:

void DwarfCfiAutomaton::executeInstruction ( uintptr_t &  nLocation,
uintptr_t &  nPc 
)
private

Execute one instruction from the location given by nLocation, incrementing it to the next.

Definition at line 70 of file DwarfCfiAutomaton.cc.

References DwarfUnwinder::decodeSleb128(), DwarfUnwinder::decodeUleb128(), ERROR, Hex, DwarfState::m_CfaRegister, DwarfState::m_CfaState, m_CurrentState, m_nCodeAlignmentFactor, m_nDataAlignmentFactor, DwarfState::m_R, and DwarfState::m_RegisterStates.

Referenced by execute().

+ Here is the caller graph for this function:

void DwarfCfiAutomaton::initialise ( const DwarfState startingState,
uintptr_t  nCodeLocation,
size_t  nCodeLen,
int32_t  nCodeAlignmentFactor,
int32_t  nDataAlignmentFactor,
uintptr_t  nStartingPc 
)

Points the automaton to code which it should use to construct the machine starting state. This state is saved for use by a DW_CFA_restore instruction.

Parameters
nCodeLocationLocation of the CFA instruction stream used to initialise the machine.
nCodeLenThe length (in bytes) of code to execute.

Definition at line 34 of file DwarfCfiAutomaton.cc.

References execute(), m_CurrentState, m_InitialState, m_nCodeAlignmentFactor, m_nDataAlignmentFactor, and m_nStartingPc.

Referenced by DwarfUnwinder::unwind().

+ Here is the caller graph for this function:

Member Data Documentation

DwarfState DwarfCfiAutomaton::m_CurrentState
private

The current state of this machine.

Definition at line 124 of file DwarfCfiAutomaton.h.

Referenced by execute(), executeInstruction(), and initialise().

DwarfState DwarfCfiAutomaton::m_InitialState
private

The starting state for this machine.

Definition at line 119 of file DwarfCfiAutomaton.h.

Referenced by initialise().

int32_t DwarfCfiAutomaton::m_nCodeAlignmentFactor
private

The code alignment factor.

Definition at line 129 of file DwarfCfiAutomaton.h.

Referenced by executeInstruction(), and initialise().

int32_t DwarfCfiAutomaton::m_nDataAlignmentFactor
private

The data alignment factor.

Definition at line 134 of file DwarfCfiAutomaton.h.

Referenced by executeInstruction(), and initialise().

uintptr_t DwarfCfiAutomaton::m_nStartingPc
private

The initial PC.

Definition at line 139 of file DwarfCfiAutomaton.h.

Referenced by execute(), and initialise().


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