mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-25 00:19:17 +08:00
hardfault_log:Fix formatting
This commit is contained in:
committed by
Daniel Agar
parent
462b572172
commit
e76dda545c
@@ -261,16 +261,16 @@ static int write_stack_detail(bool inValid, _stack_s *si, char *sp_name,
|
||||
int n = 0;
|
||||
uint32_t sbot = si->top - si->size;
|
||||
n = snprintf(&buffer[n], max - n, " %s stack: \n", sp_name);
|
||||
n += snprintf(&buffer[n], max - n, " top: 0x%08" PRIu32 "\n", si->top);
|
||||
n += snprintf(&buffer[n], max - n, " sp: 0x%08" PRIu32 " %s\n", si->sp, (inValid ? "Invalid" : "Valid"));
|
||||
n += snprintf(&buffer[n], max - n, " top: 0x%08" PRIx32 "\n", si->top);
|
||||
n += snprintf(&buffer[n], max - n, " sp: 0x%08" PRIx32 " %s\n", si->sp, (inValid ? "Invalid" : "Valid"));
|
||||
|
||||
if (n != write(fd, buffer, n)) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
n += snprintf(&buffer[n], max - n, " bottom: 0x%08" PRIu32 "\n", sbot);
|
||||
n += snprintf(&buffer[n], max - n, " size: 0x%08" PRIu32 "\n", si->size);
|
||||
n += snprintf(&buffer[n], max - n, " bottom: 0x%08" PRIx32 "\n", sbot);
|
||||
n += snprintf(&buffer[n], max - n, " size: 0x%08" PRIx32 "\n", si->size);
|
||||
|
||||
if (n != write(fd, buffer, n)) {
|
||||
return -EIO;
|
||||
@@ -282,10 +282,11 @@ static int write_stack_detail(bool inValid, _stack_s *si, char *sp_name,
|
||||
tcb.adj_stack_size = si->size;
|
||||
|
||||
if (verify_ram_address(sbot, si->size)) {
|
||||
n = snprintf(buffer, max, " used: %08zu\n", up_check_tcbstack(&tcb));
|
||||
n = snprintf(buffer, max, " used: 0x%08zx\n", up_check_tcbstack(&tcb));
|
||||
|
||||
} else {
|
||||
n = snprintf(buffer, max, "Invalid Stack! (Corrupted TCB) Stack base: %08" PRIu32 " Stack size: %08" PRIu32
|
||||
n = snprintf(buffer, max, "Invalid Stack! (Corrupted TCB) Stack base: 0x%08" PRIx32 " Stack size: 0x%08"
|
||||
PRIx32
|
||||
"\n", sbot,
|
||||
si->size);
|
||||
}
|
||||
@@ -356,7 +357,7 @@ static int write_stack(bool inValid, int winsize, uint32_t wtopaddr,
|
||||
marker[0] = '\0';
|
||||
}
|
||||
|
||||
n = snprintf(buffer, max, "0x%08" PRIu32 " 0x%08" PRIu32 "%s\n", wtopaddr, stack[i], marker);
|
||||
n = snprintf(buffer, max, "0x%08" PRIx32 " 0x%08" PRIx32 "%s\n", wtopaddr, stack[i], marker);
|
||||
|
||||
if (n != write(outfd, buffer, n)) {
|
||||
ret = -EIO;
|
||||
@@ -377,8 +378,8 @@ static int write_stack(bool inValid, int winsize, uint32_t wtopaddr,
|
||||
static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
||||
{
|
||||
int n = snprintf(buffer, max,
|
||||
" r0:0x%08" PRIu32 " r1:0x%08" PRIu32 " r2:0x%08" PRIu32 " r3:0x%08" PRIu32 " r4:0x%08" PRIu32 " r5:0x%08" PRIu32
|
||||
" r6:0x%08" PRIu32 " r7:0x%08" PRIu32 "\n",
|
||||
" r0:0x%08" PRIx32 " r1:0x%08" PRIx32 " r2:0x%08" PRIx32 " r3:0x%08" PRIx32 " r4:0x%08" PRIx32 " r5:0x%08" PRIx32
|
||||
" r6:0x%08" PRIx32 " r7:0x%08" PRIx32 "\n",
|
||||
regs[REG_R0], regs[REG_R1],
|
||||
regs[REG_R2], regs[REG_R3],
|
||||
regs[REG_R4], regs[REG_R5],
|
||||
@@ -389,8 +390,8 @@ static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
||||
}
|
||||
|
||||
n = snprintf(buffer, max,
|
||||
" r8:0x%08" PRIu32 " r9:0x%08" PRIu32 " r10:0x%08" PRIu32 " r11:0x%08" PRIu32 " r12:0x%08" PRIu32 " sp:0x%08" PRIu32
|
||||
" lr:0x%08" PRIu32 " pc:0x%08" PRIu32 "\n",
|
||||
" r8:0x%08" PRIx32 " r9:0x%08" PRIx32 " r10:0x%08" PRIx32 " r11:0x%08" PRIx32 " r12:0x%08" PRIx32 " sp:0x%08" PRIx32
|
||||
" lr:0x%08" PRIx32 " pc:0x%08" PRIx32 "\n",
|
||||
regs[REG_R8], regs[REG_R9],
|
||||
regs[REG_R10], regs[REG_R11],
|
||||
regs[REG_R12], regs[REG_R13],
|
||||
@@ -401,11 +402,11 @@ static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARMV7M_USEBASEPRI
|
||||
n = snprintf(buffer, max, " xpsr:0x%08" PRIu32 " basepri:0x%08" PRIu32 " control:0x%08" PRIu32 "\n",
|
||||
n = snprintf(buffer, max, " xpsr:0x%08" PRIx32 " basepri:0x%08" PRIx32 " control:0x%08" PRIx32 "\n",
|
||||
regs[REG_XPSR], regs[REG_BASEPRI],
|
||||
getcontrol());
|
||||
#else
|
||||
n = snprintf(buffer, max, " xpsr:0x%08" PRIu32 " primask:0x%08" PRIu32 " control:0x%08" PRIu32 "\n",
|
||||
n = snprintf(buffer, max, " xpsr:0x%08" PRIx32 " primask:0x%08" PRIx32 " control:0x%08" PRIx32 "\n",
|
||||
regs[REG_XPSR], regs[REG_PRIMASK],
|
||||
getcontrol());
|
||||
#endif
|
||||
@@ -415,7 +416,7 @@ static int write_registers(uint32_t regs[], char *buffer, int max, int fd)
|
||||
}
|
||||
|
||||
#ifdef REG_EXC_RETURN
|
||||
n = snprintf(buffer, max, " exe return:0x%08" PRIu32 "\n", regs[REG_EXC_RETURN]);
|
||||
n = snprintf(buffer, max, " exe return:0x%08" PRIx32 "\n", regs[REG_EXC_RETURN]);
|
||||
|
||||
if (n != write(fd, buffer, n)) {
|
||||
return -EIO;
|
||||
@@ -432,11 +433,11 @@ static int write_fault_registers(fault_regs_s *fault_regs, char *buffer, int max
|
||||
{
|
||||
#if defined(CONFIG_ARCH_CORTEXM7)
|
||||
const char fmt[] =
|
||||
" cfsr:0x%08" PRIu32 " hfsr:0x%08" PRIu32 " dfsr:0x%08" PRIu32 " mmfsr:0x%08" PRIu32 " bfsr:0x%08" PRIu32
|
||||
" afsr:0x%08" PRIu32 " abfsr:0x%08" PRIu32 " \n";
|
||||
" cfsr:0x%08" PRIx32 " hfsr:0x%08" PRIx32 " dfsr:0x%08" PRIx32 " mmfsr:0x%08" PRIx32 " bfsr:0x%08" PRIx32
|
||||
" afsr:0x%08" PRIx32 " abfsr:0x%08" PRIx32 " \n";
|
||||
#else
|
||||
const char fmt[] = " cfsr:0x%08" PRIu32 " hfsr:0x%08" PRIu32 " dfsr:0x%08" PRIu32 " mmfsr:0x%08" PRIu32
|
||||
" bfsr:0x%08" PRIu32 " afsr:0x%08" PRIu32 "\n";
|
||||
const char fmt[] = " cfsr:0x%08" PRIx32 " hfsr:0x%08" PRIx32 " dfsr:0x%08" PRIx32 " mmfsr:0x%08" PRIx32
|
||||
" bfsr:0x%08" PRIx32 " afsr:0x%08" PRIx32 "\n";
|
||||
#endif
|
||||
int n = snprintf(buffer, max, fmt,
|
||||
fault_regs->cfsr, fault_regs->hfsr, fault_regs->dfsr,
|
||||
@@ -1080,7 +1081,7 @@ __EXPORT int hardfault_check_status(char *caller)
|
||||
} else {
|
||||
ret = state;
|
||||
identify(caller);
|
||||
hfsyslog(LOG_INFO, "Fault Log info File No %" PRIu8 " Length %" PRIu8 " flags:0x%02" PRIu16 " state:%d\n",
|
||||
hfsyslog(LOG_INFO, "Fault Log info File No %" PRIu8 " Length %" PRIu16 " flags:0x%02" PRIx16 " state:%d\n",
|
||||
desc.fileno, desc.len, desc.flags, state);
|
||||
|
||||
if (state == OK) {
|
||||
|
||||
Reference in New Issue
Block a user