runtime: fix runtime.Breakpoint() on windows/arm64

Fixes #53837

Change-Id: I4219fe35aac1a88aae2905998fbb1d7db87bbfb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/418734
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
This commit is contained in:
qmuntal 2022-07-21 12:18:51 +02:00 committed by Cherry Mui
parent 795a88d0c3
commit 9fcc8b2c1e

View file

@ -107,8 +107,18 @@ nocgo:
DATA runtime·mainPC+0(SB)/8,$runtime·main<ABIInternal>(SB) DATA runtime·mainPC+0(SB)/8,$runtime·main<ABIInternal>(SB)
GLOBL runtime·mainPC(SB),RODATA,$8 GLOBL runtime·mainPC(SB),RODATA,$8
// Windows ARM64 needs an immediate 0xf000 argument.
// See go.dev/issues/53837.
#define BREAK \
#ifdef GOOS_windows \
BRK $0xf000 \
#else \
BRK \
#endif \
TEXT runtime·breakpoint(SB),NOSPLIT|NOFRAME,$0-0 TEXT runtime·breakpoint(SB),NOSPLIT|NOFRAME,$0-0
BRK BREAK
RET RET
TEXT runtime·asminit(SB),NOSPLIT|NOFRAME,$0-0 TEXT runtime·asminit(SB),NOSPLIT|NOFRAME,$0-0
@ -1325,7 +1335,7 @@ TEXT runtime·debugCallV2<ABIInternal>(SB),NOSPLIT|NOFRAME,$0-0
// Set R20 to 8 and invoke BRK. The debugger should get the // Set R20 to 8 and invoke BRK. The debugger should get the
// reason a call can't be injected from SP+8 and resume execution. // reason a call can't be injected from SP+8 and resume execution.
MOVD $8, R20 MOVD $8, R20
BRK BREAK
JMP restore JMP restore
good: good:
@ -1374,7 +1384,7 @@ good:
MOVD $20, R0 MOVD $20, R0
MOVD R0, 16(RSP) // length of debugCallFrameTooLarge string MOVD R0, 16(RSP) // length of debugCallFrameTooLarge string
MOVD $8, R20 MOVD $8, R20
BRK BREAK
JMP restore JMP restore
restore: restore:
@ -1383,7 +1393,7 @@ restore:
// Set R20 to 16 and invoke BRK. The debugger should restore // Set R20 to 16 and invoke BRK. The debugger should restore
// all registers except for PC and RSP and resume execution. // all registers except for PC and RSP and resume execution.
MOVD $16, R20 MOVD $16, R20
BRK BREAK
// We must not modify flags after this point. // We must not modify flags after this point.
// Restore pointer-containing registers, which may have been // Restore pointer-containing registers, which may have been
@ -1414,9 +1424,9 @@ restore:
TEXT NAME(SB),WRAPPER,$MAXSIZE-0; \ TEXT NAME(SB),WRAPPER,$MAXSIZE-0; \
NO_LOCAL_POINTERS; \ NO_LOCAL_POINTERS; \
MOVD $0, R20; \ MOVD $0, R20; \
BRK; \ BREAK; \
MOVD $1, R20; \ MOVD $1, R20; \
BRK; \ BREAK; \
RET RET
DEBUG_CALL_FN(debugCall32<>, 32) DEBUG_CALL_FN(debugCall32<>, 32)
DEBUG_CALL_FN(debugCall64<>, 64) DEBUG_CALL_FN(debugCall64<>, 64)
@ -1439,7 +1449,7 @@ TEXT runtime·debugCallPanicked(SB),NOSPLIT,$16-16
MOVD val_data+8(FP), R0 MOVD val_data+8(FP), R0
MOVD R0, 16(RSP) MOVD R0, 16(RSP)
MOVD $2, R20 MOVD $2, R20
BRK BREAK
RET RET
// Note: these functions use a special calling convention to save generated code space. // Note: these functions use a special calling convention to save generated code space.