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