diff mbox

libgo patch committed: Don't use PtraceRegs if not defined

Message ID mcry5sohrxs.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor Jan. 31, 2012, 2:23 p.m. UTC
The libgo library only defines PtraceRegs on a few systems.  However, it
was using PtraceRegs on every GNU/Linux system.  This patch fix this
taking the easy way out, by moving a copy of the two small functions
which use PtraceRegs into the processor-specific files which define
PtraceRegs.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 8942226864dd libgo/go/syscall/libcall_linux.go
--- a/libgo/go/syscall/libcall_linux.go	Mon Jan 30 15:51:16 2012 -0800
+++ b/libgo/go/syscall/libcall_linux.go	Tue Jan 31 06:20:56 2012 -0800
@@ -139,14 +139,6 @@ 
 	return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data)
 }
 
-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)))
-}
-
 func PtraceSetOptions(pid int, options int) (err error) {
 	return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options))
 }
diff -r 8942226864dd libgo/go/syscall/syscall_linux_386.go
--- a/libgo/go/syscall/syscall_linux_386.go	Mon Jan 30 15:51:16 2012 -0800
+++ b/libgo/go/syscall/syscall_linux_386.go	Tue Jan 31 06:20:56 2012 -0800
@@ -6,10 +6,20 @@ 
 
 package syscall
 
+import "unsafe"
+
 func (r *PtraceRegs) PC() uint64 {
-	return uint64(uint32(r.Eip));
+	return uint64(uint32(r.Eip))
 }
 
 func (r *PtraceRegs) SetPC(pc uint64) {
-	r.Eip = int32(pc);
+	r.Eip = int32(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)))
+}
diff -r 8942226864dd libgo/go/syscall/syscall_linux_alpha.go
--- a/libgo/go/syscall/syscall_linux_alpha.go	Mon Jan 30 15:51:16 2012 -0800
+++ b/libgo/go/syscall/syscall_linux_alpha.go	Tue Jan 31 06:20:56 2012 -0800
@@ -6,42 +6,52 @@ 
 
 package syscall
 
+import "unsafe"
+
 type PtraceRegs struct {
-	R0 uint64
-	R1 uint64
-	R2 uint64
-	R3 uint64
-	R4 uint64
-	R5 uint64
-	R6 uint64
-	R7 uint64
-	R8 uint64
-	R19 uint64
-	R20 uint64
-	R21 uint64
-	R22 uint64
-	R23 uint64
-	R24 uint64
-	R25 uint64
-	R26 uint64
-	R27 uint64
-	R28 uint64
-	Hae uint64
+	R0      uint64
+	R1      uint64
+	R2      uint64
+	R3      uint64
+	R4      uint64
+	R5      uint64
+	R6      uint64
+	R7      uint64
+	R8      uint64
+	R19     uint64
+	R20     uint64
+	R21     uint64
+	R22     uint64
+	R23     uint64
+	R24     uint64
+	R25     uint64
+	R26     uint64
+	R27     uint64
+	R28     uint64
+	Hae     uint64
 	Trap_a0 uint64
 	Trap_a1 uint64
 	Trap_a2 uint64
-	Ps uint64
-	Pc uint64
-	Gp uint64
-	R16 uint64
-	R17 uint64
-	R18 uint64
+	Ps      uint64
+	Pc      uint64
+	Gp      uint64
+	R16     uint64
+	R17     uint64
+	R18     uint64
 }
 
 func (r *PtraceRegs) PC() uint64 {
-	return r.Pc;
+	return r.Pc
 }
 
 func (r *PtraceRegs) SetPC(pc uint64) {
-	r.Pc = pc;
+	r.Pc = 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)))
+}
diff -r 8942226864dd libgo/go/syscall/syscall_linux_amd64.go
--- a/libgo/go/syscall/syscall_linux_amd64.go	Mon Jan 30 15:51:16 2012 -0800
+++ b/libgo/go/syscall/syscall_linux_amd64.go	Tue Jan 31 06:20:56 2012 -0800
@@ -6,10 +6,20 @@ 
 
 package syscall
 
+import "unsafe"
+
 func (r *PtraceRegs) PC() uint64 {
-	return r.Rip;
+	return r.Rip
 }
 
 func (r *PtraceRegs) SetPC(pc uint64) {
-	r.Rip = pc;
+	r.Rip = 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)))
+}