pussuw commented on a change in pull request #5782: URL: https://github.com/apache/incubator-nuttx/pull/5782#discussion_r834615075
########## File path: arch/risc-v/src/common/riscv_assert.c ########## @@ -338,6 +338,10 @@ static void riscv_dumpstate(void) else { riscv_saveusercontext(rtcb->xcp.regs); + + /* riscv_saveusercontext modifies the local context (a0), restore it */ + + rtcb = running_task(); Review comment: the prototype is int riscv_saveusercontext (regs); /* SYS call 0: * * int riscv_saveusercontext(uint64_t *saveregs); * * Return: * 0: Normal Return * 1: Context Switch Return */ I did what this comment says. So the asm function returns 0 in a0 to the caller, and 1 to the context. > > li s0, 1 /* return 1 (in context) */ <<- This destroys rtcb! > REGSTORE s0, REG_A0(a0) > > li a0, 0 /* return 0 (back to caller) */ > ret > So in the context (caller) a0 is destroyed. That is rtcb so it must be re-acquired. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org