ReactOS 0.4.15-dev-8235-gcd88a97
dwarfinfo.c File Reference
#include <ntifs.h>
#include <ndk/ntndk.h>
#include <reactos/rossym.h>
#include "rossympriv.h"
#include <ntimage.h>
#include <debug.h>
#include "dwarf.h"
#include <windef.h>
Include dependency graph for dwarfinfo.c:

Go to the source code of this file.

Classes

struct  Parse
 

Macros

#define NDEBUG
 
#define OFFSET(x)   offsetof(DwarfAttrs, x), offsetof(DwarfAttrs, have.x)
 

Typedefs

typedef struct Parse Parse
 

Enumerations

enum  {
  DwarfAttrSibling = 0x01 , DwarfAttrLocation = 0x02 , DwarfAttrName = 0x03 , DwarfAttrOrdering = 0x09 ,
  DwarfAttrByteSize = 0x0B , DwarfAttrBitOffset = 0x0C , DwarfAttrBitSize = 0x0D , DwarfAttrStmtList = 0x10 ,
  DwarfAttrLowpc = 0x11 , DwarfAttrHighpc = 0x12 , DwarfAttrLanguage = 0x13 , DwarfAttrDiscr = 0x15 ,
  DwarfAttrDiscrValue = 0x16 , DwarfAttrVisibility = 0x17 , DwarfAttrImport = 0x18 , DwarfAttrStringLength = 0x19 ,
  DwarfAttrCommonRef = 0x1A , DwarfAttrCompDir = 0x1B , DwarfAttrConstValue = 0x1C , DwarfAttrContainingType = 0x1D ,
  DwarfAttrDefaultValue = 0x1E , DwarfAttrInline = 0x20 , DwarfAttrIsOptional = 0x21 , DwarfAttrLowerBound = 0x22 ,
  DwarfAttrProducer = 0x25 , DwarfAttrPrototyped = 0x27 , DwarfAttrReturnAddr = 0x2A , DwarfAttrStartScope = 0x2C ,
  DwarfAttrStrideSize = 0x2E , DwarfAttrUpperBound = 0x2F , DwarfAttrAbstractOrigin = 0x31 , DwarfAttrAccessibility = 0x32 ,
  DwarfAttrAddrClass = 0x33 , DwarfAttrArtificial = 0x34 , DwarfAttrBaseTypes = 0x35 , DwarfAttrCalling = 0x36 ,
  DwarfAttrCount = 0x37 , DwarfAttrDataMemberLoc = 0x38 , DwarfAttrDeclColumn = 0x39 , DwarfAttrDeclFile = 0x3A ,
  DwarfAttrDeclLine = 0x3B , DwarfAttrDeclaration = 0x3C , DwarfAttrDiscrList = 0x3D , DwarfAttrEncoding = 0x3E ,
  DwarfAttrExternal = 0x3F , DwarfAttrFrameBase = 0x40 , DwarfAttrFriend = 0x41 , DwarfAttrIdentifierCase = 0x42 ,
  DwarfAttrMacroInfo = 0x43 , DwarfAttrNamelistItem = 0x44 , DwarfAttrPriority = 0x45 , DwarfAttrSegment = 0x46 ,
  DwarfAttrSpecification = 0x47 , DwarfAttrStaticLink = 0x48 , DwarfAttrType = 0x49 , DwarfAttrUseLocation = 0x4A ,
  DwarfAttrVarParam = 0x4B , DwarfAttrVirtuality = 0x4C , DwarfAttrVtableElemLoc = 0x4D , DwarfAttrAllocated = 0x4E ,
  DwarfAttrAssociated = 0x4F , DwarfAttrDataLocation = 0x50 , DwarfAttrStride = 0x51 , DwarfAttrEntrypc = 0x52 ,
  DwarfAttrUseUTF8 = 0x53 , DwarfAttrExtension = 0x54 , DwarfAttrRanges = 0x55 , DwarfAttrTrampoline = 0x56 ,
  DwarfAttrCallColumn = 0x57 , DwarfAttrCallFile = 0x58 , DwarfAttrCallLine = 0x59 , DwarfAttrDescription = 0x5A ,
  DwarfAttrMax , FormAddr = 0x01 , FormDwarfBlock2 = 0x03 , FormDwarfBlock4 = 0x04 ,
  FormData2 = 0x05 , FormData4 = 0x06 , FormData8 = 0x07 , FormString = 0x08 ,
  FormDwarfBlock = 0x09 , FormDwarfBlock1 = 0x0A , FormData1 = 0x0B , FormFlag = 0x0C ,
  FormSdata = 0x0D , FormStrp = 0x0E , FormUdata = 0x0F , FormRefAddr = 0x10 ,
  FormRef1 = 0x11 , FormRef2 = 0x12 , FormRef4 = 0x13 , FormRef8 = 0x14 ,
  FormRefUdata = 0x15 , FormIndirect = 0x16
}
 

Functions

static int parseattrs (DwarfBuf *, ulong, DwarfAbbrev *, DwarfAttrs *)
 
static int getulong (DwarfBuf *, int, ulong, ulong *, int *)
 
static int getuchar (DwarfBuf *, int, uchar *)
 
static int getstring (DwarfBuf *, int, char **)
 
static int getblock (DwarfBuf *, int, DwarfBlock *)
 
static int skipform (DwarfBuf *, int)
 
static int constblock (Dwarf *, DwarfBlock *, ulong *)
 
int dwarflookupnameinunit (Dwarf *d, ulong unit, char *name, DwarfSym *s)
 
int dwarflookupsubname (Dwarf *d, DwarfSym *parent, char *name, DwarfSym *s)
 
int dwarflookuptag (Dwarf *d, ulong unit, ulong tag, DwarfSym *s)
 
int dwarfseeksym (Dwarf *d, ulong unit, ulong off, DwarfSym *s)
 
int dwarflookupfn (Dwarf *d, ulong unit, ulong pc, DwarfSym *s)
 
int dwarfenumunit (Dwarf *d, ulong unit, DwarfSym *s)
 
int dwarfenum (Dwarf *d, DwarfSym *s)
 
int dwarfnextsym (Dwarf *d, DwarfSym *s)
 
int dwarfnextsymat (Dwarf *d, DwarfSym *s, int depth)
 

Variables

static Parse plist []
 
static Parse ptab [DwarfAttrMax]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file dwarfinfo.c.

◆ OFFSET

Definition at line 337 of file dwarfinfo.c.

Typedef Documentation

◆ Parse

typedef struct Parse Parse

Definition at line 329 of file dwarfinfo.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DwarfAttrSibling 
DwarfAttrLocation 
DwarfAttrName 
DwarfAttrOrdering 
DwarfAttrByteSize 
DwarfAttrBitOffset 
DwarfAttrBitSize 
DwarfAttrStmtList 
DwarfAttrLowpc 
DwarfAttrHighpc 
DwarfAttrLanguage 
DwarfAttrDiscr 
DwarfAttrDiscrValue 
DwarfAttrVisibility 
DwarfAttrImport 
DwarfAttrStringLength 
DwarfAttrCommonRef 
DwarfAttrCompDir 
DwarfAttrConstValue 
DwarfAttrContainingType 
DwarfAttrDefaultValue 
DwarfAttrInline 
DwarfAttrIsOptional 
DwarfAttrLowerBound 
DwarfAttrProducer 
DwarfAttrPrototyped 
DwarfAttrReturnAddr 
DwarfAttrStartScope 
DwarfAttrStrideSize 
DwarfAttrUpperBound 
DwarfAttrAbstractOrigin 
DwarfAttrAccessibility 
DwarfAttrAddrClass 
DwarfAttrArtificial 
DwarfAttrBaseTypes 
DwarfAttrCalling 
DwarfAttrCount 
DwarfAttrDataMemberLoc 
DwarfAttrDeclColumn 
DwarfAttrDeclFile 
DwarfAttrDeclLine 
DwarfAttrDeclaration 
DwarfAttrDiscrList 
DwarfAttrEncoding 
DwarfAttrExternal 
DwarfAttrFrameBase 
DwarfAttrFriend 
DwarfAttrIdentifierCase 
DwarfAttrMacroInfo 
DwarfAttrNamelistItem 
DwarfAttrPriority 
DwarfAttrSegment 
DwarfAttrSpecification 
DwarfAttrStaticLink 
DwarfAttrType 
DwarfAttrUseLocation 
DwarfAttrVarParam 
DwarfAttrVirtuality 
DwarfAttrVtableElemLoc 
DwarfAttrAllocated 
DwarfAttrAssociated 
DwarfAttrDataLocation 
DwarfAttrStride 
DwarfAttrEntrypc 
DwarfAttrUseUTF8 
DwarfAttrExtension 
DwarfAttrRanges 
DwarfAttrTrampoline 
DwarfAttrCallColumn 
DwarfAttrCallFile 
DwarfAttrCallLine 
DwarfAttrDescription 
DwarfAttrMax 
FormAddr 
FormDwarfBlock2 
FormDwarfBlock4 
FormData2 
FormData4 
FormData8 
FormString 
FormDwarfBlock 
FormDwarfBlock1 
FormData1 
FormFlag 
FormSdata 
FormStrp 
FormUdata 
FormRefAddr 
FormRef1 
FormRef2 
FormRef4 
FormRef8 
FormRefUdata 
FormIndirect 

Definition at line 17 of file dwarfinfo.c.

18{
19 DwarfAttrSibling = 0x01,
20 DwarfAttrLocation = 0x02,
21 DwarfAttrName = 0x03,
22 DwarfAttrOrdering = 0x09,
23 DwarfAttrByteSize = 0x0B,
24 DwarfAttrBitOffset = 0x0C,
25 DwarfAttrBitSize = 0x0D,
26 DwarfAttrStmtList = 0x10,
27 DwarfAttrLowpc = 0x11,
28 DwarfAttrHighpc = 0x12,
29 DwarfAttrLanguage = 0x13,
30 DwarfAttrDiscr = 0x15,
33 DwarfAttrImport = 0x18,
35 DwarfAttrCommonRef = 0x1A,
36 DwarfAttrCompDir = 0x1B,
40 DwarfAttrInline = 0x20,
43 DwarfAttrProducer = 0x25,
51 DwarfAttrAddrClass = 0x33,
53 DwarfAttrBaseTypes = 0x35,
54 DwarfAttrCalling = 0x36,
55 DwarfAttrCount = 0x37,
58 DwarfAttrDeclFile = 0x3A,
59 DwarfAttrDeclLine = 0x3B,
61 DwarfAttrDiscrList = 0x3D,
62 DwarfAttrEncoding = 0x3E,
63 DwarfAttrExternal = 0x3F,
64 DwarfAttrFrameBase = 0x40,
65 DwarfAttrFriend = 0x41,
67 DwarfAttrMacroInfo = 0x43,
69 DwarfAttrPriority = 0x45,
70 DwarfAttrSegment = 0x46,
73 DwarfAttrType = 0x49,
75 DwarfAttrVarParam = 0x4B,
78 DwarfAttrAllocated = 0x4E,
81 DwarfAttrStride = 0x51,
82 DwarfAttrEntrypc = 0x52,
83 DwarfAttrUseUTF8 = 0x53,
84 DwarfAttrExtension = 0x54,
85 DwarfAttrRanges = 0x55,
88 DwarfAttrCallFile = 0x58,
89 DwarfAttrCallLine = 0x59,
92
93 FormAddr = 0x01,
94 FormDwarfBlock2 = 0x03,
95 FormDwarfBlock4 = 0x04,
96 FormData2 = 0x05,
97 FormData4 = 0x06,
98 FormData8 = 0x07,
99 FormString = 0x08,
100 FormDwarfBlock = 0x09,
101 FormDwarfBlock1 = 0x0A,
102 FormData1 = 0x0B,
103 FormFlag = 0x0C,
104 FormSdata = 0x0D,
105 FormStrp = 0x0E,
106 FormUdata = 0x0F,
107 FormRefAddr = 0x10,
108 FormRef1 = 0x11,
109 FormRef2 = 0x12,
110 FormRef4 = 0x13,
111 FormRef8 = 0x14,
112 FormRefUdata = 0x15,
113 FormIndirect = 0x16
114};
@ DwarfAttrSibling
Definition: dwarfinfo.c:19
@ DwarfAttrIsOptional
Definition: dwarfinfo.c:41
@ DwarfAttrUpperBound
Definition: dwarfinfo.c:48
@ DwarfAttrVirtuality
Definition: dwarfinfo.c:76
@ DwarfAttrDefaultValue
Definition: dwarfinfo.c:39
@ DwarfAttrUseUTF8
Definition: dwarfinfo.c:83
@ DwarfAttrConstValue
Definition: dwarfinfo.c:37
@ DwarfAttrLanguage
Definition: dwarfinfo.c:29
@ DwarfAttrTrampoline
Definition: dwarfinfo.c:86
@ DwarfAttrIdentifierCase
Definition: dwarfinfo.c:66
@ DwarfAttrAddrClass
Definition: dwarfinfo.c:51
@ FormAddr
Definition: dwarfinfo.c:93
@ DwarfAttrAllocated
Definition: dwarfinfo.c:78
@ DwarfAttrCallColumn
Definition: dwarfinfo.c:87
@ DwarfAttrExternal
Definition: dwarfinfo.c:63
@ DwarfAttrName
Definition: dwarfinfo.c:21
@ DwarfAttrNamelistItem
Definition: dwarfinfo.c:68
@ DwarfAttrAssociated
Definition: dwarfinfo.c:79
@ FormUdata
Definition: dwarfinfo.c:106
@ FormRefAddr
Definition: dwarfinfo.c:107
@ FormRef2
Definition: dwarfinfo.c:109
@ DwarfAttrMacroInfo
Definition: dwarfinfo.c:67
@ DwarfAttrOrdering
Definition: dwarfinfo.c:22
@ FormIndirect
Definition: dwarfinfo.c:113
@ FormSdata
Definition: dwarfinfo.c:104
@ FormRef4
Definition: dwarfinfo.c:110
@ DwarfAttrByteSize
Definition: dwarfinfo.c:23
@ FormDwarfBlock4
Definition: dwarfinfo.c:95
@ DwarfAttrLocation
Definition: dwarfinfo.c:20
@ DwarfAttrExtension
Definition: dwarfinfo.c:84
@ DwarfAttrSegment
Definition: dwarfinfo.c:70
@ DwarfAttrDataLocation
Definition: dwarfinfo.c:80
@ DwarfAttrCalling
Definition: dwarfinfo.c:54
@ DwarfAttrAbstractOrigin
Definition: dwarfinfo.c:49
@ DwarfAttrVarParam
Definition: dwarfinfo.c:75
@ DwarfAttrDescription
Definition: dwarfinfo.c:90
@ DwarfAttrUseLocation
Definition: dwarfinfo.c:74
@ DwarfAttrStartScope
Definition: dwarfinfo.c:46
@ DwarfAttrStrideSize
Definition: dwarfinfo.c:47
@ DwarfAttrDiscrValue
Definition: dwarfinfo.c:31
@ DwarfAttrContainingType
Definition: dwarfinfo.c:38
@ DwarfAttrCommonRef
Definition: dwarfinfo.c:35
@ DwarfAttrType
Definition: dwarfinfo.c:73
@ DwarfAttrLowerBound
Definition: dwarfinfo.c:42
@ DwarfAttrCallFile
Definition: dwarfinfo.c:88
@ DwarfAttrEntrypc
Definition: dwarfinfo.c:82
@ FormData1
Definition: dwarfinfo.c:102
@ DwarfAttrDeclaration
Definition: dwarfinfo.c:60
@ DwarfAttrStride
Definition: dwarfinfo.c:81
@ DwarfAttrDeclColumn
Definition: dwarfinfo.c:57
@ DwarfAttrFriend
Definition: dwarfinfo.c:65
@ FormRef8
Definition: dwarfinfo.c:111
@ DwarfAttrBaseTypes
Definition: dwarfinfo.c:53
@ DwarfAttrStaticLink
Definition: dwarfinfo.c:72
@ FormData8
Definition: dwarfinfo.c:98
@ DwarfAttrStringLength
Definition: dwarfinfo.c:34
@ DwarfAttrCompDir
Definition: dwarfinfo.c:36
@ DwarfAttrPrototyped
Definition: dwarfinfo.c:44
@ DwarfAttrHighpc
Definition: dwarfinfo.c:28
@ FormDwarfBlock2
Definition: dwarfinfo.c:94
@ DwarfAttrAccessibility
Definition: dwarfinfo.c:50
@ DwarfAttrReturnAddr
Definition: dwarfinfo.c:45
@ DwarfAttrCount
Definition: dwarfinfo.c:55
@ DwarfAttrArtificial
Definition: dwarfinfo.c:52
@ DwarfAttrBitSize
Definition: dwarfinfo.c:25
@ DwarfAttrCallLine
Definition: dwarfinfo.c:89
@ DwarfAttrDataMemberLoc
Definition: dwarfinfo.c:56
@ FormDwarfBlock1
Definition: dwarfinfo.c:101
@ DwarfAttrImport
Definition: dwarfinfo.c:33
@ FormRef1
Definition: dwarfinfo.c:108
@ DwarfAttrStmtList
Definition: dwarfinfo.c:26
@ DwarfAttrSpecification
Definition: dwarfinfo.c:71
@ DwarfAttrLowpc
Definition: dwarfinfo.c:27
@ DwarfAttrRanges
Definition: dwarfinfo.c:85
@ FormRefUdata
Definition: dwarfinfo.c:112
@ DwarfAttrInline
Definition: dwarfinfo.c:40
@ FormData2
Definition: dwarfinfo.c:96
@ DwarfAttrVtableElemLoc
Definition: dwarfinfo.c:77
@ DwarfAttrMax
Definition: dwarfinfo.c:91
@ FormData4
Definition: dwarfinfo.c:97
@ FormFlag
Definition: dwarfinfo.c:103
@ DwarfAttrDeclFile
Definition: dwarfinfo.c:58
@ FormDwarfBlock
Definition: dwarfinfo.c:100
@ DwarfAttrProducer
Definition: dwarfinfo.c:43
@ DwarfAttrVisibility
Definition: dwarfinfo.c:32
@ DwarfAttrEncoding
Definition: dwarfinfo.c:62
@ DwarfAttrDiscr
Definition: dwarfinfo.c:30
@ DwarfAttrPriority
Definition: dwarfinfo.c:69
@ DwarfAttrDeclLine
Definition: dwarfinfo.c:59
@ DwarfAttrFrameBase
Definition: dwarfinfo.c:64
@ DwarfAttrDiscrList
Definition: dwarfinfo.c:61
@ FormStrp
Definition: dwarfinfo.c:105
@ DwarfAttrBitOffset
Definition: dwarfinfo.c:24
@ FormString
Definition: dwarfinfo.c:99

Function Documentation

◆ constblock()

static int constblock ( Dwarf d,
DwarfBlock bl,
ulong pval 
)
static

Definition at line 595 of file dwarfinfo.c.

596{
597 DwarfBuf b;
598
599 memset(&b, 0, sizeof b);
600 b.p = bl->data;
601 b.ep = bl->data+bl->len;
602 b.d = d;
603
604 switch(dwarfget1(&b)){
605 case OpAddr:
606 *pval = dwarfgetaddr(&b);
607 return TConstant;
608 case OpConst1u:
609 *pval = dwarfget1(&b);
610 return TConstant;
611 case OpConst1s:
612 *pval = (schar)dwarfget1(&b);
613 return TConstant;
614 case OpConst2u:
615 *pval = dwarfget2(&b);
616 return TConstant;
617 case OpConst2s:
618 *pval = (s16int)dwarfget2(&b);
619 return TConstant;
620 case OpConst4u:
621 *pval = dwarfget4(&b);
622 return TConstant;
623 case OpConst4s:
624 *pval = (s32int)dwarfget4(&b);
625 return TConstant;
626 case OpConst8u:
627 *pval = (u64int)dwarfget8(&b);
628 return TConstant;
629 case OpConst8s:
630 *pval = (s64int)dwarfget8(&b);
631 return TConstant;
632 case OpConstu:
633 *pval = dwarfget128(&b);
634 return TConstant;
635 case OpConsts:
636 *pval = dwarfget128s(&b);
637 return TConstant;
638 case OpPlusUconst:
639 *pval = dwarfget128(&b);
640 return TConstant;
641 default:
642 return TBlock;
643 }
644}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define d
Definition: ke_i.h:81
#define b
Definition: ke_i.h:79
signed char schar
Definition: compat.h:5
long long s64int
Definition: compat.h:16
int s32int
Definition: compat.h:14
unsigned long long u64int
Definition: compat.h:15
short s16int
Definition: compat.h:12
#define memset(x, y, z)
Definition: compat.h:39
ulong dwarfget128(DwarfBuf *)
Definition: dwarfget.c:152
ulong dwarfget2(DwarfBuf *)
Definition: dwarfget.c:81
@ OpConst4s
Definition: dwarf.h:144
@ OpConst4u
Definition: dwarf.h:143
@ OpConsts
Definition: dwarf.h:148
@ OpConst2u
Definition: dwarf.h:141
@ OpConst8u
Definition: dwarf.h:145
@ TConstant
Definition: dwarf.h:132
@ OpPlusUconst
Definition: dwarf.h:166
@ OpAddr
Definition: dwarf.h:137
@ OpConst1s
Definition: dwarf.h:140
@ OpConst2s
Definition: dwarf.h:142
@ OpConstu
Definition: dwarf.h:147
@ TBlock
Definition: dwarf.h:131
@ OpConst8s
Definition: dwarf.h:146
@ OpConst1u
Definition: dwarf.h:139
ulong dwarfget1(DwarfBuf *)
Definition: dwarfget.c:17
long dwarfget128s(DwarfBuf *)
Definition: dwarfget.c:197
ulong dwarfgetaddr(DwarfBuf *)
Definition: dwarfget.c:123
ulong dwarfget4(DwarfBuf *)
Definition: dwarfget.c:95
uvlong dwarfget8(DwarfBuf *)
Definition: dwarfget.c:109
uchar * data
Definition: dwarf.h:202
ulong len
Definition: dwarf.h:203

Referenced by parseattrs().

◆ dwarfenum()

int dwarfenum ( Dwarf d,
DwarfSym s 
)

Definition at line 241 of file dwarfinfo.c.

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

Referenced by main().

◆ dwarfenumunit()

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

Definition at line 201 of file dwarfinfo.c.

202{
203 int i;
204 ulong aoff, len;
205
206 if(unit >= d->info.len){
207 werrstr("dwarf unit address 0x%x >= 0x%x out of range", unit, d->info.len);
208 return -1;
209 }
210 memset(s, 0, sizeof *s);
211 memset(&s->b, 0, sizeof s->b);
212
213 s->b.d = d;
214 s->b.p = d->info.data + unit;
215 s->b.ep = d->info.data + d->info.len;
216 len = dwarfget4(&s->b);
217 s->nextunit = unit + 4 + len;
218
219 if(s->b.ep - s->b.p < len){
220 badheader:
221 werrstr("bad dwarf unit header at unit 0x%lux", unit);
222 return -1;
223 }
224 s->b.ep = s->b.p+len;
225 if((i=dwarfget2(&s->b)) != 2)
226 goto badheader;
227 aoff = dwarfget4(&s->b);
228 s->b.addrsize = dwarfget1(&s->b);
229 if(d->addrsize == 0)
230 d->addrsize = s->b.addrsize;
231 if(s->b.p == nil)
232 goto badheader;
233
234 s->aoff = aoff;
235 s->unit = unit;
236 s->depth = 0;
237 return 0;
238}
unsigned long ulong
Definition: linux.h:275
GLenum GLsizei len
Definition: glext.h:6722
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
png_const_structrp png_const_inforp int * unit
Definition: png.h:2159
#define werrstr(str,...)
Definition: compat.h:34
#define nil
Definition: compat.h:23

Referenced by dwarfargvalue(), dwarfenum(), dwarflookupfn(), dwarflookupnameinunit(), dwarflookuptag(), dwarfnextsym(), and dwarfseeksym().

◆ dwarflookupfn()

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

Definition at line 181 of file dwarfinfo.c.

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

◆ 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
Definition: name.c:39

◆ 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
GLuint GLuint num
Definition: glext.h:9618
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
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 s,
int  depth 
)

Definition at line 292 of file dwarfinfo.c.

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

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

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

◆ getblock()

static int getblock ( DwarfBuf b,
int  form,
DwarfBlock bl 
)
static

Definition at line 567 of file dwarfinfo.c.

568{
569 ulong n;
570
571 switch(form){
572 default:
573 return -1;
574 case FormDwarfBlock:
575 n = dwarfget128(b);
576 goto copyn;
577 case FormDwarfBlock1:
578 n = dwarfget1(b);
579 goto copyn;
580 case FormDwarfBlock2:
581 n = dwarfget2(b);
582 goto copyn;
583 case FormDwarfBlock4:
584 n = dwarfget4(b);
585 copyn:
586 bl->data = dwarfgetnref(b, n);
587 bl->len = n;
588 if(bl->data == nil)
589 return -1;
590 return 0;
591 }
592}
int form
Definition: main.c:89
GLdouble n
Definition: glext.h:7729
uchar * dwarfgetnref(DwarfBuf *, ulong)
Definition: dwarfget.c:40

Referenced by parseattrs(), and skipform().

◆ getstring()

static int getstring ( DwarfBuf b,
int  form,
char **  s 
)
static

Definition at line 539 of file dwarfinfo.c.

540{
541 static int nbad;
542 ulong u;
543
544 switch(form){
545 default:
546 return -1;
547
548 case FormString:
549 *s = dwarfgetstring(b);
550 return 0;
551
552 case FormStrp:
553 u = dwarfget4(b);
554 if(u >= b->d->str.len){
555 if(++nbad == 1)
556 werrstr("dwarf: bad string pointer 0x%lux in attribute", u);
557 /* don't return error - maybe can proceed */
558 *s = nil;
559 }else
560 *s = (char*)b->d->str.data + u;
561 return 0;
562
563 }
564}
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 * u
Definition: glfuncs.h:240
char * dwarfgetstring(DwarfBuf *)
Definition: dwarfget.c:54

Referenced by parseattrs(), and skipform().

◆ getuchar()

static int getuchar ( DwarfBuf b,
int  form,
uchar u 
)
static

Definition at line 526 of file dwarfinfo.c.

527{
528 switch(form){
529 default:
530 return -1;
531
532 case FormFlag:
533 *u = dwarfget1(b);
534 return 0;
535 }
536}

Referenced by parseattrs(), and skipform().

◆ getulong()

static int getulong ( DwarfBuf b,
int  form,
ulong  unit,
ulong u,
int type 
)
static

Definition at line 458 of file dwarfinfo.c.

459{
460 static int nbad;
461 uvlong uv;
462
463 switch(form){
464 default:
465 return -1;
466
467 /* addresses */
468 case FormAddr:
469 *type = TAddress;
470 *u = dwarfgetaddr(b);
471 return 0;
472
473 /* references */
474 case FormRefAddr:
475 /* absolute ref in .debug_info */
476 *type = TReference;
477 *u = dwarfgetaddr(b);
478 return 0;
479 case FormRef1:
480 *u = dwarfget1(b);
481 goto relativeref;
482 case FormRef2:
483 *u = dwarfget2(b);
484 goto relativeref;
485 case FormRef4:
486 *u = dwarfget4(b);
487 goto relativeref;
488 case FormRef8:
489 *u = dwarfget8(b);
490 goto relativeref;
491 case FormRefUdata:
492 *u = dwarfget128(b);
493 relativeref:
494 *u += unit;
495 *type = TReference;
496 return 0;
497
498 /* constants */
499 case FormData1:
500 *u = dwarfget1(b);
501 goto constant;
502 case FormData2:
503 *u = dwarfget2(b);
504 goto constant;
505 case FormData4:
506 *u = dwarfget4(b);
507 goto constant;
508 case FormData8:
509 uv = dwarfget8(b);
510 *u = uv;
511 if(uv != *u && ++nbad == 1)
512 werrstr("dwarf: truncating 64-bit attribute constants");
513 goto constant;
514 case FormSdata:
515 *u = dwarfget128s(b);
516 goto constant;
517 case FormUdata:
518 *u = dwarfget128(b);
519 constant:
520 *type = TConstant;
521 return 0;
522 }
523}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
unsigned long long uvlong
Definition: compat.h:9
@ TAddress
Definition: dwarf.h:135
@ TReference
Definition: dwarf.h:130

Referenced by parseattrs(), and skipform().

◆ parseattrs()

static int parseattrs ( DwarfBuf b,
ulong  unit,
DwarfAbbrev a,
DwarfAttrs attrs 
)
static

Definition at line 407 of file dwarfinfo.c.

408{
409 int i, f, n, got;
410 static int nbad;
411 void *v;
412
413 /* initialize ptab first time through for quick access */
415 for(i=0; plist[i].name; i++)
416 ptab[plist[i].name] = plist[i];
417
418 memset(attrs, 0, sizeof *attrs);
419 attrs->tag = a->tag;
420 attrs->haskids = a->haskids;
421
422 for(i=0; i<a->nattr; i++){
423 n = a->attr[i].name;
424 f = a->attr[i].form;
425 if(n < 0 || n >= DwarfAttrMax || ptab[n].name==0){
426 if(++nbad == 1)
427 werrstr("dwarf parse attrs: unexpected attribute name 0x%x", n);
428 continue; //return -1;
429 }
430 v = (char*)attrs + ptab[n].off;
431 got = 0;
432 if(f == FormIndirect)
433 f = dwarfget128(b);
435 && getulong(b, f, unit, v, &got) >= 0)
436 ;
437 else if((ptab[n].type&TFlag) && getuchar(b, f, v) >= 0)
438 got = TFlag;
439 else if((ptab[n].type&TString) && getstring(b, f, v) >= 0)
440 got = TString;
441 else if((ptab[n].type&TBlock) && getblock(b, f, v) >= 0)
442 got = TBlock;
443 else{
444 if(skipform(b, f) < 0){
445 if(++nbad == 1)
446 werrstr("dwarf parse attrs: cannot skip form %d", f);
447 return -1;
448 }
449 }
450 if(got == TBlock && (ptab[n].type&TConstant))
451 got = constblock(b->d, v, v);
452 *((uchar*)attrs+ptab[n].haveoff) = got;
453 }
454 return 0;
455}
unsigned char uchar
Definition: Unfrag.h:59
const GLdouble * v
Definition: gl.h:2040
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
static int getstring(DwarfBuf *, int, char **)
Definition: dwarfinfo.c:539
static int getuchar(DwarfBuf *, int, uchar *)
Definition: dwarfinfo.c:526
static int constblock(Dwarf *, DwarfBlock *, ulong *)
Definition: dwarfinfo.c:595
static int getblock(DwarfBuf *, int, DwarfBlock *)
Definition: dwarfinfo.c:567
static int getulong(DwarfBuf *, int, ulong, ulong *, int *)
Definition: dwarfinfo.c:458
static Parse ptab[DwarfAttrMax]
Definition: dwarfinfo.c:404
static int skipform(DwarfBuf *, int)
Definition: dwarfinfo.c:648
static Parse plist[]
Definition: dwarfinfo.c:337
@ TString
Definition: dwarf.h:133
@ TFlag
Definition: dwarf.h:134
uchar haskids
Definition: dwarf.h:226
ulong tag
Definition: dwarf.h:225
int name
Definition: dwarfinfo.c:331

Referenced by dwarfnextsym().

◆ skipform()

static int skipform ( DwarfBuf b,
int  form 
)
static

Definition at line 648 of file dwarfinfo.c.

649{
650 int type;
652
653 if(getulong(b, form, 0, &val.c, &type) < 0
654 && getuchar(b, form, (uchar*)&val) < 0
655 && getstring(b, form, &val.s) < 0
656 && getblock(b, form, &val.b) < 0)
657 return -1;
658 return 0;
659}
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by parseattrs().

Variable Documentation

◆ plist

◆ ptab

Parse ptab[DwarfAttrMax]
static

Definition at line 404 of file dwarfinfo.c.

Referenced by parseattrs().