x/debug/dwarf: support new AttrGoEmbed field of struct members The new custom attribute 0x2903 was added to DIEs of struct members to distinguish struct embeds from regular fields. CL: https://golang.org/cl/41873 Issue: https://github.com/golang/go/issues/20037 Change-Id: Ia676c6ef0d49e4e824e28d5cb53cad590c3b4f4a Reviewed-on: https://go-review.googlesource.com/42512 Reviewed-by: John Dethridge <jcd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/dwarf/const.go b/dwarf/const.go index 454f789..b2debfb 100644 --- a/dwarf/const.go +++ b/dwarf/const.go
@@ -86,9 +86,10 @@ AttrDescription Attr = 0x5A // Go-specific attributes. - AttrGoKind Attr = 0x2900 - AttrGoKey Attr = 0x2901 - AttrGoElem Attr = 0x2902 + AttrGoKind Attr = 0x2900 + AttrGoKey Attr = 0x2901 + AttrGoElem Attr = 0x2902 + AttrGoEmbeddedField Attr = 0x2903 ) var attrNames = [...]string{ @@ -180,6 +181,8 @@ return "GoKey" case AttrGoElem: return "GoElem" + case AttrGoEmbeddedField: + return "GoEmbeddedField" } return strconv.Itoa(int(a)) }
diff --git a/dwarf/type.go b/dwarf/type.go index ae1a3f3..e501a42 100644 --- a/dwarf/type.go +++ b/dwarf/type.go
@@ -158,6 +158,7 @@ ByteSize int64 BitOffset int64 // within the ByteSize bytes at ByteOffset BitSize int64 // zero if not a bit field + Embedded bool } func (t *StructType) String() string { @@ -646,6 +647,7 @@ f.ByteSize, _ = kid.Val(AttrByteSize).(int64) f.BitOffset, haveBitOffset = kid.Val(AttrBitOffset).(int64) f.BitSize, _ = kid.Val(AttrBitSize).(int64) + f.Embedded, _ = kid.Val(AttrGoEmbeddedField).(bool) t.Field = append(t.Field, f) bito := f.BitOffset