pussuw commented on a change in pull request #5782: URL: https://github.com/apache/incubator-nuttx/pull/5782#discussion_r834653649
########## 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 content of a0 is set as arg0 by the caller. Of course the caller saves the original a0 into its stack so it is preserved, so when the caller returns to its caller, a0 is preserved. In this case, since the function takes 1 argument, and returns 1 value, the argument is given in a0 (as per the ABI) and the return value is in a0 (as per the ABI). Stack is not involved here. This is also what happens when the code is tested. After riscv_saveusercontext(rtcb->xcp.regs); rtcb is corrupted in the caller's context, and needs to be re-acquired. I think I'll just remove the return value as it is not used anywhere. -- 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