23 #include "pedigree/kernel/Log.h" 24 #include "pedigree/kernel/processor/types.h" 25 #include "pedigree/kernel/utilities/utility.h" 30 #define DWARF_MAX_REGISTERS 66 32 #define DWARF_MAX_REGISTERS 50 36 #define DWARF_REG_EAX 0 37 #define DWARF_REG_ECX 1 38 #define DWARF_REG_EDX 2 39 #define DWARF_REG_EBX 3 40 #define DWARF_REG_ESP 4 41 #define DWARF_REG_EBP 5 42 #define DWARF_REG_ESI 6 43 #define DWARF_REG_EDI 7 46 #define DWARF_REG_RAX 0 47 #define DWARF_REG_RDX 1 48 #define DWARF_REG_RCX 2 49 #define DWARF_REG_RBX 3 50 #define DWARF_REG_RSI 4 51 #define DWARF_REG_RDI 5 52 #define DWARF_REG_RBP 6 53 #define DWARF_REG_RSP 7 54 #define DWARF_REG_R8 8 55 #define DWARF_REG_R9 9 56 #define DWARF_REG_R10 10 57 #define DWARF_REG_R11 11 58 #define DWARF_REG_R12 12 59 #define DWARF_REG_R13 13 60 #define DWARF_REG_R14 14 61 #define DWARF_REG_R15 15 62 #define DWARF_REG_RFLAGS 49 65 #define DWARF_REG_ZERO 0 66 #define DWARF_REG_AT 1 67 #define DWARF_REG_V0 2 68 #define DWARF_REG_V1 3 69 #define DWARF_REG_A0 4 70 #define DWARF_REG_A1 5 71 #define DWARF_REG_A2 6 72 #define DWARF_REG_A3 7 73 #define DWARF_REG_T0 8 74 #define DWARF_REG_T1 9 75 #define DWARF_REG_T2 10 76 #define DWARF_REG_T3 11 77 #define DWARF_REG_T4 12 78 #define DWARF_REG_T5 13 79 #define DWARF_REG_T6 14 80 #define DWARF_REG_T7 15 81 #define DWARF_REG_S0 16 82 #define DWARF_REG_S1 17 83 #define DWARF_REG_S2 18 84 #define DWARF_REG_S3 19 85 #define DWARF_REG_S4 20 86 #define DWARF_REG_S5 21 87 #define DWARF_REG_S6 22 88 #define DWARF_REG_S7 23 89 #define DWARF_REG_T8 24 90 #define DWARF_REG_T9 25 91 #define DWARF_REG_K0 26 92 #define DWARF_REG_K1 27 93 #define DWARF_REG_GP 28 94 #define DWARF_REG_SP 29 95 #define DWARF_REG_FP 30 96 #define DWARF_REG_RA 31 99 #define DWARF_REG_R0 0 100 #define DWARF_REG_R1 1 101 #define DWARF_REG_R2 2 102 #define DWARF_REG_R3 3 103 #define DWARF_REG_R4 4 104 #define DWARF_REG_R5 5 105 #define DWARF_REG_R6 6 106 #define DWARF_REG_R7 7 107 #define DWARF_REG_R8 8 108 #define DWARF_REG_R9 9 109 #define DWARF_REG_R10 10 110 #define DWARF_REG_R11 11 111 #define DWARF_REG_R12 12 112 #define DWARF_REG_R13 13 113 #define DWARF_REG_R14 14 114 #define DWARF_REG_R15 15 115 #define DWARF_REG_R16 16 116 #define DWARF_REG_R17 17 117 #define DWARF_REG_R18 18 118 #define DWARF_REG_R19 19 119 #define DWARF_REG_R20 20 120 #define DWARF_REG_R21 21 121 #define DWARF_REG_R22 22 122 #define DWARF_REG_R23 23 123 #define DWARF_REG_R24 24 124 #define DWARF_REG_R25 25 125 #define DWARF_REG_R26 26 126 #define DWARF_REG_R27 27 127 #define DWARF_REG_R28 28 128 #define DWARF_REG_R29 29 129 #define DWARF_REG_R30 30 130 #define DWARF_REG_R31 31 131 #define DWARF_REG_CR 64 132 #define DWARF_REG_LR 65 // DWARF standard says this should be 108. G++ differs. 163 sizeof(RegisterState) * DWARF_MAX_REGISTERS);
165 static_cast<void *>(
m_R), 0,
166 sizeof(uintptr_t) * DWARF_MAX_REGISTERS);
177 m_CfaOffset(other.m_CfaOffset),
184 sizeof(RegisterState) * DWARF_MAX_REGISTERS);
186 static_cast<void *>(
m_R), static_cast<const void *>(other.
m_R),
187 sizeof(uintptr_t) * DWARF_MAX_REGISTERS);
194 m_CfaOffset = other.m_CfaOffset;
200 sizeof(RegisterState) * DWARF_MAX_REGISTERS);
202 static_cast<void *>(
m_R), static_cast<const void *>(other.
m_R),
203 sizeof(uintptr_t) * DWARF_MAX_REGISTERS);
207 processor_register_t getCfa(
const DwarfState &initialState)
214 static_cast<ssize_t
>(m_CfaOffset);
218 WARNING(
"DwarfState::getCfa: Expression type not implemented.");
222 ERROR(
"CfaState invalid!");
241 return initialState.
m_R[nRegister];
250 if (getCfa(initialState) < 0x2000)
258 return *
reinterpret_cast<processor_register_t *
>(
259 getCfa(initialState) +
260 static_cast<ssize_t
>(
m_R[nRegister]));
268 return getCfa(initialState) +
269 static_cast<ssize_t
>(
m_R[nRegister]);
276 return initialState.
m_R[nRegister];
306 processor_register_t
m_R[DWARF_MAX_REGISTERS];
317 processor_register_t m_CfaOffset;
uint8_t * m_CfaExpression
uintptr_t m_ReturnAddress
RegisterState m_RegisterStates[DWARF_MAX_REGISTERS]
processor_register_t getRegister(unsigned int nRegister, const DwarfState &initialState)
processor_register_t m_R[DWARF_MAX_REGISTERS]
DwarfState(const DwarfState &other)