Commit 156c5a2d authored by James Cowgill's avatar James Cowgill Committed by Ian Lance Taylor

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/43431Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 6b706892
...@@ -163,10 +163,8 @@ struct my_sockaddr_un { ...@@ -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__)
......
...@@ -183,9 +183,9 @@ func fillStat_t(s *Stat_t, st *stat_t) { ...@@ -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)
......
...@@ -211,9 +211,9 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { ...@@ -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)
......
...@@ -568,17 +568,13 @@ type InotifyEvent struct { ...@@ -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 {
......
...@@ -570,17 +570,13 @@ type InotifyEvent struct { ...@@ -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 {
......
...@@ -570,17 +570,13 @@ type InotifyEvent struct { ...@@ -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 {
......
...@@ -568,17 +568,13 @@ type InotifyEvent struct { ...@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment