From b178207920778242d59b31f6426fc0a5981df363 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 14 Feb 1999 09:27:42 +0000 Subject: [PATCH] Added possibility to load .stabs/.stabstr sections from PE dlls. Unfortunately my samples use currently typedefs which wine-dbg does not understand, so no actual parsing. --- debugger/hash.c | 5 +---- debugger/msc.c | 52 +++++++++++++++++++++++++++++++++++----------- debugger/stabs.c | 1 - include/debugger.h | 4 ++-- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/debugger/hash.c b/debugger/hash.c index c0e13918159..f4c18ed5d53 100644 --- a/debugger/hash.c +++ b/debugger/hash.c @@ -865,10 +865,7 @@ static void DEBUG_LoadEntryPoints32( HMODULE32 hModule, const char *name ) DEBUG_AddSymbol( buffer, &addr, NULL, SYM_WIN32 | SYM_FUNC ); } } - - dir = &PE_HEADER(hModule)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]; - if (dir->Size) - DEBUG_RegisterDebugInfo(hModule, name, dir->VirtualAddress, dir->Size); + DEBUG_RegisterDebugInfo(hModule, name); #undef RVA } diff --git a/debugger/msc.c b/debugger/msc.c index 35a73d8d53e..9d6b1389a62 100644 --- a/debugger/msc.c +++ b/debugger/msc.c @@ -915,17 +915,21 @@ DEBUG_InitCVDataTypes() * We don't fully process it here for performance reasons. */ int -DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name, - u_long v_addr, u_long size) +DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name) { int has_codeview = FALSE; int rtn = FALSE; int orig_size; PIMAGE_DEBUG_DIRECTORY dbgptr; + u_long v_addr, size; + PIMAGE_NT_HEADERS nth = PE_HEADER(hModule); - orig_size = size; - dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr); - for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ ) + size = nth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size; + if (size) { + v_addr = nth->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress; + dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr); + orig_size = size; + for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ ) { switch(dbgptr->Type) { @@ -936,9 +940,9 @@ DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name, } } - size = orig_size; - dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr); - for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ ) + size = orig_size; + dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr); + for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ ) { switch(dbgptr->Type) { @@ -1029,11 +1033,35 @@ DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name, default: } } - - DEBUG_next_index++; - + DEBUG_next_index++; + } + /* look for .stabs/.stabstr sections */ + { + PIMAGE_SECTION_HEADER pe_seg = PE_SECTIONS(hModule); + int i,stabsize=0,stabstrsize=0; + unsigned int stabs=0,stabstr=0; + + for (i=0;iFileHeader.NumberOfSections;i++) { + if (!strcasecmp(pe_seg[i].Name,".stab")) { + stabs = pe_seg[i].VirtualAddress; + stabsize = pe_seg[i].SizeOfRawData; + } + if (!strncasecmp(pe_seg[i].Name,".stabstr",8)) { + stabstr = pe_seg[i].VirtualAddress; + stabstrsize = pe_seg[i].SizeOfRawData; + } + } + if (stabstrsize && stabsize) { +#ifdef _WE_SUPPORT_THE_STAB_TYPES_USED_BY_MINGW_TOO + /* Won't work currently, since MINGW32 uses some special typedefs + * which we do not handle yet. Support for them is a bit difficult. + */ + DEBUG_ParseStabs(hModule,0,stabs,stabsize,stabstr,stabstrsize); +#endif + fprintf(stderr,"(stabs not loaded)"); + } + } return (rtn); - } /* diff --git a/debugger/stabs.c b/debugger/stabs.c index 67565ca2a26..b26be2141d8 100644 --- a/debugger/stabs.c +++ b/debugger/stabs.c @@ -620,7 +620,6 @@ DEBUG_ParseStabType(const char * stab) return stab_types[DEBUG_ReadTypeEnum(&c)]; } -static int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff, int stablen, diff --git a/include/debugger.h b/include/debugger.h index 74bf0bb7f47..c490e9d1521 100644 --- a/include/debugger.h +++ b/include/debugger.h @@ -271,10 +271,10 @@ extern int DEBUG_GetCurrentFrame(struct name_hash ** name, /* debugger/stabs.c */ extern int DEBUG_ReadExecutableDbgInfo(void); +extern int DEBUG_ParseStabs(char * addr, unsigned int load_offset, unsigned int staboff, int stablen, unsigned int strtaboff, int strtablen); /* debugger/msc.c */ -extern int DEBUG_RegisterDebugInfo( HMODULE32, const char *, - unsigned long, unsigned long); +extern int DEBUG_RegisterDebugInfo( HMODULE32, const char *); extern int DEBUG_ProcessDeferredDebug(void); extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name); extern void DEBUG_InfoShare(void);