20 #include "pedigree/kernel/debugger/DwarfCfiAutomaton.h" 21 #include "pedigree/kernel/Log.h" 22 #include "pedigree/kernel/debugger/DwarfUnwinder.h" 25 : m_InitialState(), m_CurrentState(), m_nCodeAlignmentFactor(),
26 m_nDataAlignmentFactor(), m_nStartingPc()
35 const DwarfState &startingState, uintptr_t nCodeLocation,
size_t nCodeLen,
36 int32_t nCodeAlignmentFactor, int32_t nDataAlignmentFactor,
37 uintptr_t nStartingPc)
49 execute(nCodeLocation, nCodeLen, static_cast<uintptr_t>(~0));
56 uintptr_t nCodeLocation,
size_t nCodeLen, uintptr_t nBreakAt)
58 uintptr_t nCurrentCodeLocation = nCodeLocation;
60 while ((nCurrentCodeLocation < nCodeLocation + nCodeLen) &&
61 (nProgramCounter <= nBreakAt))
72 uint8_t *pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
75 if ((pLocation[0] & 0xc0) == DW_CFA_advance_loc)
77 uint8_t nDelta = pLocation[0] & 0x3f;
81 else if ((pLocation[0] & 0xc0) == DW_CFA_offset)
83 uint8_t nRegister = pLocation[0] & 0x3f;
84 uint32_t nLocationOffset = 0;
85 pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
86 int32_t nOffset =
static_cast<int32_t
>(
88 nLocation += nLocationOffset;
94 else if ((pLocation[0] & 0xc0) == DW_CFA_restore)
108 processor_register_t *pAddress =
109 reinterpret_cast<processor_register_t *
>(nLocation);
111 nLocation +=
sizeof(processor_register_t);
115 case DW_CFA_advance_loc1:
117 uint8_t nDelta = *
reinterpret_cast<uint8_t *
>(nLocation);
124 case DW_CFA_advance_loc2:
126 uint16_t nDelta = *
reinterpret_cast<uint16_t *
>(nLocation);
133 case DW_CFA_advance_loc4:
135 uint32_t nDelta = *
reinterpret_cast<uint32_t *
>(nLocation);
165 uint32_t nOffset = 0;
166 pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
172 nLocation += nOffset;
178 case DW_CFA_def_cfa_register:
180 uint32_t nOffset = 0;
181 pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
184 nLocation += nOffset;
189 case DW_CFA_def_cfa_offset:
191 uint32_t nOffset = 0;
192 pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
195 nLocation += nOffset;
206 case DW_CFA_offset_extended_sf:
208 uint32_t nLocationOffset = 0;
209 pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
212 nLocation += nLocationOffset;
215 pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
219 nLocation += nLocationOffset;
250 case DW_CFA_GNU_args_size:
252 uint32_t nLocationOffset = 0;
253 pLocation =
reinterpret_cast<uint8_t *
>(nLocation);
255 nLocation += nLocationOffset;
260 "Unrecognised DWARF CFA instruction: " <<
Hex
RegisterState m_RegisterStates[DWARF_MAX_REGISTERS]
static int32_t decodeSleb128(uint8_t *pBase, uint32_t &nOffset)
void initialise(const DwarfState &startingState, uintptr_t nCodeLocation, size_t nCodeLen, int32_t nCodeAlignmentFactor, int32_t nDataAlignmentFactor, uintptr_t nStartingPc)
DwarfState m_InitialState
static uint32_t decodeUleb128(uint8_t *pBase, uint32_t &nOffset)
processor_register_t m_R[DWARF_MAX_REGISTERS]
DwarfState * execute(uintptr_t nCodeLocation, size_t nCodeLen, uintptr_t nBreakAt)
int32_t m_nDataAlignmentFactor
int32_t m_nCodeAlignmentFactor
void executeInstruction(uintptr_t &nLocation, uintptr_t &nPc)
DwarfState m_CurrentState