ReactOS  0.4.15-dev-321-g2d9b385
dwarfopen.c
Go to the documentation of this file.
1 #define NTOSAPI
2 #include <ntddk.h>
3 #include <reactos/rossym.h>
4 #include "rossympriv.h"
5 #include <ntimage.h>
6 
7 #define NDEBUG
8 #include <debug.h>
9 
10 #include "dwarf.h"
11 #include "pe.h"
12 
13 /* Adapted for PE */
14 
15 Dwarf*
17 {
18  Dwarf *d;
19 
20  if(pe == nil){
21  werrstr("nil pe passed to dwarfopen");
22  return nil;
23  }
24 
25  d = mallocz(sizeof(Dwarf), 1);
26  if(d == nil)
27  return nil;
28 
29  d->pe = pe;
30  if(pe->loadsection(pe, ".debug_abbrev", &d->abbrev) < 0
31  || pe->loadsection(pe, ".debug_aranges", &d->aranges) < 0
32  || pe->loadsection(pe, ".debug_line", &d->line) < 0
33  || pe->loadsection(pe, ".debug_pubnames", &d->pubnames) < 0
34  || pe->loadsection(pe, ".debug_info", &d->info) < 0)
35  goto err;
36  pe->loadsection(pe, ".debug_frame", &d->frame);
37  pe->loadsection(pe, ".debug_ranges", &d->ranges);
38  pe->loadsection(pe, ".debug_str", &d->str);
39 
40  return d;
41 
42 err:
43  DPRINT("Failed to open dwarf\n");
44  free(d->abbrev.data);
45  free(d->aranges.data);
46  free(d->frame.data);
47  free(d->line.data);
48  free(d->pubnames.data);
49  free(d->ranges.data);
50  free(d->str.data);
51  free(d->info.data);
52  free(d);
53  return nil;
54 }
55 
56 void
58 {
59  free(d->abbrev.data);
60  free(d->aranges.data);
61  free(d->frame.data);
62  free(d->line.data);
63  free(d->pubnames.data);
64  free(d->ranges.data);
65  free(d->str.data);
66  free(d->info.data);
67  pefree(d->pe);
68  free(d);
69 }
70 
#define werrstr(str,...)
Definition: compat.h:34
#define free
Definition: debug_ros.c:5
#define mallocz(x, y)
Definition: compat.h:36
void dwarfclose(Dwarf *d)
Definition: dwarfopen.c:57
Definition: pe.h:14
void DPRINT(...)
Definition: polytest.cpp:61
int(* loadsection)(struct _Pe *pe, char *name, struct DwarfBlock *b)
Definition: pe.h:22
#define d
Definition: ke_i.h:81
#define err(...)
Definition: dwarf.h:436
#define nil
Definition: compat.h:23
void pefree(Pe *pe)
Definition: pe.c:109
Dwarf * dwarfopen(Pe *pe)
Definition: dwarfopen.c:16