ReactOS 0.4.15-dev-7918-g2a2556c
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  DwarfParam
 
struct  DwarfBuf
 
union  DwarfVal
 
struct  DwarfAttrs
 
struct  DwarfExpr
 
struct  DwarfSym
 
struct  DwarfAttr
 
struct  DwarfAbbrev
 
struct  Dwarf
 
struct  DwarfStack
 

Macros

#define MAXIMUM_DWARF_NAME_SIZE   64
 

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 struct DwarfStack DwarfStack
 
typedef struct DwarfParam DwarfParam
 
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 *parent, DwarfSym *child)
 
int dwarfpctoline (Dwarf *, DwarfSym *proc, ulong, char **, char **, ulong *)
 
int dwarfgetarg (Dwarf *d, const char *name, DwarfBuf *locbuf, ulong cfa, PROSSYM_REGISTERS registers, ulong *value)
 
int dwarfgettype (Dwarf *d, DwarfSym *param, DwarfSym *type)
 
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 *)
 
int dwarfcomputecfa (Dwarf *d, DwarfExpr *cfa, PROSSYM_REGISTERS registers, ulong *cfaLocation)
 
int dwarfregunwind (Dwarf *d, ulong pc, ulong fde, DwarfExpr *cfa, PROSSYM_REGISTERS registers)
 
int dwarfargvalue (Dwarf *d, DwarfSym *proc, ulong pc, ulong cfa, PROSSYM_REGISTERS registers, DwarfParam *parameters)
 
int dwarfgetparams (Dwarf *d, DwarfSym *s, ulong pc, int pnum, DwarfParam *paramblocks)
 
DwarfAbbrevdwarfgetabbrev (Dwarf *, ulong, ulong)
 
int dwarfgetinfounit (Dwarf *, ulong, DwarfBlock *)
 
void dwarfdumpsym (Dwarf *d, DwarfSym *s)
 

Macro Definition Documentation

◆ MAXIMUM_DWARF_NAME_SIZE

#define MAXIMUM_DWARF_NAME_SIZE   64

Definition at line 488 of file dwarf.h.

Typedef Documentation

◆ Dwarf

typedef struct Dwarf Dwarf

Definition at line 3 of file dwarf.h.

◆ DwarfAbbrev

Definition at line 430 of file dwarf.h.

◆ DwarfAttr

Definition at line 431 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.

◆ DwarfParam

Definition at line 10 of file dwarf.h.

◆ DwarfStack

Definition at line 9 of file dwarf.h.

◆ DwarfSym

Definition at line 8 of file dwarf.h.

◆ DwarfVal

typedef union DwarfVal DwarfVal

Definition at line 11 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 13 of file dwarf.h.

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

369{
370 RuleUndef,
371 RuleSame,
376};
@ 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

◆ dwarfargvalue()

int dwarfargvalue ( Dwarf d,
DwarfSym proc,
ulong  pc,
ulong  cfa,
PROSSYM_REGISTERS  registers,
DwarfParam parameters 
)

Definition at line 909 of file dwarfinfo.c.

910{
911 int gotarg;
912 DwarfSym unit = { };
913
914 if (dwarfenumunit(d, proc->unit, &unit) == -1)
915 return -1;
916
917 werrstr("lookup in unit %x-%x, pc %x", unit.attrs.lowpc, unit.attrs.highpc, pc);
918 pc -= unit.attrs.lowpc;
919
920 werrstr("paramblock %s -> unit %x type %x fde %x len %d registers %x",
921 parameter->name,
922 parameter->unit,
923 parameter->type,
924 parameter->fde,
925 parameter->len,
926 registers);
927
928 // Seek our range in loc
929 DwarfBuf locbuf;
930 DwarfBuf instream = { };
931
932 locbuf.d = d;
933 locbuf.addrsize = d->addrsize;
934
935 if (parameter->loctype == TConstant) {
936 locbuf.p = d->loc.data + parameter->fde;
937 locbuf.ep = d->loc.data + d->loc.len;
938 ulong start, end, len;
939 do {
940 len = 0;
941 start = dwarfget4(&locbuf);
942 end = dwarfget4(&locbuf);
943 if (start && end) {
944 len = dwarfget2(&locbuf);
945 instream = locbuf;
946 instream.ep = instream.p + len;
947 locbuf.p = instream.ep;
948 }
949 werrstr("ip %x s %x e %x (%x bytes)", pc, start, end, len);
950 } while (start && end && (start > pc || end <= pc));
951 } else if (parameter->loctype == TBlock) {
952 instream = locbuf;
953 instream.p = (void *)parameter->fde;
954 instream.ep = instream.p + parameter->len;
955 } else {
956 werrstr("Wrong block type for parameter %s", parameter->name);
957 return -1;
958 }
959
960 gotarg = dwarfgetarg(d, parameter->name, &instream, cfa, registers, &parameter->value);
961 if (gotarg == -1)
962 return -1;
963
964 return 0;
965}
int registers[NUMREGS]
static IStream instream
Definition: saxreader.c:2106
static HANDLE proc()
Definition: pdb.c:34
int dwarfenumunit(Dwarf *d, ulong unit, DwarfSym *s)
Definition: dwarfinfo.c:201
int dwarfgetarg(Dwarf *d, const char *name, DwarfBuf *buf, ulong cfa, PROSSYM_REGISTERS registers, ulong *result)
Definition: dwarfinfo.c:658
uint addrsize
Definition: dwarf.h:212
Dwarf * d
Definition: dwarf.h:209
uchar * p
Definition: dwarf.h:210
uchar * ep
Definition: dwarf.h:211
char * name
Definition: compiler.c:66

Referenced by RosSymGetAddressInformation().

◆ 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

◆ dwarfcomputecfa()

int dwarfcomputecfa ( Dwarf d,
DwarfExpr cfa,
PROSSYM_REGISTERS  registers,
ulong cfaLocation 
)

Definition at line 404 of file dwarfcfa.c.

405{
406 switch (cfa->type) {
407 case RuleRegOff:
408 *cfaLocation = registers->Registers[cfa->reg] + cfa->offset;
409 werrstr("cfa reg %d (%x) offset %x = %x", cfa->reg, (ulong)registers->Registers[cfa->reg], cfa->offset, cfaLocation);
410 break;
411 default:
412 werrstr("cfa->type %x", cfa->type);
413 return -1;
414 }
415
416 return 0;
417}
int type
Definition: dwarf.h:367
ulong reg
Definition: dwarf.h:369
long offset
Definition: dwarf.h:368

Referenced by dwarfregunwind(), and RosSymGetAddressInformation().

◆ dwarfdumpsym()

void dwarfdumpsym ( Dwarf d,
DwarfSym s 
)

Definition at line 968 of file dwarfinfo.c.

969{
970 int j;
971 werrstr("tag %x\n", s->attrs.tag);
972 for (j = 0; plist[j].name; j++) {
973 char *have = ((char*)&s->attrs) + plist[j].haveoff;
974 char *attr = ((char*)&s->attrs) + plist[j].off;
975 if (*have == TString) {
976 char *str = *((char **)attr);
977 werrstr("%s: %s\n", plist[j].namestr, str);
978 } else if (*have == TReference) {
979 DwarfVal *val = ((DwarfVal*)attr);
980 werrstr("%s: %x:%x\n", plist[j].namestr, val->b.data, val->b.len);
981 } else if (*have)
982 werrstr("%s: (%x)\n", plist[j].namestr, *have);
983 }
984}
GLdouble s
Definition: gl.h:2039
GLuint GLfloat * val
Definition: glext.h:7180
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 GLint GLint j
Definition: glfuncs.h:250
static Parse plist[]
Definition: dwarfinfo.c:337
const WCHAR * str
int name
Definition: dwarfinfo.c:331
int off
Definition: dwarfinfo.c:332
int haveoff
Definition: dwarfinfo.c:333
Definition: cookie.c:202

◆ 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}

◆ 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 dwarfargvalue(), dwarfenum(), dwarflookupfn(), dwarflookupnameinunit(), dwarflookuptag(), dwarfnextsym(), and dwarfseeksym().

◆ 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 dwarfgetaddr().

◆ 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

◆ 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

◆ 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 dwarfgetaddr().

◆ 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 dwarfgetaddr().

◆ 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 dwarfgetaddr().

◆ 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

◆ 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

◆ dwarfgetarg()

int dwarfgetarg ( Dwarf d,
const char name,
DwarfBuf locbuf,
ulong  cfa,
PROSSYM_REGISTERS  registers,
ulong value 
)

Definition at line 658 of file dwarfinfo.c.

659{
660 int ret = 0;
661 DwarfStack stack = { };
663 stackpush(&stack, cfa);
664 while (buf->p < buf->ep) {
665 int opcode = dwarfget1(buf);
666 werrstr("opcode %x", opcode);
667 switch (opcode) {
668 case 0:
669 buf->p = buf->ep;
670 break;
671 case OpAddr:
672 if (d->addrsize == 4) {
674 break;
675 } else {
676 werrstr("%s: we only support 4 byte addrs", name);
677 goto fatal;
678 }
679 case OpConst1s: {
680 signed char c = dwarfget1(buf);
681 stackpush(&stack, c);
682 } break;
683 case OpConst1u:
685 break;
686 case OpConst2s: {
687 signed short s = dwarfget2(buf);
688 stackpush(&stack, s);
689 } break;
690 case OpConst2u:
692 break;
693 case OpConst4s: {
694 signed int i = dwarfget4(buf);
695 stackpush(&stack, i);
696 } break;
697 case OpConst4u:
699 break;
700 case OpConst8s:
701 case OpConst8u:
702 werrstr("const 8 not yet supported");
703 goto fatal;
704 case OpConsts:
706 break;
707 case OpConstu:
709 break;
710 case OpDup: {
711 ulong popped = stackpop(&stack);
712 stackpush(&stack, popped);
713 stackpush(&stack, popped);
714 } break;
715 case OpDrop:
716 stackpop(&stack);
717 break;
718 case OpOver: {
719 if (stack.length < 2) goto fatal;
720 stackpush(&stack, stack.data[stack.length-2]);
721 } break;
722 case OpPick: {
724 if (arg >= stack.length) goto fatal;
725 arg = stack.data[stack.length-1-arg];
727 } break;
728 case OpSwap: {
730 stackpush(&stack, b);
731 stackpush(&stack, a);
732 } break;
733 case OpRot: {
735 stackpush(&stack, b);
736 stackpush(&stack, c);
737 stackpush(&stack, a);
738 } break;
739 case OpXderef:
740 case OpXderefSize:
741 werrstr("Xderef not yet supported");
742 goto fatal;
743 case OpAbs: {
744 long a = stackpop(&stack);
745 stackpush(&stack, a < 0 ? -a : a);
746 } break;
747 case OpAnd:
749 break;
750 case OpDiv: {
752 stackpush(&stack, b / a);
753 } break;
754 case OpMinus: {
756 stackpush(&stack, b - a);
757 } break;
758 case OpMod: {
760 stackpush(&stack, b % a);
761 } break;
762 case OpMul:
764 break;
765 case OpNeg:
767 break;
768 case OpNot:
770 break;
771 case OpOr:
773 break;
774 case OpPlus:
776 break;
777 case OpPlusUconst:
779 break;
780 case OpShl: {
782 stackpush(&stack, b << a);
783 } break;
784 case OpShr: {
786 stackpush(&stack, b >> a);
787 } break;
788 case OpShra: {
789 ulong a = stackpop(&stack);
790 long b = stackpop(&stack);
791 if (b < 0)
792 b = -(-b >> a);
793 else
794 b = b >> a;
795 stackpush(&stack, b);
796 } break;
797 case OpXor:
799 break;
800 case OpSkip:
801 buf->p += dwarfget2(buf);
802 break;
803 case OpBra: {
804 ulong a = dwarfget2(buf);
805 if (stackpop(&stack))
806 buf->p += a;
807 } break;
808 case OpEq:
810 break;
811 case OpGe: {
813 stackpush(&stack, b >= a);
814 } break;
815 case OpGt: {
817 stackpush(&stack, b > a);
818 } break;
819 case OpLe: {
821 stackpush(&stack, b <= a);
822 } break;
823 case OpLt: {
825 stackpush(&stack, b < a);
826 } break;
827 case OpNe:
829 break;
830 case OpNop:
831 break;
832 case OpDeref: {
833 ulong val;
834 void* addr = (void*)stackpop(&stack);
836 (d->pe->fd,
837 &val,
838 addr,
839 d->addrsize))
840 goto fatal;
842 } break;
843 case OpDerefSize: {
845 void* addr = (void*)stackpop(&stack);
847 (d->pe->fd,
848 &val,
849 addr,
850 size))
851 goto fatal;
853 } break;
854 case OpFbreg: {
856 void* addr = (void*)cfa;
857 werrstr("FBREG cfa %x offset %x", cfa, offset);
859 (d->pe->fd,
860 &val,
862 d->addrsize))
863 goto fatal;
865 } break;
866 case OpPiece:
867 werrstr("OpPiece not supported");
868 goto fatal;
869 default:
870 if (opcode >= OpLit0 && opcode < OpReg0)
871 stackpush(&stack, opcode - OpLit0);
872 else if (opcode >= OpReg0 && opcode < OpBreg0) {
873 ulong reg = opcode - OpReg0;
874 werrstr("REG[%d] value %x", reg, (ulong)registers->Registers[reg]);
875 stackpush(&stack, registers->Registers[reg]);
876 } else if (opcode >= OpBreg0 && opcode < OpRegx) {
877 ulong val,
878 reg = opcode - OpBreg0,
880 void* addr = (void*)(ULONG_PTR)registers->Registers[reg];
881 werrstr("BREG[%d] reg %x offset %x", reg, addr, offset);
883 ((PVOID)d->pe->fd,
884 &val,
886 d->addrsize))
887 goto fatal;
889 } else {
890 werrstr("opcode %x not supported", opcode);
891 goto fatal;
892 }
893 break;
894 }
895 }
896 if (stack.length < 1) goto fatal;
897 *result = stackpop(&stack);
898 werrstr("%s: value %x", name, *result);
899 goto finish;
900
901fatal:
902 ret = -1;
903
904finish:
906 return ret;
907}
Definition: _stack.h:55
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint64EXT * result
Definition: glext.h:11304
GLintptr offset
Definition: glext.h:5920
static int reg
Definition: i386-dis.c:1290
ulong stackpop(DwarfStack *stack)
Definition: dwarfinfo.c:643
void stackinit(DwarfStack *stack)
Definition: dwarfinfo.c:622
void stackfree(DwarfStack *stack)
Definition: dwarfinfo.c:651
void stackpush(DwarfStack *stack, ulong value)
Definition: dwarfinfo.c:629
ulong dwarfget128(DwarfBuf *)
Definition: dwarfget.c:152
long dwarfget128s(DwarfBuf *)
Definition: dwarfget.c:197
ROSSYM_CALLBACKS RosSymCallbacks
Definition: init.c:14
#define finish()
Definition: seh0024.c:15
BOOLEAN(* MemGetProc)(PVOID FileContext, ULONG_PTR *Target, PVOID SourceMem, ULONG Size)
Definition: rossym.h:110
Definition: name.c:39
uint32_t ULONG_PTR
Definition: typedefs.h:65
int ret
void * arg
Definition: msvc.h:10
void fatal(const char *msg)

Referenced by dwarfargvalue(), and RosSymAggregate().

◆ 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

◆ dwarfgetparams()

int dwarfgetparams ( Dwarf d,
DwarfSym s,
ulong  pc,
int  pnum,
DwarfParam paramblocks 
)

Definition at line 987 of file dwarfinfo.c.

988{
989 int ip = 0;
990 DwarfSym param = { };
991 int res = dwarfnextsymat(d, s, &param);
992 while (res == 0 && ip < pnum) {
993 if (param.attrs.tag == TagFormalParameter &&
994 param.attrs.have.name &&
995 param.attrs.have.location) {
996 paramblocks[ip].name = malloc(strlen(param.attrs.name)+1);
997 strcpy(paramblocks[ip].name, param.attrs.name);
998 paramblocks[ip].unit = param.unit;
999 paramblocks[ip].type = param.attrs.type;
1000 paramblocks[ip].loctype = param.attrs.have.location;
1001 paramblocks[ip].len = param.attrs.location.b.len;
1002 paramblocks[ip].fde = (ulong)param.attrs.location.b.data;
1003 werrstr("param[%d] block %s -> type %x loctype %x fde %x len %x",
1004 ip,
1005 paramblocks[ip].name,
1006 paramblocks[ip].type,
1007 paramblocks[ip].loctype,
1008 paramblocks[ip].fde,
1009 paramblocks[ip].len);
1010 ip++;
1011 }
1012 res = dwarfnextsymat(d, s, &param);
1013 }
1014 return ip;
1015}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define malloc
Definition: debug_ros.c:4
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint res
Definition: glext.h:9613
GLfloat param
Definition: glext.h:5796
int dwarfnextsymat(Dwarf *d, DwarfSym *s, int depth)
Definition: dwarfinfo.c:292
char * name
Definition: dwarf.h:210
ulong type
Definition: dwarf.h:212
ulong fde
Definition: dwarf.h:214
ulong loctype
Definition: dwarf.h:213
ulong unit
Definition: dwarf.h:211
ulong len
Definition: dwarf.h:214
Definition: dhcpd.h:62
WCHAR * name
Definition: name.c:42

Referenced by RosSymGetAddressInformation().

◆ 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}

◆ dwarfgettype()

int dwarfgettype ( Dwarf d,
DwarfSym param,
DwarfSym type 
)

◆ 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}

◆ 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

◆ 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

◆ 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

◆ 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
DwarfAbbrev * dwarfgetabbrev(Dwarf *, ulong, ulong)
Definition: dwarfabbrev.c:128

Referenced by dwarfenumunit(), dwarflookupchildtag(), dwarflookuptag(), dwarfnextsym(), and dwarfnextsymat().

◆ dwarfnextsymat()

int dwarfnextsymat ( Dwarf d,
DwarfSym parent,
DwarfSym child 
)

Definition at line 292 of file dwarfinfo.c.

293{
294 uint sib;
295
296 if (!parent->attrs.haskids || !parent->childoff)
297 return -1;
298
299 child->unit = parent->unit;
300 child->aoff = parent->aoff;
301 child->depth = parent->depth + 1;
302 if(child->attrs.have.sibling){
303 sib = child->attrs.sibling;
304 if(sib < d->info.len && d->info.data+sib > child->b.p)
305 child->b.p = d->info.data+sib;
306 else if (sib >= d->info.len) {
307 werrstr("sibling reported as out of bounds %d vs %d", sib, d->info.len);
308 return -1;
309 } else if (d->info.data+sib+parent->unit < child->b.p) {
310 werrstr("subsequent sibling is listed before prev %d vs %d", sib+parent->unit, child->b.p - d->info.data);
311 return -1;
312 }
313 }
314
315 // Uninitialized
316 if (!child->b.d) {
317 child->b = parent->b;
318 child->b.p = parent->childoff + parent->b.d->info.data;
319 werrstr("Rewound to childoff %x\n", parent->childoff);
320 }
321
322 return dwarfnextsym(d, child);
323}
UINT32 uint
Definition: types.h:83
static HWND child
Definition: cursoricon.c:298
int dwarfnextsym(Dwarf *d, DwarfSym *s)
Definition: dwarfinfo.c:250

◆ 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

◆ dwarfpctoline()

int dwarfpctoline ( Dwarf d,
DwarfSym proc,
ulong  pc,
char **  file,
char **  function,
ulong line 
)

Definition at line 41 of file dwarfpc.c.

42{
43 char *cdir;
44 uchar *prog, *opcount, *end, *dirs;
45 ulong off, unit, len, vers, x, start, lastline;
46 int i, first, firstline, op, a, l, quantum, isstmt, linebase, linerange, opcodebase, nf;
47 char *files, *s;
48 DwarfBuf b;
49 DwarfSym sym;
50 State emit, cur, reset;
51 char **f, **newf;
52
53 f = nil;
54 memset(proc, 0, sizeof(*proc));
55
56 int runit = dwarfaddrtounit(d, pc, &unit);
57 if (runit < 0)
58 return -1;
59 int rtag = dwarflookuptag(d, unit, TagCompileUnit, &sym);
60 if (rtag < 0)
61 return -1;
62
63 if(!sym.attrs.have.stmtlist){
64 werrstr("no line mapping information for 0x%x", pc);
65 return -1;
66 }
67 off = sym.attrs.stmtlist;
68 if(off >= d->line.len){
69 werrstr("bad stmtlist");
70 goto bad;
71 }
72
73 if(trace) werrstr("unit 0x%x stmtlist 0x%x", unit, sym.attrs.stmtlist);
74
75 memset(&b, 0, sizeof b);
76 b.d = d;
77 b.p = d->line.data + off;
78 b.ep = b.p + d->line.len;
79 b.addrsize = sym.b.addrsize; /* should i get this from somewhere else? */
80
81 len = dwarfget4(&b);
82 if(b.p==nil || b.p+len > b.ep || b.p+len < b.p){
83 werrstr("bad len");
84 goto bad;
85 }
86
87 b.ep = b.p+len;
88 vers = dwarfget2(&b);
89 if(vers != 2){
90 werrstr("bad dwarf version 0x%x", vers);
91 return -1;
92 }
93
94 len = dwarfget4(&b);
95 if(b.p==nil || b.p+len > b.ep || b.p+len < b.p){
96 werrstr("another bad len");
97 goto bad;
98 }
99 prog = b.p+len;
100
101 quantum = dwarfget1(&b);
102 isstmt = dwarfget1(&b);
103 linebase = (schar)dwarfget1(&b);
104 linerange = (schar)dwarfget1(&b);
105 opcodebase = dwarfget1(&b);
106
107 opcount = b.p-1;
108 dwarfgetnref(&b, opcodebase-1);
109 if(b.p == nil){
110 werrstr("bad opcode chart");
111 goto bad;
112 }
113
114 /* just skip the files and dirs for now; we'll come back */
115 dirs = b.p;
116 while (b.p && *b.p)
118 dwarfget1(&b);
119
120 files = (char*)b.p;
121 while(b.p!=nil && *b.p!=0){
123 dwarfget128(&b);
124 dwarfget128(&b);
125 dwarfget128(&b);
126 }
127 dwarfget1(&b);
128
129 /* move on to the program */
130 if(b.p == nil || b.p > prog){
131 werrstr("bad header");
132 goto bad;
133 }
134 b.p = prog;
135
136 reset.addr = 0;
137 reset.file = 1;
138 reset.line = 1;
139 reset.column = 0;
140 reset.flags = isstmt ? Isstmt : 0;
141 reset.isa = 0;
142
143 cur = reset;
144 emit = reset;
145 nf = 0;
146 start = 0;
147 if(trace) werrstr("program @ %lu ... %.*H opbase = %d", b.p - d->line.data, b.ep-b.p, b.p, opcodebase);
148 first = 1;
149 while(b.p != nil){
150 firstline = 0;
151 op = dwarfget1(&b);
152 if(trace) werrstr("\tline %lu, addr 0x%x, op %d %.10H", cur.line, cur.addr, op, b.p);
153 if(op >= opcodebase){
154 a = (op - opcodebase) / linerange;
155 l = (op - opcodebase) % linerange + linebase;
156 cur.line += l;
157 cur.addr += a * quantum;
158 if(trace) werrstr(" +%d,%d", a, l);
159 emit:
160 if(first){
161 if(cur.addr > pc){
162 werrstr("found wrong line mapping 0x%x for pc 0x%x", cur.addr, pc);
163 /* This is an overzealous check. gcc can produce discontiguous ranges
164 and reorder statements, so it's possible for a future line to start
165 ahead of pc and still find a matching one. */
166 /*goto out;*/
167 firstline = 1;
168 }
169 first = 0;
170 start = cur.addr;
171 }
172 if(cur.addr > pc && !firstline)
173 break;
174 if(b.p == nil){
175 werrstr("buffer underflow in line mapping");
176 goto out;
177 }
178 emit = cur;
179 if(emit.flags & EndSequence){
180 werrstr("found wrong line mapping 0x%x-0x%x for pc 0x%x", start, cur.addr, pc);
181 goto out;
182 }
184 }else{
185 switch(op){
186 case 0: /* extended op code */
187 if(trace) werrstr(" ext");
188 len = dwarfget128(&b);
189 end = b.p+len;
190 if(b.p == nil || end > b.ep || end < b.p || len < 1)
191 goto bad;
192 switch(dwarfget1(&b)){
193 case 1: /* end sequence */
194 if(trace) werrstr(" end");
195 cur.flags |= EndSequence;
196 goto emit;
197 case 2: /* set address */
198 cur.addr = dwarfgetaddr(&b);
199 if(trace) werrstr(" set pc 0x%x", cur.addr);
200 break;
201 case 3: /* define file */
202 newf = malloc(nf+1*sizeof(f[0]));
203 if (newf)
204 RtlMoveMemory(newf, f, nf*sizeof(f[0]));
205 if(newf == nil)
206 goto out;
207 free(f);
208 f = newf;
209 f[nf++] = s = dwarfgetstring(&b);
210 DPRINT1("str %s", s);
211 dwarfget128(&b);
212 dwarfget128(&b);
213 dwarfget128(&b);
214 if(trace) werrstr(" def file %s", 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");
223 goto emit;
224 case 2: /* advance pc */
225 a = dwarfget128(&b);
226 if(trace) werrstr(" advance pc + %lu", 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", l);
232 cur.line += l;
233 break;
234 case 4: /* set file */
235 if(trace) werrstr(" set file");
236 cur.file = dwarfget128s(&b);
237 break;
238 case 5: /* set column */
239 if(trace) werrstr(" set column");
240 cur.column = dwarfget128(&b);
241 break;
242 case 6: /* negate stmt */
243 if(trace) werrstr(" negate stmt");
244 cur.flags ^= Isstmt;
245 break;
246 case 7: /* set basic block */
247 if(trace) werrstr(" set basic block");
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", 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", a);
258 cur.addr += a;
259 break;
260 case 10: /* set prologue end */
261 if(trace) werrstr(" set prologue end");
262 cur.flags |= PrologueEnd;
263 break;
264 case 11: /* set epilogue begin */
265 if(trace) werrstr(" set epilogue begin");
266 cur.flags |= EpilogueBegin;
267 break;
268 case 12: /* set isa */
269 if(trace) werrstr(" set isa");
270 cur.isa = dwarfget128(&b);
271 break;
272 default: /* something new - skip it */
273 if(trace) werrstr(" unknown %d", 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 = (uchar*)f[i];
310 }
311 s = dwarfgetstring(&b);
312 *file = s;
313 i = dwarfget128(&b); /* directory */
314 x = dwarfget128(&b);
315 x = dwarfget128(&b);
316
317 /* fetch dir name */
318 cdir = sym.attrs.have.compdir ? sym.attrs.compdir : 0;
319
320 char *dwarfdir;
321 dwarfdir = nil;
322 b.p = dirs;
323 for (x = 1; b.p && *b.p; x++) {
324 dwarfdir = dwarfgetstring(&b);
325 if (x == i) break;
326 }
327
328 if (!cdir && dwarfdir)
329 cdir = dwarfdir;
330
331 char *filefull = malloc(strlen(cdir) + strlen(*file) + 2);
332 strcpy(filefull, cdir);
333 strcat(filefull, "/");
334 strcat(filefull, *file);
335 *file = filefull;
336
337 *function = nil;
338 lastline = 0;
339
340 runit = dwarfaddrtounit(d, pc, &unit);
341 if (runit == 0) {
342 DwarfSym compunit = { };
343 int renum = dwarfenumunit(d, unit, &compunit);
344 if (renum < 0)
345 return -1;
346 renum = dwarfnextsymat(d, &compunit, proc);
347 while (renum == 0) {
348 if (proc->attrs.tag == TagSubprogram &&
349 proc->attrs.have.name)
350 {
351 if (proc->attrs.lowpc <= pc && proc->attrs.highpc > pc) {
352 *function = malloc(strlen(proc->attrs.name)+1);
353 strcpy(*function, proc->attrs.name);
354 goto done;
355 }
356 }
357 renum = dwarfnextsym(d, proc);
358 }
359 }
360
361 // Next search by declaration
362 runit = dwarfaddrtounit(d, pc, &unit);
363 if (runit == 0) {
364 DwarfSym compunit = { };
365 int renum = dwarfenumunit(d, unit, &compunit);
366 if (renum < 0)
367 return -1;
368 renum = dwarfnextsymat(d, &compunit, proc);
369 while (renum == 0) {
370 if (proc->attrs.tag == TagSubprogram &&
371 proc->attrs.have.name &&
372 proc->attrs.declfile == emit.file)
373 {
374 if (proc->attrs.declline <= *line &&
375 proc->attrs.declline > lastline) {
376 free(*function);
377 *function = malloc(strlen(proc->attrs.name)+1);
378 strcpy(*function, proc->attrs.name);
379 goto done;
380 }
381 lastline = proc->attrs.declline;
382 }
383 renum = dwarfnextsym(d, proc);
384 }
385 }
386
387 /* free at last, free at last */
388done:
389 free(f);
390 return 0;
391bad:
392 werrstr("corrupted line mapping for 0x%x", pc);
393out:
394 free(f);
395 return -1;
396}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define DPRINT1
Definition: precomp.h:8
r l[0]
Definition: byte_order.h:168
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
const GLint * first
Definition: glext.h:5794
char * prog
Definition: isohybrid.c:47
#define f
Definition: ke_i.h:83
static FILE * out
Definition: regtests2xml.c:44
@ 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
#define trace
Definition: dwarfpc.c:25
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
char * dwarfgetstring(DwarfBuf *)
Definition: dwarfget.c:54
int dwarfnextsym(Dwarf *, DwarfSym *)
Definition: dwarfinfo.c:250
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::@4963 have
uchar stmtlist
Definition: dwarf.h:282
uchar compdir
Definition: dwarf.h:239
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
Definition: fci.c:127
Definition: parser.c:49
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

◆ dwarfregunwind()

int dwarfregunwind ( Dwarf d,
ulong  pc,
ulong  fde,
DwarfExpr cfa,
PROSSYM_REGISTERS  registers 
)

Definition at line 419 of file dwarfcfa.c.

420{
421 int i;
422 State s = { };
423 DwarfExpr initr[sizeof(registers->Registers) / sizeof(registers->Registers[0])] = { };
424 DwarfExpr r[sizeof(registers->Registers) / sizeof(registers->Registers[0])] = { };
425 DwarfExpr ra;
426
427 int nr = s.nr = sizeof(registers->Registers) / sizeof(registers->Registers[0]);
428 s.initr = initr;
429 s.r = r;
430 for (i = 0; i < sizeof(r) / sizeof(r[0]); i++) {
431 r[i].type = RuleRegister;
432 r[i].offset = registers->Registers[i];
433 r[i].reg = i;
434 }
435
436 int res = dwarfunwind(d, pc, cfa, &ra, initr, sizeof(initr) / sizeof(initr[0]));
437 if (res == -1) return -1;
438
439 ulong cfaLocation;
440
441 if (dwarfcomputecfa(d, cfa, registers, &cfaLocation) == -1)
442 return -1;
443
444 for (i = 0; i < nr; i++) {
445 switch (r[i].type) {
446 case RuleUndef:
447 werrstr("Undefined register slot %d", i);
448 assert(FALSE);
449 break;
450 case RuleSame:
451 break;
452 case RuleRegister:
453 registers->Registers[i] = registers->Registers[r[i].reg];
454 break;
455 case RuleRegOff: {
458 (d->pe->fd,
459 &registers->Registers[i],
460 r[i].offset + registers->Registers[r[i].reg],
461 d->addrsize);
462 if (!success) return -1;
463 } break;
464 case RuleCfaOffset:
465 {
468 (d->pe->fd,
469 &registers->Registers[i],
470 r[i].offset + cfaLocation,
471 d->addrsize);
472 werrstr("reg[%d] = %x: cfa offset (cfa %x, offset %x) -> @%x", i, (ulong)registers->Registers[i], cfaLocation, initr[i].offset, r[i].offset + cfaLocation);
473 if (!success) return -1;
474 } break;
475 default:
476 werrstr("We don't yet support cfa rule %d in slot %d", r[i].type, i);
477 assert(FALSE);
478 break;
479 }
480 }
481
482 ulong cfaSpace[4];
483 for (i = 0; i < sizeof(cfaSpace) / sizeof(cfaSpace[0]); i++) {
485 (d->pe->fd, &cfaSpace[i], cfaLocation + (i * 4), d->addrsize);
486 }
487 werrstr("CFA(%x) [%08x, %08x, %08x, %08x]",
488 cfaLocation, cfaSpace[0], cfaSpace[1], cfaSpace[2], cfaSpace[3]);
489
490 return 0;
491}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
#define assert(x)
Definition: debug.h:53
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
ULONG nr
Definition: thread.c:7
int dwarfcomputecfa(Dwarf *d, DwarfExpr *cfa, PROSSYM_REGISTERS registers, ulong *cfaLocation)
Definition: dwarfcfa.c:404
int dwarfunwind(Dwarf *d, ulong pc, DwarfExpr *cfa, DwarfExpr *ra, DwarfExpr *r, int nr)
Definition: dwarfcfa.c:42
#define success(from, fromstr, to, tostr)

Referenced by 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}