]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add GOOS, GOARCH; fix FuncLine
authorRuss Cox <rsc@golang.org>
Thu, 2 Sep 2010 18:19:12 +0000 (14:19 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 2 Sep 2010 18:19:12 +0000 (14:19 -0400)
Changes to FuncLine sync it with symtab.c's funcline.

R=r
CC=girard.m1, golang-dev
https://golang.org/cl/2083041

src/pkg/runtime/extern.go
src/pkg/runtime/mkversion.c

index f73c20f45e647aa6cf071aa682a87bdf3d3d4312..0d0bfa777fdf51fa7d74a9bb4a72149045ea9dac 100644 (file)
@@ -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
index bf33c0f85bb00c676efc5e61671848cb80e35518..9790d3f093f9c539b88d1be57d1a3d33bfdad34c 100644 (file)
@@ -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);
 }