/ go / db / token.go
token.go
 1  package db
 2  
 3  type (
 4  	TokenKind       uint8
 5  	TokenNameKind   uint8
 6  	TokenMemberKind uint8
 7  )
 8  
 9  const (
10  	// OriginalName means this string appeared verbatim in the original sample, and was not altered.
11  	OriginalName TokenNameKind = iota
12  	// DemangledName is provided in the case that the OriginalName was mangled by the compiler.
13  	DemangledName
14  	// Mangled names can be automatically Binanaized, i.e. converted into a naive syntax for wide
15  	// compatibility with SRE tools
16  	BinanaizedName
17  )
18  
19  const (
20  	// The token was obtained from a PDB or a Mach-O symtab
21  	OriginalSymbolToken TokenKind = iota
22  	// The token was found by scanning the non-executable sections of the binary for 0-terminated ASCII strings
23  	OriginalStringToken
24  	// The token is a datatype was obtained from a PDB or DWARF debugging file
25  	OriginalDatatypeToken
26  	// This token is a constant named value with no address
27  	OriginalConstantToken
28  )
29  
30  const (
31  	ConstantValueMember TokenMemberKind = iota
32  	EnumMember
33  	// This is a part of a struct
34  	// key = the field name
35  	// value = the C type of the field
36  	FieldMember
37  	// This is a method of a class
38  	MethodMember
39  	// This in argument to a function
40  	ParameterMember
41  	// This is a local variable in a function
42  	LocalMember
43  	// This is a statically declared variable in a function
44  	StaticLocalMember
45  )
46  
47  type TokenName struct {
48  	Kind TokenNameKind `json:"kind" parquet:"kind"`
49  	Name string        `json:"name" parquet:"name,dict"`
50  }
51  
52  type TokenMember struct {
53  	Kind  TokenMemberKind `json:"kind" parquet:"kind"`
54  	Key   string          `json:"key,omitempty" parquet:"key,dict"`
55  	Value string          `json:"value" parquet:"value,dict"`
56  }
57  
58  type Token struct {
59  	// Unique 64-bit identifier
60  	ID uint64 `json:"id" parquet:"id"`
61  	// The SHA-256 hash id of the sample which generated the token
62  	Source string `json:"src" parquet:"src,dict"`
63  	// The color and subhead of the token
64  	Kind TokenKind `json:"kind" parquet:"kind"`
65  	// If this is a datatype, keyword tells you what kind of datatype it is. Useful when generating C code.
66  	Keyword string `json:"keyword,omitempty" parquet:"keyword,dict"`
67  	// If this is a global variable/constant, this tells you the data type
68  	Datatype string `json:"datatype,omitempty" parquet:"datatype,dict"`
69  	// The section where the token originated
70  	Section string `json:"section,omitempty"`
71  	// The offset (in hexadecimal) where the symbol
72  	Offset string `json:"offset,omitempty"`
73  	// Alternate names for the token
74  	Names []TokenName `json:"names"`
75  	// Clickable references to other tokens
76  	Highlights []string `json:"crumbs,omitempty"`
77  	// Struct/Enum members
78  	Members []TokenMember `json:"members,omitempty"`
79  }