ReactOS  0.4.14-dev-317-g96040ec
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 NTOSAPI
 
#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 15 of file dwarfabbrev.c.

◆ NTOSAPI

#define NTOSAPI

Definition at line 9 of file dwarfabbrev.c.

Function Documentation

◆ dwarfgetabbrev()

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

Definition at line 129 of file dwarfabbrev.c.

130 {
131  DwarfAbbrev *a;
132  int na;
133 
134  if((na = loadabbrevs(d, off, &a)) < 0){
135  werrstr("loadabbrevs: %r");
136  return nil;
137  }
138  return findabbrev(a, na, num);
139 }
#define werrstr(str,...)
Definition: compat.h:34
#define a
Definition: ke_i.h:78
#define d
Definition: ke_i.h:81
GLuint GLuint num
Definition: glext.h:9618
static int loadabbrevs(Dwarf *d, ulong off, DwarfAbbrev **aa)
Definition: dwarfabbrev.c:26
#define nil
Definition: compat.h:23
static DwarfAbbrev * findabbrev(DwarfAbbrev *a, int na, ulong num)
Definition: dwarfabbrev.c:117
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
off
Definition: i386-dis.c:3909

◆ findabbrev()

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

Definition at line 117 of file dwarfabbrev.c.

118 {
119  int i;
120 
121  for(i=0; i<na; i++)
122  if(a[i].num == num)
123  return &a[i];
124  werrstr("abbrev not found");
125  return nil;
126 }
#define werrstr(str,...)
Definition: compat.h:34
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
GLuint GLuint num
Definition: glext.h:9618
#define nil
Definition: compat.h:23
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by dwarfgetabbrev().

◆ loadabbrevs()

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

Definition at line 26 of file dwarfabbrev.c.

27 {
28  int nattr, nabbrev;
29  DwarfAbbrev *abbrev;
30  DwarfAttr *attr;
31 
32  if(d->acache.off == off && d->acache.na){
33  *aa = d->acache.a;
34  return d->acache.na;
35  }
36 
37  /* two passes - once to count, then allocate, then a second to copy */
38  if(parseabbrevs(d, off, nil, nil, &nabbrev, &nattr) < 0) {
39  return -1;
40  }
41 
42  abbrev = malloc(nabbrev*sizeof(DwarfAbbrev) + nattr*sizeof(DwarfAttr));
43  attr = (DwarfAttr*)(abbrev+nabbrev);
44 
45  if(parseabbrevs(d, off, abbrev, attr, nil, nil) < 0){
46  free(abbrev);
47  return -1;
48  }
49 
50  free(d->acache.a);
51  d->acache.a = abbrev;
52  d->acache.na = nabbrev;
53  d->acache.off = off;
54 
55  *aa = abbrev;
56  return nabbrev;
57 }
#define free
Definition: debug_ros.c:5
static int parseabbrevs(Dwarf *, ulong, DwarfAbbrev *, DwarfAttr *, int *, int *)
Definition: dwarfabbrev.c:60
#define d
Definition: ke_i.h:81
Definition: cookie.c:170
__u8 attr
Definition: mkdosfs.c:359
#define nil
Definition: compat.h:23
#define malloc
Definition: debug_ros.c:4
off
Definition: i386-dis.c:3909

Referenced by dwarfgetabbrev().

◆ parseabbrevs()

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

Definition at line 60 of file dwarfabbrev.c.

61 {
62  int i, nabbrev, nattr, haskids;
63  ulong num, tag, name, form;
64  DwarfBuf b;
65 
66  if(off >= d->abbrev.len){
67  werrstr("bad abbrev section offset 0x%lux >= 0x%lux\n", off, d->abbrev.len);
68  return -1;
69  }
70 
71  memset(&b, 0, sizeof b);
72  b.p = d->abbrev.data + off;
73  b.ep = d->abbrev.data + d->abbrev.len;
74 
75  nabbrev = 0;
76  nattr = 0;
77  for(;;){
78  if(b.p == nil){
79  werrstr("malformed abbrev data");
80  return -1;
81  }
82  num = dwarfget128(&b);
83  if(num == 0)
84  break;
85  tag = dwarfget128(&b);
86  haskids = dwarfget1(&b);
87  for(i=0;; i++){
88  name = dwarfget128(&b);
89  form = dwarfget128(&b);
90  if(name == 0 && form == 0)
91  break;
92  if(attr){
93  attr[i].name = name;
94  attr[i].form = form;
95  }
96  }
97  if(abbrev){
98  abbrev->num = num;
99  abbrev->tag = tag;
100  abbrev->haskids = haskids;
101  abbrev->attr = attr;
102  abbrev->nattr = i;
103  abbrev++;
104  attr += i;
105  }
106  nabbrev++;
107  nattr += i;
108  }
109  if(pnabbrev)
110  *pnabbrev = nabbrev;
111  if(pnattr)
112  *pnattr = nattr;
113  return 0;
114 }
#define werrstr(str,...)
Definition: compat.h:34
int form
Definition: main.c:89
Definition: ecma_167.h:138
int nattr
Definition: dwarf.h:431
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
ulong dwarfget1(DwarfBuf *)
Definition: dwarfget.c:18
ulong tag
Definition: dwarf.h:428
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
ulong num
Definition: dwarf.h:427
#define d
Definition: ke_i.h:81
GLuint GLuint num
Definition: glext.h:9618
Definition: cookie.c:170
__u8 attr
Definition: mkdosfs.c:359
unsigned long ulong
Definition: linux.h:275
ulong dwarfget128(DwarfBuf *)
Definition: dwarfget.c:153
DwarfAttr * attr
Definition: dwarf.h:430
#define nil
Definition: compat.h:23
Definition: name.c:36
WCHAR * name
Definition: cookie.c:172
uchar haskids
Definition: dwarf.h:429
#define memset(x, y, z)
Definition: compat.h:39
off
Definition: i386-dis.c:3909
GLuint const GLchar * name
Definition: glext.h:6031
char * tag
Definition: main.c:59

Referenced by loadabbrevs().