ReactOS 0.4.15-dev-6661-gcc6e444
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 17 of file dwarfaranges.c.

18{
19 DwarfBuf b;
20 int segsize, i;
21 ulong len, id, off, base, size;
22 uchar *start, *end;
23
24 memset(&b, 0, sizeof b);
25 b.d = d;
26 b.p = d->aranges.data;
27 b.ep = b.p + d->aranges.len;
28
29 while(b.p < b.ep){
30 start = b.p;
31 len = dwarfget4(&b);
32 if (!len) { b.ep = b.p - 4; return -1; }
33 if((id = dwarfget2(&b)) != 2){
34 if(b.p == nil){
35 underflow:
36 werrstr("buffer underflow reading address ranges header");
37 }else
38 werrstr("bad dwarf version 0x%x in address ranges header", id);
39 return -1;
40 }
41 off = dwarfget4(&b);
42 b.addrsize = dwarfget1(&b);
43 if(d->addrsize == 0)
44 d->addrsize = b.addrsize;
45 segsize = dwarfget1(&b);
46 USED(segsize); /* what am i supposed to do with this? */
47 if(b.p == nil)
48 goto underflow;
49 if((i = (b.p-start) % (2*b.addrsize)) != 0)
50 b.p += 2*b.addrsize - i;
51 end = start+4+len;
52 while(b.p!=nil && b.p<end){
55 if (!size) continue;
56 if(b.p == nil)
57 goto underflow;
58 if(base <= addr && addr < base+size){
59 *unit = off;
60 return 0;
61 }
62 }
63 if(b.p == nil)
64 goto underflow;
65 b.p = end;
66 }
67 werrstr("address 0x%lux is not listed in dwarf debugging symbols", addr);
68 return -1;
69}
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:82
ulong dwarfget1(DwarfBuf *)
Definition: dwarfget.c:18
ulong dwarfgetaddr(DwarfBuf *)
Definition: dwarfget.c:124
ulong dwarfget4(DwarfBuf *)
Definition: dwarfget.c:96

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 242 of file dwarfinfo.c.

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

Referenced by main().

◆ dwarfenumunit()

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

Definition at line 202 of file dwarfinfo.c.

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

Referenced by _dwarfnametounit(), and dwarfpctoline().

◆ dwarfget1()

ulong dwarfget1 ( DwarfBuf b)

Definition at line 18 of file dwarfget.c.

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

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

◆ dwarfget128()

ulong dwarfget128 ( DwarfBuf b)

Definition at line 153 of file dwarfget.c.

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

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

◆ dwarfget128s()

long dwarfget128s ( DwarfBuf b)

Definition at line 198 of file dwarfget.c.

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

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

◆ dwarfget2()

ulong dwarfget2 ( DwarfBuf b)

Definition at line 82 of file dwarfget.c.

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

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

◆ dwarfget4()

ulong dwarfget4 ( DwarfBuf b)

Definition at line 96 of file dwarfget.c.

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

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

◆ dwarfget8()

uvlong dwarfget8 ( DwarfBuf b)

Definition at line 110 of file dwarfget.c.

111{
112 uvlong v;
113
114 if(b->p==nil || b->p+8 > b->ep){
115 b->p = nil;
116 return 0;
117 }
118 v = b->d->pe->e8(b->p);
119 b->p += 8;
120 return v;
121}
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 129 of file dwarfabbrev.c.

130{
131 DwarfAbbrev *a;
132 int na;
133
134 if((na = loadabbrevs(d, off, &a)) < 0){
135 werrstr("loadabbrevs: %r");
136 return nil;
137 }
138 return findabbrev(a, na, num);
139}
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:117
static int loadabbrevs(Dwarf *d, ulong off, DwarfAbbrev **aa)
Definition: dwarfabbrev.c:26

Referenced by dwarfnextsym().

◆ dwarfgetaddr()

ulong dwarfgetaddr ( DwarfBuf b)

Definition at line 124 of file dwarfget.c.

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

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 28 of file dwarfget.c.

29{
30 if(b->p==nil || b->p+n > b->ep){
31 b->p = nil;
32 memset(a, 0, n);
33 return -1;
34 }
35 memmove(a, b->p, n);
36 b->p += n;
37 return 0;
38}
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 41 of file dwarfget.c.

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

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

◆ dwarfgetstring()

char * dwarfgetstring ( DwarfBuf b)

Definition at line 55 of file dwarfget.c.

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

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

◆ dwarflookupfn()

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

Definition at line 182 of file dwarfinfo.c.

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

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 126 of file dwarfinfo.c.

127{
128 if(dwarfenumunit(d, unit, s) < 0)
129 return -1;
130
131 dwarfnextsymat(d, s, 0); /* s is now the CompileUnit */
132 while(dwarfnextsymat(d, s, 1) == 1)
133 if(s->attrs.name && strcmp(s->attrs.name, name) == 0)
134 return 0;
135 werrstr("symbol '%s' not found", name);
136 return -1;
137}
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 141 of file dwarfinfo.c.

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

◆ dwarflookuptag()

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

Definition at line 152 of file dwarfinfo.c.

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

Referenced by dwarfpctoline().

◆ dwarfnextsym()

int dwarfnextsym ( Dwarf d,
DwarfSym s 
)

Definition at line 251 of file dwarfinfo.c.

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

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

◆ dwarfnextsymat()

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

Definition at line 293 of file dwarfinfo.c.

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

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:71
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 49 of file dwarfpc.c.

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

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

Referenced by RosSymAggregate().

◆ dwarfunwind()

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

Definition at line 48 of file dwarfcfa.c.

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