aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/syscall/syscall_linux_mipsx.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-06-21 21:42:41 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-06-21 21:42:41 +0000
commit8d4b68a7c4091c99c8d591e93efae5748a7ced13 (patch)
tree51c565ff797d0d2f7799adc97742845805f0a8a1 /libgo/go/syscall/syscall_linux_mipsx.go
parent4ded86690e9fd3c71e1ff47beea31079ad8a7b4f (diff)
downloadgcc-8d4b68a7c4091c99c8d591e93efae5748a7ced13.zip
gcc-8d4b68a7c4091c99c8d591e93efae5748a7ced13.tar.gz
gcc-8d4b68a7c4091c99c8d591e93efae5748a7ced13.tar.bz2
libgo, syscall: fix ptrace implementation on MIPS
On MIPS, the correct structure for PtraceRegs is 'struct pt_regs' which is declared in linux/ptrace.h. Previously no PtraceRegs structure was created on MIPS because 'struct user_regs_struct' doesn't exist there. Fallback to using pt_regs when the PtraceRegs structure is generated in mksysinfo.sh, then adjust syscall_linux_mipsx.go to read the program counter from the correct field. In addition, implement PtraceGetRegs and PtraceSetRegs on all 3 ABI variants. syscall_linux_mips64x.go can now be removed since the ptrace code on all 3 ABIs is identical. Reviewed-on: https://go-review.googlesource.com/46150 From-SVN: r249472
Diffstat (limited to 'libgo/go/syscall/syscall_linux_mipsx.go')
-rw-r--r--libgo/go/syscall/syscall_linux_mipsx.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/libgo/go/syscall/syscall_linux_mipsx.go b/libgo/go/syscall/syscall_linux_mipsx.go
index af319ac..06dd1ea 100644
--- a/libgo/go/syscall/syscall_linux_mipsx.go
+++ b/libgo/go/syscall/syscall_linux_mipsx.go
@@ -3,10 +3,24 @@
// license that can be found in the LICENSE file.
// +build linux
-// +build mips mipsle
+// +build mips mipsle mips64 mips64le mips64p32 mips64p32le
package syscall
-func (r *PtraceRegs) PC() uint64 { return uint64(r.Regs[64]) }
+import "unsafe"
-func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = uint32(pc) }
+func (r *PtraceRegs) PC() uint64 {
+ return r.Cp0_epc
+}
+
+func (r *PtraceRegs) SetPC(pc uint64) {
+ r.Cp0_epc = pc
+}
+
+func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
+ return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
+}
+
+func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
+ return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
+}