diff options
| author | Derek Parker <parkerderek86@gmail.com> | 2025-07-23 17:52:35 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-07-23 11:17:01 -0700 |
| commit | 489868f7769be02cd5f222754f26ac2aa70c64f3 (patch) | |
| tree | 71e877e98528e31fe895085e659fefbcf57e9fdd /src/cmd/link | |
| parent | 71c2bf551303930faa32886446910fa5bd0a701a (diff) | |
| download | go-489868f7769be02cd5f222754f26ac2aa70c64f3.tar.xz | |
cmd/link: scope test to linux & net.sendFile
Limits the scope of new test added in 71c2bf551303930faa32886446910fa5bd0a701a.
Discussion: https://go-review.googlesource.com/c/go/+/684377.
Change-Id: I0e8f513eb564aae277ba8a80ebdad469eb1e6e6a
GitHub-Last-Rev: add2b2e2096e5221ac3d54376c1afa1bec10482c
GitHub-Pull-Request: golang/go#74720
Reviewed-on: https://go-review.googlesource.com/c/go/+/689916
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/cmd/link')
| -rw-r--r-- | src/cmd/link/dwarf_test.go | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go index 4305354d16..d269aa70c6 100644 --- a/src/cmd/link/dwarf_test.go +++ b/src/cmd/link/dwarf_test.go @@ -257,7 +257,18 @@ func TestDWARFiOS(t *testing.T) { }) } +// This test ensures that variables promoted to the heap, specifically +// function return parameters, have correct location lists generated. +// +// TODO(deparker): This test is intentionally limited to GOOS=="linux" +// and scoped to net.sendFile, which was the function reported originally in +// issue #65405. There is relevant discussion in https://go-review.googlesource.com/c/go/+/684377 +// pertaining to these limitations. There are other missing location lists which must be fixed +// particularly in functions where `linkname` is involved. func TestDWARFLocationList(t *testing.T) { + if runtime.GOOS != "linux" { + t.Skip("skipping test on non-linux OS") + } testenv.MustHaveCGO(t) testenv.MustHaveGoBuild(t) @@ -305,22 +316,10 @@ func TestDWARFLocationList(t *testing.T) { // Look for the net.sendFile subprogram if entry.Tag == dwarf.TagSubprogram { fnName, ok := entry.Val(dwarf.AttrName).(string) - if !ok { + if !ok || fnName != "net.sendFile" { + reader.SkipChildren() continue } - if strings.Contains(fnName, ".eq") || // Ignore autogenerated equality funcs - strings.HasPrefix(fnName, "internal/") || // Ignore internal/runtime package TODO(deparker): Fix these too (likely same issue as other ignored packages below). - strings.HasPrefix(fnName, "runtime.") || // Ignore runtime package which contain funcs implemented in assembly or exposed through linkname which seems to not generate location lists correctly (most likely linkname causing this). TODO(deparker) Fix these too. - strings.HasPrefix(fnName, "reflect.") || // Ignore reflect package. TODO(deparker) Fix these too. - strings.HasPrefix(fnName, "time.") { // Ignore funcs in time package which are exposed through linkname and seem to not generate location lists correctly TODO(deparker) Fix these too. - continue - } - if fnName == "syscall.compileCallback" || fnName == "maps.clone" { - continue // Ignore for now, possibly caused by linkname usage. TODO(deparker) Fix this too. - } - if runtime.GOOS == "windows" && strings.HasPrefix(fnName, "syscall.") { - continue // Ignore, caused by linkname usage. TODO(deparker) Fix these too. - } for { paramEntry, err := reader.Next() @@ -332,13 +331,8 @@ func TestDWARFLocationList(t *testing.T) { } if paramEntry.Tag == dwarf.TagFormalParameter { - paramName, hasName := paramEntry.Val(dwarf.AttrName).(string) - if !hasName { - continue - } - if paramName[0] == '~' { - continue - } + paramName, _ := paramEntry.Val(dwarf.AttrName).(string) + // Check if this parameter has a location attribute if loc := paramEntry.Val(dwarf.AttrLocation); loc != nil { switch locData := loc.(type) { |
