void DumpSections( void ) { dw_sectnum sect; sortTables(); for( sect = 0; sect < DW_DEBUG_MAX; ++sect ) { if( sect > 0 ) printf( "\n" ); printf( "%s:\n", sectionNames[sect] ); switch( sect ) { case DW_DEBUG_ABBREV: dumpAbbrevs( Sections[sect].data, Sections[sect].max_offset ); break; case DW_DEBUG_INFO: dumpInfo( Sections[sect].data, Sections[sect].max_offset ); break; case DW_DEBUG_LINE: dumpLines( Sections[sect].data, Sections[sect].max_offset ); break; case DW_DEBUG_REF: dumpRef( Sections[sect].data, Sections[sect].max_offset ); break; case DW_DEBUG_ARANGES: dumpARanges( Sections[sect].data, Sections[sect].max_offset ); break; case DW_DEBUG_STR: // Strings are displayed when dumping other sections break; default: dumpHex( Sections[sect].data, Sections[sect].max_offset, 0 ); break; } } }
// Dump segments in a chain static void dumpSegments( FILE *f, int count ) { sym_segdef seg; char name[256]; unsigned_32 seg_start; unsigned_32 sym_tab_offset; int i; for( i = 0; i < count; ++i ) { seg_start = ftell( f ); fread( &seg, 1, SYM_SEGDEF_FIXSIZE, f ); readString( f, name ); printf( "--Segment '%s'\n", name ); printf( " Next segment at 0x%06x, %d symbols, table at 0x%06x\n", SYM_PTR_TO_OFS( seg.next_ptr ), seg.num_syms, seg_start + seg.sym_tab_ofs ); printf( " Segment load address 0x%04x, phys addr 0x%04x, flags 0x%02x\n", seg.load_addr, seg.phys_0, seg.sym_type ); printf( " Line nums at 0x%06x, loaded flag 0x%02x, curr instance 0x%02x\n", SYM_PTR_TO_OFS( seg.linnum_ptr ), seg.is_loaded, seg.curr_inst ); sym_tab_offset = seg.sym_tab_ofs; /* if alphabetically sorted symbol table is present, it'll be right after * the first table (which is sorted by address) */ if( DumpAlphaSorted && (seg.sym_type & SYM_FLAG_ALPHA) ) { printf( " Symbols in alphabetical order:\n" ); sym_tab_offset += seg.num_syms * sizeof( unsigned_16 ); } dumpSymTable( f, seg.num_syms, seg_start, sym_tab_offset, (seg.sym_type & SYM_FLAG_32BIT) != 0 ); if( seg.linnum_ptr != 0 ) { dumpLines( f, SYM_PTR_TO_OFS( seg.linnum_ptr ) ); } fseek( f, SYM_PTR_TO_OFS( seg.next_ptr ), SEEK_SET ); }; }