ReactOS  0.4.15-dev-3442-gc05a45e
dwarf.h
Go to the documentation of this file.
1 #include "compat.h"
2 
3 typedef struct Dwarf Dwarf;
4 typedef struct DwarfAttrs DwarfAttrs;
5 typedef struct DwarfBlock DwarfBlock;
6 typedef struct DwarfBuf DwarfBuf;
7 typedef struct DwarfExpr DwarfExpr;
8 typedef struct DwarfSym DwarfSym;
9 typedef struct DwarfStack DwarfStack;
10 typedef struct DwarfParam DwarfParam;
11 typedef union DwarfVal DwarfVal;
12 
13 enum
14 {
15  TagArrayType = 0x01,
16  TagClassType = 0x02,
17  TagEntryPoint = 0x03,
21  TagLabel = 0x0A,
23  TagMember = 0x0D,
27  TagStringType = 0x12,
28  TagStructType = 0x13,
30  TagTypedef = 0x16,
31  TagUnionType = 0x17,
33  TagVariant = 0x19,
38  TagModule = 0x1E,
40  TagSetType = 0x20,
42  TagWithStmt = 0x22,
44  TagBaseType = 0x24,
46  TagConstType = 0x26,
47  TagConstant = 0x27,
48  TagEnumerator = 0x28,
49  TagFileType = 0x29,
50  TagFriend = 0x2A,
51  TagNamelist = 0x2B,
53  TagPackedType = 0x2D,
54  TagSubprogram = 0x2E,
57  TagThrownType = 0x31,
60  TagVariable = 0x34,
65  TagNamespace = 0x39,
71 
72  TypeAddress = 0x01,
73  TypeBoolean = 0x02,
75  TypeFloat = 0x04,
76  TypeSigned = 0x05,
78  TypeUnsigned = 0x07,
81 
82  AccessPublic = 0x01,
84  AccessPrivate = 0x03,
85 
86  VisLocal = 0x01,
87  VisExported = 0x02,
88  VisQualified = 0x03,
89 
90  VirtNone = 0x00,
91  VirtVirtual = 0x01,
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 
112  IdCaseUpper = 0x01,
113  IdCaseLower = 0x02,
115 
119  /* 0x40-0xFF reserved */
120 
121  InNone = 0x00,
122  InInlined = 0x01,
125 
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 */
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 };
201 
202 struct DwarfBlock
203 {
204  uchar *data;
205  ulong len;
206 };
207 
209 {
210  char *name;
216 };
217 
218 /* not for consumer use */
219 struct DwarfBuf
220 {
221  Dwarf *d;
222  uchar *p;
223  uchar *ep;
224  uint addrsize;
225 };
226 
227 union DwarfVal
228 {
229  char *s;
230  ulong c;
231  ulong r;
232  DwarfBlock b;
233 };
234 
235 struct DwarfAttrs
236 {
237  ulong tag;
238  uchar haskids;
239 
240  /* whether we have it, along with type */
241  struct {
247  uchar bitsize;
248  uchar bytesize;
249  uchar calling;
251  uchar compdir;
254  uchar count;
257  uchar declfile;
258  uchar declline;
260  uchar discr;
263  uchar encoding;
265  uchar friend;
266  uchar highpc;
267  uchar entrypc;
269  uchar import;
270  uchar inlined;
277  uchar language;
278  uchar location;
280  uchar lowpc;
282  uchar name;
284  uchar ordering;
285  uchar priority;
286  uchar producer;
287  uchar ranges;
289  uchar segment;
290  uchar sibling;
294  uchar stmtlist;
297  uchar type;
303  } have;
304 
310  ulong bitsize;
311  ulong bytesize;
312  ulong calling;
314  char* compdir;
317  ulong count;
320  ulong declfile;
321  ulong declline;
323  ulong discr;
326  ulong encoding;
328  ulong friend;
329  ulong highpc;
330  ulong entrypc;
332  ulong import;
333  ulong inlined;
340  ulong language;
343  ulong lowpc;
345  char* name;
347  ulong ordering;
348  ulong priority;
349  char* producer;
350  ulong ranges;
353  ulong sibling;
357  ulong stmtlist;
360  ulong type;
366 };
367 
368 enum
369 {
376 };
377 struct DwarfExpr
378 {
379  int type;
380  long offset;
381  ulong reg;
382  DwarfBlock loc;
383 };
384 
385 struct DwarfSym
386 {
388 
389 /* not for consumer use... */
391  DwarfBuf b;
392  int depth;
394  ulong aoff;
395 };
396 
397 struct _Pe;
398 Dwarf *dwarfopen(struct _Pe *elf);
399 void dwarfclose(Dwarf*);
402 int dwarflookupname(Dwarf*, char*, DwarfSym*);
403 int dwarflookupnameinunit(Dwarf*, ulong, char*, DwarfSym*);
404 int dwarflookupsubname(Dwarf*, DwarfSym*, char*, DwarfSym*);
408 int dwarfenum(Dwarf*, DwarfSym*);
409 int dwarfnextsym(Dwarf*, DwarfSym*);
411 int dwarfpctoline(Dwarf*, DwarfSym *proc, ulong, char**, char**, ulong *);
412 int dwarfgetarg(Dwarf *d, const char *name, DwarfBuf *locbuf, ulong cfa, PROSSYM_REGISTERS registers, ulong *value);
414 
420 long dwarfget128s(DwarfBuf*);
422 int dwarfgetn(DwarfBuf*, uchar*, int);
424 char *dwarfgetstring(DwarfBuf*);
428 int dwarfgetparams(Dwarf *d, DwarfSym *s, ulong pc, int pnum, DwarfParam *paramblocks);
429 
430 typedef struct DwarfAbbrev DwarfAbbrev;
431 typedef struct DwarfAttr DwarfAttr;
432 
433 struct DwarfAttr
434 {
435  ulong name;
436  ulong form;
437 };
438 
439 struct DwarfAbbrev
440 {
441  ulong num;
442  ulong tag;
443  uchar haskids;
444  DwarfAttr *attr;
445  int nattr;
446 };
447 
448 struct _Pe;
449 
450 struct Dwarf
451 {
452  struct _Pe *pe;
453 
454  char **reg;
455  int nreg;
456  int addrsize;
465  DwarfBlock str;
467 
468  /* little cache */
469  struct {
470  DwarfAbbrev *a;
471  int na;
472  ulong off;
473  } acache;
474 };
475 
477 {
478  ulong storage[16]; // own storage
481 };
482 
484 
486 void dwarfdumpsym(Dwarf *d, DwarfSym *s);
487 
488 #define MAXIMUM_DWARF_NAME_SIZE 64
Definition: dwarf.h:153
uchar lowpc
Definition: dwarf.h:268
int dwarfgetinfounit(Dwarf *, ulong, DwarfBlock *)
uint addrsize
Definition: dwarf.h:212
struct Dwarf::@4721 acache
uchar visibility
Definition: dwarf.h:289
int dwarfaddrtounit(Dwarf *, ulong, ulong *)
Definition: dwarfaranges.c:17
Definition: dwarf.h:157
uchar upperbound
Definition: dwarf.h:286
uchar identifiercase
Definition: dwarf.h:256
uchar location
Definition: dwarf.h:266
uchar bitoffset
Definition: dwarf.h:234
int dwarfnextsym(Dwarf *, DwarfSym *)
Definition: dwarfinfo.c:251
DwarfBlock info
Definition: dwarf.h:446
Definition: dwarf.h:149
Definition: pdh_main.c:93
Definition: dwarf.h:179
ulong storage[16]
Definition: dwarf.h:478
uchar stridesize
Definition: dwarf.h:283
Definition: dwarf.h:119
Definition: dwarf.h:167
uchar namelistitem
Definition: dwarf.h:271
ulong name
Definition: dwarf.h:421
unsigned char uchar
Definition: Unfrag.h:59
Definition: dwarf.h:164
Definition: dwarf.h:161
Definition: dwarf.h:186
uchar language
Definition: dwarf.h:265
ulong value
Definition: dwarf.h:215
DwarfBlock frame
Definition: dwarf.h:445
uchar isexternal
Definition: dwarf.h:261
char * dwarfgetstring(DwarfBuf *)
Definition: dwarfget.c:55
ulong max
Definition: dwarf.h:480
Definition: dwarf.h:171
Dwarf * dwarfopen(struct _Pe *elf)
Definition: dwarfopen.c:16
Definition: dwarf.h:154
int dwarfcomputecfa(Dwarf *d, DwarfExpr *cfa, PROSSYM_REGISTERS registers, ulong *cfaLocation)
Definition: dwarfcfa.c:404
Dwarf * d
Definition: dwarf.h:209
uchar ordering
Definition: dwarf.h:272
uchar vtableelemloc
Definition: dwarf.h:290
ulong dwarfget4(DwarfBuf *)
Definition: dwarfget.c:96
uchar * data
Definition: dwarf.h:202
int dwarfnextsymat(Dwarf *, DwarfSym *, int)
Definition: dwarfinfo.c:293
Definition: pe.h:14
Definition: dwarf.h:151
int dwarfgettype(Dwarf *d, DwarfSym *param, DwarfSym *type)
static HANDLE proc()
Definition: pdb.c:32
int dwarflookupsubname(Dwarf *, DwarfSym *, char *, DwarfSym *)
Definition: dwarfinfo.c:141
uchar discr
Definition: dwarf.h:248
Definition: dwarf.h:131
uchar declcolumn
Definition: dwarf.h:244
Definition: dwarf.h:134
Definition: dwarf.h:84
DwarfBlock pubnames
Definition: dwarf.h:448
Definition: dwarf.h:187
uchar priority
Definition: dwarf.h:273
DwarfBlock line
Definition: dwarf.h:447
ulong fde
Definition: dwarf.h:214
Definition: dwarf.h:177
uchar declline
Definition: dwarf.h:246
static HWND child
Definition: cursoricon.c:298
uchar isvarparam
Definition: dwarf.h:264
Definition: dwarf.h:181
int nattr
Definition: dwarf.h:431
int dwarflookupname(Dwarf *, char *, DwarfSym *)
Definition: dwarfpubnames.c:67
int dwarfpctoline(Dwarf *, ulong, char **, char **, char **, char **, ulong *, ulong *, ulong *)
Definition: dwarfpc.c:49
Definition: dwarf.h:93
Definition: dwarf.h:163
uchar isartificial
Definition: dwarf.h:259
DwarfBlock loc
Definition: dwarf.h:466
int dwarfseeksym(Dwarf *, ulong, ulong, DwarfSym *)
Definition: dwarfinfo.c:171
Definition: dwarf.h:19
int na
Definition: dwarf.h:456
uchar type
Definition: dwarf.h:285
Definition: dwarf.h:183
ulong tag
Definition: dwarf.h:225
Definition: dwarf.h:188
ulong dwarfget1(DwarfBuf *)
Definition: dwarfget.c:18
int dwarfargvalue(Dwarf *d, DwarfSym *proc, ulong pc, ulong cfa, PROSSYM_REGISTERS registers, DwarfParam *parameters)
Definition: dwarfinfo.c:909
int nreg
Definition: dwarf.h:441
Definition: dwarf.h:170
Definition: dwarf.h:88
uchar compdir
Definition: dwarf.h:239
Definition: dwarf.h:158
Definition: dwarf.h:185
ulong unit
Definition: dwarf.h:379
DwarfBlock abbrev
Definition: dwarf.h:443
uchar declfile
Definition: dwarf.h:245
ulong childoff
Definition: dwarf.h:393
char * name
Definition: dwarf.h:210
uchar virtuality
Definition: dwarf.h:288
uchar stringlength
Definition: dwarf.h:284
ulong tag
Definition: dwarf.h:428
uchar bitsize
Definition: dwarf.h:235
uchar encoding
Definition: dwarf.h:251
Definition: dwarf.h:106
long offset
Definition: dwarf.h:368
uchar containingtype
Definition: dwarf.h:241
int dwarfenumunit(Dwarf *, ulong, DwarfSym *)
Definition: dwarfinfo.c:202
uchar abstractorigin
Definition: dwarf.h:230
Definition: dwarf.h:176
uchar addrclass
Definition: dwarf.h:232
int dwarfenum(Dwarf *, DwarfSym *)
Definition: dwarfinfo.c:242
int registers[NUMREGS]
struct DwarfAttrs::@4720 have
uchar haskids
Definition: dwarf.h:226
ulong length
Definition: dwarf.h:480
ulong num
Definition: dwarf.h:427
uchar accessibility
Definition: dwarf.h:231
r parent
Definition: btrfs.c:2944
uchar specification
Definition: dwarf.h:279
int addrsize
Definition: dwarf.h:442
DwarfBlock pubtypes
Definition: dwarf.h:449
DwarfBlock b
Definition: dwarf.h:220
Definition: dwarf.h:150
ulong len
Definition: dwarf.h:203
ulong reg
Definition: dwarf.h:369
uchar returnaddr
Definition: dwarf.h:276
GLfloat param
Definition: glext.h:5796
Definition: dwarf.h:194
ulong len
Definition: dwarf.h:214
Definition: dwarf.h:175
int dwarfgetarg(Dwarf *d, const char *name, DwarfBuf *locbuf, ulong cfa, PROSSYM_REGISTERS registers, ulong *value)
Definition: dwarfinfo.c:658
uchar calling
Definition: dwarf.h:237
uchar * p
Definition: dwarf.h:210
Definition: dwarf.h:160
long dwarfget128s(DwarfBuf *)
Definition: dwarfget.c:198
uchar inlined
Definition: dwarf.h:258
ulong loctype
Definition: dwarf.h:213
ulong dwarfget2(DwarfBuf *)
Definition: dwarfget.c:82
ulong c
Definition: dwarf.h:218
Definition: dwarf.h:165
uchar stmtlist
Definition: dwarf.h:282
ulong nextunit
Definition: dwarf.h:384
Definition: dwarf.h:162
Definition: dwarf.h:103
uchar isprototyped
Definition: dwarf.h:263
GLdouble s
Definition: gl.h:2039
ulong unit
Definition: dwarf.h:211
Definition: dwarf.h:168
uchar lowerbound
Definition: dwarf.h:267
Definition: dwarf.h:152
int dwarfgetparams(Dwarf *d, DwarfSym *s, ulong pc, int pnum, DwarfParam *paramblocks)
Definition: dwarfinfo.c:987
Definition: dwarf.h:195
uchar segment
Definition: dwarf.h:277
uchar bytesize
Definition: dwarf.h:236
uchar constvalue
Definition: dwarf.h:240
unsigned long ulong
Definition: linux.h:275
uchar entrypc
Definition: dwarf.h:255
DwarfBuf b
Definition: dwarf.h:378
uchar isdeclaration
Definition: dwarf.h:260
ulong dwarfget128(DwarfBuf *)
Definition: dwarfget.c:153
DwarfBlock ranges
Definition: dwarf.h:450
Definition: dwarf.h:436
uchar datamemberloc
Definition: dwarf.h:243
DwarfAttr * attr
Definition: dwarf.h:430
struct _Pe * pe
Definition: dwarf.h:438
DwarfAbbrev * a
Definition: dwarf.h:455
ulong * data
Definition: dwarf.h:479
char ** reg
Definition: dwarf.h:440
ulong type
Definition: dwarf.h:212
uchar discrlist
Definition: dwarf.h:249
uchar highpc
Definition: dwarf.h:254
Definition: dwarf.h:174
int dwarfgetn(DwarfBuf *, uchar *, int)
Definition: dwarfget.c:28
Definition: dwarf.h:133
DwarfAbbrev * dwarfgetabbrev(Dwarf *, ulong, ulong)
Definition: dwarfabbrev.c:129
uchar basetypes
Definition: dwarf.h:233
int dwarflookupnameinunit(Dwarf *, ulong, char *, DwarfSym *)
Definition: dwarfinfo.c:126
Definition: dwarf.h:156
uchar staticlink
Definition: dwarf.h:281
uchar * ep
Definition: dwarf.h:211
unsigned long long uvlong
Definition: compat.h:9
ulong form
Definition: dwarf.h:422
uchar * dwarfgetnref(DwarfBuf *, ulong)
Definition: dwarfget.c:41
Definition: dwarf.h:92
Definition: name.c:38
uvlong dwarfget8(DwarfBuf *)
Definition: dwarfget.c:110
int depth
Definition: dwarf.h:382
uchar haskids
Definition: dwarf.h:429
uchar name
Definition: dwarf.h:270
DwarfBlock str
Definition: dwarf.h:451
uchar ranges
Definition: dwarf.h:275
Definition: dwarf.h:172
Definition: dwarf.h:191
Definition: dwarf.h:178
int dwarflookupfn(Dwarf *, ulong, ulong, DwarfSym *)
Definition: dwarfinfo.c:182
ulong aoff
Definition: dwarf.h:381
ulong off
Definition: dwarf.h:457
Definition: dwarf.h:173
Definition: dwarf.h:138
uint num
Definition: dwarf.h:390
uchar count
Definition: dwarf.h:242
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
UINT32 uint
Definition: types.h:83
DwarfBlock loc
Definition: dwarf.h:370
int dwarfregunwind(Dwarf *d, ulong pc, ulong fde, DwarfExpr *cfa, PROSSYM_REGISTERS registers)
Definition: dwarfcfa.c:419
int dwarflookuptag(Dwarf *, ulong, ulong, DwarfSym *)
Definition: dwarfinfo.c:152
ulong r
Definition: dwarf.h:219
uchar sibling
Definition: dwarf.h:278
char * s
Definition: dwarf.h:217
Definition: dwarf.h:169
uchar isoptional
Definition: dwarf.h:262
void dwarfclose(Dwarf *)
Definition: dwarfopen.c:57
uchar uselocation
Definition: dwarf.h:287
uchar discrvalue
Definition: dwarf.h:250
int type
Definition: dwarf.h:367
uchar framebase
Definition: dwarf.h:252
ulong dwarfgetaddr(DwarfBuf *)
Definition: dwarfget.c:124
DwarfAttrs attrs
Definition: dwarf.h:375
uchar defaultvalue
Definition: dwarf.h:247
#define d
Definition: ke_i.h:81
uchar startscope
Definition: dwarf.h:280
uchar commonref
Definition: dwarf.h:238
Definition: dwarf.h:159
uchar macroinfo
Definition: dwarf.h:269
Definition: dwarf.h:137
void dwarfdumpsym(Dwarf *d, DwarfSym *s)
Definition: dwarfinfo.c:968
DwarfBlock aranges
Definition: dwarf.h:444
uchar producer
Definition: dwarf.h:274