Standardize some hexadecimals

This commit is contained in:
Scott Lahteine
2018-05-08 09:17:44 -05:00
parent ec05408453
commit d1b619be52
27 changed files with 204 additions and 204 deletions

View File

@@ -80,7 +80,7 @@ void UnwInitState(UnwState * const state, /**< Pointer to structure to fill.
// Detect if function names are available
static int __attribute__ ((noinline)) has_function_names(void) {
uint32_t flag_word = ((uint32_t*)(((uint32_t)(&has_function_names)) & (-4))) [-1];
return ((flag_word & 0xff000000) == 0xff000000) ? 1 : 0;
return ((flag_word & 0xFF000000) == 0xFF000000) ? 1 : 0;
}
/**

View File

@@ -104,7 +104,7 @@ typedef struct {
* Macros
**************************************************************************/
#define M_IsOriginValid(v) (((v) & 0x7f) ? true : false)
#define M_IsOriginValid(v) (((v) & 0x7F) ? true : false)
#define M_Origin2Str(v) ((v) ? "VALID" : "INVALID")
#if defined(UNW_DEBUG)

View File

@@ -28,7 +28,7 @@
static int32_t signExtend11(uint16_t value) {
if(value & 0x400) {
value |= 0xfffff800;
value |= 0xFFFFF800;
}
return value;
@@ -66,7 +66,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
/*
* Detect 32bit thumb instructions
*/
if ((instr & 0xe000) == 0xe000 && (instr & 0x1800) != 0) {
if ((instr & 0xE000) == 0xE000 && (instr & 0x1800) != 0) {
uint16_t instr2;
/* Check next address */
@@ -83,7 +83,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
* Load/Store multiple: Only interpret
* PUSH and POP
*/
if ((instr & 0xfe6f) == 0xe82d) {
if ((instr & 0xFE6F) == 0xE82D) {
bool L = (instr & 0x10) ? true : false;
uint16_t rList = instr2;
@@ -171,7 +171,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
/*
* PUSH register
*/
else if (instr == 0xf84d && (instr2 & 0x0fff) == 0x0d04) {
else if (instr == 0xF84D && (instr2 & 0x0FFF) == 0x0D04) {
uint8_t r = instr2 >> 12;
/* Store to memory: PUSH */
@@ -187,7 +187,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
/*
* POP register
*/
else if (instr == 0xf85d && (instr2 & 0x0fff) == 0x0b04) {
else if (instr == 0xF85D && (instr2 & 0x0FFF) == 0x0B04) {
uint8_t r = instr2 >> 12;
/* Load from memory: POP */
@@ -246,7 +246,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
/*
* TBB / TBH
*/
else if ((instr & 0xfff0) == 0xe8d0 && (instr2 & 0xffe0) == 0xf000) {
else if ((instr & 0xFFF0) == 0xE8D0 && (instr2 & 0xFFE0) == 0xF000) {
/* We are only interested in
* the forms
* TBB [PC, ...]
@@ -254,8 +254,8 @@ UnwResult UnwStartThumb(UnwState * const state) {
* as those are used by the C compiler to implement
* the switch clauses
*/
uint8_t rn = instr & 0xf;
uint8_t rm = instr2 & 0xf;
uint8_t rn = instr & 0xF;
uint8_t rm = instr2 & 0xF;
bool H = (instr2 & 0x10) ? true : false;
UnwPrintd5("TB%c [r%d,r%d%s]\n", H ? 'H' : 'B', rn, rm, H ? ",LSL #1" : "");
@@ -280,19 +280,19 @@ UnwResult UnwStartThumb(UnwState * const state) {
/*
* Unconditional branch
*/
else if ((instr & 0xf800) == 0xf000 && (instr2 & 0xd000) == 0x9000) {
else if ((instr & 0xF800) == 0xF000 && (instr2 & 0xD000) == 0x9000) {
uint32_t v;
uint8_t S = (instr & 0x400) >> 10;
uint16_t imm10 = (instr & 0x3ff);
uint16_t imm10 = (instr & 0x3FF);
uint8_t J1 = (instr2 & 0x2000) >> 13;
uint8_t J2 = (instr2 & 0x0800) >> 11;
uint16_t imm11 = (instr2 & 0x7ff);
uint16_t imm11 = (instr2 & 0x7FF);
uint8_t I1 = J1 ^ S ^ 1;
uint8_t I2 = J2 ^ S ^ 1;
uint32_t imm32 = (S << 24) | (I1 << 23) | (I2 << 22) |(imm10 << 12) | (imm11 << 1);
if (S) imm32 |= 0xfe000000;
if (S) imm32 |= 0xFE000000;
UnwPrintd2("B %d \n", imm32);
@@ -321,18 +321,18 @@ UnwResult UnwStartThumb(UnwState * const state) {
/*
* Branch with link
*/
else if ((instr & 0xf800) == 0xf000 && (instr2 & 0xd000) == 0xd000) {
else if ((instr & 0xF800) == 0xF000 && (instr2 & 0xD000) == 0xD000) {
uint8_t S = (instr & 0x400) >> 10;
uint16_t imm10 = (instr & 0x3ff);
uint16_t imm10 = (instr & 0x3FF);
uint8_t J1 = (instr2 & 0x2000) >> 13;
uint8_t J2 = (instr2 & 0x0800) >> 11;
uint16_t imm11 = (instr2 & 0x7ff);
uint16_t imm11 = (instr2 & 0x7FF);
uint8_t I1 = J1 ^ S ^ 1;
uint8_t I2 = J2 ^ S ^ 1;
uint32_t imm32 = (S << 24) | (I1 << 23) | (I2 << 22) |(imm10 << 12) | (imm11 << 1);
if (S) imm32 |= 0xfe000000;
if (S) imm32 |= 0xFE000000;
UnwPrintd2("BL %d \n", imm32);
@@ -377,18 +377,18 @@ UnwResult UnwStartThumb(UnwState * const state) {
/*
* Conditional branches. Usually not taken, unless infinite loop is detected
*/
else if ((instr & 0xf800) == 0xf000 && (instr2 & 0xd000) == 0x8000) {
else if ((instr & 0xF800) == 0xF000 && (instr2 & 0xD000) == 0x8000) {
uint8_t S = (instr & 0x400) >> 10;
uint16_t imm6 = (instr & 0x3f);
uint16_t imm6 = (instr & 0x3F);
uint8_t J1 = (instr2 & 0x2000) >> 13;
uint8_t J2 = (instr2 & 0x0800) >> 11;
uint16_t imm11 = (instr2 & 0x7ff);
uint16_t imm11 = (instr2 & 0x7FF);
uint8_t I1 = J1 ^ S ^ 1;
uint8_t I2 = J2 ^ S ^ 1;
uint32_t imm32 = (S << 20) | (I1 << 19) | (I2 << 18) |(imm6 << 12) | (imm11 << 1);
if (S) imm32 |= 0xffe00000;
if (S) imm32 |= 0xFFE00000;
UnwPrintd2("Bcond %d\n", imm32);
@@ -412,9 +412,9 @@ UnwResult UnwStartThumb(UnwState * const state) {
* PC-relative load
* LDR Rd,[PC, #+/-imm]
*/
else if((instr & 0xff7f) == 0xf85f) {
uint8_t rt = (instr2 & 0xf000) >> 12;
uint8_t imm12 = (instr2 & 0x0fff);
else if((instr & 0xFF7F) == 0xF85F) {
uint8_t rt = (instr2 & 0xF000) >> 12;
uint8_t imm12 = (instr2 & 0x0FFF);
bool A = (instr & 0x80) ? true : false;
uint32_t address;
@@ -434,10 +434,10 @@ UnwResult UnwStartThumb(UnwState * const state) {
* We are only interested when destination is PC.
* LDR Rt,[Rn , #n]
*/
else if ((instr & 0xfff0) == 0xf8d0) {
uint8_t rn = (instr & 0xf);
uint8_t rt = (instr2 & 0xf000) >> 12;
uint16_t imm12 = (instr2 & 0xfff);
else if ((instr & 0xFFF0) == 0xF8D0) {
uint8_t rn = (instr & 0xF);
uint8_t rt = (instr2 & 0xF000) >> 12;
uint16_t imm12 = (instr2 & 0xFFF);
/* If destination is PC and we don't know the source value, then fail */
if (!M_IsOriginValid(state->regData[rn].o)) {
@@ -456,10 +456,10 @@ UnwResult UnwStartThumb(UnwState * const state) {
* LDR Rt,[Rn], #+/-n]
* LDR Rt,[Rn, #+/-n]!
*/
else if ((instr & 0xfff0) == 0xf850 && (instr2 & 0x0800) == 0x0800) {
uint8_t rn = (instr & 0xf);
uint8_t rt = (instr2 & 0xf000) >> 12;
uint16_t imm8 = (instr2 & 0xff);
else if ((instr & 0xFFF0) == 0xF850 && (instr2 & 0x0800) == 0x0800) {
uint8_t rn = (instr & 0xF);
uint8_t rt = (instr2 & 0xF000) >> 12;
uint16_t imm8 = (instr2 & 0xFF);
bool P = (instr2 & 0x400) ? true : false;
bool U = (instr2 & 0x200) ? true : false;
bool W = (instr2 & 0x100) ? true : false;
@@ -493,10 +493,10 @@ UnwResult UnwStartThumb(UnwState * const state) {
* ldr Rt, [Rn, Rm, lsl #x]
* Where Rt is PC, Rn value is known, Rm is not known or unknown
*/
else if ((instr & 0xfff0) == 0xf850 && (instr2 & 0x0fc0) == 0x0000) {
uint8_t rn = (instr & 0xf);
uint8_t rt = (instr2 & 0xf000) >> 12;
uint8_t rm = (instr2 & 0xf);
else if ((instr & 0xFFF0) == 0xF850 && (instr2 & 0x0FC0) == 0x0000) {
uint8_t rn = (instr & 0xF);
uint8_t rt = (instr2 & 0xF000) >> 12;
uint8_t rm = (instr2 & 0xF);
uint8_t imm2 = (instr2 & 0x30) >> 4;
if (!M_IsOriginValid(state->regData[rn].o) ||
@@ -534,10 +534,10 @@ UnwResult UnwStartThumb(UnwState * const state) {
* LSR Rd, Rs, #Offset5
* ASR Rd, Rs, #Offset5
*/
else if((instr & 0xe000) == 0x0000 && (instr & 0x1800) != 0x1800) {
else if((instr & 0xE000) == 0x0000 && (instr & 0x1800) != 0x1800) {
bool signExtend;
uint8_t op = (instr & 0x1800) >> 11;
uint8_t offset5 = (instr & 0x07c0) >> 6;
uint8_t offset5 = (instr & 0x07C0) >> 6;
uint8_t rs = (instr & 0x0038) >> 3;
uint8_t rd = (instr & 0x0007);
@@ -562,7 +562,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
signExtend = (state->regData[rs].v & 0x8000) ? true : false;
state->regData[rd].v = state->regData[rs].v >> offset5;
if(signExtend) {
state->regData[rd].v |= 0xffffffff << (32 - offset5);
state->regData[rd].v |= 0xFFFFFFFF << (32 - offset5);
}
state->regData[rd].o = state->regData[rs].o;
state->regData[rd].o |= REG_VAL_ARITHMETIC;
@@ -575,10 +575,10 @@ UnwResult UnwStartThumb(UnwState * const state) {
* SUB Rd, Rs, Rn
* SUB Rd, Rs, #Offset3
*/
else if((instr & 0xf800) == 0x1800) {
else if((instr & 0xF800) == 0x1800) {
bool I = (instr & 0x0400) ? true : false;
bool op = (instr & 0x0200) ? true : false;
uint8_t rn = (instr & 0x01c0) >> 6;
uint8_t rn = (instr & 0x01C0) >> 6;
uint8_t rs = (instr & 0x0038) >> 3;
uint8_t rd = (instr & 0x0007);
@@ -627,11 +627,11 @@ UnwResult UnwStartThumb(UnwState * const state) {
* ADD Rd, #Offset8
* SUB Rd, #Offset8
*/
else if((instr & 0xe000) == 0x2000) {
else if((instr & 0xE000) == 0x2000) {
uint8_t op = (instr & 0x1800) >> 11;
uint8_t rd = (instr & 0x0700) >> 8;
uint8_t offset8 = (instr & 0x00ff);
uint8_t offset8 = (instr & 0x00FF);
switch(op) {
case 0: /* MOV */
@@ -676,8 +676,8 @@ UnwResult UnwStartThumb(UnwState * const state) {
* BIC Rd, Rs
* MVN Rd, Rs
*/
else if((instr & 0xfc00) == 0x4000) {
uint8_t op = (instr & 0x03c0) >> 6;
else if((instr & 0xFC00) == 0x4000) {
uint8_t op = (instr & 0x03C0) >> 6;
uint8_t rs = (instr & 0x0038) >> 3;
uint8_t rd = (instr & 0x0007);
@@ -741,7 +741,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
case 4: /* ASR */
if(state->regData[rd].v & 0x80000000) {
state->regData[rd].v >>= state->regData[rs].v;
state->regData[rd].v |= 0xffffffff << (32 - state->regData[rs].v);
state->regData[rd].v |= 0xFFFFFFFF << (32 - state->regData[rs].v);
}
else {
state->regData[rd].v >>= state->regData[rs].v;
@@ -826,7 +826,7 @@ UnwResult UnwStartThumb(UnwState * const state) {
* CMP Hd, Rs
* MOV Hd, Hs
*/
else if((instr & 0xfc00) == 0x4400) {
else if((instr & 0xFC00) == 0x4400) {
uint8_t op = (instr & 0x0300) >> 8;
bool h1 = (instr & 0x0080) ? true: false;
bool h2 = (instr & 0x0040) ? true: false;
@@ -894,9 +894,9 @@ UnwResult UnwStartThumb(UnwState * const state) {
/* Format 9: PC-relative load
* LDR Rd,[PC, #imm]
*/
else if((instr & 0xf800) == 0x4800) {
else if((instr & 0xF800) == 0x4800) {
uint8_t rd = (instr & 0x0700) >> 8;
uint8_t word8 = (instr & 0x00ff);
uint8_t word8 = (instr & 0x00FF);
uint32_t address;
/* Compute load address, adding a word to account for prefetch */
@@ -912,8 +912,8 @@ UnwResult UnwStartThumb(UnwState * const state) {
* ADD sp,#+imm
* ADD sp,#-imm
*/
else if((instr & 0xff00) == 0xB000) {
uint8_t value = (instr & 0x7f) * 4;
else if((instr & 0xFF00) == 0xB000) {
uint8_t value = (instr & 0x7F) * 4;
/* Check the negative bit */
if((instr & 0x80) != 0) {
@@ -931,10 +931,10 @@ UnwResult UnwStartThumb(UnwState * const state) {
* POP {Rlist}
* POP {Rlist, PC}
*/
else if((instr & 0xf600) == 0xb400) {
else if((instr & 0xF600) == 0xB400) {
bool L = (instr & 0x0800) ? true : false;
bool R = (instr & 0x0100) ? true : false;
uint8_t rList = (instr & 0x00ff);
uint8_t rList = (instr & 0x00FF);
if(L) {
uint8_t r;
@@ -1038,9 +1038,9 @@ UnwResult UnwStartThumb(UnwState * const state) {
* Conditional branches
* Bcond
*/
else if((instr & 0xf000) == 0xd000) {
int32_t branchValue = (instr & 0xff);
if (branchValue & 0x80) branchValue |= 0xffffff00;
else if((instr & 0xF000) == 0xD000) {
int32_t branchValue = (instr & 0xFF);
if (branchValue & 0x80) branchValue |= 0xFFFFFF00;
/* Branch distance is twice that specified in the instruction. */
branchValue *= 2;
@@ -1067,9 +1067,9 @@ UnwResult UnwStartThumb(UnwState * const state) {
/* Format 18: unconditional branch
* B label
*/
else if((instr & 0xf800) == 0xe000) {
else if((instr & 0xF800) == 0xE000) {
uint32_t v;
int32_t branchValue = signExtend11(instr & 0x07ff);
int32_t branchValue = signExtend11(instr & 0x07FF);
/* Branch distance is twice that specified in the instruction. */
branchValue *= 2;

View File

@@ -29,7 +29,7 @@ void __aeabi_unwind_cpp_pr2(void) {};
static inline __attribute__((always_inline)) uint32_t prel31_to_addr(const uint32_t *prel31) {
uint32_t offset = (((uint32_t)(*prel31)) << 1) >> 1;
return ((uint32_t)prel31 + offset) & 0x7fffffff;
return ((uint32_t)prel31 + offset) & 0x7FFFFFFF;
}
static const UnwTabEntry *UnwTabSearchIndex(const UnwTabEntry *start, const UnwTabEntry *end, uint32_t ip) {
@@ -54,8 +54,8 @@ static const char *UnwTabGetFunctionName(const UnwindCallbacks *cb, uint32_t add
if (!cb->readW(address-4,&flag_word))
return NULL;
if ((flag_word & 0xff000000) == 0xff000000) {
return (const char *)(address - 4 - (flag_word & 0x00ffffff));
if ((flag_word & 0xFF000000) == 0xFF000000) {
return (const char *)(address - 4 - (flag_word & 0x00FFFFFF));
}
return NULL;
}
@@ -77,7 +77,7 @@ static int UnwTabGetNextInstruction(const UnwindCallbacks *cb, UnwTabState *ucb)
uint32_t v = 0;
if (!cb->readW(ucb->current, &v))
return -1;
instruction = (v >> (ucb->byte << 3)) & 0xff;
instruction = (v >> (ucb->byte << 3)) & 0xFF;
/* Move the next byte */
--ucb->byte;
@@ -104,12 +104,12 @@ static UnwResult UnwTabStateInit(const UnwindCallbacks *cb, UnwTabState *ucb, ui
if (!cb->readW(instructions, &v))
return UNWIND_DREAD_W_FAIL;
if ((v & 0xff000000) == 0x80000000) {
if ((v & 0xFF000000) == 0x80000000) {
ucb->remaining = 3;
ucb->byte = 2;
/* Is a long unwind description */
} else if ((v & 0xff000000) == 0x81000000) {
ucb->remaining = ((v & 0x00ff0000) >> 14) + 2;
} else if ((v & 0xFF000000) == 0x81000000) {
ucb->remaining = ((v & 0x00FF0000) >> 14) + 2;
ucb->byte = 1;
} else
return UNWIND_UNSUPPORTED_DWARF_PERSONALITY;
@@ -138,15 +138,15 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
/* Consume all instruction byte */
while ((instruction = UnwTabGetNextInstruction(cb, ucb)) != -1) {
if ((instruction & 0xc0) == 0x00) { // ARM_EXIDX_CMD_DATA_POP
if ((instruction & 0xC0) == 0x00) { // ARM_EXIDX_CMD_DATA_POP
/* vsp = vsp + (xxxxxx << 2) + 4 */
ucb->vrs[13] += ((instruction & 0x3f) << 2) + 4;
ucb->vrs[13] += ((instruction & 0x3F) << 2) + 4;
} else
if ((instruction & 0xc0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH
if ((instruction & 0xC0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH
/* vsp = vsp - (xxxxxx << 2) - 4 */
ucb->vrs[13] -= ((instruction & 0x3f) << 2) - 4;
ucb->vrs[13] -= ((instruction & 0x3F) << 2) - 4;
} else
if ((instruction & 0xf0) == 0x80) {
if ((instruction & 0xF0) == 0x80) {
/* pop under mask {r15-r12},{r11-r4} or refuse to unwind */
instruction = instruction << 8 | UnwTabGetNextInstruction(cb, ucb);
@@ -156,7 +156,7 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
/* Pop registers using mask */ // ARM_EXIDX_CMD_REG_POP
vsp = ucb->vrs[13];
mask = instruction & 0xfff;
mask = instruction & 0xFFF;
reg = 4;
while (mask) {
@@ -176,13 +176,13 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
ucb->vrs[13] = vsp;
} else
if ((instruction & 0xf0) == 0x90 && // ARM_EXIDX_CMD_REG_TO_SP
instruction != 0x9d &&
instruction != 0x9f) {
if ((instruction & 0xF0) == 0x90 && // ARM_EXIDX_CMD_REG_TO_SP
instruction != 0x9D &&
instruction != 0x9F) {
/* vsp = r[nnnn] */
ucb->vrs[13] = ucb->vrs[instruction & 0x0f];
ucb->vrs[13] = ucb->vrs[instruction & 0x0F];
} else
if ((instruction & 0xf0) == 0xa0) { // ARM_EXIDX_CMD_REG_POP
if ((instruction & 0xF0) == 0xA0) { // ARM_EXIDX_CMD_REG_POP
/* pop r4-r[4+nnn] or pop r4-r[4+nnn], r14*/
vsp = ucb->vrs[13];
@@ -206,7 +206,7 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
ucb->vrs[13] = vsp;
} else
if (instruction == 0xb0) { // ARM_EXIDX_CMD_FINISH
if (instruction == 0xB0) { // ARM_EXIDX_CMD_FINISH
/* finished */
if (ucb->vrs[15] == 0)
ucb->vrs[15] = ucb->vrs[14];
@@ -215,7 +215,7 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
return UNWIND_SUCCESS;
} else
if (instruction == 0xb1) { // ARM_EXIDX_CMD_REG_POP
if (instruction == 0xB1) { // ARM_EXIDX_CMD_REG_POP
/* pop register under mask {r3,r2,r1,r0} */
vsp = ucb->vrs[13];
mask = UnwTabGetNextInstruction(cb, ucb);
@@ -236,14 +236,14 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
ucb->vrs[13] = (uint32_t)vsp;
} else
if (instruction == 0xb2) { // ARM_EXIDX_CMD_DATA_POP
if (instruction == 0xB2) { // ARM_EXIDX_CMD_DATA_POP
/* vps = vsp + 0x204 + (uleb128 << 2) */
ucb->vrs[13] += 0x204 + (UnwTabGetNextInstruction(cb, ucb) << 2);
} else
if (instruction == 0xb3 || // ARM_EXIDX_CMD_VFP_POP
instruction == 0xc8 ||
instruction == 0xc9) {
if (instruction == 0xB3 || // ARM_EXIDX_CMD_VFP_POP
instruction == 0xC8 ||
instruction == 0xC9) {
/* pop VFP double-precision registers */
vsp = ucb->vrs[13];
@@ -256,12 +256,12 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
ucb->vrs[14] = v;
vsp += 4;
if (instruction == 0xc8) {
if (instruction == 0xC8) {
/* D[16+sssss]-D[16+ssss+cccc] */
ucb->vrs[14] |= 1 << 16;
}
if (instruction != 0xb3) {
if (instruction != 0xB3) {
/* D[sssss]-D[ssss+cccc] */
ucb->vrs[14] |= 1 << 17;
}
@@ -269,13 +269,13 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat
ucb->vrs[13] = vsp;
} else
if ((instruction & 0xf8) == 0xb8 ||
(instruction & 0xf8) == 0xd0) {
if ((instruction & 0xF8) == 0xB8 ||
(instruction & 0xF8) == 0xD0) {
/* Pop VFP double precision registers D[8]-D[8+nnn] */
ucb->vrs[14] = 0x80 | (instruction & 0x07);
if ((instruction & 0xf8) == 0xd0) {
if ((instruction & 0xF8) == 0xD0) {
ucb->vrs[14] = 1 << 17;
}
@@ -337,7 +337,7 @@ static UnwResult UnwTabUnwindFrame(const UnwindCallbacks *cb, UnwindFrame *frame
/* Check for exception return */
/* TODO Test with other ARM processors to verify this method. */
if ((ucb.vrs[15] & 0xf0000000) == 0xf0000000) {
if ((ucb.vrs[15] & 0xF0000000) == 0xF0000000) {
/* According to the Cortex Programming Manual (p.44), the stack address is always 8-byte aligned (Cortex-M7).
Depending on where the exception came from (MSP or PSP), we need the right SP value to work with.
@@ -354,20 +354,20 @@ static UnwResult UnwTabUnwindFrame(const UnwindCallbacks *cb, UnwindFrame *frame
If we need to start from the PSP, we need to go up exactly 6 words to find the PC.
See the ARMv7-M Architecture Reference Manual p.594 and Cortex-M7 Processor Programming Manual p.44/p.45 for details.
*/
if ((ucb.vrs[15] & 0xc) == 0) {
/* Return to Handler Mode: MSP (0xffffff-1) */
if ((ucb.vrs[15] & 0xC) == 0) {
/* Return to Handler Mode: MSP (0xFFFFFF-1) */
stack = ucb.vrs[13];
/* The PC is always 2 words down from the MSP, if it was a non-floating-point exception */
stack -= 2*4;
/* If there was a VFP exception (0xffffffe1), the PC is located another 18 words down */
if ((ucb.vrs[15] & 0xf0) == 0xe0) {
/* If there was a VFP exception (0xFFFFFFE1), the PC is located another 18 words down */
if ((ucb.vrs[15] & 0xF0) == 0xE0) {
stack -= 18*4;
}
}
else {
/* Return to Thread Mode: PSP (0xffffff-d) */
/* Return to Thread Mode: PSP (0xFFFFFF-d) */
stack = read_psp();
/* The PC is always 6 words up from the PSP */
@@ -423,7 +423,7 @@ UnwResult UnwindByTableStart(UnwindFrame* frame, const UnwindCallbacks *cb, void
const UnwTabEntry *index = UnwTabSearchIndex(__exidx_start, __exidx_end, frame->pc);
/* Clear last bit (Thumb indicator) */
frame->pc &= 0xfffffffeU;
frame->pc &= 0xFFFFFFFEU;
/* Generate the backtrace information */
entry.address = frame->pc;

View File

@@ -91,9 +91,9 @@ bool UnwMemHashWrite(MemData * const memData, uint32_t addr, uint32_t val, bool
M_SetIdxUsed(memData->tracked, i);
}
else {
#if defined(UNW_DEBUG)
memData->v[i] = 0xdeadbeef;
#endif
#if defined(UNW_DEBUG)
memData->v[i] = 0xDEADBEEF;
#endif
M_ClrIdxUsed(memData->tracked, i);
}