diff options
author | Alessandro Arzilli <alessandro.arzilli@gmail.com> | 2021-09-03 17:00:41 +0200 |
---|---|---|
committer | Than McIntosh <thanm@google.com> | 2021-09-20 18:31:54 +0000 |
commit | 6268468e024ce7fa063611b98a2f11f17fd4bad8 (patch) | |
tree | 222fe3712e895b087fb934de1afca70c5feae623 /src/cmd/link/internal/ld/dwarf_test.go | |
parent | 6acac8b6856b2531f4ac7ee0eb37048d588d98c7 (diff) | |
download | go-6268468e024ce7fa063611b98a2f11f17fd4bad8.tar.gz go-6268468e024ce7fa063611b98a2f11f17fd4bad8.zip |
cmd/link: generate DIE for types referenced only through dictionaries
Generate debug_info entries for types that are only referenced through
dictionaries.
Change-Id: Ic36c2e6d9588ec6746793bb213c2dc0e17a8a850
Reviewed-on: https://go-review.googlesource.com/c/go/+/350532
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/link/internal/ld/dwarf_test.go')
-rw-r--r-- | src/cmd/link/internal/ld/dwarf_test.go | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go index 3d112d97a4..db9002491e 100644 --- a/src/cmd/link/internal/ld/dwarf_test.go +++ b/src/cmd/link/internal/ld/dwarf_test.go @@ -1749,7 +1749,9 @@ func main() { } func TestDictIndex(t *testing.T) { - // Check that variables with a parametric type have a dictionary index attribute + // Check that variables with a parametric type have a dictionary index + // attribute and that types that are only referenced through dictionaries + // have DIEs. testenv.MustHaveGoBuild(t) if runtime.GOOS == "plan9" { @@ -1765,6 +1767,8 @@ package main import "fmt" +type CustomInt int + func testfn[T any](arg T) { var mapvar = make(map[int]T) mapvar[0] = arg @@ -1772,7 +1776,7 @@ func testfn[T any](arg T) { } func main() { - testfn("test") + testfn(CustomInt(3)) } ` @@ -1829,4 +1833,19 @@ func main() { t.Errorf("could not find DW_AT_go_dict_index attribute offset %#x (%T)", off, entry.Val(intdwarf.DW_AT_go_dict_index)) } } + + rdr.Seek(0) + ex := examiner{} + if err := ex.populate(rdr); err != nil { + t.Fatalf("error reading DWARF: %v", err) + } + for _, typeName := range []string{"main.CustomInt", "map[int]main.CustomInt"} { + dies := ex.Named(typeName) + if len(dies) != 1 { + t.Errorf("wanted 1 DIE named %s, found %v", typeName, len(dies)) + } + if dies[0].Val(intdwarf.DW_AT_go_runtime_type).(uint64) == 0 { + t.Errorf("type %s does not have DW_AT_go_runtime_type", typeName) + } + } } |