ReactOS 0.4.15-dev-7704-gc07eb9f
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
15Dwarf*
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
42err:
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
56void
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 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:71
Definition: dwarf.h:437
Definition: pe.h:14
int(* loadsection)(struct _Pe *pe, char *name, struct DwarfBlock *b)
Definition: pe.h:22