@@ -82,28 +82,18 @@ static void ets_printf_P(const char *str, ...) {
8282 }
8383}
8484
85- #define FAKE_REASON_NONE 255
86- #define FAKE_REASON_USER 254
87- static int fake_rst_reason = FAKE_REASON_NONE;
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;
8889
8990void __wrap_system_restart_local () {
9091 register uint32_t sp asm (" a1" );
9192 uint32_t sp_dump = sp;
9293
93- #if 0
94- if (gdb_present()) {
95- /* When GDBStub is present, exceptions are handled by GDBStub,
96- but Soft WDT will still call this function.
97- Trigger an exception to break into GDB.
98- TODO: check why gdb_do_break() or asm("break.n 0") do not
99- break into GDB here. */
100- raise_exception();
101- }
102- #endif
103-
10494 struct rst_info rst_info;
10595 memset (&rst_info, 0 , sizeof (rst_info));
106- if (fake_rst_reason == FAKE_REASON_NONE )
96+ if (user_reset_reason == USER_REASON_NONE )
10797 {
10898 system_rtc_mem_read (0 , &rst_info, sizeof (rst_info));
10999 if (rst_info.reason != REASON_SOFT_WDT_RST &&
@@ -114,7 +104,7 @@ void __wrap_system_restart_local() {
114104 }
115105 }
116106 else
117- rst_info.reason = fake_rst_reason ;
107+ rst_info.reason = user_reset_reason ;
118108
119109 // TODO: ets_install_putc1 definition is wrong in ets_sys.h, need cast
120110 ets_install_putc1 ((void *)&uart_write_char_d);
@@ -233,24 +223,13 @@ static void uart1_write_char_d(char c) {
233223}
234224
235225static void raise_exception () {
236- #if 0
237-
238- // works but also showing
239- // "Fatal exception 29(StoreProhibitedCause)"
240- *((char*)0) = 0;
241-
242- #else
243-
244226 if (gdb_present ())
245- // *((char*)0) = 0;
246227 __asm__ __volatile__ (" syscall" ); // triggers GDB when enabled
247228
248- fake_rst_reason = FAKE_REASON_USER ;
229+ user_reset_reason = USER_REASON_SWEXCEPTION ;
249230 ets_printf_P (PSTR (" \n User exception (panic/abort/assert)" ));
250231 __wrap_system_restart_local ();
251232
252- #endif
253-
254233 while (1 ); // never reached, needed to satisfy "noreturn" attribute
255234}
256235
0 commit comments