1 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* 16 dwarfopen(Pe *pe) 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 57 dwarfclose(Dwarf *d) 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 71