diff options
| author | Russ Cox <rsc@golang.org> | 2013-10-09 11:08:22 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2013-10-09 11:08:22 -0400 |
| commit | 0965459bd908fdbd0ffc6a6cb82d58bd0091fc0a (patch) | |
| tree | e3a0696dc9193344bd12e09c8f0f0fa387537e04 /src | |
| parent | 7bbe0163c7def3eca41fa0e2d950fdfe37f37562 (diff) | |
| download | go-0965459bd908fdbd0ffc6a6cb82d58bd0091fc0a.tar.xz | |
debug/dwarf: handle surprising clang encoding
Fixes a bug in cgo on OS X using clang.
See golang.org/issue/6472 for details.
Fixes #6472.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14575043
Diffstat (limited to 'src')
| -rw-r--r-- | src/pkg/debug/dwarf/type.go | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/pkg/debug/dwarf/type.go b/src/pkg/debug/dwarf/type.go index 54000fbd75..1fbae6c144 100644 --- a/src/pkg/debug/dwarf/type.go +++ b/src/pkg/debug/dwarf/type.go @@ -271,24 +271,43 @@ func (d *Data) Type(off Offset) (Type, error) { // d.Type recursively, to handle circular types correctly. var typ Type + nextDepth := 0 + // Get next child; set err if error happens. next := func() *Entry { if !e.Children { return nil } - kid, err1 := r.Next() - if err1 != nil { - err = err1 - return nil - } - if kid == nil { - err = DecodeError{"info", r.b.off, "unexpected end of DWARF entries"} - return nil - } - if kid.Tag == 0 { - return nil + // Only return direct children. + // Skip over composite entries that happen to be nested + // inside this one. Most DWARF generators wouldn't generate + // such a thing, but clang does. + // See golang.org/issue/6472. + for { + kid, err1 := r.Next() + if err1 != nil { + err = err1 + return nil + } + if kid == nil { + err = DecodeError{"info", r.b.off, "unexpected end of DWARF entries"} + return nil + } + if kid.Tag == 0 { + if nextDepth > 0 { + nextDepth-- + continue + } + return nil + } + if kid.Children { + nextDepth++ + } + if nextDepth > 0 { + continue + } + return kid } - return kid } // Get Type referred to by Entry's AttrType field. |
