[RISC-V, LOONGARCH64] Fix FuncEvalHijack stackallocation (#88493)
authort-mustafin <66252296+t-mustafin@users.noreply.github.com>
Sat, 8 Jul 2023 08:46:36 +0000 (11:46 +0300)
committerGitHub <noreply@github.com>
Sat, 8 Jul 2023 08:46:36 +0000 (10:46 +0200)
src/coreclr/debug/ee/loongarch64/dbghelpers.S
src/coreclr/debug/ee/riscv64/dbghelpers.S
src/coreclr/pal/src/arch/loongarch64/activationhandlerwrapper.S
src/coreclr/pal/src/arch/loongarch64/dispatchexceptionwrapper.S

index 07103d6..25452aa 100644 (file)
@@ -8,7 +8,7 @@
 // hijacking stub used to perform a func-eval, see Debugger::FuncEvalSetup() for use.
 //
 // on entry:
-//   x0  : pointer to DebuggerEval object
+//   a0  : pointer to DebuggerEval object
 //
 
 // @dbgtodo- once we port Funceval, use the ExceptionHijack stub instead of this func-eval stub.
@@ -17,9 +17,9 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, UnhandledExceptionHandlerUnix
     //       you change the prolog you will also need to update the personality routine.
 
     // push arg to the stack so our personality routine can find it
-    // push lr to get good stacktrace in debugger
+    // push ra to get good stacktrace in debugger
     //                            $fp,$ra
-    PROLOG_SAVE_REG_PAIR_INDEXED  22, 1, -32
+    PROLOG_SAVE_REG_PAIR_INDEXED  22, 1, 32
     st.d  $a0, $sp, 16
 
     // FuncEvalHijackWorker returns the address we should jump to.
index 71b584d..9376760 100644 (file)
@@ -17,8 +17,8 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, UnhandledExceptionHandlerUnix
     //       you change the prolog you will also need to update the personality routine.
 
     // push arg to the stack so our personality routine can find it
-    // push lr to get good stacktrace in debugger
-    PROLOG_SAVE_REG_PAIR_INDEXED  fp, ra, -32
+    // push ra to get good stacktrace in debugger
+    PROLOG_SAVE_REG_PAIR_INDEXED  fp, ra, 32
     sd  a0, 16(sp)
 
     // FuncEvalHijackWorker returns the address we should jump to.
index 9cc8663..59ad00d 100644 (file)
@@ -11,7 +11,7 @@ C_FUNC(ActivationHandlerReturnOffset):
 
 NESTED_ENTRY ActivationHandlerWrapper, _TEXT, NoHandler
     //                           $fp,$ra
-    PROLOG_SAVE_REG_PAIR_INDEXED 22, 1, -(16 + CONTEXT_Size)
+    PROLOG_SAVE_REG_PAIR_INDEXED 22, 1, (16 + CONTEXT_Size)
     // Should never actually run
     EMIT_BREAKPOINT
     bl      EXTERNAL_C_FUNC(ActivationHandler)
index 0548f03..d29913c 100644 (file)
@@ -34,7 +34,7 @@ C_FUNC(PAL_DispatchExceptionReturnOffset):
 
 NESTED_ENTRY PAL_DispatchExceptionWrapper, _TEXT, NoHandler
     //                           $fp,$ra
-    PROLOG_SAVE_REG_PAIR_INDEXED 22, 1, -16
+    PROLOG_SAVE_REG_PAIR_INDEXED 22, 1, 16
     // Should never actually run
     EMIT_BREAKPOINT
     bl      EXTERNAL_C_FUNC(PAL_DispatchException)