Index: mksysinfo.sh =================================================================== --- mksysinfo.sh (revision 172872) +++ mksysinfo.sh (working copy) @@ -261,6 +261,16 @@ if test "$regs" != ""; then echo "type PtraceRegs struct {$nregs }" >> ${OUT} fi +# MIPS/Linux is special with respect to PTRACE_GETREGS. +if grep -q -e '^const _mips ' gen-sysinfo.go \ + && grep -q -e '^const _linux ' gen-sysinfo.go ; then + if grep -q -e '__MIPS_SIM = __ABIO32' gen-sysinfo.go ; then + echo "type PtraceRegs [EF_SIZE / 4]uint32" >> ${OUT} + else + echo "type PtraceRegs [EF_SIZE / 8]uint64" >> ${OUT} + fi +fi + # Some basic types. echo 'type Size_t _size_t' >> ${OUT} echo "type Ssize_t _ssize_t" >> ${OUT} Index: syscalls/syscall_linux_mipsn32.go =================================================================== --- syscalls/syscall_linux_mipsn32.go (revision 0) +++ syscalls/syscall_linux_mipsn32.go (revision 0) @@ -0,0 +1,15 @@ +// syscall_linux_mipsn32.go -- GNU/Linux MIPS n32 ABI specific support + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +func (r *PtraceRegs) PC() uint64 { + return r[EF_CP0_EPC]; +} + +func (r *PtraceRegs) SetPC(pc uint64) { + r[EF_CP0_EPC] = pc; +} Index: syscalls/syscall_linux_mipsn64.go =================================================================== --- syscalls/syscall_linux_mipsn64.go (revision 0) +++ syscalls/syscall_linux_mipsn64.go (revision 0) @@ -0,0 +1,15 @@ +// syscall_linux_mipsn64.go -- GNU/Linux MIPS n64 ABI specific support + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +func (r *PtraceRegs) PC() uint64 { + return r[EF_CP0_EPC]; +} + +func (r *PtraceRegs) SetPC(pc uint64) { + r[EF_CP0_EPC] = pc; +} Index: syscalls/syscall_linux_mipso32.go =================================================================== --- syscalls/syscall_linux_mipso32.go (revision 0) +++ syscalls/syscall_linux_mipso32.go (revision 0) @@ -0,0 +1,15 @@ +// syscall_linux_mipso32.go -- GNU/Linux MIPS o32 ABI specific support + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +func (r *PtraceRegs) PC() uint64 { + return uint64(r[EF_CP0_EPC]); +} + +func (r *PtraceRegs) SetPC(pc uint64) { + r[EF_CP0_EPC] = uint32(pc); +} Index: go/debug/proc/regs_linux_mipsn32.go =================================================================== --- go/debug/proc/regs_linux_mipsn32.go (revision 0) +++ go/debug/proc/regs_linux_mipsn32.go (revision 0) @@ -0,0 +1,100 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proc + +import ( + "os" + "strconv" + "syscall" +) + +type _MipsRegs struct { + regs syscall.PtraceRegs + setter func(*syscall.PtraceRegs) os.Error +} + +var names = []string{ + "zero", + "at", + "v0", + "v1", + "a0", + "a1", + "a2", + "a3", + "a4", + "a5", + "a6", + "a7", + "t0", + "t1", + "t2", + "t3", + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "t8", + "t9", + "k0", + "k1", + "gp", + "sp", + "s8", + "ra", + "lo", + "hi", + "pc", +} + +func (r *_MipsRegs) PC() Word { return Word(r.regs[syscall.EF_CP0_EPC]) } + +func (r *_MipsRegs) SetPC(val Word) os.Error { + r.regs[syscall.EF_CP0_EPC] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Link() Word { return Word(r.regs[syscall.EF_REG31]) } + +func (r *_MipsRegs) SetLink(val Word) os.Error { + r.regs[syscall.EF_REG31] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + + +func (r *_MipsRegs) SP() Word { return Word(r.regs[syscall.EF_REG29]) } + +func (r *_MipsRegs) SetSP(val Word) os.Error { + r.regs[syscall.EF_REG29] = uint64(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Names() []string { return names } + +func (r *_MipsRegs) Get(i int) Word { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + return Word(r.regs[i]) +} + +func (r *_MipsRegs) Set(i int, val Word) os.Error { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + r.regs[i] = uint64(val) + return r.setter(&r.regs) +} + +func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs { + res := _MipsRegs{} + res.regs = *regs + res.setter = setter + return &res +} Index: go/debug/proc/regs_linux_mipso32.go =================================================================== --- go/debug/proc/regs_linux_mipso32.go (revision 0) +++ go/debug/proc/regs_linux_mipso32.go (revision 0) @@ -0,0 +1,100 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proc + +import ( + "os" + "strconv" + "syscall" +) + +type _MipsRegs struct { + regs syscall.PtraceRegs + setter func(*syscall.PtraceRegs) os.Error +} + +var names = []string{ + "zero", + "at", + "v0", + "v1", + "a0", + "a1", + "a2", + "a3", + "t0", + "t1", + "t2", + "t3", + "t4", + "t5", + "t6", + "t7", + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "t8", + "t9", + "k0", + "k1", + "gp", + "sp", + "s8", + "ra", + "lo", + "hi", + "pc", +} + +func (r *_MipsRegs) PC() Word { return Word(r.regs[syscall.EF_CP0_EPC]) } + +func (r *_MipsRegs) SetPC(val Word) os.Error { + r.regs[syscall.EF_CP0_EPC] = uint32(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Link() Word { return Word(r.regs[syscall.EF_REG31]) } + +func (r *_MipsRegs) SetLink(val Word) os.Error { + r.regs[syscall.EF_REG31] = uint32(val) + return r.setter(&r.regs) +} + + +func (r *_MipsRegs) SP() Word { return Word(r.regs[syscall.EF_REG29]) } + +func (r *_MipsRegs) SetSP(val Word) os.Error { + r.regs[syscall.EF_REG29] = uint32(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Names() []string { return names } + +func (r *_MipsRegs) Get(i int) Word { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + return Word(r.regs[i]) +} + +func (r *_MipsRegs) Set(i int, val Word) os.Error { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + r.regs[i] = uint32(val) + return r.setter(&r.regs) +} + +func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs { + res := _MipsRegs{} + res.regs = *regs + res.setter = setter + return &res +} Index: go/debug/proc/regs_linux_mipsn64.go =================================================================== --- go/debug/proc/regs_linux_mipsn64.go (revision 0) +++ go/debug/proc/regs_linux_mipsn64.go (revision 0) @@ -0,0 +1,100 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proc + +import ( + "os" + "strconv" + "syscall" +) + +type _MipsRegs struct { + regs syscall.PtraceRegs + setter func(*syscall.PtraceRegs) os.Error +} + +var names = []string{ + "zero", + "at", + "v0", + "v1", + "a0", + "a1", + "a2", + "a3", + "a4", + "a5", + "a6", + "a7", + "t0", + "t1", + "t2", + "t3", + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "t8", + "t9", + "k0", + "k1", + "gp", + "sp", + "s8", + "ra", + "lo", + "hi", + "pc", +} + +func (r *_MipsRegs) PC() Word { return Word(r.regs[syscall.EF_CP0_EPC]) } + +func (r *_MipsRegs) SetPC(val Word) os.Error { + r.regs[syscall.EF_CP0_EPC] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Link() Word { return Word(r.regs[syscall.EF_REG31]) } + +func (r *_MipsRegs) SetLink(val Word) os.Error { + r.regs[syscall.EF_REG31] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + + +func (r *_MipsRegs) SP() Word { return Word(r.regs[syscall.EF_REG29]) } + +func (r *_MipsRegs) SetSP(val Word) os.Error { + r.regs[syscall.EF_REG29] = uint64(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Names() []string { return names } + +func (r *_MipsRegs) Get(i int) Word { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + return Word(r.regs[i]) +} + +func (r *_MipsRegs) Set(i int, val Word) os.Error { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + r.regs[i] = uint64(val) + return r.setter(&r.regs) +} + +func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs { + res := _MipsRegs{} + res.regs = *regs + res.setter = setter + return &res +}