ReactOS 0.4.15-dev-8419-g7f0e8a3
dwarf.h File Reference
#include "compat.h"
Include dependency graph for dwarf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DwarfBlock
 
struct  DwarfBuf
 
union  DwarfVal
 
struct  DwarfAttrs
 
struct  DwarfExpr
 
struct  DwarfSym
 
struct  DwarfAttr
 
struct  DwarfAbbrev
 
struct  Dwarf
 

Macros

#define SYMBOL_SIZE   18
 
#define MAXIMUM_DWARF_NAME_SIZE   64
 
#define MAXIMUM_COFF_SYMBOL_LENGTH   256
 

Typedefs

typedef struct Dwarf Dwarf
 
typedef struct DwarfAttrs DwarfAttrs
 
typedef struct DwarfBlock DwarfBlock
 
typedef struct DwarfBuf DwarfBuf
 
typedef struct DwarfExpr DwarfExpr
 
typedef struct DwarfSym DwarfSym
 
typedef union DwarfVal DwarfVal
 
typedef struct DwarfAbbrev DwarfAbbrev
 
typedef struct DwarfAttr DwarfAttr
 

Enumerations

enum  {
  TagArrayType = 0x01 , TagClassType = 0x02 , TagEntryPoint = 0x03 , TagEnumerationType = 0x04 ,
  TagFormalParameter = 0x05 , TagImportedDeclaration = 0x08 , TagLabel = 0x0A , TagLexDwarfBlock = 0x0B ,
  TagMember = 0x0D , TagPointerType = 0x0F , TagReferenceType = 0x10 , TagCompileUnit = 0x11 ,
  TagStringType = 0x12 , TagStructType = 0x13 , TagSubroutineType = 0x15 , TagTypedef = 0x16 ,
  TagUnionType = 0x17 , TagUnspecifiedParameters = 0x18 , TagVariant = 0x19 , TagCommonDwarfBlock = 0x1A ,
  TagCommonInclusion = 0x1B , TagInheritance = 0x1C , TagInlinedSubroutine = 0x1D , TagModule = 0x1E ,
  TagPtrToMemberType = 0x1F , TagSetType = 0x20 , TagSubrangeType = 0x21 , TagWithStmt = 0x22 ,
  TagAccessDeclaration = 0x23 , TagBaseType = 0x24 , TagCatchDwarfBlock = 0x25 , TagConstType = 0x26 ,
  TagConstant = 0x27 , TagEnumerator = 0x28 , TagFileType = 0x29 , TagFriend = 0x2A ,
  TagNamelist = 0x2B , TagNamelistItem = 0x2C , TagPackedType = 0x2D , TagSubprogram = 0x2E ,
  TagTemplateTypeParameter = 0x2F , TagTemplateValueParameter = 0x30 , TagThrownType = 0x31 , TagTryDwarfBlock = 0x32 ,
  TagVariantPart = 0x33 , TagVariable = 0x34 , TagVolatileType = 0x35 , TagDwarfProcedure = 0x36 ,
  TagRestrictType = 0x37 , TagInterfaceType = 0x38 , TagNamespace = 0x39 , TagImportedModule = 0x3A ,
  TagUnspecifiedType = 0x3B , TagPartialUnit = 0x3C , TagImportedUnit = 0x3D , TagMutableType = 0x3E ,
  TypeAddress = 0x01 , TypeBoolean = 0x02 , TypeComplexFloat = 0x03 , TypeFloat = 0x04 ,
  TypeSigned = 0x05 , TypeSignedChar = 0x06 , TypeUnsigned = 0x07 , TypeUnsignedChar = 0x08 ,
  TypeImaginaryFloat = 0x09 , AccessPublic = 0x01 , AccessProtected = 0x02 , AccessPrivate = 0x03 ,
  VisLocal = 0x01 , VisExported = 0x02 , VisQualified = 0x03 , VirtNone = 0x00 ,
  VirtVirtual = 0x01 , VirtPureVirtual = 0x02 , LangC89 = 0x0001 , LangC = 0x0002 ,
  LangAda83 = 0x0003 , LangCplusplus = 0x0004 , LangCobol74 = 0x0005 , LangCobol85 = 0x0006 ,
  LangFortran77 = 0x0007 , LangFortran90 = 0x0008 , LangPascal83 = 0x0009 , LangModula2 = 0x000A ,
  LangJava = 0x000B , LangC99 = 0x000C , LangAda95 = 0x000D , LangFortran95 = 0x000E ,
  LangPLI = 0x000F , IdCaseSensitive = 0x00 , IdCaseUpper = 0x01 , IdCaseLower = 0x02 ,
  IdCaseInsensitive = 0x03 , CallingNormal = 0x01 , CallingProgram = 0x02 , CallingNocall = 0x03 ,
  InNone = 0x00 , InInlined = 0x01 , InDeclaredNotInlined = 0x02 , InDeclaredInlined = 0x03 ,
  OrderRowMajor = 0x00 , OrderColumnMajor = 0x01 , DiscLabel = 0x00 , DiscRange = 0x01 ,
  TReference = 1<<0 , TBlock = 1<<1 , TConstant = 1<<2 , TString = 1<<3 ,
  TFlag = 1<<4 , TAddress = 1<<5 , OpAddr = 0x03 , OpDeref = 0x06 ,
  OpConst1u = 0x08 , OpConst1s = 0x09 , OpConst2u = 0x0A , OpConst2s = 0x0B ,
  OpConst4u = 0x0C , OpConst4s = 0x0D , OpConst8u = 0x0E , OpConst8s = 0x0F ,
  OpConstu = 0x10 , OpConsts = 0x11 , OpDup = 0x12 , OpDrop = 0x13 ,
  OpOver = 0x14 , OpPick = 0x15 , OpSwap = 0x16 , OpRot = 0x17 ,
  OpXderef = 0x18 , OpAbs = 0x19 , OpAnd = 0x1A , OpDiv = 0x1B ,
  OpMinus = 0x1C , OpMod = 0x1D , OpMul = 0x1E , OpNeg = 0x1F ,
  OpNot = 0x20 , OpOr = 0x21 , OpPlus = 0x22 , OpPlusUconst = 0x23 ,
  OpShl = 0x24 , OpShr = 0x25 , OpShra = 0x26 , OpXor = 0x27 ,
  OpSkip = 0x2F , OpBra = 0x28 , OpEq = 0x29 , OpGe = 0x2A ,
  OpGt = 0x2B , OpLe = 0x2C , OpLt = 0x2D , OpNe = 0x2E ,
  OpLit0 = 0x30 , OpReg0 = 0x50 , OpBreg0 = 0x70 , OpRegx = 0x90 ,
  OpFbreg = 0x91 , OpBregx = 0x92 , OpPiece = 0x93 , OpDerefSize = 0x94 ,
  OpXderefSize = 0x95 , OpNop = 0x96 , OpPushObjAddr = 0x97 , OpCall2 = 0x98 ,
  OpCall4 = 0x99 , OpCallRef = 0x9A
}
 
enum  {
  RuleUndef , RuleSame , RuleCfaOffset , RuleRegister ,
  RuleRegOff , RuleLocation
}
 

Functions

Dwarfdwarfopen (struct _Pe *elf)
 
void dwarfclose (Dwarf *)
 
int dwarfaddrtounit (Dwarf *, ulong, ulong *)
 
int dwarflookupfn (Dwarf *, ulong, ulong, DwarfSym *)
 
int dwarflookupname (Dwarf *, char *, DwarfSym *)
 
int dwarflookupnameinunit (Dwarf *, ulong, char *, DwarfSym *)
 
int dwarflookupsubname (Dwarf *, DwarfSym *, char *, DwarfSym *)
 
int dwarflookuptag (Dwarf *, ulong, ulong, DwarfSym *)
 
int dwarfenumunit (Dwarf *, ulong, DwarfSym *)
 
int dwarfseeksym (Dwarf *, ulong, ulong, DwarfSym *)
 
int dwarfenum (Dwarf *, DwarfSym *)
 
int dwarfnextsym (Dwarf *, DwarfSym *)
 
int dwarfnextsymat (Dwarf *, DwarfSym *, int)
 
int dwarfpctoline (Dwarf *, ulong, char **, char **, char **, char **, ulong *, ulong *, ulong *)
 
int dwarfunwind (Dwarf *, ulong, DwarfExpr *, DwarfExpr *, DwarfExpr *, int)
 
ulong dwarfget1 (DwarfBuf *)
 
ulong dwarfget2 (DwarfBuf *)
 
ulong dwarfget4 (DwarfBuf *)
 
uvlong dwarfget8 (DwarfBuf *)
 
ulong dwarfget128 (DwarfBuf *)
 
long dwarfget128s (DwarfBuf *)
 
ulong dwarfgetaddr (DwarfBuf *)
 
int dwarfgetn (DwarfBuf *, uchar *, int)
 
uchardwarfgetnref (DwarfBuf *, ulong)
 
chardwarfgetstring (DwarfBuf *)
 
DwarfAbbrevdwarfgetabbrev (Dwarf *, ulong, ulong)
 
int dwarfgetinfounit (Dwarf *, ulong, DwarfBlock *)
 

Variables

int dwarf386nregs
 
chardwarf386regs []
 
chardwarf386fp
 

Macro Definition Documentation

◆ MAXIMUM_COFF_SYMBOL_LENGTH

#define MAXIMUM_COFF_SYMBOL_LENGTH   256

Definition at line 471 of file dwarf.h.

◆ MAXIMUM_DWARF_NAME_SIZE

#define MAXIMUM_DWARF_NAME_SIZE   64

Definition at line 470 of file dwarf.h.

◆ SYMBOL_SIZE

#define SYMBOL_SIZE   18

Definition at line 469 of file dwarf.h.

Typedef Documentation

◆ Dwarf

typedef struct Dwarf Dwarf

Definition at line 3 of file dwarf.h.

◆ DwarfAbbrev

Definition at line 416 of file dwarf.h.

◆ DwarfAttr

Definition at line 417 of file dwarf.h.

◆ DwarfAttrs

Definition at line 4 of file dwarf.h.

◆ DwarfBlock

Definition at line 5 of file dwarf.h.

◆ DwarfBuf

Definition at line 6 of file dwarf.h.

◆ DwarfExpr

Definition at line 7 of file dwarf.h.

◆ DwarfSym

Definition at line 8 of file dwarf.h.

◆ DwarfVal

typedef union DwarfVal DwarfVal

Definition at line 9 of file dwarf.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TagArrayType 
TagClassType 
TagEntryPoint 
TagEnumerationType 
TagFormalParameter 
TagImportedDeclaration 
TagLabel 
TagLexDwarfBlock 
TagMember 
TagPointerType 
TagReferenceType 
TagCompileUnit 
TagStringType 
TagStructType 
TagSubroutineType 
TagTypedef 
TagUnionType 
TagUnspecifiedParameters 
TagVariant 
TagCommonDwarfBlock 
TagCommonInclusion 
TagInheritance 
TagInlinedSubroutine 
TagModule 
TagPtrToMemberType 
TagSetType 
TagSubrangeType 
TagWithStmt 
TagAccessDeclaration 
TagBaseType 
TagCatchDwarfBlock 
TagConstType 
TagConstant 
TagEnumerator 
TagFileType 
TagFriend 
TagNamelist 
TagNamelistItem 
TagPackedType 
TagSubprogram 
TagTemplateTypeParameter 
TagTemplateValueParameter 
TagThrownType 
TagTryDwarfBlock 
TagVariantPart 
TagVariable 
TagVolatileType 
TagDwarfProcedure 
TagRestrictType 
TagInterfaceType 
TagNamespace 
TagImportedModule 
TagUnspecifiedType 
TagPartialUnit 
TagImportedUnit 
TagMutableType 
TypeAddress 
TypeBoolean 
TypeComplexFloat 
TypeFloat 
TypeSigned 
TypeSignedChar 
TypeUnsigned 
TypeUnsignedChar 
TypeImaginaryFloat 
AccessPublic 
AccessProtected 
AccessPrivate 
VisLocal 
VisExported 
VisQualified 
VirtNone 
VirtVirtual 
VirtPureVirtual 
LangC89 
LangC 
LangAda83 
LangCplusplus 
LangCobol74 
LangCobol85 
LangFortran77 
LangFortran90 
LangPascal83 
LangModula2 
LangJava 
LangC99 
LangAda95 
LangFortran95 
LangPLI 
IdCaseSensitive 
IdCaseUpper 
IdCaseLower 
IdCaseInsensitive 
CallingNormal 
CallingProgram 
CallingNocall 
InNone 
InInlined 
InDeclaredNotInlined 
InDeclaredInlined 
OrderRowMajor 
OrderColumnMajor 
DiscLabel 
DiscRange 
TReference 
TBlock 
TConstant 
TString 
TFlag 
TAddress 
OpAddr 
OpDeref 
OpConst1u 
OpConst1s 
OpConst2u 
OpConst2s 
OpConst4u 
OpConst4s 
OpConst8u 
OpConst8s 
OpConstu 
OpConsts 
OpDup 
OpDrop 
OpOver 
OpPick 
OpSwap 
OpRot 
OpXderef 
OpAbs 
OpAnd 
OpDiv 
OpMinus 
OpMod 
OpMul 
OpNeg 
OpNot 
OpOr 
OpPlus 
OpPlusUconst 
OpShl 
OpShr 
OpShra 
OpXor 
OpSkip 
OpBra 
OpEq 
OpGe 
OpGt 
OpLe 
OpLt 
OpNe 
OpLit0 
OpReg0 
OpBreg0 
OpRegx 
OpFbreg 
OpBregx 
OpPiece 
OpDerefSize 
OpXderefSize 
OpNop 
OpPushObjAddr 
OpCall2 
OpCall4 
OpCallRef 

Definition at line 11 of file dwarf.h.

12{
13 TagArrayType = 0x01,
14 TagClassType = 0x02,
15 TagEntryPoint = 0x03,
16 TagEnumerationType = 0x04,
17 TagFormalParameter = 0x05,
19 TagLabel = 0x0A,
20 TagLexDwarfBlock = 0x0B,
21 TagMember = 0x0D,
22 TagPointerType = 0x0F,
23 TagReferenceType = 0x10,
24 TagCompileUnit = 0x11,
25 TagStringType = 0x12,
26 TagStructType = 0x13,
27 TagSubroutineType = 0x15,
28 TagTypedef = 0x16,
29 TagUnionType = 0x17,
31 TagVariant = 0x19,
33 TagCommonInclusion = 0x1B,
34 TagInheritance = 0x1C,
36 TagModule = 0x1E,
37 TagPtrToMemberType = 0x1F,
38 TagSetType = 0x20,
39 TagSubrangeType = 0x21,
40 TagWithStmt = 0x22,
42 TagBaseType = 0x24,
43 TagCatchDwarfBlock = 0x25,
44 TagConstType = 0x26,
45 TagConstant = 0x27,
46 TagEnumerator = 0x28,
47 TagFileType = 0x29,
48 TagFriend = 0x2A,
49 TagNamelist = 0x2B,
50 TagNamelistItem = 0x2C,
51 TagPackedType = 0x2D,
52 TagSubprogram = 0x2E,
55 TagThrownType = 0x31,
56 TagTryDwarfBlock = 0x32,
57 TagVariantPart = 0x33,
58 TagVariable = 0x34,
59 TagVolatileType = 0x35,
60 TagDwarfProcedure = 0x36,
61 TagRestrictType = 0x37,
62 TagInterfaceType = 0x38,
63 TagNamespace = 0x39,
64 TagImportedModule = 0x3A,
65 TagUnspecifiedType = 0x3B,
66 TagPartialUnit = 0x3C,
67 TagImportedUnit = 0x3D,
68 TagMutableType = 0x3E,
69
70 TypeAddress = 0x01,
71 TypeBoolean = 0x02,
72 TypeComplexFloat = 0x03,
73 TypeFloat = 0x04,
74 TypeSigned = 0x05,
75 TypeSignedChar = 0x06,
76 TypeUnsigned = 0x07,
77 TypeUnsignedChar = 0x08,
78 TypeImaginaryFloat = 0x09,
79
80 AccessPublic = 0x01,
81 AccessProtected = 0x02,
82 AccessPrivate = 0x03,
83
84 VisLocal = 0x01,
85 VisExported = 0x02,
86 VisQualified = 0x03,
87
88 VirtNone = 0x00,
89 VirtVirtual = 0x01,
90 VirtPureVirtual = 0x02,
91
92 LangC89 = 0x0001,
93 LangC = 0x0002,
94 LangAda83 = 0x0003,
95 LangCplusplus = 0x0004,
96 LangCobol74 = 0x0005,
97 LangCobol85 = 0x0006,
98 LangFortran77 = 0x0007,
99 LangFortran90 = 0x0008,
100 LangPascal83 = 0x0009,
101 LangModula2 = 0x000A,
102 LangJava = 0x000B,
103 LangC99 = 0x000C,
104 LangAda95 = 0x000D,
105 LangFortran95 = 0x000E,
106 LangPLI = 0x000F,
107 /* 0x8000-0xFFFF reserved */
108
109 IdCaseSensitive = 0x00,
110 IdCaseUpper = 0x01,
111 IdCaseLower = 0x02,
112 IdCaseInsensitive = 0x03,
113
114 CallingNormal = 0x01,
115 CallingProgram = 0x02,
116 CallingNocall = 0x03,
117 /* 0x40-0xFF reserved */
118
119 InNone = 0x00,
120 InInlined = 0x01,
122 InDeclaredInlined = 0x03,
123
124 OrderRowMajor = 0x00,
125 OrderColumnMajor = 0x01,
126
127 DiscLabel = 0x00,
128 DiscRange = 0x01,
129
130 TReference = 1<<0,
131 TBlock = 1<<1,
132 TConstant = 1<<2,
133 TString = 1<<3,
134 TFlag = 1<<4,
135 TAddress = 1<<5,
136
137 OpAddr = 0x03, /* 1 op, const addr */
138 OpDeref = 0x06,
139 OpConst1u = 0x08, /* 1 op, 1 byte const */
140 OpConst1s = 0x09, /* " signed */
141 OpConst2u = 0x0A, /* 1 op, 2 byte const */
142 OpConst2s = 0x0B, /* " signed */
143 OpConst4u = 0x0C, /* 1 op, 4 byte const */
144 OpConst4s = 0x0D, /* " signed */
145 OpConst8u = 0x0E, /* 1 op, 8 byte const */
146 OpConst8s = 0x0F, /* " signed */
147 OpConstu = 0x10, /* 1 op, LEB128 const */
148 OpConsts = 0x11, /* " signed */
149 OpDup = 0x12,
150 OpDrop = 0x13,
151 OpOver = 0x14,
152 OpPick = 0x15, /* 1 op, 1 byte stack index */
153 OpSwap = 0x16,
154 OpRot = 0x17,
155 OpXderef = 0x18,
156 OpAbs = 0x19,
157 OpAnd = 0x1A,
158 OpDiv = 0x1B,
159 OpMinus = 0x1C,
160 OpMod = 0x1D,
161 OpMul = 0x1E,
162 OpNeg = 0x1F,
163 OpNot = 0x20,
164 OpOr = 0x21,
165 OpPlus = 0x22,
166 OpPlusUconst = 0x23, /* 1 op, ULEB128 addend */
167 OpShl = 0x24,
168 OpShr = 0x25,
169 OpShra = 0x26,
170 OpXor = 0x27,
171 OpSkip = 0x2F, /* 1 op, signed 2-byte constant */
172 OpBra = 0x28, /* 1 op, signed 2-byte constant */
173 OpEq = 0x29,
174 OpGe = 0x2A,
175 OpGt = 0x2B,
176 OpLe = 0x2C,
177 OpLt = 0x2D,
178 OpNe = 0x2E,
179 OpLit0 = 0x30,
180 /* OpLitN = OpLit0 + N for N = 0..31 */
181 OpReg0 = 0x50,
182 /* OpRegN = OpReg0 + N for N = 0..31 */
183 OpBreg0 = 0x70, /* 1 op, signed LEB128 constant */
184 /* OpBregN = OpBreg0 + N for N = 0..31 */
185 OpRegx = 0x90, /* 1 op, ULEB128 register */
186 OpFbreg = 0x91, /* 1 op, SLEB128 offset */
187 OpBregx = 0x92, /* 2 op, ULEB128 reg, SLEB128 off */
188 OpPiece = 0x93, /* 1 op, ULEB128 size of piece */
189 OpDerefSize = 0x94, /* 1-byte size of data retrieved */
190 OpXderefSize = 0x95, /* 1-byte size of data retrieved */
191 OpNop = 0x96,
192 /* next four new in Dwarf v3 */
193 OpPushObjAddr = 0x97,
194 OpCall2 = 0x98, /* 2-byte offset of DIE */
195 OpCall4 = 0x99, /* 4-byte offset of DIE */
196 OpCallRef = 0x9A /* 4- or 8- byte offset of DIE */
197 /* 0xE0-0xFF reserved for user-specific */
198};
@ LangC
Definition: dwarf.h:93
@ TagSetType
Definition: dwarf.h:38
@ TypeAddress
Definition: dwarf.h:70
@ TagNamelist
Definition: dwarf.h:49
@ OpLit0
Definition: dwarf.h:179
@ LangC99
Definition: dwarf.h:103
@ OpConst4s
Definition: dwarf.h:144
@ OpCall4
Definition: dwarf.h:195
@ TagLabel
Definition: dwarf.h:19
@ TagTryDwarfBlock
Definition: dwarf.h:56
@ TagCompileUnit
Definition: dwarf.h:24
@ VirtNone
Definition: dwarf.h:88
@ TagStringType
Definition: dwarf.h:25
@ LangPLI
Definition: dwarf.h:106
@ OpLe
Definition: dwarf.h:176
@ TagStructType
Definition: dwarf.h:26
@ TagVariantPart
Definition: dwarf.h:57
@ TagVariable
Definition: dwarf.h:58
@ TagFormalParameter
Definition: dwarf.h:17
@ TagPtrToMemberType
Definition: dwarf.h:37
@ CallingNocall
Definition: dwarf.h:116
@ LangAda95
Definition: dwarf.h:104
@ OpGt
Definition: dwarf.h:175
@ OpConst4u
Definition: dwarf.h:143
@ LangJava
Definition: dwarf.h:102
@ OpConsts
Definition: dwarf.h:148
@ TypeUnsignedChar
Definition: dwarf.h:77
@ TypeUnsigned
Definition: dwarf.h:76
@ OpConst2u
Definition: dwarf.h:141
@ TypeFloat
Definition: dwarf.h:73
@ OpMul
Definition: dwarf.h:161
@ TagCommonDwarfBlock
Definition: dwarf.h:32
@ TagVolatileType
Definition: dwarf.h:59
@ AccessPublic
Definition: dwarf.h:80
@ TAddress
Definition: dwarf.h:135
@ OpConst8u
Definition: dwarf.h:145
@ TagConstant
Definition: dwarf.h:45
@ OpSwap
Definition: dwarf.h:153
@ DiscRange
Definition: dwarf.h:128
@ OpNeg
Definition: dwarf.h:162
@ TypeSigned
Definition: dwarf.h:74
@ TagTemplateTypeParameter
Definition: dwarf.h:53
@ OpReg0
Definition: dwarf.h:181
@ OpRegx
Definition: dwarf.h:185
@ LangPascal83
Definition: dwarf.h:100
@ TString
Definition: dwarf.h:133
@ TagInterfaceType
Definition: dwarf.h:62
@ LangCplusplus
Definition: dwarf.h:95
@ VisQualified
Definition: dwarf.h:86
@ OpDrop
Definition: dwarf.h:150
@ TagVariant
Definition: dwarf.h:31
@ OpPlus
Definition: dwarf.h:165
@ LangCobol74
Definition: dwarf.h:96
@ OpDup
Definition: dwarf.h:149
@ TagInheritance
Definition: dwarf.h:34
@ TReference
Definition: dwarf.h:130
@ TagImportedUnit
Definition: dwarf.h:67
@ TagDwarfProcedure
Definition: dwarf.h:60
@ TagUnionType
Definition: dwarf.h:29
@ TagNamespace
Definition: dwarf.h:63
@ TConstant
Definition: dwarf.h:132
@ OpCallRef
Definition: dwarf.h:196
@ OpMod
Definition: dwarf.h:160
@ CallingProgram
Definition: dwarf.h:115
@ OpDiv
Definition: dwarf.h:158
@ OpPlusUconst
Definition: dwarf.h:166
@ OpAddr
Definition: dwarf.h:137
@ OpLt
Definition: dwarf.h:177
@ OpXor
Definition: dwarf.h:170
@ TypeSignedChar
Definition: dwarf.h:75
@ TagEnumerationType
Definition: dwarf.h:16
@ OpRot
Definition: dwarf.h:154
@ TagMember
Definition: dwarf.h:21
@ TagLexDwarfBlock
Definition: dwarf.h:20
@ InDeclaredNotInlined
Definition: dwarf.h:121
@ TagPartialUnit
Definition: dwarf.h:66
@ TagCatchDwarfBlock
Definition: dwarf.h:43
@ OpFbreg
Definition: dwarf.h:186
@ AccessProtected
Definition: dwarf.h:81
@ DiscLabel
Definition: dwarf.h:127
@ TagNamelistItem
Definition: dwarf.h:50
@ OpNe
Definition: dwarf.h:178
@ InDeclaredInlined
Definition: dwarf.h:122
@ IdCaseUpper
Definition: dwarf.h:110
@ VirtVirtual
Definition: dwarf.h:89
@ OpBregx
Definition: dwarf.h:187
@ OpEq
Definition: dwarf.h:173
@ IdCaseSensitive
Definition: dwarf.h:109
@ TypeComplexFloat
Definition: dwarf.h:72
@ TagBaseType
Definition: dwarf.h:42
@ TagEntryPoint
Definition: dwarf.h:15
@ OpOr
Definition: dwarf.h:164
@ VisLocal
Definition: dwarf.h:84
@ OpConst1s
Definition: dwarf.h:140
@ TagTypedef
Definition: dwarf.h:28
@ LangFortran90
Definition: dwarf.h:99
@ TypeBoolean
Definition: dwarf.h:71
@ TagPackedType
Definition: dwarf.h:51
@ TagMutableType
Definition: dwarf.h:68
@ OrderRowMajor
Definition: dwarf.h:124
@ OpBreg0
Definition: dwarf.h:183
@ OpNop
Definition: dwarf.h:191
@ TagImportedModule
Definition: dwarf.h:64
@ InNone
Definition: dwarf.h:119
@ TagTemplateValueParameter
Definition: dwarf.h:54
@ OpXderef
Definition: dwarf.h:155
@ LangModula2
Definition: dwarf.h:101
@ OpPiece
Definition: dwarf.h:188
@ OpBra
Definition: dwarf.h:172
@ TagReferenceType
Definition: dwarf.h:23
@ OpMinus
Definition: dwarf.h:159
@ LangCobol85
Definition: dwarf.h:97
@ TagWithStmt
Definition: dwarf.h:40
@ TagConstType
Definition: dwarf.h:44
@ OpAnd
Definition: dwarf.h:157
@ OpXderefSize
Definition: dwarf.h:190
@ IdCaseLower
Definition: dwarf.h:111
@ TypeImaginaryFloat
Definition: dwarf.h:78
@ TagSubprogram
Definition: dwarf.h:52
@ VirtPureVirtual
Definition: dwarf.h:90
@ TagEnumerator
Definition: dwarf.h:46
@ OpConst2s
Definition: dwarf.h:142
@ OpPushObjAddr
Definition: dwarf.h:193
@ OpConstu
Definition: dwarf.h:147
@ OpGe
Definition: dwarf.h:174
@ OpShra
Definition: dwarf.h:169
@ OpPick
Definition: dwarf.h:152
@ TagThrownType
Definition: dwarf.h:55
@ TBlock
Definition: dwarf.h:131
@ TagSubrangeType
Definition: dwarf.h:39
@ TagArrayType
Definition: dwarf.h:13
@ OpConst8s
Definition: dwarf.h:146
@ OpNot
Definition: dwarf.h:163
@ TagInlinedSubroutine
Definition: dwarf.h:35
@ TagFileType
Definition: dwarf.h:47
@ TagClassType
Definition: dwarf.h:14
@ AccessPrivate
Definition: dwarf.h:82
@ OpAbs
Definition: dwarf.h:156
@ TagSubroutineType
Definition: dwarf.h:27
@ OpConst1u
Definition: dwarf.h:139
@ OpDerefSize
Definition: dwarf.h:189
@ TagUnspecifiedParameters
Definition: dwarf.h:30
@ TagUnspecifiedType
Definition: dwarf.h:65
@ OpShr
Definition: dwarf.h:168
@ OpSkip
Definition: dwarf.h:171
@ LangAda83
Definition: dwarf.h:94
@ InInlined
Definition: dwarf.h:120
@ TagAccessDeclaration
Definition: dwarf.h:41
@ LangC89
Definition: dwarf.h:92
@ OpShl
Definition: dwarf.h:167
@ LangFortran95
Definition: dwarf.h:105
@ TagRestrictType
Definition: dwarf.h:61
@ OpOver
Definition: dwarf.h:151
@ IdCaseInsensitive
Definition: dwarf.h:112
@ OpCall2
Definition: dwarf.h:194
@ TagCommonInclusion
Definition: dwarf.h:33
@ TagPointerType
Definition: dwarf.h:22
@ OrderColumnMajor
Definition: dwarf.h:125
@ OpDeref
Definition: dwarf.h:138
@ TFlag
Definition: dwarf.h:134
@ TagImportedDeclaration
Definition: dwarf.h:18
@ CallingNormal
Definition: dwarf.h:114
@ VisExported
Definition: dwarf.h:85
@ TagModule
Definition: dwarf.h:36
@ TagFriend
Definition: dwarf.h:48
@ LangFortran77
Definition: dwarf.h:98

◆ anonymous enum

anonymous enum
Enumerator
RuleUndef 
RuleSame 
RuleCfaOffset 
RuleRegister 
RuleRegOff 
RuleLocation 

Definition at line 356 of file dwarf.h.

357{
358 RuleUndef,
359 RuleSame,
364};
@ RuleLocation
Definition: dwarf.h:363
@ RuleRegOff
Definition: dwarf.h:362
@ RuleRegister
Definition: dwarf.h:361
@ RuleSame
Definition: dwarf.h:359
@ RuleCfaOffset
Definition: dwarf.h:360
@ RuleUndef
Definition: dwarf.h:358

Function Documentation

◆ dwarfaddrtounit()

int dwarfaddrtounit ( Dwarf d,
ulong  addr,
ulong unit 
)

Definition at line 16 of file dwarfaranges.c.

17{
18 DwarfBuf b;
19 int segsize, i;
20 ulong len, id, off, base, size;
21 uchar *start, *end;
22
23 memset(&b, 0, sizeof b);
24 b.d = d;
25 b.p = d->aranges.data;
26 b.ep = b.p + d->aranges.len;
27
28 while(b.p < b.ep){
29 start = b.p;
30 len = dwarfget4(&b);
31 if (!len) { b.ep = b.p - 4; return -1; }
32 if((id = dwarfget2(&b)) != 2){
33 if(b.p == nil){
34 underflow:
35 werrstr("buffer underflow reading address ranges header");
36 }else
37 werrstr("bad dwarf version 0x%x in address ranges header", id);
38 return -1;
39 }
40 off = dwarfget4(&b);
41 b.addrsize = dwarfget1(&b);
42 if(d->addrsize == 0)
43 d->addrsize = b.addrsize;
44 segsize = dwarfget1(&b);
45 USED(segsize); /* what am i supposed to do with this? */
46 if(b.p == nil)
47 goto underflow;
48 if((i = (b.p-start) % (2*b.addrsize)) != 0)
49 b.p += 2*b.addrsize - i;
50 end = start+4+len;
51 while(b.p!=nil && b.p<end){
54 if (!size) continue;
55 if(b.p == nil)
56 goto underflow;
57 if(base <= addr && addr < base+size){
58 *unit = off;
59 return 0;
60 }
61 }
62 if(b.p == nil)
63 goto underflow;
64 b.p = end;
65 }
66 werrstr("address 0x%lux is not listed in dwarf debugging symbols", addr);
67 return -1;
68}
unsigned char uchar
Definition: Unfrag.h:59
unsigned long ulong
Definition: linux.h:275
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define d
Definition: ke_i.h:81
#define b
Definition: ke_i.h:79
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
#define werrstr(str,...)
Definition: compat.h:34
#define USED(x)
Definition: compat.h:38
#define nil
Definition: compat.h:23
#define memset(x, y, z)
Definition: compat.h:39
ulong dwarfget2(DwarfBuf *)
Definition: dwarfget.c:81
ulong dwarfget1(DwarfBuf *)
Definition: dwarfget.c:17
ulong dwarfgetaddr(DwarfBuf *)
Definition: dwarfget.c:123
ulong dwarfget4(DwarfBuf *)
Definition: dwarfget.c:95

Referenced by dwarfpctoline(), and RosSymAggregate().

◆ dwarfclose()

void dwarfclose ( Dwarf d)

Definition at line 57 of file dwarfopen.c.

58{
59 free(d->abbrev.data);
60 free(d->aranges.data);
61 free(d->frame.data);
62 free(d->line.data);
63 free(d->pubnames.data);
64 free(d->ranges.data);
65 free(d->str.data);
66 free(d->info.data);
67 pefree(d->pe);
68 free(d);
69}
#define free
Definition: debug_ros.c:5
void pefree(Pe *pe)
Definition: pe.c:109

Referenced by RosSymDelete().

◆ dwarfenum()

int dwarfenum ( Dwarf d,
DwarfSym s 
)

Definition at line 241 of file dwarfinfo.c.

242{
243 if(dwarfenumunit(d, 0, s) < 0)
244 return -1;
245 s->allunits = 1;
246 return 0;
247}
GLdouble s
Definition: gl.h:2039
int dwarfenumunit(Dwarf *d, ulong unit, DwarfSym *s)
Definition: dwarfinfo.c:201

Referenced by main().

◆ dwarfenumunit()

int dwarfenumunit ( Dwarf d,
ulong  unit,
DwarfSym s 
)

Definition at line 201 of file dwarfinfo.c.

202{
203 int i;
204 ulong aoff, len;
205
206 if(unit >= d->info.len){
207 werrstr("dwarf unit address 0x%x >= 0x%x out of range", unit, d->info.len);
208 return -1;
209 }
210 memset(s, 0, sizeof *s);
211 memset(&s->b, 0, sizeof s->b);
212
213 s->b.d = d;
214 s->b.p = d->info.data + unit;
215 s->b.ep = d->info.data + d->info.len;
216 len = dwarfget4(&s->b);
217 s->nextunit = unit + 4 + len;
218
219 if(s->b.ep - s->b.p < len){
220 badheader:
221 werrstr("bad dwarf unit header at unit 0x%lux", unit);
222 return -1;
223 }
224 s->b.ep = s->b.p+len;
225 if((i=dwarfget2(&s->b)) != 2)
226 goto badheader;
227 aoff = dwarfget4(&s->b);
228 s->b.addrsize = dwarfget1(&s->b);
229 if(d->addrsize == 0)
230 d->addrsize = s->b.addrsize;
231 if(s->b.p == nil)
232 goto badheader;
233
234 s->aoff = aoff;
235 s->unit = unit;
236 s->depth = 0;
237 return 0;
238}

Referenced by _dwarfnametounit(), and dwarfpctoline().

◆ dwarfget1()

ulong dwarfget1 ( DwarfBuf b)

Definition at line 17 of file dwarfget.c.

18{
19 if(b->p==nil || b->p+1 > b->ep){
20 b->p = nil;
21 return 0;
22 }
23 return *b->p++;
24}

Referenced by constblock(), dexec(), dwarfaddrtounit(), dwarfenumunit(), dwarfgetarg(), dwarfpctoline(), findfde(), getblock(), getuchar(), getulong(), and parseabbrevs().

◆ dwarfget128()

ulong dwarfget128 ( DwarfBuf b)

Definition at line 152 of file dwarfget.c.

153{
154 static int nbad;
155 ulong c, d;
156
157 if(b->p == nil)
158 return 0;
159 c = *b->p++;
160 if(!(c&0x80))
161{n1++;
162 return c;
163}
164 c &= ~0x80;
165 d = *b->p++;
166 c |= (d&0x7F)<<7;
167 if(!(d&0x80))
168{n2++;
169 return c;
170}
171 d = *b->p++;
172 c |= (d&0x7F)<<14;
173 if(!(d&0x80))
174{n3++;
175 return c;
176}
177 d = *b->p++;
178 c |= (d&0x7F)<<21;
179 if(!(d&0x80))
180{n4++;
181 return c;
182}
183 d = *b->p++;
184 c |= (d&0x7F)<<28;
185 if(!(d&0x80))
186{n5++;
187 return c;
188}
189 while(b->p<b->ep && *b->p&0x80)
190 b->p++;
191 if(++nbad == 1)
192 werrstr("dwarf: overflow during parsing of uleb128 integer\n");
193 return c;
194}
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
int n4
Definition: dwarfget.c:147
int n5
Definition: dwarfget.c:147
int n2
Definition: dwarfget.c:147
int n1
Definition: dwarfget.c:147
int n3
Definition: dwarfget.c:147

Referenced by constblock(), dexec(), dwarfgetarg(), dwarfnextsym(), dwarfpctoline(), findfde(), getblock(), getulong(), parseabbrevs(), and parseattrs().

◆ dwarfget128s()

long dwarfget128s ( DwarfBuf b)

Definition at line 197 of file dwarfget.c.

198{
199 int nb, c;
200 ulong v;
201 static int nbad;
202
203 v = 0;
204 nb = 0;
205 if(b->p==nil)
206 return 0;
207 while(b->p<b->ep){
208 c = *b->p++;
209 v |= (c & 0x7F)<<nb;
210 nb += 7;
211 if(!(c&0x80))
212 break;
213 }
214 if(v&(1<<(nb-1)))
215 v |= ~(((ulong)1<<nb)-1);
216 if(nb > 8*sizeof(ulong)){
217 if(0)
218 if(++nbad == 1)
219 werrstr("dwarf: overflow during parsing of sleb128 integer: got %d bits", nb);
220 }
221 return v;
222}
const GLdouble * v
Definition: gl.h:2040

Referenced by constblock(), dexec(), dwarfgetarg(), dwarfpctoline(), findfde(), and getulong().

◆ dwarfget2()

ulong dwarfget2 ( DwarfBuf b)

Definition at line 81 of file dwarfget.c.

82{
83 ulong v;
84
85 if(b->p==nil || b->p+2 > b->ep){
86 b->p = nil;
87 return 0;
88 }
89 v = b->d->pe->e2(b->p);
90 b->p += 2;
91 return v;
92}

Referenced by _dwarfnametounit(), constblock(), dexec(), dwarfaddrtounit(), dwarfargvalue(), dwarfenumunit(), dwarfgetarg(), dwarfpctoline(), getblock(), and getulong().

◆ dwarfget4()

ulong dwarfget4 ( DwarfBuf b)

Definition at line 95 of file dwarfget.c.

96{
97 ulong v;
98
99 if(b->p==nil || b->p+4 > b->ep){
100 b->p = nil;
101 return 0;
102 }
103 v = b->d->pe->e4(b->p);
104 b->p += 4;
105 return v;
106}

Referenced by _dwarfnametounit(), constblock(), dexec(), dwarfaddrtounit(), dwarfargvalue(), dwarfenumunit(), dwarfgetarg(), dwarfpctoline(), findfde(), getblock(), getstring(), and getulong().

◆ dwarfget8()

uvlong dwarfget8 ( DwarfBuf b)

Definition at line 109 of file dwarfget.c.

110{
111 uvlong v;
112
113 if(b->p==nil || b->p+8 > b->ep){
114 b->p = nil;
115 return 0;
116 }
117 v = b->d->pe->e8(b->p);
118 b->p += 8;
119 return v;
120}
unsigned long long uvlong
Definition: compat.h:9

Referenced by constblock(), and getulong().

◆ dwarfgetabbrev()

DwarfAbbrev * dwarfgetabbrev ( Dwarf d,
ulong  off,
ulong  num 
)

Definition at line 128 of file dwarfabbrev.c.

129{
130 DwarfAbbrev *a;
131 int na;
132
133 if((na = loadabbrevs(d, off, &a)) < 0){
134 werrstr("loadabbrevs: %r");
135 return nil;
136 }
137 return findabbrev(a, na, num);
138}
GLuint GLuint num
Definition: glext.h:9618
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
static DwarfAbbrev * findabbrev(DwarfAbbrev *a, int na, ulong num)
Definition: dwarfabbrev.c:116
static int loadabbrevs(Dwarf *d, ulong off, DwarfAbbrev **aa)
Definition: dwarfabbrev.c:25

Referenced by dwarfnextsym().

◆ dwarfgetaddr()

ulong dwarfgetaddr ( DwarfBuf b)

Definition at line 123 of file dwarfget.c.

124{
125 static int nbad;
126
127 if(b->addrsize == 0)
128 b->addrsize = b->d->addrsize;
129
130 switch(b->addrsize){
131 case 1:
132 return dwarfget1(b);
133 case 2:
134 return dwarfget2(b);
135 case 4:
136 return dwarfget4(b);
137 case 8:
138 return dwarfget8(b);
139 default:
140 if(++nbad == 1)
141 werrstr("dwarf: unexpected address size %lud in dwarfgetaddr\n", b->addrsize);
142 b->p = nil;
143 return 0;
144 }
145}
ulong dwarfget1(DwarfBuf *b)
Definition: dwarfget.c:17
uvlong dwarfget8(DwarfBuf *b)
Definition: dwarfget.c:109
ulong dwarfget4(DwarfBuf *b)
Definition: dwarfget.c:95
ulong dwarfget2(DwarfBuf *b)
Definition: dwarfget.c:81

Referenced by constblock(), dexec(), dwarfaddrtounit(), dwarfpctoline(), findfde(), and getulong().

◆ dwarfgetinfounit()

int dwarfgetinfounit ( Dwarf ,
ulong  ,
DwarfBlock  
)

◆ dwarfgetn()

int dwarfgetn ( DwarfBuf b,
uchar a,
int  n 
)

Definition at line 27 of file dwarfget.c.

28{
29 if(b->p==nil || b->p+n > b->ep){
30 b->p = nil;
31 memset(a, 0, n);
32 return -1;
33 }
34 memmove(a, b->p, n);
35 b->p += n;
36 return 0;
37}
GLdouble n
Definition: glext.h:7729
#define memmove(s1, s2, n)
Definition: mkisofs.h:881

◆ dwarfgetnref()

uchar * dwarfgetnref ( DwarfBuf b,
ulong  n 
)

Definition at line 40 of file dwarfget.c.

41{
42 uchar *p;
43
44 if(b->p==nil || b->p+n > b->ep){
45 b->p = nil;
46 return nil;
47 }
48 p = b->p;
49 b->p += n;
50 return p;
51}
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by dexec(), dwarfpctoline(), and getblock().

◆ dwarfgetstring()

char * dwarfgetstring ( DwarfBuf b)

Definition at line 54 of file dwarfget.c.

55{
56 char *s;
57
58 if(b->p == nil)
59 return nil;
60 s = (char*)b->p;
61 while(b->p < b->ep && *b->p)
62 b->p++;
63 if(b->p >= b->ep){
64 b->p = nil;
65 return nil;
66 }
67 b->p++;
68 return s;
69}

Referenced by _dwarfnametounit(), dwarfpctoline(), findfde(), and getstring().

◆ dwarflookupfn()

int dwarflookupfn ( Dwarf d,
ulong  unit,
ulong  pc,
DwarfSym s 
)

Definition at line 181 of file dwarfinfo.c.

182{
183 if(dwarfenumunit(d, unit, s) < 0)
184 return -1;
185
186 if(dwarfnextsymat(d, s, 0) != 1)
187 return -1;
188 /* s is now the CompileUnit */
189
190 while(dwarfnextsymat(d, s, 1) == 1){
191 if(s->attrs.tag != TagSubprogram)
192 continue;
193 if(s->attrs.lowpc <= pc && pc < s->attrs.highpc)
194 return 0;
195 }
196 werrstr("fn containing pc 0x%lux not found", pc);
197 return -1;
198}
int dwarfnextsymat(Dwarf *d, DwarfSym *s, int depth)
Definition: dwarfinfo.c:292

Referenced by dwarfpctoline().

◆ dwarflookupname()

int dwarflookupname ( Dwarf d,
char name,
DwarfSym sym 
)

Definition at line 67 of file dwarfpubnames.c.

68{
69 return _dwarfnametounit(d, name, &d->pubnames, sym);
70}
static int _dwarfnametounit(Dwarf *d, char *name, DwarfBlock *bl, DwarfSym *s)
Definition: dwarfpubnames.c:12
Definition: name.c:39

◆ dwarflookupnameinunit()

int dwarflookupnameinunit ( Dwarf d,
ulong  unit,
char name,
DwarfSym s 
)

Definition at line 125 of file dwarfinfo.c.

126{
127 if(dwarfenumunit(d, unit, s) < 0)
128 return -1;
129
130 dwarfnextsymat(d, s, 0); /* s is now the CompileUnit */
131 while(dwarfnextsymat(d, s, 1) == 1)
132 if(s->attrs.name && strcmp(s->attrs.name, name) == 0)
133 return 0;
134 werrstr("symbol '%s' not found", name);
135 return -1;
136}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by RosSymAggregate().

◆ dwarflookupsubname()

int dwarflookupsubname ( Dwarf d,
DwarfSym parent,
char name,
DwarfSym s 
)

Definition at line 140 of file dwarfinfo.c.

141{
142 *s = *parent;
143 while(dwarfnextsymat(d, s, parent->depth+1))
144 if(s->attrs.name && strcmp(s->attrs.name, name) == 0)
145 return 0;
146 werrstr("symbol '%s' not found", name);
147 return -1;
148}
r parent
Definition: btrfs.c:3010

◆ dwarflookuptag()

int dwarflookuptag ( Dwarf d,
ulong  unit,
ulong  tag,
DwarfSym s 
)

Definition at line 151 of file dwarfinfo.c.

152{
153 if(dwarfenumunit(d, unit, s) < 0) {
154 return -1;
155 }
156
157 dwarfnextsymat(d, s, 0); /* s is now the CompileUnit */
158 if(s->attrs.tag == tag) {
159 return 0;
160 }
161 while(dwarfnextsymat(d, s, 1) == 1)
162 if(s->attrs.tag == tag) {
163 return 0;
164 }
165 werrstr("symbol with tag 0x%lux not found", tag);
166 return -1;
167}
Definition: ecma_167.h:138

Referenced by dwarfpctoline().

◆ dwarfnextsym()

int dwarfnextsym ( Dwarf d,
DwarfSym s 
)

Definition at line 250 of file dwarfinfo.c.

251{
252 ulong num;
253 DwarfAbbrev *a;
254
255 if(s->attrs.haskids)
256 s->depth++;
257top:
258 if(s->b.p >= s->b.ep){
259 if(s->allunits && s->nextunit < d->info.len){
260 if(dwarfenumunit(d, s->nextunit, s) < 0) {
261 return -1;
262 }
263 s->allunits = 1;
264 goto top;
265 }
266 return 0;
267 }
268
269 s->uoff = s->b.p - (d->info.data+s->unit);
270 num = dwarfget128(&s->b);
271 if(num == 0){
272 if(s->depth == 0) {
273 return 0;
274 }
275 if(s->depth > 0)
276 s->depth--;
277 goto top;
278 }
279
280 a = dwarfgetabbrev(d, s->aoff, num);
281 if(a == nil){
282 werrstr("getabbrev %ud %ud for %ud,%ud: %r\n", s->aoff, num, s->unit, s->uoff);
283 return -1;
284 }
285 if(parseattrs(&s->b, s->unit, a, &s->attrs) < 0) {
286 return -1;
287 }
288 return 1;
289}
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
static int parseattrs(DwarfBuf *, ulong, DwarfAbbrev *, DwarfAttrs *)
Definition: dwarfinfo.c:407
ulong dwarfget128(DwarfBuf *)
Definition: dwarfget.c:152
DwarfAbbrev * dwarfgetabbrev(Dwarf *, ulong, ulong)
Definition: dwarfabbrev.c:128

Referenced by _dwarfnametounit(), dwarfpctoline(), and main().

◆ dwarfnextsymat()

int dwarfnextsymat ( Dwarf d,
DwarfSym s,
int  depth 
)

Definition at line 292 of file dwarfinfo.c.

293{
294 int r;
295 DwarfSym t;
296 uint sib;
297
298 if(s->depth == depth && s->attrs.have.sibling){
299 sib = s->attrs.sibling;
300 if(sib < d->info.len && d->info.data+sib >= s->b.p)
301 s->b.p = d->info.data+sib;
302 s->attrs.haskids = 0;
303 }
304
305 /*
306 * The funny game with t and s make sure that
307 * if we get to the end of a run of a particular
308 * depth, we leave s so that a call to nextsymat with depth-1
309 * will actually produce the desired guy. We could change
310 * the interface to dwarfnextsym instead, but I'm scared
311 * to touch it.
312 */
313 t = *s;
314 for(;;){
315 if((r = dwarfnextsym(d, &t)) != 1) {
316 return r;
317 }
318 if(t.depth < depth){
319 /* went too far - nothing to see */
320 return 0;
321 }
322 *s = t;
323 if(t.depth == depth) {
324 return 1;
325 }
326 }
327}
UINT32 uint
Definition: types.h:83
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
int dwarfnextsym(Dwarf *d, DwarfSym *s)
Definition: dwarfinfo.c:250

Referenced by dwarfgetparams(), dwarflookupchildtag(), dwarflookupfn(), dwarflookupnameinunit(), dwarflookupsubname(), dwarflookuptag(), dwarfnextsym(), dwarfpctoline(), dwarfseeksym(), and RosSymAggregate().

◆ dwarfopen()

Dwarf * dwarfopen ( struct _Pe elf)

Definition at line 16 of file dwarfopen.c.

17{
18 Dwarf *d;
19
20 if(pe == nil){
21 werrstr("nil pe passed to dwarfopen");
22 return nil;
23 }
24
25 d = mallocz(sizeof(Dwarf), 1);
26 if(d == nil)
27 return nil;
28
29 d->pe = pe;
30 if(pe->loadsection(pe, ".debug_abbrev", &d->abbrev) < 0
31 || pe->loadsection(pe, ".debug_aranges", &d->aranges) < 0
32 || pe->loadsection(pe, ".debug_line", &d->line) < 0
33 || pe->loadsection(pe, ".debug_pubnames", &d->pubnames) < 0
34 || pe->loadsection(pe, ".debug_info", &d->info) < 0)
35 goto err;
36 pe->loadsection(pe, ".debug_frame", &d->frame);
37 pe->loadsection(pe, ".debug_ranges", &d->ranges);
38 pe->loadsection(pe, ".debug_str", &d->str);
39
40 return d;
41
42err:
43 DPRINT("Failed to open dwarf\n");
44 free(d->abbrev.data);
45 free(d->aranges.data);
46 free(d->frame.data);
47 free(d->line.data);
48 free(d->pubnames.data);
49 free(d->ranges.data);
50 free(d->str.data);
51 free(d->info.data);
52 free(d);
53 return nil;
54}
#define err(...)
#define mallocz(x, y)
Definition: compat.h:36
#define DPRINT
Definition: sndvol32.h:73
Definition: dwarf.h:437

Referenced by main(), RosSymCreateFromFile(), and RosSymCreateFromMem().

◆ dwarfpctoline()

int dwarfpctoline ( Dwarf d,
ulong  pc,
char **  cdir,
char **  dir,
char **  file,
char **  function,
ulong line,
ulong mtime,
ulong length 
)

Definition at line 48 of file dwarfpc.c.

49{
50 uchar *prog, *opcount, *end, *dirs;
51 ulong off, unit, len, vers, x, start, lastline;
52 int i, first, firstline, op, a, l, quantum, isstmt, linebase, linerange, opcodebase, nf;
53 char *files, *s;
54 DwarfBuf b;
55 DwarfSym sym;
56 State emit, cur, reset;
57 uchar **f, **newf;
58
59 f = nil;
60
61 if(dwarfaddrtounit(d, pc, &unit) < 0
62 || dwarflookuptag(d, unit, TagCompileUnit, &sym) < 0)
63 return -1;
64
65 if(!sym.attrs.have.stmtlist){
66 werrstr("no line mapping information for 0x%x", pc);
67 return -1;
68 }
69 off = sym.attrs.stmtlist;
70 if(off >= d->line.len){
71 werrstr("bad stmtlist\n");
72 goto bad;
73 }
74
75 if(trace) werrstr("unit 0x%x stmtlist 0x%x", unit, sym.attrs.stmtlist);
76
77 memset(&b, 0, sizeof b);
78 b.d = d;
79 b.p = d->line.data + off;
80 b.ep = b.p + d->line.len;
81 b.addrsize = sym.b.addrsize; /* should i get this from somewhere else? */
82
83 len = dwarfget4(&b);
84 if(b.p==nil || b.p+len > b.ep || b.p+len < b.p){
85 werrstr("bad len\n");
86 goto bad;
87 }
88
89 b.ep = b.p+len;
90 vers = dwarfget2(&b);
91 if(vers != 2){
92 werrstr("bad dwarf version 0x%x", vers);
93 return -1;
94 }
95
96 len = dwarfget4(&b);
97 if(b.p==nil || b.p+len > b.ep || b.p+len < b.p){
98 werrstr("another bad len\n");
99 goto bad;
100 }
101 prog = b.p+len;
102
103 quantum = dwarfget1(&b);
104 isstmt = dwarfget1(&b);
105 linebase = (schar)dwarfget1(&b);
106 linerange = (schar)dwarfget1(&b);
107 opcodebase = dwarfget1(&b);
108
109 opcount = b.p-1;
110 dwarfgetnref(&b, opcodebase-1);
111 if(b.p == nil){
112 werrstr("bad opcode chart\n");
113 goto bad;
114 }
115
116 /* just skip the files and dirs for now; we'll come back */
117 dirs = b.p;
118 while (b.p && *b.p)
120 dwarfget1(&b);
121
122 files = (char*)b.p;
123 while(b.p!=nil && *b.p!=0){
125 dwarfget128(&b);
126 dwarfget128(&b);
127 dwarfget128(&b);
128 }
129 dwarfget1(&b);
130
131 /* move on to the program */
132 if(b.p == nil || b.p > prog){
133 werrstr("bad header\n");
134 goto bad;
135 }
136 b.p = prog;
137
138 reset.addr = 0;
139 reset.file = 1;
140 reset.line = 1;
141 reset.column = 0;
142 reset.flags = isstmt ? Isstmt : 0;
143 reset.isa = 0;
144
145 cur = reset;
146 emit = reset;
147 nf = 0;
148 start = 0;
149 if(trace) werrstr("program @ %lu ... %.*H opbase = %d\n", b.p - d->line.data, b.ep-b.p, b.p, opcodebase);
150 first = 1;
151 while(b.p != nil){
152 firstline = 0;
153 op = dwarfget1(&b);
154 if(trace) werrstr("\tline %lu, addr 0x%x, op %d %.10H", cur.line, cur.addr, op, b.p);
155 if(op >= opcodebase){
156 a = (op - opcodebase) / linerange;
157 l = (op - opcodebase) % linerange + linebase;
158 cur.line += l;
159 cur.addr += a * quantum;
160 if(trace) werrstr(" +%d,%d\n", a, l);
161 emit:
162 if(first){
163 if(cur.addr > pc){
164 werrstr("found wrong line mapping 0x%x for pc 0x%x", cur.addr, pc);
165 /* This is an overzealous check. gcc can produce discontiguous ranges
166 and reorder statements, so it's possible for a future line to start
167 ahead of pc and still find a matching one. */
168 /*goto out;*/
169 firstline = 1;
170 }
171 first = 0;
172 start = cur.addr;
173 }
174 if(cur.addr > pc && !firstline)
175 break;
176 if(b.p == nil){
177 werrstr("buffer underflow in line mapping");
178 goto out;
179 }
180 emit = cur;
181 if(emit.flags & EndSequence){
182 werrstr("found wrong line mapping 0x%x-0x%x for pc 0x%x", start, cur.addr, pc);
183 goto out;
184 }
186 }else{
187 switch(op){
188 case 0: /* extended op code */
189 if(trace) werrstr(" ext");
190 len = dwarfget128(&b);
191 end = b.p+len;
192 if(b.p == nil || end > b.ep || end < b.p || len < 1)
193 goto bad;
194 switch(dwarfget1(&b)){
195 case 1: /* end sequence */
196 if(trace) werrstr(" end\n");
197 cur.flags |= EndSequence;
198 goto emit;
199 case 2: /* set address */
200 cur.addr = dwarfgetaddr(&b);
201 if(trace) werrstr(" set pc 0x%x\n", cur.addr);
202 break;
203 case 3: /* define file */
204 newf = malloc(nf+1*sizeof(f[0]));
205 if (newf)
206 RtlMoveMemory(newf, f, nf*sizeof(f[0]));
207 if(newf == nil)
208 goto out;
209 f[nf++] = b.p;
210 s = dwarfgetstring(&b);
211 dwarfget128(&b);
212 dwarfget128(&b);
213 dwarfget128(&b);
214 if(trace) werrstr(" def file %s\n", s);
215 break;
216 }
217 if(b.p == nil || b.p > end)
218 goto bad;
219 b.p = end;
220 break;
221 case 1: /* emit */
222 if(trace) werrstr(" emit\n");
223 goto emit;
224 case 2: /* advance pc */
225 a = dwarfget128(&b);
226 if(trace) werrstr(" advance pc + %lu\n", a*quantum);
227 cur.addr += a * quantum;
228 break;
229 case 3: /* advance line */
230 l = dwarfget128s(&b);
231 if(trace) werrstr(" advance line + %ld\n", l);
232 cur.line += l;
233 break;
234 case 4: /* set file */
235 if(trace) werrstr(" set file\n");
236 cur.file = dwarfget128s(&b);
237 break;
238 case 5: /* set column */
239 if(trace) werrstr(" set column\n");
240 cur.column = dwarfget128(&b);
241 break;
242 case 6: /* negate stmt */
243 if(trace) werrstr(" negate stmt\n");
244 cur.flags ^= Isstmt;
245 break;
246 case 7: /* set basic block */
247 if(trace) werrstr(" set basic block\n");
248 cur.flags |= BasicDwarfBlock;
249 break;
250 case 8: /* const add pc */
251 a = (255 - opcodebase) / linerange * quantum;
252 if(trace) werrstr(" const add pc + %d\n", a);
253 cur.addr += a;
254 break;
255 case 9: /* fixed advance pc */
256 a = dwarfget2(&b);
257 if(trace) werrstr(" fixed advance pc + %d\n", a);
258 cur.addr += a;
259 break;
260 case 10: /* set prologue end */
261 if(trace) werrstr(" set prologue end\n");
262 cur.flags |= PrologueEnd;
263 break;
264 case 11: /* set epilogue begin */
265 if(trace) werrstr(" set epilogue begin\n");
266 cur.flags |= EpilogueBegin;
267 break;
268 case 12: /* set isa */
269 if(trace) werrstr(" set isa\n");
270 cur.isa = dwarfget128(&b);
271 break;
272 default: /* something new - skip it */
273 if(trace) werrstr(" unknown %d\n", opcount[op]);
274 for(i=0; i<opcount[op]; i++)
275 dwarfget128(&b);
276 break;
277 }
278 }
279 }
280 if(b.p == nil)
281 goto bad;
282
283 /* finally! the data we seek is in "emit" */
284
285 if(emit.file == 0){
286 werrstr("invalid file index in mapping data");
287 goto out;
288 }
289 if(line)
290 *line = emit.line;
291
292 /* skip over first emit.file-2 guys */
293 b.p = (uchar*)files;
294 for(i=emit.file-1; i > 0 && b.p!=nil && *b.p!=0; i--){
296 dwarfget128(&b);
297 dwarfget128(&b);
298 dwarfget128(&b);
299 }
300 if(b.p == nil){
301 werrstr("problem parsing file data second time (cannot happen)");
302 goto bad;
303 }
304 if(*b.p == 0){
305 if(i >= nf){
306 werrstr("bad file index in mapping data");
307 goto bad;
308 }
309 b.p = f[i];
310 }
311 s = dwarfgetstring(&b);
312 if(file)
313 *file = s;
314 i = dwarfget128(&b); /* directory */
315 x = dwarfget128(&b);
316 if(mtime)
317 *mtime = x;
318 x = dwarfget128(&b);
319 if(length)
320 *length = x;
321
322 /* fetch dir name */
323 if(cdir)
324 *cdir = sym.attrs.compdir;
325
326 if(dir){
327 *dir = nil;
328 b.p = dirs;
329 for (x = 1; b.p && *b.p; x++)
330 if (x == i) {
331 *dir = dwarfgetstring(&b);
332 break;
333 }
334 }
335
336 *function = nil;
337 lastline = 0;
338#if 0
339 if (dwarfenumunit(d, unit, &proc) >= 0) {
340 dwarfnextsymat(d, &proc, 0);
341 while (dwarfnextsymat(d, &proc, 1) == 1) {
342 if (proc.attrs.tag == TagSubprogram &&
343 proc.attrs.have.name &&
344 proc.attrs.declfile == emit.file &&
345 proc.attrs.declline <= *line &&
346 proc.attrs.declline > lastline) {
347 lastline = proc.attrs.declline;
348 free(*function);
349 *function = malloc(strlen(proc.attrs.name)+1);
350 strcpy(*function, proc.attrs.name);
351 }
352 }
353 }
354#elif 1
355 ulong lastaddr = 0;
356 *function = NULL;
357 for (i = 0; i < d->pe->nsymbols; i++) {
358 if (d->pe->symtab[i].address > lastaddr &&
359 d->pe->symtab[i].address <= pc - d->pe->imagebase &&
360 d->pe->symtab[i].address < d->pe->imagesize) {
361 lastaddr = d->pe->symtab[i].address;
362 *function = d->pe->symtab[i].name;
363 }
364 }
365#else
366 // *sigh* we get unrelocated low_pc and high_pc because the dwarf symbols
367 // are not 'loaded' in the PE sense.
368 if (dwarflookupfn(d, unit, pc, &proc) >= 0) {
369 *function = malloc(strlen(proc.attrs.name)+1);
370 strcpy(*function, proc.attrs.name);
371 }
372#endif
373
374 /* free at last, free at last */
375 free(f);
376 return 0;
377
378bad:
379 werrstr("corrupted line mapping for 0x%x", pc);
380out:
381 free(f);
382 return -1;
383}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int dir
Definition: maze.c:112
r l[0]
Definition: byte_order.h:168
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
UINT op
Definition: effect.c:236
FxCollectionEntry * cur
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLboolean reset
Definition: glext.h:5666
GLfloat f
Definition: glext.h:7540
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
const GLint * first
Definition: glext.h:5794
char * prog
Definition: isohybrid.c:47
#define f
Definition: ke_i.h:83
static HANDLE proc()
Definition: pdb.c:34
static FILE * out
Definition: regtests2xml.c:44
#define trace
Definition: dwarfpc.c:25
@ BasicDwarfBlock
Definition: dwarfpc.c:30
@ EpilogueBegin
Definition: dwarfpc.c:33
@ Isstmt
Definition: dwarfpc.c:29
@ PrologueEnd
Definition: dwarfpc.c:32
@ EndSequence
Definition: dwarfpc.c:31
signed char schar
Definition: compat.h:5
int dwarfenumunit(Dwarf *, ulong, DwarfSym *)
Definition: dwarfinfo.c:201
int dwarflookuptag(Dwarf *, ulong, ulong, DwarfSym *)
Definition: dwarfinfo.c:151
int dwarflookupfn(Dwarf *, ulong, ulong, DwarfSym *)
Definition: dwarfinfo.c:181
char * dwarfgetstring(DwarfBuf *)
Definition: dwarfget.c:54
long dwarfget128s(DwarfBuf *)
Definition: dwarfget.c:197
uchar * dwarfgetnref(DwarfBuf *, ulong)
Definition: dwarfget.c:40
int dwarfaddrtounit(Dwarf *, ulong, ulong *)
Definition: dwarfaranges.c:16
int dwarfnextsymat(Dwarf *, DwarfSym *, int)
Definition: dwarfinfo.c:292
struct DwarfAttrs::@4961 have
uchar stmtlist
Definition: dwarf.h:282
uchar compdir
Definition: dwarf.h:239
uint addrsize
Definition: dwarf.h:212
DwarfAttrs attrs
Definition: dwarf.h:375
DwarfBuf b
Definition: dwarf.h:378
ulong line
Definition: dwarfpc.c:41
ulong file
Definition: dwarfpc.c:40
ulong flags
Definition: dwarfpc.c:43
char * name
Definition: compiler.c:66
Definition: fci.c:127
Definition: parser.c:49
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by main(), and RosSymGetAddressInformation().

◆ dwarfseeksym()

int dwarfseeksym ( Dwarf d,
ulong  unit,
ulong  off,
DwarfSym s 
)

Definition at line 170 of file dwarfinfo.c.

171{
172 if(dwarfenumunit(d, unit, s) < 0)
173 return -1;
174 s->b.p = d->info.data + unit + off;
175 if(dwarfnextsymat(d, s, 0) != 1)
176 return -1;
177 return 0;
178}

Referenced by RosSymAggregate().

◆ dwarfunwind()

int dwarfunwind ( Dwarf d,
ulong  pc,
DwarfExpr cfa,
DwarfExpr ra,
DwarfExpr r,
int  nr 
)

Definition at line 47 of file dwarfcfa.c.

48{
49 int i, ret;
50 DwarfBuf fde, b;
51 DwarfExpr *initr;
52 State s;
53
54 initr = mallocz(nr*sizeof(initr[0]), 1);
55 if(initr == 0)
56 return -1;
57
58 memset(&s, 0, sizeof s);
59 s.loc = 0;
60 s.cfa = cfa;
61 s.ra = ra;
62 s.r = r;
63 s.nr = nr;
64
65 if(findfde(d, pc, &s, &fde) < 0){
66 free(initr);
67 return -1;
68 }
69
70 memset(r, 0, nr*sizeof(r[0]));
71 for(i=0; i<nr; i++)
72 r[i].type = RuleSame;
73 if(trace) werrstr("s.init %p-%p, fde %p-%p\n", s.init.p, s.init.ep, fde.p, fde.ep);
74 b = s.init;
75 if(dexec(&b, &s, 0) < 0)
76 goto err;
77
78 s.initr = initr;
79 memmove(initr, r, nr*sizeof(initr[0]));
80
81 if(trace) werrstr("s.loc 0x%lux pc 0x%lux\n", s.loc, pc);
82 while(s.loc < pc){
83 if(trace) werrstr("s.loc 0x%lux pc 0x%lux\n", s.loc, pc);
84 if(dexec(&fde, &s, 1) < 0)
85 goto err;
86 }
87 *ra = s.r[s.rareg];
88
89 ret = 0;
90 goto out;
91
92err:
93 ret = -1;
94out:
95 free(initr);
96 for(i=0; i<s.nstack; i++)
97 free(s.stack[i]);
98 free(s.stack);
99 return ret;
100}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
ULONG nr
Definition: thread.c:7
static int findfde(Dwarf *, ulong, State *, DwarfBuf *)
Definition: dwarfcfa.c:109
#define trace
Definition: dwarfcfa.c:21
static int dexec(DwarfBuf *, State *, int)
Definition: dwarfcfa.c:189
uchar * p
Definition: dwarf.h:210
uchar * ep
Definition: dwarf.h:211
int ret

Referenced by dwarfregunwind(), and printrules().

Variable Documentation

◆ dwarf386fp

char* dwarf386fp
extern

◆ dwarf386nregs

int dwarf386nregs
extern

Definition at line 22 of file dwarf386.c.

◆ dwarf386regs

char* dwarf386regs[]
extern

Definition at line 10 of file dwarf386.c.