Commit ec88f781 authored by Than McIntosh's avatar Than McIntosh

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: 's avatarCherry Zhang <cherryyz@google.com>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarHeschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent be9c9946
......@@ -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)
......
......@@ -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)
......
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)
}
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")
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment