1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 // An Attr identifies the attribute type in a DWARF Entry's Field.
15 AttrSibling Attr
= 0x01
16 AttrLocation Attr
= 0x02
18 AttrOrdering Attr
= 0x09
19 AttrByteSize Attr
= 0x0B
20 AttrBitOffset Attr
= 0x0C
21 AttrBitSize Attr
= 0x0D
22 AttrStmtList Attr
= 0x10
24 AttrHighpc Attr
= 0x12
25 AttrLanguage Attr
= 0x13
27 AttrDiscrValue Attr
= 0x16
28 AttrVisibility Attr
= 0x17
29 AttrImport Attr
= 0x18
30 AttrStringLength Attr
= 0x19
31 AttrCommonRef Attr
= 0x1A
32 AttrCompDir Attr
= 0x1B
33 AttrConstValue Attr
= 0x1C
34 AttrContainingType Attr
= 0x1D
35 AttrDefaultValue Attr
= 0x1E
36 AttrInline Attr
= 0x20
37 AttrIsOptional Attr
= 0x21
38 AttrLowerBound Attr
= 0x22
39 AttrProducer Attr
= 0x25
40 AttrPrototyped Attr
= 0x27
41 AttrReturnAddr Attr
= 0x2A
42 AttrStartScope Attr
= 0x2C
43 AttrStrideSize Attr
= 0x2E
44 AttrUpperBound Attr
= 0x2F
45 AttrAbstractOrigin Attr
= 0x31
46 AttrAccessibility Attr
= 0x32
47 AttrAddrClass Attr
= 0x33
48 AttrArtificial Attr
= 0x34
49 AttrBaseTypes Attr
= 0x35
50 AttrCalling Attr
= 0x36
52 AttrDataMemberLoc Attr
= 0x38
53 AttrDeclColumn Attr
= 0x39
54 AttrDeclFile Attr
= 0x3A
55 AttrDeclLine Attr
= 0x3B
56 AttrDeclaration Attr
= 0x3C
57 AttrDiscrList Attr
= 0x3D
58 AttrEncoding Attr
= 0x3E
59 AttrExternal Attr
= 0x3F
60 AttrFrameBase Attr
= 0x40
61 AttrFriend Attr
= 0x41
62 AttrIdentifierCase Attr
= 0x42
63 AttrMacroInfo Attr
= 0x43
64 AttrNamelistItem Attr
= 0x44
65 AttrPriority Attr
= 0x45
66 AttrSegment Attr
= 0x46
67 AttrSpecification Attr
= 0x47
68 AttrStaticLink Attr
= 0x48
70 AttrUseLocation Attr
= 0x4A
71 AttrVarParam Attr
= 0x4B
72 AttrVirtuality Attr
= 0x4C
73 AttrVtableElemLoc Attr
= 0x4D
74 AttrAllocated Attr
= 0x4E
75 AttrAssociated Attr
= 0x4F
76 AttrDataLocation Attr
= 0x50
77 AttrStride Attr
= 0x51
78 AttrEntrypc Attr
= 0x52
79 AttrUseUTF8 Attr
= 0x53
80 AttrExtension Attr
= 0x54
81 AttrRanges Attr
= 0x55
82 AttrTrampoline Attr
= 0x56
83 AttrCallColumn Attr
= 0x57
84 AttrCallFile Attr
= 0x58
85 AttrCallLine Attr
= 0x59
86 AttrDescription Attr
= 0x5A
89 var attrNames
= [...]string{
90 AttrSibling
: "Sibling",
91 AttrLocation
: "Location",
93 AttrOrdering
: "Ordering",
94 AttrByteSize
: "ByteSize",
95 AttrBitOffset
: "BitOffset",
96 AttrBitSize
: "BitSize",
97 AttrStmtList
: "StmtList",
100 AttrLanguage
: "Language",
102 AttrDiscrValue
: "DiscrValue",
103 AttrVisibility
: "Visibility",
104 AttrImport
: "Import",
105 AttrStringLength
: "StringLength",
106 AttrCommonRef
: "CommonRef",
107 AttrCompDir
: "CompDir",
108 AttrConstValue
: "ConstValue",
109 AttrContainingType
: "ContainingType",
110 AttrDefaultValue
: "DefaultValue",
111 AttrInline
: "Inline",
112 AttrIsOptional
: "IsOptional",
113 AttrLowerBound
: "LowerBound",
114 AttrProducer
: "Producer",
115 AttrPrototyped
: "Prototyped",
116 AttrReturnAddr
: "ReturnAddr",
117 AttrStartScope
: "StartScope",
118 AttrStrideSize
: "StrideSize",
119 AttrUpperBound
: "UpperBound",
120 AttrAbstractOrigin
: "AbstractOrigin",
121 AttrAccessibility
: "Accessibility",
122 AttrAddrClass
: "AddrClass",
123 AttrArtificial
: "Artificial",
124 AttrBaseTypes
: "BaseTypes",
125 AttrCalling
: "Calling",
127 AttrDataMemberLoc
: "DataMemberLoc",
128 AttrDeclColumn
: "DeclColumn",
129 AttrDeclFile
: "DeclFile",
130 AttrDeclLine
: "DeclLine",
131 AttrDeclaration
: "Declaration",
132 AttrDiscrList
: "DiscrList",
133 AttrEncoding
: "Encoding",
134 AttrExternal
: "External",
135 AttrFrameBase
: "FrameBase",
136 AttrFriend
: "Friend",
137 AttrIdentifierCase
: "IdentifierCase",
138 AttrMacroInfo
: "MacroInfo",
139 AttrNamelistItem
: "NamelistItem",
140 AttrPriority
: "Priority",
141 AttrSegment
: "Segment",
142 AttrSpecification
: "Specification",
143 AttrStaticLink
: "StaticLink",
145 AttrUseLocation
: "UseLocation",
146 AttrVarParam
: "VarParam",
147 AttrVirtuality
: "Virtuality",
148 AttrVtableElemLoc
: "VtableElemLoc",
149 AttrAllocated
: "Allocated",
150 AttrAssociated
: "Associated",
151 AttrDataLocation
: "DataLocation",
152 AttrStride
: "Stride",
153 AttrEntrypc
: "Entrypc",
154 AttrUseUTF8
: "UseUTF8",
155 AttrExtension
: "Extension",
156 AttrRanges
: "Ranges",
157 AttrTrampoline
: "Trampoline",
158 AttrCallColumn
: "CallColumn",
159 AttrCallFile
: "CallFile",
160 AttrCallLine
: "CallLine",
161 AttrDescription
: "Description",
164 func (a Attr
) String() string {
165 if int(a
) < len(attrNames
) {
171 return strconv
.Itoa(int(a
))
174 func (a Attr
) GoString() string {
175 if int(a
) < len(attrNames
) {
178 return "dwarf.Attr" + s
181 return "dwarf.Attr(" + strconv
.FormatInt(int64(a
), 10) + ")"
184 // A format is a DWARF data encoding format.
189 formAddr format
= 0x01
190 formDwarfBlock2 format
= 0x03
191 formDwarfBlock4 format
= 0x04
192 formData2 format
= 0x05
193 formData4 format
= 0x06
194 formData8 format
= 0x07
195 formString format
= 0x08
196 formDwarfBlock format
= 0x09
197 formDwarfBlock1 format
= 0x0A
198 formData1 format
= 0x0B
199 formFlag format
= 0x0C
200 formSdata format
= 0x0D
201 formStrp format
= 0x0E
202 formUdata format
= 0x0F
203 formRefAddr format
= 0x10
204 formRef1 format
= 0x11
205 formRef2 format
= 0x12
206 formRef4 format
= 0x13
207 formRef8 format
= 0x14
208 formRefUdata format
= 0x15
209 formIndirect format
= 0x16
210 // The following are new in DWARF 4.
211 formSecOffset format
= 0x17
212 formExprloc format
= 0x18
213 formFlagPresent format
= 0x19
214 formRefSig8 format
= 0x20
217 // A Tag is the classification (the type) of an Entry.
221 TagArrayType Tag
= 0x01
222 TagClassType Tag
= 0x02
223 TagEntryPoint Tag
= 0x03
224 TagEnumerationType Tag
= 0x04
225 TagFormalParameter Tag
= 0x05
226 TagImportedDeclaration Tag
= 0x08
228 TagLexDwarfBlock Tag
= 0x0B
230 TagPointerType Tag
= 0x0F
231 TagReferenceType Tag
= 0x10
232 TagCompileUnit Tag
= 0x11
233 TagStringType Tag
= 0x12
234 TagStructType Tag
= 0x13
235 TagSubroutineType Tag
= 0x15
236 TagTypedef Tag
= 0x16
237 TagUnionType Tag
= 0x17
238 TagUnspecifiedParameters Tag
= 0x18
239 TagVariant Tag
= 0x19
240 TagCommonDwarfBlock Tag
= 0x1A
241 TagCommonInclusion Tag
= 0x1B
242 TagInheritance Tag
= 0x1C
243 TagInlinedSubroutine Tag
= 0x1D
245 TagPtrToMemberType Tag
= 0x1F
246 TagSetType Tag
= 0x20
247 TagSubrangeType Tag
= 0x21
248 TagWithStmt Tag
= 0x22
249 TagAccessDeclaration Tag
= 0x23
250 TagBaseType Tag
= 0x24
251 TagCatchDwarfBlock Tag
= 0x25
252 TagConstType Tag
= 0x26
253 TagConstant Tag
= 0x27
254 TagEnumerator Tag
= 0x28
255 TagFileType Tag
= 0x29
257 TagNamelist Tag
= 0x2B
258 TagNamelistItem Tag
= 0x2C
259 TagPackedType Tag
= 0x2D
260 TagSubprogram Tag
= 0x2E
261 TagTemplateTypeParameter Tag
= 0x2F
262 TagTemplateValueParameter Tag
= 0x30
263 TagThrownType Tag
= 0x31
264 TagTryDwarfBlock Tag
= 0x32
265 TagVariantPart Tag
= 0x33
266 TagVariable Tag
= 0x34
267 TagVolatileType Tag
= 0x35
268 // The following are new in DWARF 3.
269 TagDwarfProcedure Tag
= 0x36
270 TagRestrictType Tag
= 0x37
271 TagInterfaceType Tag
= 0x38
272 TagNamespace Tag
= 0x39
273 TagImportedModule Tag
= 0x3A
274 TagUnspecifiedType Tag
= 0x3B
275 TagPartialUnit Tag
= 0x3C
276 TagImportedUnit Tag
= 0x3D
277 TagMutableType Tag
= 0x3E // Later removed from DWARF.
278 TagCondition Tag
= 0x3F
279 TagSharedType Tag
= 0x40
280 // The following are new in DWARF 4.
281 TagTypeUnit Tag
= 0x41
282 TagRvalueReferenceType Tag
= 0x42
283 TagTemplateAlias Tag
= 0x43
286 var tagNames
= [...]string{
287 TagArrayType
: "ArrayType",
288 TagClassType
: "ClassType",
289 TagEntryPoint
: "EntryPoint",
290 TagEnumerationType
: "EnumerationType",
291 TagFormalParameter
: "FormalParameter",
292 TagImportedDeclaration
: "ImportedDeclaration",
294 TagLexDwarfBlock
: "LexDwarfBlock",
296 TagPointerType
: "PointerType",
297 TagReferenceType
: "ReferenceType",
298 TagCompileUnit
: "CompileUnit",
299 TagStringType
: "StringType",
300 TagStructType
: "StructType",
301 TagSubroutineType
: "SubroutineType",
302 TagTypedef
: "Typedef",
303 TagUnionType
: "UnionType",
304 TagUnspecifiedParameters
: "UnspecifiedParameters",
305 TagVariant
: "Variant",
306 TagCommonDwarfBlock
: "CommonDwarfBlock",
307 TagCommonInclusion
: "CommonInclusion",
308 TagInheritance
: "Inheritance",
309 TagInlinedSubroutine
: "InlinedSubroutine",
311 TagPtrToMemberType
: "PtrToMemberType",
312 TagSetType
: "SetType",
313 TagSubrangeType
: "SubrangeType",
314 TagWithStmt
: "WithStmt",
315 TagAccessDeclaration
: "AccessDeclaration",
316 TagBaseType
: "BaseType",
317 TagCatchDwarfBlock
: "CatchDwarfBlock",
318 TagConstType
: "ConstType",
319 TagConstant
: "Constant",
320 TagEnumerator
: "Enumerator",
321 TagFileType
: "FileType",
323 TagNamelist
: "Namelist",
324 TagNamelistItem
: "NamelistItem",
325 TagPackedType
: "PackedType",
326 TagSubprogram
: "Subprogram",
327 TagTemplateTypeParameter
: "TemplateTypeParameter",
328 TagTemplateValueParameter
: "TemplateValueParameter",
329 TagThrownType
: "ThrownType",
330 TagTryDwarfBlock
: "TryDwarfBlock",
331 TagVariantPart
: "VariantPart",
332 TagVariable
: "Variable",
333 TagVolatileType
: "VolatileType",
334 TagDwarfProcedure
: "DwarfProcedure",
335 TagRestrictType
: "RestrictType",
336 TagInterfaceType
: "InterfaceType",
337 TagNamespace
: "Namespace",
338 TagImportedModule
: "ImportedModule",
339 TagUnspecifiedType
: "UnspecifiedType",
340 TagPartialUnit
: "PartialUnit",
341 TagImportedUnit
: "ImportedUnit",
342 TagMutableType
: "MutableType",
343 TagCondition
: "Condition",
344 TagSharedType
: "SharedType",
345 TagTypeUnit
: "TypeUnit",
346 TagRvalueReferenceType
: "RvalueReferenceType",
347 TagTemplateAlias
: "TemplateAlias",
350 func (t Tag
) String() string {
351 if int(t
) < len(tagNames
) {
357 return strconv
.Itoa(int(t
))
360 func (t Tag
) GoString() string {
361 if int(t
) < len(tagNames
) {
364 return "dwarf.Tag" + s
367 return "dwarf.Tag(" + strconv
.FormatInt(int64(t
), 10) + ")"
370 // Location expression operators.
371 // The debug info encodes value locations like 8(R3)
372 // as a sequence of these op codes.
373 // This package does not implement full expressions;
374 // the opPlusUconst operator is expected by the type parser.
376 opAddr
= 0x03 /* 1 op, const addr */
378 opConst1u
= 0x08 /* 1 op, 1 byte const */
379 opConst1s
= 0x09 /* " signed */
380 opConst2u
= 0x0A /* 1 op, 2 byte const */
381 opConst2s
= 0x0B /* " signed */
382 opConst4u
= 0x0C /* 1 op, 4 byte const */
383 opConst4s
= 0x0D /* " signed */
384 opConst8u
= 0x0E /* 1 op, 8 byte const */
385 opConst8s
= 0x0F /* " signed */
386 opConstu
= 0x10 /* 1 op, LEB128 const */
387 opConsts
= 0x11 /* " signed */
391 opPick
= 0x15 /* 1 op, 1 byte stack index */
405 opPlusUconst
= 0x23 /* 1 op, ULEB128 addend */
410 opSkip
= 0x2F /* 1 op, signed 2-byte constant */
411 opBra
= 0x28 /* 1 op, signed 2-byte constant */
419 /* OpLitN = OpLit0 + N for N = 0..31 */
421 /* OpRegN = OpReg0 + N for N = 0..31 */
422 opBreg0
= 0x70 /* 1 op, signed LEB128 constant */
423 /* OpBregN = OpBreg0 + N for N = 0..31 */
424 opRegx
= 0x90 /* 1 op, ULEB128 register */
425 opFbreg
= 0x91 /* 1 op, SLEB128 offset */
426 opBregx
= 0x92 /* 2 op, ULEB128 reg; SLEB128 off */
427 opPiece
= 0x93 /* 1 op, ULEB128 size of piece */
428 opDerefSize
= 0x94 /* 1-byte size of data retrieved */
429 opXderefSize
= 0x95 /* 1-byte size of data retrieved */
431 /* next four new in Dwarf v3 */
433 opCall2
= 0x98 /* 2-byte offset of DIE */
434 opCall4
= 0x99 /* 4-byte offset of DIE */
435 opCallRef
= 0x9A /* 4- or 8- byte offset of DIE */
436 /* 0xE0-0xFF reserved for user-specific */
439 // Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry.
443 encComplexFloat
= 0x03
448 encUnsignedChar
= 0x08
449 encImaginaryFloat
= 0x09
452 // Line number opcodes.
461 LineSetBasicBlock
= 7
463 LineFixedAdvancePC
= 9
464 // next 3 are DWARF 3
465 LineSetPrologueEnd
= 10
466 LineSetEpilogueBegin
= 11
470 // Line number extended opcodes.
472 LineExtEndSequence
= 1
473 LineExtSetAddress
= 2
474 LineExtDefineFile
= 3
476 LineExtSetDiscriminator
= 4