Commit b1782079 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

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.
parent fb019223
...@@ -865,10 +865,7 @@ static void DEBUG_LoadEntryPoints32( HMODULE32 hModule, const char *name ) ...@@ -865,10 +865,7 @@ static void DEBUG_LoadEntryPoints32( HMODULE32 hModule, const char *name )
DEBUG_AddSymbol( buffer, &addr, NULL, SYM_WIN32 | SYM_FUNC ); DEBUG_AddSymbol( buffer, &addr, NULL, SYM_WIN32 | SYM_FUNC );
} }
} }
DEBUG_RegisterDebugInfo(hModule, name);
dir = &PE_HEADER(hModule)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG];
if (dir->Size)
DEBUG_RegisterDebugInfo(hModule, name, dir->VirtualAddress, dir->Size);
#undef RVA #undef RVA
} }
......
...@@ -915,17 +915,21 @@ DEBUG_InitCVDataTypes() ...@@ -915,17 +915,21 @@ DEBUG_InitCVDataTypes()
* We don't fully process it here for performance reasons. * We don't fully process it here for performance reasons.
*/ */
int int
DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name, DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name)
u_long v_addr, u_long size)
{ {
int has_codeview = FALSE; int has_codeview = FALSE;
int rtn = FALSE; int rtn = FALSE;
int orig_size; int orig_size;
PIMAGE_DEBUG_DIRECTORY dbgptr; PIMAGE_DEBUG_DIRECTORY dbgptr;
u_long v_addr, size;
orig_size = size; PIMAGE_NT_HEADERS nth = PE_HEADER(hModule);
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) switch(dbgptr->Type)
{ {
...@@ -936,9 +940,9 @@ DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name, ...@@ -936,9 +940,9 @@ DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name,
} }
} }
size = orig_size; size = orig_size;
dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr); dbgptr = (PIMAGE_DEBUG_DIRECTORY) (hModule + v_addr);
for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ ) for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ )
{ {
switch(dbgptr->Type) switch(dbgptr->Type)
{ {
...@@ -1029,11 +1033,35 @@ DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name, ...@@ -1029,11 +1033,35 @@ DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name,
default: 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;i<nth->FileHeader.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); return (rtn);
} }
/* /*
......
...@@ -620,7 +620,6 @@ DEBUG_ParseStabType(const char * stab) ...@@ -620,7 +620,6 @@ DEBUG_ParseStabType(const char * stab)
return stab_types[DEBUG_ReadTypeEnum(&c)]; return stab_types[DEBUG_ReadTypeEnum(&c)];
} }
static
int int
DEBUG_ParseStabs(char * addr, unsigned int load_offset, DEBUG_ParseStabs(char * addr, unsigned int load_offset,
unsigned int staboff, int stablen, unsigned int staboff, int stablen,
......
...@@ -271,10 +271,10 @@ extern int DEBUG_GetCurrentFrame(struct name_hash ** name, ...@@ -271,10 +271,10 @@ extern int DEBUG_GetCurrentFrame(struct name_hash ** name,
/* debugger/stabs.c */ /* debugger/stabs.c */
extern int DEBUG_ReadExecutableDbgInfo(void); 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 */ /* debugger/msc.c */
extern int DEBUG_RegisterDebugInfo( HMODULE32, const char *, extern int DEBUG_RegisterDebugInfo( HMODULE32, const char *);
unsigned long, unsigned long);
extern int DEBUG_ProcessDeferredDebug(void); extern int DEBUG_ProcessDeferredDebug(void);
extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name); extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name);
extern void DEBUG_InfoShare(void); extern void DEBUG_InfoShare(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment