dwarf_test.go (go1.19.src) | : | dwarf_test.go (go1.19.1.src) | ||
---|---|---|---|---|
skipping to change at line 1845 | skipping to change at line 1845 | |||
} | } | |||
// Examine params for this subprogram. | // Examine params for this subprogram. | |||
foundParams := processParams(die, &ex) | foundParams := processParams(die, &ex) | |||
if foundParams != tc.expected { | if foundParams != tc.expected { | |||
t.Errorf("check failed for testcase %s -- wanted:\n%s\ngo t:%s\n", | t.Errorf("check failed for testcase %s -- wanted:\n%s\ngo t:%s\n", | |||
tc.tag, tc.expected, foundParams) | tc.tag, tc.expected, foundParams) | |||
} | } | |||
} | } | |||
} | } | |||
func TestIssue54320(t *testing.T) { | ||||
// Check that when trampolines are used, the DWARF LPT is correctly | ||||
// emitted in the final binary | ||||
testenv.MustHaveGoBuild(t) | ||||
if runtime.GOOS == "plan9" { | ||||
t.Skip("skipping on plan9; no DWARF symbol table in executables") | ||||
} | ||||
t.Parallel() | ||||
const prog = ` | ||||
package main | ||||
import "fmt" | ||||
func main() { | ||||
fmt.Printf("Hello world\n"); | ||||
} | ||||
` | ||||
dir := t.TempDir() | ||||
f := gobuild(t, dir, prog, "-ldflags=-debugtramp=2") | ||||
defer f.Close() | ||||
d, err := f.DWARF() | ||||
if err != nil { | ||||
t.Fatalf("error reading DWARF: %v", err) | ||||
} | ||||
rdr := d.Reader() | ||||
found := false | ||||
var entry *dwarf.Entry | ||||
for entry, err = rdr.Next(); entry != nil; entry, err = rdr.Next() { | ||||
if err != nil { | ||||
t.Fatalf("error reading DWARF: %v", err) | ||||
} | ||||
if entry.Tag != dwarf.TagCompileUnit { | ||||
continue | ||||
} | ||||
name, _ := entry.Val(dwarf.AttrName).(string) | ||||
if name == "main" { | ||||
found = true | ||||
break | ||||
} | ||||
rdr.SkipChildren() | ||||
} | ||||
if !found { | ||||
t.Fatalf("could not find main compile unit") | ||||
} | ||||
lr, err := d.LineReader(entry) | ||||
if err != nil { | ||||
t.Fatalf("error obtaining linereader: %v", err) | ||||
} | ||||
var le dwarf.LineEntry | ||||
found = false | ||||
for { | ||||
if err := lr.Next(&le); err != nil { | ||||
if err == io.EOF { | ||||
break | ||||
} | ||||
t.Fatalf("error reading linentry: %v", err) | ||||
} | ||||
// check LE contains an entry to test.go | ||||
if le.File == nil { | ||||
continue | ||||
} | ||||
file := filepath.Base(le.File.Name) | ||||
if file == "test.go" { | ||||
found = true | ||||
break | ||||
} | ||||
} | ||||
if !found { | ||||
t.Errorf("no LPT entries for test.go") | ||||
} | ||||
} | ||||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 0 lines changed or added |