diff --git a/cores/esp8266/cont.S b/cores/esp8266/cont.S index 06ad2a74cc..4304db448c 100644 --- a/cores/esp8266/cont.S +++ b/cores/esp8266/cont.S @@ -58,6 +58,30 @@ cont_continue: ret .size cont_yield, . - cont_yield +//////////////////////////////////////////////////// + +/* + The purpose of cont_wrapper is to signal to xtensa-gdb + that we want to treat this function as the outermost one. + + From: binutils-gdb-xtensa/gdb/xtensa-tdep.c:2677 + "Special case for terminating backtrace at a function that wants to + be seen as the outermost one. Such a function will clear it's RA (A0) + register to 0 in the prologue instead of saving its original value." +*/ + + .text + .align 4 + .literal_position + .global cont_wrapper + .type cont_wrapper, @function +cont_wrapper: + movi a0, 0 + callx0 a3 + movi a2, cont_norm + jx a2 + .size cont_wrapper, . - cont_wrapper + //////////////////////////////////////////////////// .text @@ -91,8 +115,8 @@ cont_run: /* set new stack*/ l32i a1, a2, 16; /* goto pfn */ - movi a0, cont_norm - jx a3 + movi a2, cont_wrapper + jx a2 cont_resume: /* a1 <- cont_ctx.sp_yield */