summaryrefslogtreecommitdiff
path: root/libgo/go/debug/proc/regs_linux_386.go
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libgo/go/debug/proc/regs_linux_386.go
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libgo/go/debug/proc/regs_linux_386.go')
-rw-r--r--libgo/go/debug/proc/regs_linux_386.go143
1 files changed, 143 insertions, 0 deletions
diff --git a/libgo/go/debug/proc/regs_linux_386.go b/libgo/go/debug/proc/regs_linux_386.go
new file mode 100644
index 000000000..b4a9769db
--- /dev/null
+++ b/libgo/go/debug/proc/regs_linux_386.go
@@ -0,0 +1,143 @@
+// Copyright 2009 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 _386Regs struct {
+ syscall.PtraceRegs
+ setter func(*syscall.PtraceRegs) os.Error
+}
+
+var names = []string{
+ "eax",
+ "ebx",
+ "ecx",
+ "edx",
+ "esi",
+ "edi",
+ "ebp",
+ "esp",
+ "eip",
+ "eflags",
+ "cs",
+ "ss",
+ "ds",
+ "es",
+ "fs",
+ "gs",
+}
+
+func (r *_386Regs) PC() Word { return Word(r.Eip) }
+
+func (r *_386Regs) SetPC(val Word) os.Error {
+ r.Eip = int32(val)
+ return r.setter(&r.PtraceRegs)
+}
+
+func (r *_386Regs) Link() Word {
+ // TODO(austin)
+ panic("No link register")
+}
+
+func (r *_386Regs) SetLink(val Word) os.Error { panic("No link register") }
+
+func (r *_386Regs) SP() Word { return Word(r.Esp) }
+
+func (r *_386Regs) SetSP(val Word) os.Error {
+ r.Esp = int32(val)
+ return r.setter(&r.PtraceRegs)
+}
+
+func (r *_386Regs) Names() []string { return names }
+
+func (r *_386Regs) Get(i int) Word {
+ switch i {
+ case 0:
+ return Word(uint32(r.Eax))
+ case 1:
+ return Word(uint32(r.Ebx))
+ case 2:
+ return Word(uint32(r.Ecx))
+ case 3:
+ return Word(uint32(r.Edx))
+ case 4:
+ return Word(uint32(r.Esi))
+ case 5:
+ return Word(uint32(r.Edi))
+ case 6:
+ return Word(uint32(r.Ebp))
+ case 7:
+ return Word(uint32(r.Esp))
+ case 8:
+ return Word(uint32(r.Eip))
+ case 9:
+ return Word(uint32(r.Eflags))
+ case 10:
+ return Word(r.Xcs)
+ case 11:
+ return Word(r.Xss)
+ case 12:
+ return Word(r.Xds)
+ case 13:
+ return Word(r.Xes)
+ case 14:
+ return Word(r.Xfs)
+ case 15:
+ return Word(r.Xgs)
+ }
+ panic("invalid register index " + strconv.Itoa(i))
+}
+
+func (r *_386Regs) Set(i int, val Word) os.Error {
+ switch i {
+ case 0:
+ r.Eax = int32(val)
+ case 1:
+ r.Ebx = int32(val)
+ case 2:
+ r.Ecx = int32(val)
+ case 3:
+ r.Edx = int32(val)
+ case 4:
+ r.Esi = int32(val)
+ case 5:
+ r.Edi = int32(val)
+ case 6:
+ r.Ebp = int32(val)
+ case 7:
+ r.Esp = int32(val)
+ case 8:
+ r.Eip = int32(val)
+ case 9:
+ r.Eflags = int32(val)
+ case 10:
+ r.Xcs = int32(val)
+ case 11:
+ r.Xss = int32(val)
+ case 12:
+ r.Xds = int32(val)
+ case 13:
+ r.Xes = int32(val)
+ case 14:
+ r.Xfs = int32(val)
+ case 15:
+ r.Xgs = int32(val)
+ default:
+ panic("invalid register index " + strconv.Itoa(i))
+ }
+ return r.setter(&r.PtraceRegs)
+}
+
+func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs {
+ res := _386Regs{}
+ res.PtraceRegs = *regs
+ res.setter = setter
+ return &res
+}