ReactOS 0.4.16-dev-91-g764881a
dwarfabbrev.c File Reference
#include <ntddk.h>
#include <reactos/rossym.h>
#include "rossympriv.h"
#include <ntimage.h>
#include <debug.h>
#include "dwarf.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 14 of file dwarfabbrev.c.

Function Documentation

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

◆ findabbrev()

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

Definition at line 116 of file dwarfabbrev.c.

117{
118 int i;
119
120 for(i=0; i<na; i++)
121 if(a[i].num == num)
122 return &a[i];
123 werrstr("abbrev not found");
124 return nil;
125}
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

Referenced by dwarfgetabbrev().

◆ loadabbrevs()

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

Definition at line 25 of file dwarfabbrev.c.

26{
27 int nattr, nabbrev;
28 DwarfAbbrev *abbrev;
30
31 if(d->acache.off == off && d->acache.na){
32 *aa = d->acache.a;
33 return d->acache.na;
34 }
35
36 /* two passes - once to count, then allocate, then a second to copy */
37 if(parseabbrevs(d, off, nil, nil, &nabbrev, &nattr) < 0) {
38 return -1;
39 }
40
41 abbrev = malloc(nabbrev*sizeof(DwarfAbbrev) + nattr*sizeof(DwarfAttr));
42 attr = (DwarfAttr*)(abbrev+nabbrev);
43
44 if(parseabbrevs(d, off, abbrev, attr, nil, nil) < 0){
45 free(abbrev);
46 return -1;
47 }
48
49 free(d->acache.a);
50 d->acache.a = abbrev;
51 d->acache.na = nabbrev;
52 d->acache.off = off;
53
54 *aa = abbrev;
55 return nabbrev;
56}
#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

Referenced by dwarfgetabbrev().

◆ parseabbrevs()

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

Definition at line 59 of file dwarfabbrev.c.

60{
61 int i, nabbrev, nattr, haskids;
63 DwarfBuf b;
64
65 if(off >= d->abbrev.len){
66 werrstr("bad abbrev section offset 0x%lux >= 0x%lux\n", off, d->abbrev.len);
67 return -1;
68 }
69
70 memset(&b, 0, sizeof b);
71 b.p = d->abbrev.data + off;
72 b.ep = d->abbrev.data + d->abbrev.len;
73
74 nabbrev = 0;
75 nattr = 0;
76 for(;;){
77 if(b.p == nil){
78 werrstr("malformed abbrev data");
79 return -1;
80 }
81 num = dwarfget128(&b);
82 if(num == 0)
83 break;
84 tag = dwarfget128(&b);
85 haskids = dwarfget1(&b);
86 for(i=0;; i++){
87 name = dwarfget128(&b);
88 form = dwarfget128(&b);
89 if(name == 0 && form == 0)
90 break;
91 if(attr){
92 attr[i].name = name;
93 attr[i].form = form;
94 }
95 }
96 if(abbrev){
97 abbrev->num = num;
98 abbrev->tag = tag;
99 abbrev->haskids = haskids;
100 abbrev->attr = attr;
101 abbrev->nattr = i;
102 abbrev++;
103 attr += i;
104 }
105 nabbrev++;
106 nattr += i;
107 }
108 if(pnabbrev)
109 *pnabbrev = nabbrev;
110 if(pnattr)
111 *pnattr = nattr;
112 return 0;
113}
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

Referenced by loadabbrevs().