mirror of https://github.com/golang/go.git
debug/dwarf: add test for split DWARF
This adds a test that debug/dwarf can read the skeleton DWARF data from a split DWARF image (though it doesn't currently support piecing the external DWARF data back together). This should work because there's nothing particularly different about skeleton DWARF data, but previously failed because of poor handling of unrecognized attributes. Updates #12592. Change-Id: I2fc5f4679883b05ebd7ec9f0b5c398a758181a32 Reviewed-on: https://go-review.googlesource.com/14542 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: jcd . <jcd@golang.org>
This commit is contained in:
parent
6044dd098d
commit
2cbd7072b1
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package dwarf_test
|
||||
|
||||
import (
|
||||
. "debug/dwarf"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSplit(t *testing.T) {
|
||||
// debug/dwarf doesn't (currently) support split DWARF, but
|
||||
// the attributes that pointed to the split DWARF used to
|
||||
// cause loading the DWARF data to fail entirely (issue
|
||||
// #12592). Test that we can at least read the DWARF data.
|
||||
d := elfData(t, "testdata/split.elf")
|
||||
r := d.Reader()
|
||||
e, err := r.Next()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if e.Tag != TagCompileUnit {
|
||||
t.Fatalf("bad tag: have %s, want %s", e.Tag, TagCompileUnit)
|
||||
}
|
||||
// Check that we were able to parse the unknown section offset
|
||||
// field, even if we can't figure out its DWARF class.
|
||||
const AttrGNUAddrBase Attr = 0x2133
|
||||
f := e.AttrField(AttrGNUAddrBase)
|
||||
if _, ok := f.Val.(int64); !ok {
|
||||
t.Fatalf("bad attribute value type: have %T, want int64", f.Val)
|
||||
}
|
||||
if f.Class != ClassUnknown {
|
||||
t.Fatalf("bad class: have %s, want %s", f.Class, ClassUnknown)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// gcc -gsplit-dwarf split.c -o split.elf
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
Binary file not shown.
Loading…
Reference in New Issue