The Pedigree Project
0.1
|
#include <DwarfCfiAutomaton.h>
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) |
DwarfState * | execute (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 |
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.
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.
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.
nCodeLocation | Location of the CFA instruction stream to execute. |
nCodeLen | Maximum length (in bytes) of code to execute. |
nBreakAt | Execution should stop when the table row for this instruction has been constructed. |
Definition at line 55 of file DwarfCfiAutomaton.cc.
References executeInstruction(), m_CurrentState, and m_nStartingPc.
Referenced by initialise(), and DwarfUnwinder::unwind().
|
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().
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.
nCodeLocation | Location of the CFA instruction stream used to initialise the machine. |
nCodeLen | The 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().
|
private |
The current state of this machine.
Definition at line 124 of file DwarfCfiAutomaton.h.
Referenced by execute(), executeInstruction(), and initialise().
|
private |
The starting state for this machine.
Definition at line 119 of file DwarfCfiAutomaton.h.
Referenced by initialise().
|
private |
The code alignment factor.
Definition at line 129 of file DwarfCfiAutomaton.h.
Referenced by executeInstruction(), and initialise().
|
private |
The data alignment factor.
Definition at line 134 of file DwarfCfiAutomaton.h.
Referenced by executeInstruction(), and initialise().
|
private |
The initial PC.
Definition at line 139 of file DwarfCfiAutomaton.h.
Referenced by execute(), and initialise().