ReactOS 0.4.15-dev-7918-g2a2556c
dwarfabbrev.c File Reference
#include <precomp.h>
#include <debug.h>
Include dependency graph for dwarfabbrev.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static int parseabbrevs (Dwarf *, ulong, DwarfAbbrev *, DwarfAttr *, int *, int *)
 
DwarfAbbrevdwarfgetabbrev (Dwarf *, ulong, ulong)
 
static int loadabbrevs (Dwarf *d, ulong off, DwarfAbbrev **aa)
 
static DwarfAbbrevfindabbrev (DwarfAbbrev *a, int na, ulong num)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file dwarfabbrev.c.

Function Documentation

◆ dwarfgetabbrev()

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

Definition at line 125 of file dwarfabbrev.c.

126{
127 DwarfAbbrev *a;
128 int na;
129 werrstr("want num %d\n", num);
130 if((na = loadabbrevs(d, off, &a)) < 0){
131 werrstr("loadabbrevs: %r");
132 return nil;
133 }
134 return findabbrev(a, na, num);
135}
GLuint GLuint num
Definition: glext.h:9618
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define d
Definition: ke_i.h:81
#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
#define werrstr(str,...)
Definition: compat.h:34
#define nil
Definition: compat.h:23

Referenced by dwarfnextsym().

◆ findabbrev()

static DwarfAbbrev * findabbrev ( DwarfAbbrev a,
int  na,
ulong  num 
)
static

Definition at line 111 of file dwarfabbrev.c.

112{
113 int i;
114
115 for(i=0; i<na; i++) {
116 if(a[i].num == num) {
117 return &a[i];
118 }
119 }
120 werrstr("abbrev not found (%x)", na);
121 return nil;
122}
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

◆ loadabbrevs()

static int loadabbrevs ( Dwarf d,
ulong  off,
DwarfAbbrev **  aa 
)
static

Definition at line 18 of file dwarfabbrev.c.

19{
20 int nattr, nabbrev;
21 DwarfAbbrev *abbrev;
23
24 if(d->acache.off == off && d->acache.na){
25 *aa = d->acache.a;
26 return d->acache.na;
27 }
28
29 /* two passes - once to count, then allocate, then a second to copy */
30 if(parseabbrevs(d, off, nil, nil, &nabbrev, &nattr) < 0) {
31 return -1;
32 }
33
34 abbrev = malloc(nabbrev*sizeof(DwarfAbbrev) + nattr*sizeof(DwarfAttr));
35 attr = (DwarfAttr*)(abbrev+nabbrev);
36
37 if(parseabbrevs(d, off, abbrev, attr, nil, nil) < 0){
38 free(abbrev);
39 return -1;
40 }
41
42 free(d->acache.a);
43 d->acache.a = abbrev;
44 d->acache.na = nabbrev;
45 d->acache.off = off;
46
47 *aa = abbrev;
48 return nabbrev;
49}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
static int parseabbrevs(Dwarf *, ulong, DwarfAbbrev *, DwarfAttr *, int *, int *)
Definition: dwarfabbrev.c:59
Definition: cookie.c:202

◆ parseabbrevs()

static int parseabbrevs ( Dwarf d,
ulong  off,
DwarfAbbrev abbrev,
DwarfAttr attr,
int pnabbrev,
int pnattr 
)
static

Definition at line 52 of file dwarfabbrev.c.

53{
54 int i, nabbrev, nattr, haskids;
56 DwarfBuf b;
57
58 if(off >= d->abbrev.len){
59 werrstr("bad abbrev section offset 0x%lux >= 0x%lux", off, d->abbrev.len);
60 return -1;
61 }
62
63 memset(&b, 0, sizeof b);
64 b.p = d->abbrev.data + off;
65 b.ep = d->abbrev.data + d->abbrev.len;
66
67 nabbrev = 0;
68 nattr = 0;
69 for(;;){
70 if(b.p == nil){
71 werrstr("malformed abbrev data");
72 return -1;
73 }
74 num = dwarfget128(&b);
75 if(num == 0)
76 break;
77 tag = dwarfget128(&b);
78 werrstr("abbrev: num %d tag %x @ %x", num, tag, b.p - d->abbrev.data);
79 haskids = dwarfget1(&b);
80 for(i=0;; i++){
81 name = dwarfget128(&b);
82 form = dwarfget128(&b);
83 assert(form < 0x3000);
84 if(name == 0 && form == 0)
85 break;
86 if(attr){
87 attr[i].name = name;
88 attr[i].form = form;
89 }
90 }
91 if(abbrev){
92 abbrev->num = num;
93 abbrev->tag = tag;
94 abbrev->haskids = haskids;
95 abbrev->attr = attr;
96 abbrev->nattr = i;
97 abbrev++;
98 attr += i;
99 }
100 nabbrev++;
101 nattr += i;
102 }
103 if(pnabbrev)
104 *pnabbrev = nabbrev;
105 if(pnattr)
106 *pnattr = nattr;
107 return 0;
108}
#define assert(x)
Definition: debug.h:53
unsigned long ulong
Definition: linux.h:275
int form
Definition: main.c:89
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
#define memset(x, y, z)
Definition: compat.h:39
ulong dwarfget128(DwarfBuf *)
Definition: dwarfget.c:152
ulong dwarfget1(DwarfBuf *)
Definition: dwarfget.c:17
int nattr
Definition: dwarf.h:431
ulong num
Definition: dwarf.h:427
ulong tag
Definition: dwarf.h:428
uchar haskids
Definition: dwarf.h:429
DwarfAttr * attr
Definition: dwarf.h:430
WCHAR * name
Definition: cookie.c:203
Definition: name.c:39
Definition: ecma_167.h:138