1
0
mirror of https://github.com/golang/go synced 2024-11-07 05:46:17 -07:00

cmd/compile: call objabi.PathToPrefix when emitting abstract fn

When generating an abstract function DIE, call objabi.PathToPrefix on
the import path so as to be consistent with how the linker handles
import paths. This is intended to resolve another problem with DWARF
inline info generation in which there are multiple inconsistent
versions of an abstract function DIE for a function whose package path
is rewritten/canonicalized by objabi.PathToPrefix.

Fixes #26237

Change-Id: I4b64c090ae43a1ad87f47587a1a71f19bc5fc8e8
Reviewed-on: https://go-review.googlesource.com/123036
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Than McIntosh 2018-07-10 12:23:31 -04:00
parent be9c994609
commit ec88f781c2
4 changed files with 51 additions and 1 deletions

View File

@ -8,6 +8,7 @@
package dwarf
import (
"cmd/internal/objabi"
"errors"
"fmt"
"sort"
@ -1096,7 +1097,7 @@ func PutAbstractFunc(ctxt Context, s *FnState) error {
// be rewritten, since it would change the offsets of the
// child DIEs (which we're relying on in order for abstract
// origin references to work).
fullname = s.Importpath + "." + s.Name[3:]
fullname = objabi.PathToPrefix(s.Importpath) + "." + s.Name[3:]
}
putattr(ctxt, s.Absfn, abbrev, DW_FORM_string, DW_CLS_STRING, int64(len(fullname)), fullname)

View File

@ -830,6 +830,23 @@ func TestAbstractOriginSanityIssue25459(t *testing.T) {
}
}
func TestAbstractOriginSanityIssue26237(t *testing.T) {
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
t.Skip("skipping on plan9; no DWARF symbol table in executables")
}
if runtime.GOOS == "solaris" || runtime.GOOS == "darwin" {
t.Skip("skipping on solaris and darwin, pending resolution of issue #23168")
}
if wd, err := os.Getwd(); err == nil {
gopathdir := filepath.Join(wd, "testdata", "issue26237")
abstractOriginSanity(t, gopathdir, DefaultOpt)
} else {
t.Fatalf("os.Getwd() failed %v", err)
}
}
func TestRuntimeTypeAttr(t *testing.T) {
testenv.MustHaveGoBuild(t)

View File

@ -0,0 +1,16 @@
package b
var q int
func Top(x int) int {
q += 1
if q != x {
return 3
}
return 4
}
func OOO(x int) int {
defer func() { q += x & 7 }()
return Top(x + 1)
}

View File

@ -0,0 +1,16 @@
package main
import (
"fmt"
b "b.dir"
)
var skyx int
func main() {
skyx += b.OOO(skyx)
if b.Top(1) == 99 {
fmt.Printf("Beware the Jabberwock, my son!\n")
}
}