Skip to content

Commit 3187bbc

Browse files
committed
per reviews: naming, handle "unhandled return" case
1 parent 73f7fa6 commit 3187bbc

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Diff for: cores/esp8266/core_esp8266_postmortem.cpp

+14-9
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ static void uart0_write_char_d(char c);
5252
static void uart1_write_char_d(char c);
5353
static void print_stack(uint32_t start, uint32_t end);
5454

55+
// using numbers different from "REASON_" in user_interface.h (=0..6)
56+
enum rst_reason_sw
57+
{
58+
REASON_USER_SWEXCEPTION_RST = 254
59+
};
60+
static int s_user_reset_reason = REASON_DEFAULT_RST;
61+
5562
// From UMM, the last caller of a malloc/realloc/calloc which failed:
5663
extern void *umm_last_fail_alloc_addr;
5764
extern int umm_last_fail_alloc_size;
@@ -82,29 +89,24 @@ static void ets_printf_P(const char *str, ...) {
8289
}
8390
}
8491

85-
#define USER_REASON_NONE 255
86-
#define USER_REASON_SWEXCEPTION 254
87-
// using numbers different from "REASON_" in user_interface.h 0..6
88-
static int user_reset_reason = USER_REASON_NONE;
89-
9092
void __wrap_system_restart_local() {
9193
register uint32_t sp asm("a1");
9294
uint32_t sp_dump = sp;
9395

9496
struct rst_info rst_info;
9597
memset(&rst_info, 0, sizeof(rst_info));
96-
if (user_reset_reason == USER_REASON_NONE)
98+
if (s_user_reset_reason == REASON_DEFAULT_RST)
9799
{
98100
system_rtc_mem_read(0, &rst_info, sizeof(rst_info));
99101
if (rst_info.reason != REASON_SOFT_WDT_RST &&
100102
rst_info.reason != REASON_EXCEPTION_RST &&
101103
rst_info.reason != REASON_WDT_RST)
102104
{
103-
return;
105+
rst_info.reason = REASON_DEFAULT_RST;
104106
}
105107
}
106108
else
107-
rst_info.reason = user_reset_reason;
109+
rst_info.reason = s_user_reset_reason;
108110

109111
// TODO: ets_install_putc1 definition is wrong in ets_sys.h, need cast
110112
ets_install_putc1((void *)&uart_write_char_d);
@@ -129,6 +131,9 @@ void __wrap_system_restart_local() {
129131
else if (rst_info.reason == REASON_SOFT_WDT_RST) {
130132
ets_printf_P(PSTR("\nSoft WDT reset\n"));
131133
}
134+
else {
135+
ets_printf_P(PSTR("\nGeneric Soft Reset\n"));
136+
}
132137

133138
uint32_t cont_stack_start = (uint32_t) &(g_pcont->stack);
134139
uint32_t cont_stack_end = (uint32_t) g_pcont->stack_end;
@@ -226,7 +231,7 @@ static void raise_exception() {
226231
if (gdb_present())
227232
__asm__ __volatile__ ("syscall"); // triggers GDB when enabled
228233

229-
user_reset_reason = USER_REASON_SWEXCEPTION;
234+
s_user_reset_reason = REASON_USER_SWEXCEPTION_RST;
230235
ets_printf_P(PSTR("\nUser exception (panic/abort/assert)"));
231236
__wrap_system_restart_local();
232237

0 commit comments

Comments
 (0)