unix: use struct pt_regs for PtraceRegs on mips

On mips, "struct user" bears no relation to the actual structure used by
PTRACE_GETREGS. The real structure is "struct pt_regs" which is declared
in asm/ptrace.h

Fixes golang/go#20338.

Change-Id: I604d27bd2b0a0903784380cbd3fa2fd9b9811fa5
Reviewed-on: https://go-review.googlesource.com/43431
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
James Cowgill
2017-05-12 16:47:49 +00:00
committed by Ian Lance Taylor
parent 6b7068925c
commit 156c5a2da4
7 changed files with 33 additions and 51 deletions
+1 -3
View File
@@ -163,10 +163,8 @@ struct my_sockaddr_un {
typedef struct user_regs PtraceRegs; typedef struct user_regs PtraceRegs;
#elif defined(__aarch64__) #elif defined(__aarch64__)
typedef struct user_pt_regs PtraceRegs; typedef struct user_pt_regs PtraceRegs;
#elif defined(__powerpc64__) #elif defined(__mips__) || defined(__powerpc64__)
typedef struct pt_regs PtraceRegs; typedef struct pt_regs PtraceRegs;
#elif defined(__mips__)
typedef struct user PtraceRegs;
#elif defined(__s390x__) #elif defined(__s390x__)
typedef struct _user_regs_struct PtraceRegs; typedef struct _user_regs_struct PtraceRegs;
#elif defined(__sparc__) #elif defined(__sparc__)
+2 -2
View File
@@ -183,9 +183,9 @@ func fillStat_t(s *Stat_t, st *stat_t) {
s.Blocks = st.Blocks s.Blocks = st.Blocks
} }
func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } func (r *PtraceRegs) PC() uint64 { return r.Epc }
func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc }
func (iov *Iovec) SetLen(length int) { func (iov *Iovec) SetLen(length int) {
iov.Len = uint64(length) iov.Len = uint64(length)
+2 -2
View File
@@ -211,9 +211,9 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) {
return setrlimit(resource, &rl) return setrlimit(resource, &rl)
} }
func (r *PtraceRegs) PC() uint64 { return uint64(r.Regs[64]) } func (r *PtraceRegs) PC() uint64 { return r.Epc }
func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = uint32(pc) } func (r *PtraceRegs) SetPC(pc uint64) { r.Epc = pc }
func (iov *Iovec) SetLen(length int) { func (iov *Iovec) SetLen(length int) {
iov.Len = uint32(length) iov.Len = uint32(length)
+7 -11
View File
@@ -568,17 +568,13 @@ type InotifyEvent struct {
const SizeofInotifyEvent = 0x10 const SizeofInotifyEvent = 0x10
type PtraceRegs struct { type PtraceRegs struct {
Regs [109]uint32 Regs [32]uint64
U_tsize uint32 Lo uint64
U_dsize uint32 Hi uint64
U_ssize uint32 Epc uint64
Start_code uint32 Badvaddr uint64
Start_data uint32 Status uint64
Start_stack uint32 Cause uint64
Signal int32
U_ar0 *byte
Magic uint32
U_comm [32]int8
} }
type FdSet struct { type FdSet struct {
+7 -11
View File
@@ -570,17 +570,13 @@ type InotifyEvent struct {
const SizeofInotifyEvent = 0x10 const SizeofInotifyEvent = 0x10
type PtraceRegs struct { type PtraceRegs struct {
Regs [102]uint64 Regs [32]uint64
U_tsize uint64 Lo uint64
U_dsize uint64 Hi uint64
U_ssize uint64 Epc uint64
Start_code uint64 Badvaddr uint64
Start_data uint64 Status uint64
Start_stack uint64 Cause uint64
Signal int64
U_ar0 uint64
Magic uint64
U_comm [32]int8
} }
type FdSet struct { type FdSet struct {
+7 -11
View File
@@ -570,17 +570,13 @@ type InotifyEvent struct {
const SizeofInotifyEvent = 0x10 const SizeofInotifyEvent = 0x10
type PtraceRegs struct { type PtraceRegs struct {
Regs [102]uint64 Regs [32]uint64
U_tsize uint64 Lo uint64
U_dsize uint64 Hi uint64
U_ssize uint64 Epc uint64
Start_code uint64 Badvaddr uint64
Start_data uint64 Status uint64
Start_stack uint64 Cause uint64
Signal int64
U_ar0 uint64
Magic uint64
U_comm [32]int8
} }
type FdSet struct { type FdSet struct {
+7 -11
View File
@@ -568,17 +568,13 @@ type InotifyEvent struct {
const SizeofInotifyEvent = 0x10 const SizeofInotifyEvent = 0x10
type PtraceRegs struct { type PtraceRegs struct {
Regs [109]uint32 Regs [32]uint64
U_tsize uint32 Lo uint64
U_dsize uint32 Hi uint64
U_ssize uint32 Epc uint64
Start_code uint32 Badvaddr uint64
Start_data uint32 Status uint64
Start_stack uint32 Cause uint64
Signal int32
U_ar0 *byte
Magic uint32
U_comm [32]int8
} }
type FdSet struct { type FdSet struct {