aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-09-02 14:19:12 -0400
committerRuss Cox <rsc@golang.org>2010-09-02 14:19:12 -0400
commit4e645558947725b8577f71dbb14d43e5852611cb (patch)
treed64e66727bb390cfa2e5c13618f6ea9b35775ca3
parentdea283750b9b7774cd0ee0d320a038dbff90803f (diff)
downloadgo-4e645558947725b8577f71dbb14d43e5852611cb.tar.gz
go-4e645558947725b8577f71dbb14d43e5852611cb.zip
runtime: add GOOS, GOARCH; fix FuncLine
Changes to FuncLine sync it with symtab.c's funcline. R=r CC=girard.m1, golang-dev https://golang.org/cl/2083041
-rw-r--r--src/pkg/runtime/extern.go28
-rw-r--r--src/pkg/runtime/mkversion.c6
2 files changed, 25 insertions, 9 deletions
diff --git a/src/pkg/runtime/extern.go b/src/pkg/runtime/extern.go
index f73c20f45e..0d0bfa777f 100644
--- a/src/pkg/runtime/extern.go
+++ b/src/pkg/runtime/extern.go
@@ -66,13 +66,17 @@ func (f *Func) Entry() uintptr { return f.entry }
func (f *Func) FileLine(pc uintptr) (file string, line int) {
// NOTE(rsc): If you edit this function, also edit
// symtab.c:/^funcline.
- const PcQuant = 1
+ var pcQuant uintptr = 1
+ if GOARCH == "arm" {
+ pcQuant = 4
+ }
+ targetpc := pc
p := f.pcln
- pc1 := f.pc0
+ pc = f.pc0
line = int(f.ln0)
file = f.src
- for i := 0; i < len(p) && pc1 <= pc; i++ {
+ for i := 0; i < len(p) && pc <= targetpc; i++ {
switch {
case p[i] == 0:
line += int(p[i+1]<<24) | int(p[i+2]<<16) | int(p[i+3]<<8) | int(p[i+4])
@@ -80,11 +84,11 @@ func (f *Func) FileLine(pc uintptr) (file string, line int) {
case p[i] <= 64:
line += int(p[i])
case p[i] <= 128:
- line += int(p[i] - 64)
+ line -= int(p[i] - 64)
default:
- line += PcQuant * int(p[i]-129)
+ pc += pcQuant * uintptr(p[i]-129)
}
- pc += PcQuant
+ pc += pcQuant
}
return
}
@@ -165,4 +169,14 @@ func GOROOT() string {
// a release tag like "release.2010-03-04".
// A trailing + indicates that the tree had local modifications
// at the time of the build.
-func Version() string { return defaultVersion }
+func Version() string {
+ return theVersion
+}
+
+// GOOS is the Go tree's operating system target:
+// one of darwin, freebsd, linux, and so on.
+const GOOS string = theGoos
+
+// GOARCH is the Go tree's architecture target:
+// 386, amd64, or arm.
+const GOARCH string = theGoarch
diff --git a/src/pkg/runtime/mkversion.c b/src/pkg/runtime/mkversion.c
index bf33c0f85b..9790d3f093 100644
--- a/src/pkg/runtime/mkversion.c
+++ b/src/pkg/runtime/mkversion.c
@@ -5,11 +5,13 @@ char *template =
"// generated by mkversion.c; do not edit.\n"
"package runtime\n"
"const defaultGoroot = \"%s\"\n"
- "const defaultVersion = \"%s\"\n";
+ "const theVersion = \"%s\"\n"
+ "const theGoarch = \"%s\"\n"
+ "const theGoos = \"%s\"\n";
void
main(void)
{
- print(template, getgoroot(), getgoversion());
+ print(template, getgoroot(), getgoversion(), getgoarch(), getgoos());
exits(0);
}