mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #6257 from SenRamakri/sen_FaultHandlerFixes
Fix for Crash dump formatting issues and adding more info to crash dumppull/6311/head
commit
f67fe4a7a3
|
|
@ -144,6 +144,11 @@ Fault_Handler_Continue2
|
||||||
MRS R2,MSP ; Get MSP
|
MRS R2,MSP ; Get MSP
|
||||||
STR R2,[R1]
|
STR R2,[R1]
|
||||||
ADDS R1,#4
|
ADDS R1,#4
|
||||||
|
MOV R2,LR ; Get current LR(EXC_RETURN)
|
||||||
|
STR R2,[R1]
|
||||||
|
ADDS R1,#4
|
||||||
|
MRS R2,CONTROL ; Get CONTROL Reg
|
||||||
|
STR R2,[R1]
|
||||||
LDR R3,=mbed_fault_handler ; Load address of mbedFaultHandler
|
LDR R3,=mbed_fault_handler ; Load address of mbedFaultHandler
|
||||||
MOV R0,R12
|
MOV R0,R12
|
||||||
LDR R1,=mbed_fault_context
|
LDR R1,=mbed_fault_context
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,11 @@ Fault_Handler_Continue2:
|
||||||
MRS R2,MSP // Get MSP
|
MRS R2,MSP // Get MSP
|
||||||
STR R2,[R1]
|
STR R2,[R1]
|
||||||
ADDS R1,#4
|
ADDS R1,#4
|
||||||
|
MOV R2,LR // Get current LR(EXC_RETURN)
|
||||||
|
STR R2,[R1]
|
||||||
|
ADDS R1,#4
|
||||||
|
MRS R2,CONTROL // Get CONTROL Reg
|
||||||
|
STR R2,[R1]
|
||||||
LDR R3,=mbed_fault_handler // Load address of mbedFaultHandler
|
LDR R3,=mbed_fault_handler // Load address of mbedFaultHandler
|
||||||
MOV R0,R12
|
MOV R0,R12
|
||||||
LDR R1,=mbed_fault_context
|
LDR R1,=mbed_fault_context
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,11 @@ Fault_Handler_Continue2
|
||||||
MRS R2,MSP ; Get MSP
|
MRS R2,MSP ; Get MSP
|
||||||
STR R2,[R1]
|
STR R2,[R1]
|
||||||
ADDS R1,#4
|
ADDS R1,#4
|
||||||
|
MOV R2,LR ; Get current LR(EXC_RETURN)
|
||||||
|
STR R2,[R1]
|
||||||
|
ADDS R1,#4
|
||||||
|
MRS R2,CONTROL ; Get CONTROL Reg
|
||||||
|
STR R2,[R1]
|
||||||
LDR R3,=mbed_fault_handler ; Load address of mbedFaultHandler
|
LDR R3,=mbed_fault_handler ; Load address of mbedFaultHandler
|
||||||
MOV R0,R12
|
MOV R0,R12
|
||||||
LDR R1,=mbed_fault_context
|
LDR R1,=mbed_fault_context
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,27 @@ void print_context_info()
|
||||||
fault_print_str("\nBFAR : %",(uint32_t *)&SCB->BFAR);
|
fault_print_str("\nBFAR : %",(uint32_t *)&SCB->BFAR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
//Print Mode
|
||||||
|
if(mbed_fault_context.EXC_RETURN & 0x8) {
|
||||||
|
fault_print_str("\nMode : Thread", NULL);
|
||||||
|
//Print Priv level in Thread mode - We capture CONTROL reg which reflects the privilege.
|
||||||
|
//Note that the CONTROL register captured still reflects the privilege status of the
|
||||||
|
//thread mode eventhough we are in Handler mode by the time we capture it.
|
||||||
|
if(mbed_fault_context.CONTROL & 0x1) {
|
||||||
|
fault_print_str("\nPriv : User", NULL);
|
||||||
|
} else {
|
||||||
|
fault_print_str("\nPriv : Privileged", NULL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fault_print_str("\nMode : Handler", NULL);
|
||||||
|
fault_print_str("\nPriv : Privileged", NULL);
|
||||||
|
}
|
||||||
|
//Print Return Stack
|
||||||
|
if(mbed_fault_context.EXC_RETURN & 0x4) {
|
||||||
|
fault_print_str("\nStack: PSP", NULL);
|
||||||
|
} else {
|
||||||
|
fault_print_str("\nStack: MSP", NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prints thread info from a list */
|
/* Prints thread info from a list */
|
||||||
|
|
@ -194,9 +214,6 @@ void fault_print_str(char *fmtstr, uint32_t *values)
|
||||||
char hex_str[9]={0};
|
char hex_str[9]={0};
|
||||||
|
|
||||||
while(fmtstr[i] != '\0') {
|
while(fmtstr[i] != '\0') {
|
||||||
if(fmtstr[i] == '\n' || fmtstr[i] == '\r') {
|
|
||||||
serial_putc(&stdio_uart, '\r');
|
|
||||||
} else {
|
|
||||||
if(fmtstr[i]=='%') {
|
if(fmtstr[i]=='%') {
|
||||||
hex_to_str(values[vidx++],hex_str);
|
hex_to_str(values[vidx++],hex_str);
|
||||||
for(idx=7; idx>=0; idx--) {
|
for(idx=7; idx>=0; idx--) {
|
||||||
|
|
@ -205,7 +222,6 @@ void fault_print_str(char *fmtstr, uint32_t *values)
|
||||||
} else {
|
} else {
|
||||||
serial_putc(&stdio_uart, fmtstr[i]);
|
serial_putc(&stdio_uart, fmtstr[i]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ typedef struct {
|
||||||
uint32_t xPSR;
|
uint32_t xPSR;
|
||||||
uint32_t PSP;
|
uint32_t PSP;
|
||||||
uint32_t MSP;
|
uint32_t MSP;
|
||||||
|
uint32_t EXC_RETURN;
|
||||||
|
uint32_t CONTROL;
|
||||||
} mbed_fault_context_t;
|
} mbed_fault_context_t;
|
||||||
|
|
||||||
//Fault type definitions
|
//Fault type definitions
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue