xiaoxiang781216 commented on a change in pull request #5782: URL: https://github.com/apache/incubator-nuttx/pull/5782#discussion_r834611239
########## 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 of riscv_saveusercontext indicates that it modifies the return value in context (a0,which is rtcb). I just did what the prototype indicated. So yes, indeed, rtcb will not be preserved as it is destroyed by riscv_saveusercontext . > a0 is used to pass argument and return value, it's expect that riscv_saveusercontext will destroy a0. But, if rtcb is still used after riscv_saveusercontext, compiler will save rtcb to other callee saved register or even stack before invoking riscv_saveusercontext. So, I don't understand why we need specially handle it here. Since the similar code exist in other arch too, it's better to fix all place if this is a real problem, but I don't think so. > I can of course change what riscv_saveusercontext does, and modify the prototype? what prototype? -- 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