func (e *Entry) AttrField(a Attr) *Field {
	for i, f := range e.Field {
		if f.Attr == a {
			return &e.Field[i]
		}
	}
	return nil
}
AttrField returns the Field associated with attribute Attr in
Entry, or nil if there is no such attribute.
package dwarf
import (
	"encoding/binary"
	"errors"
	"strconv"
)
type abbrev struct {
	tag      Tag
	children bool
	field    []afield
}
type afield struct {
	attr  Attr
	fmt   format
	class Class
	val   int64  
}
type abbrevTable map[uint32]abbrev
func (d *Data) parseAbbrev(off uint64, vers int) (abbrevTable, error) {
	if m, ok := d.abbrevCache[off]; ok {
		return m, nil
	}
	data := d.abbrev
	if off > uint64(len(data)) {
		data = nil
	} else {
		data = data[off:]
	}
	b := makeBuf(d, unknownFormat{}, "abbrev", 0, data)
	m := make(abbrevTable)
	for {
		id := uint32(b.uint())
		if id == 0 {
			break
		}
		n := 0
		b1 := b  
		b1.uint()
		b1.uint8()
		for {
			tag := b1.uint()
			fmt := b1.uint()
			if tag == 0 && fmt == 0 {
				break
			}
			if format(fmt) == formImplicitConst {
				b1.int()
			}
			n++
		}
		if b1.err != nil {
			return nil, b1.err
		}
		var a abbrev
		a.tag = Tag(b.uint())
		a.children = b.uint8() != 0
		a.field = make([]afield, n)
		for i := range a.field {
			a.field[i].attr = Attr(b.uint())
			a.field[i].fmt = format(b.uint())
			a.field[i].class = formToClass(a.field[i].fmt, a.field[i].attr, vers, &b)
			if a.field[i].fmt == formImplicitConst {
				a.field[i].val = b.int()
			}
		}
		b.uint()
		b.uint()
		m[id] = a
	}
	if b.err != nil {
		return nil, b.err
	}
	d.abbrevCache[off] = m
	return m, nil
}
var attrIsExprloc = map[Attr]bool{
	AttrLocation:      true,
	AttrByteSize:      true,
	AttrBitOffset:     true,
	AttrBitSize:       true,
	AttrStringLength:  true,
	AttrLowerBound:    true,
	AttrReturnAddr:    true,
	AttrStrideSize:    true,
	AttrUpperBound:    true,
	AttrCount:         true,
	AttrDataMemberLoc: true,
	AttrFrameBase:     true,
	AttrSegment:       true,
	AttrStaticLink:    true,
	AttrUseLocation:   true,
	AttrVtableElemLoc: true,
	AttrAllocated:     true,
	AttrAssociated:    true,
	AttrDataLocation:  true,
	AttrStride:        true,
}
var attrPtrClass = map[Attr]Class{
	AttrLocation:      ClassLocListPtr,
	AttrStmtList:      ClassLinePtr,
	AttrStringLength:  ClassLocListPtr,
	AttrReturnAddr:    ClassLocListPtr,
	AttrStartScope:    ClassRangeListPtr,
	AttrDataMemberLoc: ClassLocListPtr,
	AttrFrameBase:     ClassLocListPtr,
	AttrMacroInfo:     ClassMacPtr,
	AttrSegment:       ClassLocListPtr,
	AttrStaticLink:    ClassLocListPtr,
	AttrUseLocation:   ClassLocListPtr,
	AttrVtableElemLoc: ClassLocListPtr,
	AttrRanges:        ClassRangeListPtr,
	AttrStrOffsetsBase: ClassStrOffsetsPtr,
	AttrAddrBase:       ClassAddrPtr,
	AttrRnglistsBase:   ClassRngListsPtr,
	AttrLoclistsBase:   ClassLocListPtr,
}
func formToClass(form format, attr Attr, vers int, b *buf) Class {
	switch form {
	default:
		b.error("cannot determine class of unknown attribute form")
		return 0
	case formIndirect:
		return ClassUnknown
	case formAddr, formAddrx, formAddrx1, formAddrx2, formAddrx3, formAddrx4:
		return ClassAddress
	case formDwarfBlock1, formDwarfBlock2, formDwarfBlock4, formDwarfBlock:
		if attrIsExprloc[attr] {
			return ClassExprLoc
		}
		return ClassBlock
	case formData1, formData2, formData4, formData8, formSdata, formUdata, formData16, formImplicitConst:
		if class, ok := attrPtrClass[attr]; vers < 4 && ok {
			return class
		}
		return ClassConstant
	case formFlag, formFlagPresent:
		return ClassFlag
	case formRefAddr, formRef1, formRef2, formRef4, formRef8, formRefUdata, formRefSup4, formRefSup8:
		return ClassReference
	case formRefSig8:
		return ClassReferenceSig
	case formString, formStrp, formStrx, formStrpSup, formLineStrp, formStrx1, formStrx2, formStrx3, formStrx4:
		return ClassString
	case formSecOffset:
		if class, ok := attrPtrClass[attr]; ok {
			return class
		}
		return ClassUnknown
	case formExprloc:
		return ClassExprLoc
	case formGnuRefAlt:
		return ClassReferenceAlt
	case formGnuStrpAlt:
		return ClassStringAlt
	case formLoclistx:
		return ClassLocList
	case formRnglistx:
		return ClassRngList
	}
}
type Entry struct {
	Offset   Offset  
	Tag      Tag     
	Children bool    
	Field    []Field
}
type Field struct {
	Attr  Attr
	Val   interface{}
	Class Class
}
type Class int
const (
	ClassUnknown Class = iota
	ClassAddress
	ClassBlock
	ClassConstant
	ClassExprLoc
	ClassFlag
	ClassLinePtr
	ClassLocListPtr
	ClassMacPtr
	ClassRangeListPtr
	ClassReference
	ClassReferenceSig
	ClassString
	ClassReferenceAlt
	ClassStringAlt
	ClassAddrPtr
	ClassLocList
	ClassRngList
	ClassRngListsPtr
	ClassStrOffsetsPtr
)
func (i Class) GoString() string {
	return "dwarf." + i.String()
}
func (e *Entry) Val(a Attr) interface{} {
	if f := e.AttrField(a); f != nil {
		return f.Val
	}
	return nil
}