fix(debug): cross-compile for arm64, riscv64 and loong64
Test / vet (push) Successful in 47s
Test / test (push) Successful in 2m35s
Test / build (push) Successful in 40s

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-08-30 11:27:54 +02:00
parent 8f84dac10b
commit 62f6fb4faf
10 changed files with 61 additions and 40 deletions
+16 -7
View File
@@ -44,25 +44,34 @@ func (s *Session) SetRegs(regs *Regs) error {
return nil
}
// FPRegs holds the RISC-V FP register state (F0-F31).
// ntPrFPREG is the NT_PRFPREG note type (ELF NT ver): the FP register set.
const ntPrFPREG = 0x2
// FPRegs holds the RISC-V FP register state, matching the kernel's
// user_fp_struct layout (32 64-bit FP registers plus fcsr).
type FPRegs struct {
F [32][16]byte // F0-F31 (128-bit, lower 64 bits used for double)
F [32]uint64 // F0-F31 (64-bit FP registers)
FCSR uint32
}
// GetFPRegs retrieves the FP register state.
// GetFPRegs retrieves the FP register state via PTRACE_GETREGSET with
// NT_PRFPREG (this architecture has no PTRACE_GETFPREGS request).
func (s *Session) GetFPRegs() (FPRegs, error) {
var fp FPRegs
iovec := syscall.Iovec{
Base: (*byte)(unsafe.Pointer(&fp)),
Len: uint64(unsafe.Sizeof(fp)),
}
_, _, errno := syscall.Syscall6(
syscall.SYS_PTRACE,
uintptr(syscall.PTRACE_GETFPREGS),
uintptr(syscall.PTRACE_GETREGSET),
uintptr(s.pid),
0,
uintptr(unsafe.Pointer(&fp)),
uintptr(ntPrFPREG),
uintptr(unsafe.Pointer(&iovec)),
0, 0,
)
if errno != 0 {
return fp, fmt.Errorf("debug: PTRACE_GETFPREGS: %w", errno)
return fp, fmt.Errorf("debug: PTRACE_GETREGSET (NT_PRFPREG): %w", errno)
}
return fp, nil
}