Source file src/debug/dwarf/const.go

     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.
     4  
     5  // Constants
     6  
     7  package dwarf
     8  
     9  //go:generate stringer -type Attr -trimprefix=Attr
    10  
    11  // An Attr identifies the attribute type in a DWARF Entry's Field.
    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  	// The following are new in DWARF 3.
    75  	AttrAllocated     Attr = 0x4E
    76  	AttrAssociated    Attr = 0x4F
    77  	AttrDataLocation  Attr = 0x50
    78  	AttrStride        Attr = 0x51
    79  	AttrEntrypc       Attr = 0x52
    80  	AttrUseUTF8       Attr = 0x53
    81  	AttrExtension     Attr = 0x54
    82  	AttrRanges        Attr = 0x55
    83  	AttrTrampoline    Attr = 0x56
    84  	AttrCallColumn    Attr = 0x57
    85  	AttrCallFile      Attr = 0x58
    86  	AttrCallLine      Attr = 0x59
    87  	AttrDescription   Attr = 0x5A
    88  	AttrBinaryScale   Attr = 0x5B
    89  	AttrDecimalScale  Attr = 0x5C
    90  	AttrSmall         Attr = 0x5D
    91  	AttrDecimalSign   Attr = 0x5E
    92  	AttrDigitCount    Attr = 0x5F
    93  	AttrPictureString Attr = 0x60
    94  	AttrMutable       Attr = 0x61
    95  	AttrThreadsScaled Attr = 0x62
    96  	AttrExplicit      Attr = 0x63
    97  	AttrObjectPointer Attr = 0x64
    98  	AttrEndianity     Attr = 0x65
    99  	AttrElemental     Attr = 0x66
   100  	AttrPure          Attr = 0x67
   101  	AttrRecursive     Attr = 0x68
   102  	// The following are new in DWARF 4.
   103  	AttrSignature      Attr = 0x69
   104  	AttrMainSubprogram Attr = 0x6A
   105  	AttrDataBitOffset  Attr = 0x6B
   106  	AttrConstExpr      Attr = 0x6C
   107  	AttrEnumClass      Attr = 0x6D
   108  	AttrLinkageName    Attr = 0x6E
   109  	// The following are new in DWARF 5.
   110  	AttrStringLengthBitSize  Attr = 0x6F
   111  	AttrStringLengthByteSize Attr = 0x70
   112  	AttrRank                 Attr = 0x71
   113  	AttrStrOffsetsBase       Attr = 0x72
   114  	AttrAddrBase             Attr = 0x73
   115  	AttrRnglistsBase         Attr = 0x74
   116  	AttrDwoName              Attr = 0x76
   117  	AttrReference            Attr = 0x77
   118  	AttrRvalueReference      Attr = 0x78
   119  	AttrMacros               Attr = 0x79
   120  	AttrCallAllCalls         Attr = 0x7A
   121  	AttrCallAllSourceCalls   Attr = 0x7B
   122  	AttrCallAllTailCalls     Attr = 0x7C
   123  	AttrCallReturnPC         Attr = 0x7D
   124  	AttrCallValue            Attr = 0x7E
   125  	AttrCallOrigin           Attr = 0x7F
   126  	AttrCallParameter        Attr = 0x80
   127  	AttrCallPC               Attr = 0x81
   128  	AttrCallTailCall         Attr = 0x82
   129  	AttrCallTarget           Attr = 0x83
   130  	AttrCallTargetClobbered  Attr = 0x84
   131  	AttrCallDataLocation     Attr = 0x85
   132  	AttrCallDataValue        Attr = 0x86
   133  	AttrNoreturn             Attr = 0x87
   134  	AttrAlignment            Attr = 0x88
   135  	AttrExportSymbols        Attr = 0x89
   136  	AttrDeleted              Attr = 0x8A
   137  	AttrDefaulted            Attr = 0x8B
   138  	AttrLoclistsBase         Attr = 0x8C
   139  )
   140  
   141  func (a Attr) GoString() string {
   142  	if str, ok := _Attr_map[a]; ok {
   143  		return "dwarf.Attr" + str
   144  	}
   145  	return "dwarf." + a.String()
   146  }
   147  
   148  // A format is a DWARF data encoding format.
   149  type format uint32
   150  
   151  const (
   152  	// value formats
   153  	formAddr        format = 0x01
   154  	formDwarfBlock2 format = 0x03
   155  	formDwarfBlock4 format = 0x04
   156  	formData2       format = 0x05
   157  	formData4       format = 0x06
   158  	formData8       format = 0x07
   159  	formString      format = 0x08
   160  	formDwarfBlock  format = 0x09
   161  	formDwarfBlock1 format = 0x0A
   162  	formData1       format = 0x0B
   163  	formFlag        format = 0x0C
   164  	formSdata       format = 0x0D
   165  	formStrp        format = 0x0E
   166  	formUdata       format = 0x0F
   167  	formRefAddr     format = 0x10
   168  	formRef1        format = 0x11
   169  	formRef2        format = 0x12
   170  	formRef4        format = 0x13
   171  	formRef8        format = 0x14
   172  	formRefUdata    format = 0x15
   173  	formIndirect    format = 0x16
   174  	// The following are new in DWARF 4.
   175  	formSecOffset   format = 0x17
   176  	formExprloc     format = 0x18
   177  	formFlagPresent format = 0x19
   178  	formRefSig8     format = 0x20
   179  	// The following are new in DWARF 5.
   180  	formStrx          format = 0x1A
   181  	formAddrx         format = 0x1B
   182  	formRefSup4       format = 0x1C
   183  	formStrpSup       format = 0x1D
   184  	formData16        format = 0x1E
   185  	formLineStrp      format = 0x1F
   186  	formImplicitConst format = 0x21
   187  	formLoclistx      format = 0x22
   188  	formRnglistx      format = 0x23
   189  	formRefSup8       format = 0x24
   190  	formStrx1         format = 0x25
   191  	formStrx2         format = 0x26
   192  	formStrx3         format = 0x27
   193  	formStrx4         format = 0x28
   194  	formAddrx1        format = 0x29
   195  	formAddrx2        format = 0x2A
   196  	formAddrx3        format = 0x2B
   197  	formAddrx4        format = 0x2C
   198  	// Extensions for multi-file compression (.dwz)
   199  	// http://www.dwarfstd.org/ShowIssue.php?issue=120604.1
   200  	formGnuRefAlt  format = 0x1f20
   201  	formGnuStrpAlt format = 0x1f21
   202  )
   203  
   204  //go:generate stringer -type Tag -trimprefix=Tag
   205  
   206  // A Tag is the classification (the type) of an Entry.
   207  type Tag uint32
   208  
   209  const (
   210  	TagArrayType              Tag = 0x01
   211  	TagClassType              Tag = 0x02
   212  	TagEntryPoint             Tag = 0x03
   213  	TagEnumerationType        Tag = 0x04
   214  	TagFormalParameter        Tag = 0x05
   215  	TagImportedDeclaration    Tag = 0x08
   216  	TagLabel                  Tag = 0x0A
   217  	TagLexDwarfBlock          Tag = 0x0B
   218  	TagMember                 Tag = 0x0D
   219  	TagPointerType            Tag = 0x0F
   220  	TagReferenceType          Tag = 0x10
   221  	TagCompileUnit            Tag = 0x11
   222  	TagStringType             Tag = 0x12
   223  	TagStructType             Tag = 0x13
   224  	TagSubroutineType         Tag = 0x15
   225  	TagTypedef                Tag = 0x16
   226  	TagUnionType              Tag = 0x17
   227  	TagUnspecifiedParameters  Tag = 0x18
   228  	TagVariant                Tag = 0x19
   229  	TagCommonDwarfBlock       Tag = 0x1A
   230  	TagCommonInclusion        Tag = 0x1B
   231  	TagInheritance            Tag = 0x1C
   232  	TagInlinedSubroutine      Tag = 0x1D
   233  	TagModule                 Tag = 0x1E
   234  	TagPtrToMemberType        Tag = 0x1F
   235  	TagSetType                Tag = 0x20
   236  	TagSubrangeType           Tag = 0x21
   237  	TagWithStmt               Tag = 0x22
   238  	TagAccessDeclaration      Tag = 0x23
   239  	TagBaseType               Tag = 0x24
   240  	TagCatchDwarfBlock        Tag = 0x25
   241  	TagConstType              Tag = 0x26
   242  	TagConstant               Tag = 0x27
   243  	TagEnumerator             Tag = 0x28
   244  	TagFileType               Tag = 0x29
   245  	TagFriend                 Tag = 0x2A
   246  	TagNamelist               Tag = 0x2B
   247  	TagNamelistItem           Tag = 0x2C
   248  	TagPackedType             Tag = 0x2D
   249  	TagSubprogram             Tag = 0x2E
   250  	TagTemplateTypeParameter  Tag = 0x2F
   251  	TagTemplateValueParameter Tag = 0x30
   252  	TagThrownType             Tag = 0x31
   253  	TagTryDwarfBlock          Tag = 0x32
   254  	TagVariantPart            Tag = 0x33
   255  	TagVariable               Tag = 0x34
   256  	TagVolatileType           Tag = 0x35
   257  	// The following are new in DWARF 3.
   258  	TagDwarfProcedure  Tag = 0x36
   259  	TagRestrictType    Tag = 0x37
   260  	TagInterfaceType   Tag = 0x38
   261  	TagNamespace       Tag = 0x39
   262  	TagImportedModule  Tag = 0x3A
   263  	TagUnspecifiedType Tag = 0x3B
   264  	TagPartialUnit     Tag = 0x3C
   265  	TagImportedUnit    Tag = 0x3D
   266  	TagMutableType     Tag = 0x3E // Later removed from DWARF.
   267  	TagCondition       Tag = 0x3F
   268  	TagSharedType      Tag = 0x40
   269  	// The following are new in DWARF 4.
   270  	TagTypeUnit            Tag = 0x41
   271  	TagRvalueReferenceType Tag = 0x42
   272  	TagTemplateAlias       Tag = 0x43
   273  	// The following are new in DWARF 5.
   274  	TagCoarrayType       Tag = 0x44
   275  	TagGenericSubrange   Tag = 0x45
   276  	TagDynamicType       Tag = 0x46
   277  	TagAtomicType        Tag = 0x47
   278  	TagCallSite          Tag = 0x48
   279  	TagCallSiteParameter Tag = 0x49
   280  	TagSkeletonUnit      Tag = 0x4A
   281  	TagImmutableType     Tag = 0x4B
   282  )
   283  
   284  func (t Tag) GoString() string {
   285  	if t <= TagTemplateAlias {
   286  		return "dwarf.Tag" + t.String()
   287  	}
   288  	return "dwarf." + t.String()
   289  }
   290  
   291  // Location expression operators.
   292  // The debug info encodes value locations like 8(R3)
   293  // as a sequence of these op codes.
   294  // This package does not implement full expressions;
   295  // the opPlusUconst operator is expected by the type parser.
   296  const (
   297  	opAddr       = 0x03 /* 1 op, const addr */
   298  	opDeref      = 0x06
   299  	opConst1u    = 0x08 /* 1 op, 1 byte const */
   300  	opConst1s    = 0x09 /*	" signed */
   301  	opConst2u    = 0x0A /* 1 op, 2 byte const  */
   302  	opConst2s    = 0x0B /*	" signed */
   303  	opConst4u    = 0x0C /* 1 op, 4 byte const */
   304  	opConst4s    = 0x0D /*	" signed */
   305  	opConst8u    = 0x0E /* 1 op, 8 byte const */
   306  	opConst8s    = 0x0F /*	" signed */
   307  	opConstu     = 0x10 /* 1 op, LEB128 const */
   308  	opConsts     = 0x11 /*	" signed */
   309  	opDup        = 0x12
   310  	opDrop       = 0x13
   311  	opOver       = 0x14
   312  	opPick       = 0x15 /* 1 op, 1 byte stack index */
   313  	opSwap       = 0x16
   314  	opRot        = 0x17
   315  	opXderef     = 0x18
   316  	opAbs        = 0x19
   317  	opAnd        = 0x1A
   318  	opDiv        = 0x1B
   319  	opMinus      = 0x1C
   320  	opMod        = 0x1D
   321  	opMul        = 0x1E
   322  	opNeg        = 0x1F
   323  	opNot        = 0x20
   324  	opOr         = 0x21
   325  	opPlus       = 0x22
   326  	opPlusUconst = 0x23 /* 1 op, ULEB128 addend */
   327  	opShl        = 0x24
   328  	opShr        = 0x25
   329  	opShra       = 0x26
   330  	opXor        = 0x27
   331  	opSkip       = 0x2F /* 1 op, signed 2-byte constant */
   332  	opBra        = 0x28 /* 1 op, signed 2-byte constant */
   333  	opEq         = 0x29
   334  	opGe         = 0x2A
   335  	opGt         = 0x2B
   336  	opLe         = 0x2C
   337  	opLt         = 0x2D
   338  	opNe         = 0x2E
   339  	opLit0       = 0x30
   340  	/* OpLitN = OpLit0 + N for N = 0..31 */
   341  	opReg0 = 0x50
   342  	/* OpRegN = OpReg0 + N for N = 0..31 */
   343  	opBreg0 = 0x70 /* 1 op, signed LEB128 constant */
   344  	/* OpBregN = OpBreg0 + N for N = 0..31 */
   345  	opRegx       = 0x90 /* 1 op, ULEB128 register */
   346  	opFbreg      = 0x91 /* 1 op, SLEB128 offset */
   347  	opBregx      = 0x92 /* 2 op, ULEB128 reg; SLEB128 off */
   348  	opPiece      = 0x93 /* 1 op, ULEB128 size of piece */
   349  	opDerefSize  = 0x94 /* 1-byte size of data retrieved */
   350  	opXderefSize = 0x95 /* 1-byte size of data retrieved */
   351  	opNop        = 0x96
   352  	// The following are new in DWARF 3.
   353  	opPushObjAddr    = 0x97
   354  	opCall2          = 0x98 /* 2-byte offset of DIE */
   355  	opCall4          = 0x99 /* 4-byte offset of DIE */
   356  	opCallRef        = 0x9A /* 4- or 8- byte offset of DIE */
   357  	opFormTLSAddress = 0x9B
   358  	opCallFrameCFA   = 0x9C
   359  	opBitPiece       = 0x9D
   360  	// The following are new in DWARF 4.
   361  	opImplicitValue = 0x9E
   362  	opStackValue    = 0x9F
   363  	// The following a new in DWARF 5.
   364  	opImplicitPointer = 0xA0
   365  	opAddrx           = 0xA1
   366  	opConstx          = 0xA2
   367  	opEntryValue      = 0xA3
   368  	opConstType       = 0xA4
   369  	opRegvalType      = 0xA5
   370  	opDerefType       = 0xA6
   371  	opXderefType      = 0xA7
   372  	opConvert         = 0xA8
   373  	opReinterpret     = 0xA9
   374  	/* 0xE0-0xFF reserved for user-specific */
   375  )
   376  
   377  // Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry.
   378  const (
   379  	encAddress      = 0x01
   380  	encBoolean      = 0x02
   381  	encComplexFloat = 0x03
   382  	encFloat        = 0x04
   383  	encSigned       = 0x05
   384  	encSignedChar   = 0x06
   385  	encUnsigned     = 0x07
   386  	encUnsignedChar = 0x08
   387  	// The following are new in DWARF 3.
   388  	encImaginaryFloat = 0x09
   389  	encPackedDecimal  = 0x0A
   390  	encNumericString  = 0x0B
   391  	encEdited         = 0x0C
   392  	encSignedFixed    = 0x0D
   393  	encUnsignedFixed  = 0x0E
   394  	encDecimalFloat   = 0x0F
   395  	// The following are new in DWARF 4.
   396  	encUTF = 0x10
   397  	// The following are new in DWARF 5.
   398  	encUCS   = 0x11
   399  	encASCII = 0x12
   400  )
   401  
   402  // Statement program standard opcode encodings.
   403  const (
   404  	lnsCopy           = 1
   405  	lnsAdvancePC      = 2
   406  	lnsAdvanceLine    = 3
   407  	lnsSetFile        = 4
   408  	lnsSetColumn      = 5
   409  	lnsNegateStmt     = 6
   410  	lnsSetBasicBlock  = 7
   411  	lnsConstAddPC     = 8
   412  	lnsFixedAdvancePC = 9
   413  
   414  	// DWARF 3
   415  	lnsSetPrologueEnd   = 10
   416  	lnsSetEpilogueBegin = 11
   417  	lnsSetISA           = 12
   418  )
   419  
   420  // Statement program extended opcode encodings.
   421  const (
   422  	lneEndSequence = 1
   423  	lneSetAddress  = 2
   424  	lneDefineFile  = 3
   425  
   426  	// DWARF 4
   427  	lneSetDiscriminator = 4
   428  )
   429  
   430  // Line table directory and file name entry formats.
   431  // These are new in DWARF 5.
   432  const (
   433  	lnctPath           = 0x01
   434  	lnctDirectoryIndex = 0x02
   435  	lnctTimestamp      = 0x03
   436  	lnctSize           = 0x04
   437  	lnctMD5            = 0x05
   438  )
   439  
   440  // Location list entry codes.
   441  // These are new in DWARF 5.
   442  const (
   443  	lleEndOfList       = 0x00
   444  	lleBaseAddressx    = 0x01
   445  	lleStartxEndx      = 0x02
   446  	lleStartxLength    = 0x03
   447  	lleOffsetPair      = 0x04
   448  	lleDefaultLocation = 0x05
   449  	lleBaseAddress     = 0x06
   450  	lleStartEnd        = 0x07
   451  	lleStartLength     = 0x08
   452  )
   453  
   454  // Unit header unit type encodings.
   455  // These are new in DWARF 5.
   456  const (
   457  	utCompile      = 0x01
   458  	utType         = 0x02
   459  	utPartial      = 0x03
   460  	utSkeleton     = 0x04
   461  	utSplitCompile = 0x05
   462  	utSplitType    = 0x06
   463  )
   464  
   465  // Opcodes for DWARFv5 debug_rnglists section.
   466  const (
   467  	rleEndOfList    = 0x0
   468  	rleBaseAddressx = 0x1
   469  	rleStartxEndx   = 0x2
   470  	rleStartxLength = 0x3
   471  	rleOffsetPair   = 0x4
   472  	rleBaseAddress  = 0x5
   473  	rleStartEnd     = 0x6
   474  	rleStartLength  = 0x7
   475  )
   476  

View as plain text