diff options
| author | Russ Cox <rsc@golang.org> | 2009-10-06 14:55:06 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2009-10-06 14:55:06 -0700 |
| commit | 22c98a3314b1795493ecc39180f6d655fbde1496 (patch) | |
| tree | f5b390ddea97265159af38aa200118243d51fc7f /src/pkg/debug/dwarf | |
| parent | 620ec45c5f7b3a29265efd67532177474590a947 (diff) | |
| download | go-22c98a3314b1795493ecc39180f6d655fbde1496.tar.xz | |
gofmt on crypto, debug
R=gri
DELTA=2560 (127 added, 177 deleted, 2256 changed)
OCL=35388
CL=35395
Diffstat (limited to 'src/pkg/debug/dwarf')
| -rw-r--r-- | src/pkg/debug/dwarf/buf.go | 39 | ||||
| -rw-r--r-- | src/pkg/debug/dwarf/const.go | 440 | ||||
| -rw-r--r-- | src/pkg/debug/dwarf/entry.go | 47 | ||||
| -rw-r--r-- | src/pkg/debug/dwarf/open.go | 26 | ||||
| -rw-r--r-- | src/pkg/debug/dwarf/type.go | 68 | ||||
| -rw-r--r-- | src/pkg/debug/dwarf/type_test.go | 14 | ||||
| -rw-r--r-- | src/pkg/debug/dwarf/unit.go | 13 |
7 files changed, 323 insertions, 324 deletions
diff --git a/src/pkg/debug/dwarf/buf.go b/src/pkg/debug/dwarf/buf.go index 3089180ac0..e4cb28e5dd 100644 --- a/src/pkg/debug/dwarf/buf.go +++ b/src/pkg/debug/dwarf/buf.go @@ -14,17 +14,17 @@ import ( // Data buffer being decoded. type buf struct { - dwarf *Data; - order binary.ByteOrder; - name string; - off Offset; - data []byte; - addrsize int; - err os.Error; + dwarf *Data; + order binary.ByteOrder; + name string; + off Offset; + data []byte; + addrsize int; + err os.Error; } func makeBuf(d *Data, name string, off Offset, data []byte, addrsize int) buf { - return buf{d, d.order, name, off, data, addrsize, nil} + return buf{d, d.order, name, off, data, addrsize, nil}; } func (b *buf) uint8() uint8 { @@ -33,7 +33,7 @@ func (b *buf) uint8() uint8 { return 0; } val := b.data[0]; - b.data = b.data[1:len(b.data)]; + b.data = b.data[1 : len(b.data)]; b.off++; return val; } @@ -44,7 +44,7 @@ func (b *buf) bytes(n int) []byte { return nil; } data := b.data[0:n]; - b.data = b.data[n:len(b.data)]; + b.data = b.data[n : len(b.data)]; b.off += Offset(n); return data; } @@ -57,7 +57,7 @@ func (b *buf) string() string { for i := 0; i < len(b.data); i++ { if b.data[i] == 0 { s := string(b.data[0:i]); - b.data = b.data[i+1:len(b.data)]; + b.data = b.data[i+1 : len(b.data)]; b.off += Offset(i+1); return s; } @@ -66,7 +66,7 @@ func (b *buf) string() string { return ""; } -func (b *buf) uint16() uint16{ +func (b *buf) uint16() uint16 { a := b.bytes(2); if a == nil { return 0; @@ -99,7 +99,7 @@ func (b *buf) varint() (c uint64, bits uint) { bits += 7; if byte&0x80 == 0 { b.off += Offset(i+1); - b.data = b.data[i+1:len(b.data)]; + b.data = b.data[i+1 : len(b.data)]; return c, bits; } } @@ -116,8 +116,8 @@ func (b *buf) uint() uint64 { func (b *buf) int() int64 { ux, bits := b.varint(); x := int64(ux); - if x & (1<<(bits-1)) != 0 { - x |= -1<<bits; + if x&(1<<(bits-1)) != 0 { + x |= -1 << bits; } return x; } @@ -141,17 +141,16 @@ func (b *buf) addr() uint64 { func (b *buf) error(s string) { if b.err == nil { b.data = nil; - b.err = DecodeError{b.name, b.off, s} + b.err = DecodeError{b.name, b.off, s}; } } type DecodeError struct { - Name string; - Offset Offset; - Error string; + Name string; + Offset Offset; + Error string; } func (e DecodeError) String() string { return "decoding dwarf section " + e.Name + " at offset 0x" + strconv.Itob64(int64(e.Offset), 16) + ": " + e.Error; } - diff --git a/src/pkg/debug/dwarf/const.go b/src/pkg/debug/dwarf/const.go index c2878bd6f5..b476b29b6c 100644 --- a/src/pkg/debug/dwarf/const.go +++ b/src/pkg/debug/dwarf/const.go @@ -12,81 +12,81 @@ import "strconv" type Attr uint32 const ( - AttrSibling Attr = 0x01; - AttrLocation Attr = 0x02; - AttrName Attr = 0x03; - AttrOrdering Attr = 0x09; - AttrByteSize Attr = 0x0B; - AttrBitOffset Attr = 0x0C; - AttrBitSize Attr = 0x0D; - AttrStmtList Attr = 0x10; - AttrLowpc Attr = 0x11; - AttrHighpc Attr = 0x12; - AttrLanguage Attr = 0x13; - AttrDiscr Attr = 0x15; - AttrDiscrValue Attr = 0x16; - AttrVisibility Attr = 0x17; - AttrImport Attr = 0x18; - AttrStringLength Attr = 0x19; - AttrCommonRef Attr = 0x1A; - AttrCompDir Attr = 0x1B; - AttrConstValue Attr = 0x1C; - AttrContainingType Attr = 0x1D; - AttrDefaultValue Attr = 0x1E; - AttrInline Attr = 0x20; - AttrIsOptional Attr = 0x21; - AttrLowerBound Attr = 0x22; - AttrProducer Attr = 0x25; - AttrPrototyped Attr = 0x27; - AttrReturnAddr Attr = 0x2A; - AttrStartScope Attr = 0x2C; - AttrStrideSize Attr = 0x2E; - AttrUpperBound Attr = 0x2F; - AttrAbstractOrigin Attr = 0x31; - AttrAccessibility Attr = 0x32; - AttrAddrClass Attr = 0x33; - AttrArtificial Attr = 0x34; - AttrBaseTypes Attr = 0x35; - AttrCalling Attr = 0x36; - AttrCount Attr = 0x37; - AttrDataMemberLoc Attr = 0x38; - AttrDeclColumn Attr = 0x39; - AttrDeclFile Attr = 0x3A; - AttrDeclLine Attr = 0x3B; - AttrDeclaration Attr = 0x3C; - AttrDiscrList Attr = 0x3D; - AttrEncoding Attr = 0x3E; - AttrExternal Attr = 0x3F; - AttrFrameBase Attr = 0x40; - AttrFriend Attr = 0x41; - AttrIdentifierCase Attr = 0x42; - AttrMacroInfo Attr = 0x43; - AttrNamelistItem Attr = 0x44; - AttrPriority Attr = 0x45; - AttrSegment Attr = 0x46; - AttrSpecification Attr = 0x47; - AttrStaticLink Attr = 0x48; - AttrType Attr = 0x49; - AttrUseLocation Attr = 0x4A; - AttrVarParam Attr = 0x4B; - AttrVirtuality Attr = 0x4C; - AttrVtableElemLoc Attr = 0x4D; - AttrAllocated Attr = 0x4E; - AttrAssociated Attr = 0x4F; - AttrDataLocation Attr = 0x50; - AttrStride Attr = 0x51; - AttrEntrypc Attr = 0x52; - AttrUseUTF8 Attr = 0x53; - AttrExtension Attr = 0x54; - AttrRanges Attr = 0x55; - AttrTrampoline Attr = 0x56; - AttrCallColumn Attr = 0x57; - AttrCallFile Attr = 0x58; - AttrCallLine Attr = 0x59; - AttrDescription Attr = 0x5A; + AttrSibling Attr = 0x01; + AttrLocation Attr = 0x02; + AttrName Attr = 0x03; + AttrOrdering Attr = 0x09; + AttrByteSize Attr = 0x0B; + AttrBitOffset Attr = 0x0C; + AttrBitSize Attr = 0x0D; + AttrStmtList Attr = 0x10; + AttrLowpc Attr = 0x11; + AttrHighpc Attr = 0x12; + AttrLanguage Attr = 0x13; + AttrDiscr Attr = 0x15; + AttrDiscrValue Attr = 0x16; + AttrVisibility Attr = 0x17; + AttrImport Attr = 0x18; + AttrStringLength Attr = 0x19; + AttrCommonRef Attr = 0x1A; + AttrCompDir Attr = 0x1B; + AttrConstValue Attr = 0x1C; + AttrContainingType Attr = 0x1D; + AttrDefaultValue Attr = 0x1E; + AttrInline Attr = 0x20; + AttrIsOptional Attr = 0x21; + AttrLowerBound Attr = 0x22; + AttrProducer Attr = 0x25; + AttrPrototyped Attr = 0x27; + AttrReturnAddr Attr = 0x2A; + AttrStartScope Attr = 0x2C; + AttrStrideSize Attr = 0x2E; + AttrUpperBound Attr = 0x2F; + AttrAbstractOrigin Attr = 0x31; + AttrAccessibility Attr = 0x32; + AttrAddrClass Attr = 0x33; + AttrArtificial Attr = 0x34; + AttrBaseTypes Attr = 0x35; + AttrCalling Attr = 0x36; + AttrCount Attr = 0x37; + AttrDataMemberLoc Attr = 0x38; + AttrDeclColumn Attr = 0x39; + AttrDeclFile Attr = 0x3A; + AttrDeclLine Attr = 0x3B; + AttrDeclaration Attr = 0x3C; + AttrDiscrList Attr = 0x3D; + AttrEncoding Attr = 0x3E; + AttrExternal Attr = 0x3F; + AttrFrameBase Attr = 0x40; + AttrFriend Attr = 0x41; + AttrIdentifierCase Attr = 0x42; + AttrMacroInfo Attr = 0x43; + AttrNamelistItem Attr = 0x44; + AttrPriority Attr = 0x45; + AttrSegment Attr = 0x46; + AttrSpecification Attr = 0x47; + AttrStaticLink Attr = 0x48; + AttrType Attr = 0x49; + AttrUseLocation Attr = 0x4A; + AttrVarParam Attr = 0x4B; + AttrVirtuality Attr = 0x4C; + AttrVtableElemLoc Attr = 0x4D; + AttrAllocated Attr = 0x4E; + AttrAssociated Attr = 0x4F; + AttrDataLocation Attr = 0x50; + AttrStride Attr = 0x51; + AttrEntrypc Attr = 0x52; + AttrUseUTF8 Attr = 0x53; + AttrExtension Attr = 0x54; + AttrRanges Attr = 0x55; + AttrTrampoline Attr = 0x56; + AttrCallColumn Attr = 0x57; + AttrCallFile Attr = 0x58; + AttrCallLine Attr = 0x59; + AttrDescription Attr = 0x5A; ) -var attrNames = [...]string { +var attrNames = [...]string{ AttrSibling: "Sibling", AttrLocation: "Location", AttrName: "Name", @@ -186,92 +186,92 @@ type format uint32 const ( // value formats - formAddr format = 0x01; - formDwarfBlock2 format = 0x03; - formDwarfBlock4 format = 0x04; - formData2 format = 0x05; - formData4 format = 0x06; - formData8 format = 0x07; - formString format = 0x08; - formDwarfBlock format = 0x09; - formDwarfBlock1 format = 0x0A; - formData1 format = 0x0B; - formFlag format = 0x0C; - formSdata format = 0x0D; - formStrp format = 0x0E; - formUdata format = 0x0F; - formRefAddr format = 0x10; - formRef1 format = 0x11; - formRef2 format = 0x12; - formRef4 format = 0x13; - formRef8 format = 0x14; - formRefUdata format = 0x15; - formIndirect format = 0x16; + formAddr format = 0x01; + formDwarfBlock2 format = 0x03; + formDwarfBlock4 format = 0x04; + formData2 format = 0x05; + formData4 format = 0x06; + formData8 format = 0x07; + formString format = 0x08; + formDwarfBlock format = 0x09; + formDwarfBlock1 format = 0x0A; + formData1 format = 0x0B; + formFlag format = 0x0C; + formSdata format = 0x0D; + formStrp format = 0x0E; + formUdata format = 0x0F; + formRefAddr format = 0x10; + formRef1 format = 0x11; + formRef2 format = 0x12; + formRef4 format = 0x13; + formRef8 format = 0x14; + formRefUdata format = 0x15; + formIndirect format = 0x16; ) // A Tag is the classification (the type) of an Entry. type Tag uint32 const ( - TagArrayType Tag = 0x01; - TagClassType Tag = 0x02; - TagEntryPoint Tag = 0x03; - TagEnumerationType Tag = 0x04; - TagFormalParameter Tag = 0x05; - TagImportedDeclaration Tag = 0x08; - TagLabel Tag = 0x0A; - TagLexDwarfBlock Tag = 0x0B; - TagMember Tag = 0x0D; - TagPointerType Tag = 0x0F; - TagReferenceType Tag = 0x10; - TagCompileUnit Tag = 0x11; - TagStringType Tag = 0x12; - TagStructType Tag = 0x13; - TagSubroutineType Tag = 0x15; - TagTypedef Tag = 0x16; - TagUnionType Tag = 0x17; - TagUnspecifiedParameters Tag = 0x18; - TagVariant Tag = 0x19; - TagCommonDwarfBlock Tag = 0x1A; - TagCommonInclusion Tag = 0x1B; - TagInheritance Tag = 0x1C; - TagInlinedSubroutine Tag = 0x1D; - TagModule Tag = 0x1E; - TagPtrToMemberType Tag = 0x1F; - TagSetType Tag = 0x20; - TagSubrangeType Tag = 0x21; - TagWithStmt Tag = 0x22; - TagAccessDeclaration Tag = 0x23; - TagBaseType Tag = 0x24; - TagCatchDwarfBlock Tag = 0x25; - TagConstType Tag = 0x26; - TagConstant Tag = 0x27; - TagEnumerator Tag = 0x28; - TagFileType Tag = 0x29; - TagFriend Tag = 0x2A; - TagNamelist Tag = 0x2B; - TagNamelistItem Tag = 0x2C; - TagPackedType Tag = 0x2D; - TagSubprogram Tag = 0x2E; - TagTemplateTypeParameter Tag = 0x2F; - TagTemplateValueParameter Tag = 0x30; - TagThrownType Tag = 0x31; - TagTryDwarfBlock Tag = 0x32; - TagVariantPart Tag = 0x33; - TagVariable Tag = 0x34; - TagVolatileType Tag = 0x35; - TagDwarfProcedure Tag = 0x36; - TagRestrictType Tag = 0x37; - TagInterfaceType Tag = 0x38; - TagNamespace Tag = 0x39; - TagImportedModule Tag = 0x3A; - TagUnspecifiedType Tag = 0x3B; - TagPartialUnit Tag = 0x3C; - TagImportedUnit Tag = 0x3D; - TagMutableType Tag = 0x3E; + TagArrayType Tag = 0x01; + TagClassType Tag = 0x02; + TagEntryPoint Tag = 0x03; + TagEnumerationType Tag = 0x04; + TagFormalParameter Tag = 0x05; + TagImportedDeclaration Tag = 0x08; + TagLabel Tag = 0x0A; + TagLexDwarfBlock Tag = 0x0B; + TagMember Tag = 0x0D; + TagPointerType Tag = 0x0F; + TagReferenceType Tag = 0x10; + TagCompileUnit Tag = 0x11; + TagStringType Tag = 0x12; + TagStructType Tag = 0x13; + TagSubroutineType Tag = 0x15; + TagTypedef Tag = 0x16; + TagUnionType Tag = 0x17; + TagUnspecifiedParameters Tag = 0x18; + TagVariant Tag = 0x19; + TagCommonDwarfBlock Tag = 0x1A; + TagCommonInclusion Tag = 0x1B; + TagInheritance Tag = 0x1C; + TagInlinedSubroutine Tag = 0x1D; + TagModule Tag = 0x1E; + TagPtrToMemberType Tag = 0x1F; + TagSetType Tag = 0x20; + TagSubrangeType Tag = 0x21; + TagWithStmt Tag = 0x22; + TagAccessDeclaration Tag = 0x23; + TagBaseType Tag = 0x24; + TagCatchDwarfBlock Tag = 0x25; + TagConstType Tag = 0x26; + TagConstant Tag = 0x27; + TagEnumerator Tag = 0x28; + TagFileType Tag = 0x29; + TagFriend Tag = 0x2A; + TagNamelist Tag = 0x2B; + TagNamelistItem Tag = 0x2C; + TagPackedType Tag = 0x2D; + TagSubprogram Tag = 0x2E; + TagTemplateTypeParameter Tag = 0x2F; + TagTemplateValueParameter Tag = 0x30; + TagThrownType Tag = 0x31; + TagTryDwarfBlock Tag = 0x32; + TagVariantPart Tag = 0x33; + TagVariable Tag = 0x34; + TagVolatileType Tag = 0x35; + TagDwarfProcedure Tag = 0x36; + TagRestrictType Tag = 0x37; + TagInterfaceType Tag = 0x38; + TagNamespace Tag = 0x39; + TagImportedModule Tag = 0x3A; + TagUnspecifiedType Tag = 0x3B; + TagPartialUnit Tag = 0x3C; + TagImportedUnit Tag = 0x3D; + TagMutableType Tag = 0x3E; ) -var tagNames = [...]string { +var tagNames = [...]string{ TagArrayType: "ArrayType", TagClassType: "ClassType", TagEntryPoint: "EntryPoint", @@ -356,78 +356,78 @@ func (t Tag) GoString() string { // This package does not implement full expressions; // the opPlusUconst operator is expected by the type parser. const ( - opAddr = 0x03; /* 1 op, const addr */ - opDeref = 0x06; - opConst1u = 0x08; /* 1 op, 1 byte const */ - opConst1s = 0x09; /* " signed */ - opConst2u = 0x0A; /* 1 op, 2 byte const */ - opConst2s = 0x0B; /* " signed */ - opConst4u = 0x0C; /* 1 op, 4 byte const */ - opConst4s = 0x0D; /* " signed */ - opConst8u = 0x0E; /* 1 op, 8 byte const */ - opConst8s = 0x0F; /* " signed */ - opConstu = 0x10; /* 1 op, LEB128 const */ - opConsts = 0x11; /* " signed */ - opDup = 0x12; - opDrop = 0x13; - opOver = 0x14; - opPick = 0x15; /* 1 op, 1 byte stack index */ - opSwap = 0x16; - opRot = 0x17; - opXderef = 0x18; - opAbs = 0x19; - opAnd = 0x1A; - opDiv = 0x1B; - opMinus = 0x1C; - opMod = 0x1D; - opMul = 0x1E; - opNeg = 0x1F; - opNot = 0x20; - opOr = 0x21; - opPlus = 0x22; - opPlusUconst = 0x23; /* 1 op, ULEB128 addend */ - opShl = 0x24; - opShr = 0x25; - opShra = 0x26; - opXor = 0x27; - opSkip = 0x2F; /* 1 op, signed 2-byte constant */ - opBra = 0x28; /* 1 op, signed 2-byte constant */ - opEq = 0x29; - opGe = 0x2A; - opGt = 0x2B; - opLe = 0x2C; - opLt = 0x2D; - opNe = 0x2E; - opLit0 = 0x30; - /* OpLitN = OpLit0 + N for N = 0..31 */ - opReg0 = 0x50; - /* OpRegN = OpReg0 + N for N = 0..31 */ - opBreg0 = 0x70; /* 1 op, signed LEB128 constant */ - /* OpBregN = OpBreg0 + N for N = 0..31 */ - opRegx = 0x90; /* 1 op, ULEB128 register */ - opFbreg = 0x91; /* 1 op, SLEB128 offset */ - opBregx = 0x92; /* 2 op, ULEB128 reg; SLEB128 off */ - opPiece = 0x93; /* 1 op, ULEB128 size of piece */ - opDerefSize = 0x94; /* 1-byte size of data retrieved */ - opXderefSize = 0x95; /* 1-byte size of data retrieved */ - opNop = 0x96; + opAddr = 0x03; /* 1 op, const addr */ + opDeref = 0x06; + opConst1u = 0x08; /* 1 op, 1 byte const */ + opConst1s = 0x09; /* " signed */ + opConst2u = 0x0A; /* 1 op, 2 byte const */ + opConst2s = 0x0B; /* " signed */ + opConst4u = 0x0C; /* 1 op, 4 byte const */ + opConst4s = 0x0D; /* " signed */ + opConst8u = 0x0E; /* 1 op, 8 byte const */ + opConst8s = 0x0F; /* " signed */ + opConstu = 0x10; /* 1 op, LEB128 const */ + opConsts = 0x11; /* " signed */ + opDup = 0x12; + opDrop = 0x13; + opOver = 0x14; + opPick = 0x15; /* 1 op, 1 byte stack index */ + opSwap = 0x16; + opRot = 0x17; + opXderef = 0x18; + opAbs = 0x19; + opAnd = 0x1A; + opDiv = 0x1B; + opMinus = 0x1C; + opMod = 0x1D; + opMul = 0x1E; + opNeg = 0x1F; + opNot = 0x20; + opOr = 0x21; + opPlus = 0x22; + opPlusUconst = 0x23; /* 1 op, ULEB128 addend */ + opShl = 0x24; + opShr = 0x25; + opShra = 0x26; + opXor = 0x27; + opSkip = 0x2F; /* 1 op, signed 2-byte constant */ + opBra = 0x28; /* 1 op, signed 2-byte constant */ + opEq = 0x29; + opGe = 0x2A; + opGt = 0x2B; + opLe = 0x2C; + opLt = 0x2D; + opNe = 0x2E; + opLit0 = 0x30; + /* OpLitN = OpLit0 + N for N = 0..31 */ + opReg0 = 0x50; + /* OpRegN = OpReg0 + N for N = 0..31 */ + opBreg0 = 0x70; /* 1 op, signed LEB128 constant */ + /* OpBregN = OpBreg0 + N for N = 0..31 */ + opRegx = 0x90; /* 1 op, ULEB128 register */ + opFbreg = 0x91; /* 1 op, SLEB128 offset */ + opBregx = 0x92; /* 2 op, ULEB128 reg; SLEB128 off */ + opPiece = 0x93; /* 1 op, ULEB128 size of piece */ + opDerefSize = 0x94; /* 1-byte size of data retrieved */ + opXderefSize = 0x95; /* 1-byte size of data retrieved */ + opNop = 0x96; /* next four new in Dwarf v3 */ - opPushObjAddr = 0x97; - opCall2 = 0x98; /* 2-byte offset of DIE */ - opCall4 = 0x99; /* 4-byte offset of DIE */ - opCallRef = 0x9A /* 4- or 8- byte offset of DIE */ - /* 0xE0-0xFF reserved for user-specific */ + opPushObjAddr = 0x97; + opCall2 = 0x98; /* 2-byte offset of DIE */ + opCall4 = 0x99; /* 4-byte offset of DIE */ + opCallRef = 0x9A; /* 4- or 8- byte offset of DIE */ +/* 0xE0-0xFF reserved for user-specific */ ) // Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry. const ( - encAddress = 0x01; - encBoolean = 0x02; - encComplexFloat = 0x03; - encFloat = 0x04; - encSigned = 0x05; - encSignedChar = 0x06; - encUnsigned = 0x07; - encUnsignedChar = 0x08; - encImaginaryFloat = 0x09; + encAddress = 0x01; + encBoolean = 0x02; + encComplexFloat = 0x03; + encFloat = 0x04; + encSigned = 0x05; + encSignedChar = 0x06; + encUnsigned = 0x07; + encUnsignedChar = 0x08; + encImaginaryFloat = 0x09; ) diff --git a/src/pkg/debug/dwarf/entry.go b/src/pkg/debug/dwarf/entry.go index 986e098a80..0554a249bf 100644 --- a/src/pkg/debug/dwarf/entry.go +++ b/src/pkg/debug/dwarf/entry.go @@ -14,14 +14,14 @@ import "os" // a single entry's description: a sequence of attributes type abbrev struct { - tag Tag; - children bool; - field []afield; + tag Tag; + children bool; + field []afield; } type afield struct { - attr Attr; - fmt format; + attr Attr; + fmt format; } // a map from entry format ids to their descriptions @@ -92,16 +92,16 @@ func (d *Data) parseAbbrev(off uint32) (abbrevTable, os.Error) { // An entry is a sequence of attribute/value pairs. type Entry struct { - Offset Offset; // offset of Entry in DWARF info - Tag Tag; // tag (kind of Entry) - Children bool; // whether Entry is followed by children - Field []Field; + Offset Offset; // offset of Entry in DWARF info + Tag Tag; // tag (kind of Entry) + Children bool; // whether Entry is followed by children + Field []Field; } // A Field is a single attribute/value pair in an Entry. type Field struct { - Attr Attr; - Val interface{}; + Attr Attr; + Val interface{}; } // Val returns the value associated with attribute Attr in Entry, @@ -141,7 +141,7 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry { Offset: off, Tag: a.tag, Children: a.children, - Field: make([]Field, len(a.field)) + Field: make([]Field, len(a.field)), }; for i := range e.Field { e.Field[i].Attr = a.field[i].attr; @@ -149,7 +149,7 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry { if fmt == formIndirect { fmt = format(b.uint()); } - var val interface{}; + var val interface{} switch fmt { default: b.error("unknown entry attr format"); @@ -230,12 +230,12 @@ func (b *buf) entry(atab abbrevTable, ubase Offset) *Entry { // If an entry has children, its Children field will be true, and the children // follow, terminated by an Entry with Tag 0. type Reader struct { - b buf; - d *Data; - err os.Error; - unit int; - lastChildren bool; // .Children of last entry returned by Next - lastSibling Offset; // .Val(AttrSibling) of last entry returned by Next + b buf; + d *Data; + err os.Error; + unit int; + lastChildren bool; // .Children of last entry returned by Next + lastSibling Offset; // .Val(AttrSibling) of last entry returned by Next } // Reader returns a new Reader for Data. @@ -267,9 +267,9 @@ func (r *Reader) Seek(off Offset) { var u *unit; for i = range d.unit { u = &d.unit[i]; - if u.off <= off && off < u.off+Offset(len(u.data)) { + if u.off <= off && off < u.off + Offset(len(u.data)) { r.unit = i; - r.b = makeBuf(r.d, "info", off, u.data[off-u.off:len(u.data)], u.addrsize); + r.b = makeBuf(r.d, "info", off, u.data[off - u.off : len(u.data)], u.addrsize); return; } } @@ -278,7 +278,7 @@ func (r *Reader) Seek(off Offset) { // maybeNextUnit advances to the next unit if this one is finished. func (r *Reader) maybeNextUnit() { - for len(r.b.data) == 0 && r.unit+1 < len(r.d.unit) { + for len(r.b.data) == 0 && r.unit + 1 < len(r.d.unit) { r.unit++; u := &r.d.unit[r.unit]; r.b = makeBuf(r.d, "info", u.off, u.data, u.addrsize); @@ -318,7 +318,7 @@ func (r *Reader) Next() (*Entry, os.Error) { // the last Entry returned by Next. If that Entry did not have // children or Next has not been called, SkipChildren is a no-op. func (r *Reader) SkipChildren() { - if r.err != nil || !r.lastChildren{ + if r.err != nil || !r.lastChildren { return; } @@ -341,4 +341,3 @@ func (r *Reader) SkipChildren() { } } } - diff --git a/src/pkg/debug/dwarf/open.go b/src/pkg/debug/dwarf/open.go index 15d0b6ea6b..f2cfa4c930 100644 --- a/src/pkg/debug/dwarf/open.go +++ b/src/pkg/debug/dwarf/open.go @@ -16,21 +16,21 @@ import ( // loaded from an executable file (for example, an ELF or Mach-O executable). type Data struct { // raw data - abbrev []byte; - aranges []byte; - frame []byte; - info []byte; - line []byte; - pubnames []byte; - ranges []byte; - str []byte; + abbrev []byte; + aranges []byte; + frame []byte; + info []byte; + line []byte; + pubnames []byte; + ranges []byte; + str []byte; // parsed data - abbrevCache map[uint32] abbrevTable; - addrsize int; - order binary.ByteOrder; - typeCache map[Offset] Type; - unit []unit; + abbrevCache map[uint32]abbrevTable; + addrsize int; + order binary.ByteOrder; + typeCache map[Offset]Type; + unit []unit; } // New returns a new Data object initialized from the given parameters. diff --git a/src/pkg/debug/dwarf/type.go b/src/pkg/debug/dwarf/type.go index 63b63db04e..91334bdf29 100644 --- a/src/pkg/debug/dwarf/type.go +++ b/src/pkg/debug/dwarf/type.go @@ -25,8 +25,8 @@ type Type interface { // If a field is not known or not applicable for a given type, // the zero value is used. type CommonType struct { - ByteSize int64; // size of value of this type, in bytes - Name string; // name that can be used to refer to type + ByteSize int64; // size of value of this type, in bytes + Name string; // name that can be used to refer to type } func (c *CommonType) Common() *CommonType { @@ -42,8 +42,8 @@ func (c *CommonType) Size() int64 { // A BasicType holds fields common to all basic types. type BasicType struct { CommonType; - BitSize int64; - BitOffset int64; + BitSize int64; + BitOffset int64; } func (b *BasicType) Basic() *BasicType { @@ -54,7 +54,7 @@ func (t *BasicType) String() string { if t.Name != "" { return t.Name; } - return "?" + return "?"; } // A CharType represents a signed character type. @@ -102,8 +102,8 @@ type AddrType struct { // A QualType represents a type that has the C/C++ "const", "restrict", or "volatile" qualifier. type QualType struct { CommonType; - Qual string; - Type Type; + Qual string; + Type Type; } func (t *QualType) String() string { @@ -117,9 +117,9 @@ func (t *QualType) Size() int64 { // An ArrayType represents a fixed size array type. type ArrayType struct { CommonType; - Type Type; - StrideBitSize int64; // if > 0, number of bits to hold each element - Count int64; // if == -1, an incomplete array, like char x[]. + Type Type; + StrideBitSize int64; // if > 0, number of bits to hold each element + Count int64; // if == -1, an incomplete array, like char x[]. } func (t *ArrayType) String() string { @@ -142,7 +142,7 @@ func (t *VoidType) String() string { // A PtrType represents a pointer type. type PtrType struct { CommonType; - Type Type; + Type Type; } func (t *PtrType) String() string { @@ -152,20 +152,20 @@ func (t *PtrType) String() string { // A StructType represents a struct, union, or C++ class type. type StructType struct { CommonType; - StructName string; - Kind string; // "struct", "union", or "class". - Field []*StructField; - Incomplete bool; // if true, struct, union, class is declared but not defined + StructName string; + Kind string; // "struct", "union", or "class". + Field []*StructField; + Incomplete bool; // if true, struct, union, class is declared but not defined } // A StructField represents a field in a struct, union, or C++ class type. type StructField struct { - Name string; - Type Type; - ByteOffset int64; - ByteSize int64; - BitOffset int64; // within the ByteSize bytes at ByteOffset - BitSize int64; // zero if not a bit field + Name string; + Type Type; + ByteOffset int64; + ByteSize int64; + BitOffset int64; // within the ByteSize bytes at ByteOffset + BitSize int64; // zero if not a bit field } func (t *StructType) String() string { @@ -205,14 +205,14 @@ func (t *StructType) Defn() string { // (inside CommonType). type EnumType struct { CommonType; - EnumName string; - Val []*EnumValue; + EnumName string; + Val []*EnumValue; } // An EnumValue represents a single enumeration value. type EnumValue struct { - Name string; - Val int64; + Name string; + Val int64; } func (t *EnumType) String() string { @@ -234,8 +234,8 @@ func (t *EnumType) String() string { // A FuncType represents a function type. type FuncType struct { CommonType; - ReturnType Type; - ParamType []Type; + ReturnType Type; + ParamType []Type; } func (t *FuncType) String() string { @@ -265,7 +265,7 @@ func (t *DotDotDotType) String() string { // A TypedefType represents a named type. type TypedefType struct { CommonType; - Type Type; + Type Type; } func (t *TypedefType) String() string { @@ -358,7 +358,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) { case TagSubrangeType: max, ok := kid.Val(AttrUpperBound).(int64); if !ok { - max = -2; // Count == -1, as in x[]. + max = -2; // Count == -1, as in x[]. } if ndim == 0 { t.Count = max+1; @@ -415,7 +415,9 @@ func (d *Data) Type(off Offset) (Type, os.Error) { typ = new(UcharType); } d.typeCache[off] = typ; - t := typ.(interface{Basic() *BasicType}).Basic(); + t := typ.(interface { + Basic() *BasicType; + }).Basic(); t.Name = name; t.BitSize, _ = e.Val(AttrBitSize).(int64); t.BitOffset, _ = e.Val(AttrBitOffset).(int64); @@ -479,7 +481,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) { } t.Field = fld; } - t.Field = t.Field[0:n+1]; + t.Field = t.Field[0 : n+1]; t.Field[n] = f; } } @@ -530,7 +532,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) { } t.Val = val; } - t.Val = t.Val[0:n+1]; + t.Val = t.Val[0 : n+1]; t.Val[n] = f; } } @@ -586,7 +588,7 @@ func (d *Data) Type(off Offset) (Type, os.Error) { } t.ParamType = param; } - t.ParamType = t.ParamType[0:n+1]; + t.ParamType = t.ParamType[0 : n+1]; t.ParamType[n] = tkid; } diff --git a/src/pkg/debug/dwarf/type_test.go b/src/pkg/debug/dwarf/type_test.go index d3aa6aa632..22a00c21c5 100644 --- a/src/pkg/debug/dwarf/type_test.go +++ b/src/pkg/debug/dwarf/type_test.go @@ -5,13 +5,13 @@ package dwarf_test import ( - . "debug/dwarf"; - "debug/elf"; - "debug/macho"; - "testing"; + . "debug/dwarf"; + "debug/elf"; + "debug/macho"; + "testing"; ) -var typedefTests = map[string]string { +var typedefTests = map[string]string{ "t_ptr_volatile_int": "*volatile int", "t_ptr_const_char": "*const char", "t_long": "long int", @@ -26,8 +26,8 @@ var typedefTests = map[string]string { "t_my_union": "union my_union {vi volatile int@0; x char@0 : 1@7; y int@0 : 4@28; array [40]long long int@0}", "t_my_enum": "enum my_enum {e1=1; e2=2; e3=-5; e4=1000000000000000}", "t_my_list": "struct list {val short int@0; next *t_my_list@8}", - "t_my_tree": "struct tree {left *struct tree@0; right *struct tree@8; val long long unsigned int@16}" -}; + "t_my_tree": "struct tree {left *struct tree@0; right *struct tree@8; val long long unsigned int@16}", +} func elfData(t *testing.T, name string) *Data { f, err := elf.Open(name); diff --git a/src/pkg/debug/dwarf/unit.go b/src/pkg/debug/dwarf/unit.go index 040151f39d..d4bcf5889d 100644 --- a/src/pkg/debug/dwarf/unit.go +++ b/src/pkg/debug/dwarf/unit.go @@ -13,11 +13,11 @@ import ( // Each unit has its own abbreviation table and address size. type unit struct { - base Offset; // byte offset of header within the aggregate info - off Offset; // byte offset of data within the aggregate info - data []byte; - atable abbrevTable; - addrsize int; + base Offset; // byte offset of header within the aggregate info + off Offset; // byte offset of data within the aggregate info + data []byte; + atable abbrevTable; + addrsize int; } func (d *Data) parseUnits() ([]unit, os.Error) { @@ -53,11 +53,10 @@ func (d *Data) parseUnits() ([]unit, os.Error) { u.atable = atable; u.addrsize = int(b.uint8()); u.off = b.off; - u.data = b.bytes(int(n - (2+4+1))); + u.data = b.bytes(int(n-(2+4+1))); } if b.err != nil { return nil, b.err; } return units, nil; } - |
