fix(debug): cross-compile for arm64, riscv64 and loong64
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user