src/pkg/debug/dwarf/const.go - The Go Programming Language

Golang

Source file src/pkg/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	import "strconv"
    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		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	// A format is a DWARF data encoding format.
   185	type format uint32
   186	
   187	const (
   188		// value formats
   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	
   212	// A Tag is the classification (the type) of an Entry.
   213	type Tag uint32
   214	
   215	const (
   216		TagArrayType              Tag = 0x01
   217		TagClassType              Tag = 0x02
   218		TagEntryPoint             Tag = 0x03
   219		TagEnumerationType        Tag = 0x04
   220		TagFormalParameter        Tag = 0x05
   221		TagImportedDeclaration    Tag = 0x08
   222		TagLabel                  Tag = 0x0A
   223		TagLexDwarfBlock          Tag = 0x0B
   224		TagMember                 Tag = 0x0D
   225		TagPointerType            Tag = 0x0F
   226		TagReferenceType          Tag = 0x10
   227		TagCompileUnit            Tag = 0x11
   228		TagStringType             Tag = 0x12
   229		TagStructType             Tag = 0x13
   230		TagSubroutineType         Tag = 0x15
   231		TagTypedef                Tag = 0x16
   232		TagUnionType              Tag = 0x17
   233		TagUnspecifiedParameters  Tag = 0x18
   234		TagVariant                Tag = 0x19
   235		TagCommonDwarfBlock       Tag = 0x1A
   236		TagCommonInclusion        Tag = 0x1B
   237		TagInheritance            Tag = 0x1C
   238		TagInlinedSubroutine      Tag = 0x1D
   239		TagModule                 Tag = 0x1E
   240		TagPtrToMemberType        Tag = 0x1F
   241		TagSetType                Tag = 0x20
   242		TagSubrangeType           Tag = 0x21
   243		TagWithStmt               Tag = 0x22
   244		TagAccessDeclaration      Tag = 0x23
   245		TagBaseType               Tag = 0x24
   246		TagCatchDwarfBlock        Tag = 0x25
   247		TagConstType              Tag = 0x26
   248		TagConstant               Tag = 0x27
   249		TagEnumerator             Tag = 0x28
   250		TagFileType               Tag = 0x29
   251		TagFriend                 Tag = 0x2A
   252		TagNamelist               Tag = 0x2B
   253		TagNamelistItem           Tag = 0x2C
   254		TagPackedType             Tag = 0x2D
   255		TagSubprogram             Tag = 0x2E
   256		TagTemplateTypeParameter  Tag = 0x2F
   257		TagTemplateValueParameter Tag = 0x30
   258		TagThrownType             Tag = 0x31
   259		TagTryDwarfBlock          Tag = 0x32
   260		TagVariantPart            Tag = 0x33
   261		TagVariable               Tag = 0x34
   262		TagVolatileType           Tag = 0x35
   263		TagDwarfProcedure         Tag = 0x36
   264		TagRestrictType           Tag = 0x37
   265		TagInterfaceType          Tag = 0x38
   266		TagNamespace              Tag = 0x39
   267		TagImportedModule         Tag = 0x3A
   268		TagUnspecifiedType        Tag = 0x3B
   269		TagPartialUnit            Tag = 0x3C
   270		TagImportedUnit           Tag = 0x3D
   271		TagMutableType            Tag = 0x3E
   272	)
   273	
   274	var tagNames = [...]string{
   275		TagArrayType:              "ArrayType",
   276		TagClassType:              "ClassType",
   277		TagEntryPoint:             "EntryPoint",
   278		TagEnumerationType:        "EnumerationType",
   279		TagFormalParameter:        "FormalParameter",
   280		TagImportedDeclaration:    "ImportedDeclaration",
   281		TagLabel:                  "Label",
   282		TagLexDwarfBlock:          "LexDwarfBlock",
   283		TagMember:                 "Member",
   284		TagPointerType:            "PointerType",
   285		TagReferenceType:          "ReferenceType",
   286		TagCompileUnit:            "CompileUnit",
   287		TagStringType:             "StringType",
   288		TagStructType:             "StructType",
   289		TagSubroutineType:         "SubroutineType",
   290		TagTypedef:                "Typedef",
   291		TagUnionType:              "UnionType",
   292		TagUnspecifiedParameters:  "UnspecifiedParameters",
   293		TagVariant:                "Variant",
   294		TagCommonDwarfBlock:       "CommonDwarfBlock",
   295		TagCommonInclusion:        "CommonInclusion",
   296		TagInheritance:            "Inheritance",
   297		TagInlinedSubroutine:      "InlinedSubroutine",
   298		TagModule:                 "Module",
   299		TagPtrToMemberType:        "PtrToMemberType",
   300		TagSetType:                "SetType",
   301		TagSubrangeType:           "SubrangeType",
   302		TagWithStmt:               "WithStmt",
   303		TagAccessDeclaration:      "AccessDeclaration",
   304		TagBaseType:               "BaseType",
   305		TagCatchDwarfBlock:        "CatchDwarfBlock",
   306		TagConstType:              "ConstType",
   307		TagConstant:               "Constant",
   308		TagEnumerator:             "Enumerator",
   309		TagFileType:               "FileType",
   310		TagFriend:                 "Friend",
   311		TagNamelist:               "Namelist",
   312		TagNamelistItem:           "NamelistItem",
   313		TagPackedType:             "PackedType",
   314		TagSubprogram:             "Subprogram",
   315		TagTemplateTypeParameter:  "TemplateTypeParameter",
   316		TagTemplateValueParameter: "TemplateValueParameter",
   317		TagThrownType:             "ThrownType",
   318		TagTryDwarfBlock:          "TryDwarfBlock",
   319		TagVariantPart:            "VariantPart",
   320		TagVariable:               "Variable",
   321		TagVolatileType:           "VolatileType",
   322		TagDwarfProcedure:         "DwarfProcedure",
   323		TagRestrictType:           "RestrictType",
   324		TagInterfaceType:          "InterfaceType",
   325		TagNamespace:              "Namespace",
   326		TagImportedModule:         "ImportedModule",
   327		TagUnspecifiedType:        "UnspecifiedType",
   328		TagPartialUnit:            "PartialUnit",
   329		TagImportedUnit:           "ImportedUnit",
   330		TagMutableType:            "MutableType",
   331	}
   332	
   333	func (t Tag) String() string {
   334		if int(t) < len(tagNames) {
   335			s := tagNames[t]
   336			if s != "" {
   337				return s
   338			}
   339		}
   340		return strconv.Itoa(int(t))
   341	}
   342	
   343	func (t Tag) GoString() string {
   344		if int(t) < len(tagNames) {
   345			s := tagNames[t]
   346			if s != "" {
   347				return "dwarf.Tag" + s
   348			}
   349		}
   350		return "dwarf.Tag(" + strconv.FormatInt(int64(t), 10) + ")"
   351	}
   352	
   353	// Location expression operators.
   354	// The debug info encodes value locations like 8(R3)
   355	// as a sequence of these op codes.
   356	// This package does not implement full expressions;
   357	// the opPlusUconst operator is expected by the type parser.
   358	const (
   359		opAddr       = 0x03 /* 1 op, const addr */
   360		opDeref      = 0x06
   361		opConst1u    = 0x08 /* 1 op, 1 byte const */
   362		opConst1s    = 0x09 /*	" signed */
   363		opConst2u    = 0x0A /* 1 op, 2 byte const  */
   364		opConst2s    = 0x0B /*	" signed */
   365		opConst4u    = 0x0C /* 1 op, 4 byte const */
   366		opConst4s    = 0x0D /*	" signed */
   367		opConst8u    = 0x0E /* 1 op, 8 byte const */
   368		opConst8s    = 0x0F /*	" signed */
   369		opConstu     = 0x10 /* 1 op, LEB128 const */
   370		opConsts     = 0x11 /*	" signed */
   371		opDup        = 0x12
   372		opDrop       = 0x13
   373		opOver       = 0x14
   374		opPick       = 0x15 /* 1 op, 1 byte stack index */
   375		opSwap       = 0x16
   376		opRot        = 0x17
   377		opXderef     = 0x18
   378		opAbs        = 0x19
   379		opAnd        = 0x1A
   380		opDiv        = 0x1B
   381		opMinus      = 0x1C
   382		opMod        = 0x1D
   383		opMul        = 0x1E
   384		opNeg        = 0x1F
   385		opNot        = 0x20
   386		opOr         = 0x21
   387		opPlus       = 0x22
   388		opPlusUconst = 0x23 /* 1 op, ULEB128 addend */
   389		opShl        = 0x24
   390		opShr        = 0x25
   391		opShra       = 0x26
   392		opXor        = 0x27
   393		opSkip       = 0x2F /* 1 op, signed 2-byte constant */
   394		opBra        = 0x28 /* 1 op, signed 2-byte constant */
   395		opEq         = 0x29
   396		opGe         = 0x2A
   397		opGt         = 0x2B
   398		opLe         = 0x2C
   399		opLt         = 0x2D
   400		opNe         = 0x2E
   401		opLit0       = 0x30
   402		/* OpLitN = OpLit0 + N for N = 0..31 */
   403		opReg0 = 0x50
   404		/* OpRegN = OpReg0 + N for N = 0..31 */
   405		opBreg0 = 0x70 /* 1 op, signed LEB128 constant */
   406		/* OpBregN = OpBreg0 + N for N = 0..31 */
   407		opRegx       = 0x90 /* 1 op, ULEB128 register */
   408		opFbreg      = 0x91 /* 1 op, SLEB128 offset */
   409		opBregx      = 0x92 /* 2 op, ULEB128 reg; SLEB128 off */
   410		opPiece      = 0x93 /* 1 op, ULEB128 size of piece */
   411		opDerefSize  = 0x94 /* 1-byte size of data retrieved */
   412		opXderefSize = 0x95 /* 1-byte size of data retrieved */
   413		opNop        = 0x96
   414		/* next four new in Dwarf v3 */
   415		opPushObjAddr = 0x97
   416		opCall2       = 0x98 /* 2-byte offset of DIE */
   417		opCall4       = 0x99 /* 4-byte offset of DIE */
   418		opCallRef     = 0x9A /* 4- or 8- byte offset of DIE */
   419		/* 0xE0-0xFF reserved for user-specific */
   420	)
   421	
   422	// Basic type encodings -- the value for AttrEncoding in a TagBaseType Entry.
   423	const (
   424		encAddress        = 0x01
   425		encBoolean        = 0x02
   426		encComplexFloat   = 0x03
   427		encFloat          = 0x04
   428		encSigned         = 0x05
   429		encSignedChar     = 0x06
   430		encUnsigned       = 0x07
   431		encUnsignedChar   = 0x08
   432		encImaginaryFloat = 0x09
   433	)