1
2
3
4
5
6
7 package dwarf
8
9 import "strconv"
10
11
12 type Attr uint32
13
14 const (
15 AttrSibling Attr = 0x01
16 AttrLocation Attr = 0x02
17 AttrName Attr = 0x03
18 AttrOrdering Attr = 0x09
19 AttrByteSize Attr = 0x0B
20 AttrBitOffset Attr = 0x0C
21 AttrBitSize Attr = 0x0D
22 AttrStmtList Attr = 0x10
23 AttrLowpc Attr = 0x11
24 AttrHighpc Attr = 0x12
25 AttrLanguage Attr = 0x13
26 AttrDiscr Attr = 0x15
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
51 AttrCount Attr = 0x37
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
69 AttrType Attr = 0x49
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
87 )
88
89 var attrNames = [...]string{
90 AttrSibling: "Sibling",
91 AttrLocation: "Location",
92 AttrName: "Name",
93 AttrOrdering: "Ordering",
94 AttrByteSize: "ByteSize",
95 AttrBitOffset: "BitOffset",
96 AttrBitSize: "BitSize",
97 AttrStmtList: "StmtList",
98 AttrLowpc: "Lowpc",
99 AttrHighpc: "Highpc",
100 AttrLanguage: "Language",
101 AttrDiscr: "Discr",
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",
126 AttrCount: "Count",
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",
144 AttrType: "Type",
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",
162 }
163
164 func (a Attr) String() string {
165 if int(a) < len(attrNames) {
166 s := attrNames[a]
167 if s != "" {
168 return s
169 }
170 }
171 return strconv.Itoa(int(a))
172 }
173
174 func (a Attr) GoString() string {
175 if int(a) < len(attrNames) {
176 s := attrNames[a]
177 if s != "" {
178 return "dwarf.Attr" + s
179 }
180 }
181 return "dwarf.Attr(" + strconv.FormatInt(int64(a), 10) + ")"
182 }
183
184
185 type format uint32
186
187 const (
188
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
211 formSecOffset format = 0x17
212 formExprloc format = 0x18
213 formFlagPresent format = 0x19
214 formRefSig8 format = 0x20
215
216
217 formGnuRefAlt format = 0x1f20
218 formGnuStrpAlt format = 0x1f21
219 )
220
221
222 type Tag uint32
223
224 const (
225 TagArrayType Tag = 0x01
226 TagClassType Tag = 0x02
227 TagEntryPoint Tag = 0x03
228 TagEnumerationType Tag = 0x04
229 TagFormalParameter Tag = 0x05
230 TagImportedDeclaration Tag = 0x08
231 TagLabel Tag = 0x0A
232 TagLexDwarfBlock Tag = 0x0B
233 TagMember Tag = 0x0D
234 TagPointerType Tag = 0x0F
235 TagReferenceType Tag = 0x10
236 TagCompileUnit Tag = 0x11
237 TagStringType Tag = 0x12
238 TagStructType Tag = 0x13
239 TagSubroutineType Tag = 0x15
240 TagTypedef Tag = 0x16
241 TagUnionType Tag = 0x17
242 TagUnspecifiedParameters Tag = 0x18
243 TagVariant Tag = 0x19
244 TagCommonDwarfBlock Tag = 0x1A
245 TagCommonInclusion Tag = 0x1B
246 TagInheritance Tag = 0x1C
247 TagInlinedSubroutine Tag = 0x1D
248 TagModule Tag = 0x1E
249 TagPtrToMemberType Tag = 0x1F
250 TagSetType Tag = 0x20
251 TagSubrangeType Tag = 0x21
252 TagWithStmt Tag = 0x22
253 TagAccessDeclaration Tag = 0x23
254 TagBaseType Tag = 0x24
255 TagCatchDwarfBlock Tag = 0x25
256 TagConstType Tag = 0x26
257 TagConstant Tag = 0x27
258 TagEnumerator Tag = 0x28
259 TagFileType Tag = 0x29
260 TagFriend Tag = 0x2A
261 TagNamelist Tag = 0x2B
262 TagNamelistItem Tag = 0x2C
263 TagPackedType Tag = 0x2D
264 TagSubprogram Tag = 0x2E
265 TagTemplateTypeParameter Tag = 0x2F
266 TagTemplateValueParameter Tag = 0x30
267 TagThrownType Tag = 0x31
268 TagTryDwarfBlock Tag = 0x32
269 TagVariantPart Tag = 0x33
270 TagVariable Tag = 0x34
271 TagVolatileType Tag = 0x35
272
273 TagDwarfProcedure Tag = 0x36
274 TagRestrictType Tag = 0x37
275 TagInterfaceType Tag = 0x38
276 TagNamespace Tag = 0x39
277 TagImportedModule Tag = 0x3A
278 TagUnspecifiedType Tag = 0x3B
279 TagPartialUnit Tag = 0x3C
280 TagImportedUnit Tag = 0x3D
281 TagMutableType Tag = 0x3E
282 TagCondition Tag = 0x3F
283 TagSharedType Tag = 0x40
284
285 TagTypeUnit Tag = 0x41
286 TagRvalueReferenceType Tag = 0x42
287 TagTemplateAlias Tag = 0x43
288 )
289
290 var tagNames = [...]string{
291 TagArrayType: "ArrayType",
292 TagClassType: "ClassType",
293 TagEntryPoint: "EntryPoint",
294 TagEnumerationType: "EnumerationType",
295 TagFormalParameter: "FormalParameter",
296 TagImportedDeclaration: "ImportedDeclaration",
297 TagLabel: "Label",
298 TagLexDwarfBlock: "LexDwarfBlock",
299 TagMember: "Member",
300 TagPointerType: "PointerType",
301 TagReferenceType: "ReferenceType",
302 TagCompileUnit: "CompileUnit",
303 TagStringType: "StringType",
304 TagStructType: "StructType",
305 TagSubroutineType: "SubroutineType",
306 TagTypedef: "Typedef",
307 TagUnionType: "UnionType",
308 TagUnspecifiedParameters: "UnspecifiedParameters",
309 TagVariant: "Variant",
310 TagCommonDwarfBlock: "CommonDwarfBlock",
311 TagCommonInclusion: "CommonInclusion",
312 TagInheritance: "Inheritance",
313 TagInlinedSubroutine: "InlinedSubroutine",
314 TagModule: "Module",
315 TagPtrToMemberType: "PtrToMemberType",
316 TagSetType: "SetType",
317 TagSubrangeType: "SubrangeType",
318 TagWithStmt: "WithStmt",
319 TagAccessDeclaration: "AccessDeclaration",
320 TagBaseType: "BaseType",
321 TagCatchDwarfBlock: "CatchDwarfBlock",
322 TagConstType: "ConstType",
323 TagConstant: "Constant",
324 TagEnumerator: "Enumerator",
325 TagFileType: "FileType",
326 TagFriend: "Friend",
327 TagNamelist: "Namelist",
328 TagNamelistItem: "NamelistItem",
329 TagPackedType: "PackedType",
330 TagSubprogram: "Subprogram",
331 TagTemplateTypeParameter: "TemplateTypeParameter",
332 TagTemplateValueParameter: "TemplateValueParameter",
333 TagThrownType: "ThrownType",
334 TagTryDwarfBlock: "TryDwarfBlock",
335 TagVariantPart: "VariantPart",
336 TagVariable: "Variable",
337 TagVolatileType: "VolatileType",
338 TagDwarfProcedure: "DwarfProcedure",
339 TagRestrictType: "RestrictType",
340 TagInterfaceType: "InterfaceType",
341 TagNamespace: "Namespace",
342 TagImportedModule: "ImportedModule",
343 TagUnspecifiedType: "UnspecifiedType",
344 TagPartialUnit: "PartialUnit",
345 TagImportedUnit: "ImportedUnit",
346 TagMutableType: "MutableType",
347 TagCondition: "Condition",
348 TagSharedType: "SharedType",
349 TagTypeUnit: "TypeUnit",
350 TagRvalueReferenceType: "RvalueReferenceType",
351 TagTemplateAlias: "TemplateAlias",
352 }
353
354 func (t Tag) String() string {
355 if int(t) < len(tagNames) {
356 s := tagNames[t]
357 if s != "" {
358 return s
359 }
360 }
361 return strconv.Itoa(int(t))
362 }
363
364 func (t Tag) GoString() string {
365 if int(t) < len(tagNames) {
366 s := tagNames[t]
367 if s != "" {
368 return "dwarf.Tag" + s
369 }
370 }
371 return "dwarf.Tag(" + strconv.FormatInt(int64(t), 10) + ")"
372 }
373
374
375
376
377
378
379 const (
380 opAddr = 0x03
381 opDeref = 0x06
382 opConst1u = 0x08
383 opConst1s = 0x09
384 opConst2u = 0x0A
385 opConst2s = 0x0B
386 opConst4u = 0x0C
387 opConst4s = 0x0D
388 opConst8u = 0x0E
389 opConst8s = 0x0F
390 opConstu = 0x10
391 opConsts = 0x11
392 opDup = 0x12
393 opDrop = 0x13
394 opOver = 0x14
395 opPick = 0x15
396 opSwap = 0x16
397 opRot = 0x17
398 opXderef = 0x18
399 opAbs = 0x19
400 opAnd = 0x1A
401 opDiv = 0x1B
402 opMinus = 0x1C
403 opMod = 0x1D
404 opMul = 0x1E
405 opNeg = 0x1F
406 opNot = 0x20
407 opOr = 0x21
408 opPlus = 0x22
409 opPlusUconst = 0x23
410 opShl = 0x24
411 opShr = 0x25
412 opShra = 0x26
413 opXor = 0x27
414 opSkip = 0x2F
415 opBra = 0x28
416 opEq = 0x29
417 opGe = 0x2A
418 opGt = 0x2B
419 opLe = 0x2C
420 opLt = 0x2D
421 opNe = 0x2E
422 opLit0 = 0x30
423
424 opReg0 = 0x50
425
426 opBreg0 = 0x70
427
428 opRegx = 0x90
429 opFbreg = 0x91
430 opBregx = 0x92
431 opPiece = 0x93
432 opDerefSize = 0x94
433 opXderefSize = 0x95
434 opNop = 0x96
435
436 opPushObjAddr = 0x97
437 opCall2 = 0x98
438 opCall4 = 0x99
439 opCallRef = 0x9A
440
441 )
442
443
444 const (
445 encAddress = 0x01
446 encBoolean = 0x02
447 encComplexFloat = 0x03
448 encFloat = 0x04
449 encSigned = 0x05
450 encSignedChar = 0x06
451 encUnsigned = 0x07
452 encUnsignedChar = 0x08
453 encImaginaryFloat = 0x09
454 )
455
456
457 const (
458 lnsCopy = 1
459 lnsAdvancePC = 2
460 lnsAdvanceLine = 3
461 lnsSetFile = 4
462 lnsSetColumn = 5
463 lnsNegateStmt = 6
464 lnsSetBasicBlock = 7
465 lnsConstAddPC = 8
466 lnsFixedAdvancePC = 9
467
468
469 lnsSetPrologueEnd = 10
470 lnsSetEpilogueBegin = 11
471 lnsSetISA = 12
472 )
473
474
475 const (
476 lneEndSequence = 1
477 lneSetAddress = 2
478 lneDefineFile = 3
479
480
481 lneSetDiscriminator = 4
482 )
483
View as plain text