Commit 954a612c authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

- implement SymUnDName and UndecorateSymbolName on top of

msvcrt.__unDName - implement SYMOPT_UNDNAME support
parent e21f7c2a
...@@ -33,14 +33,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); ...@@ -33,14 +33,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
* + funcargtype:s are (partly) wrong: they should be a specific struct (like * + funcargtype:s are (partly) wrong: they should be a specific struct (like
* typedef) pointing to the actual type (and not a direct access) * typedef) pointing to the actual type (and not a direct access)
* + we should store the underlying type for an enum in the symt_enum struct * + we should store the underlying type for an enum in the symt_enum struct
* - most options (dbghelp_options) are not used (loading lines, decoration...) * + for enums, we store the names & values (associated to the enum type),
* but those values are not directly usable from a debugger (that's why, I
* assume, that we have also to define constants for enum values, as
* Codeview does BTW.
* - most options (dbghelp_options) are not used (loading lines...)
* - in symbol lookup by name, we don't use RE everywhere we should. Moreover, when * - in symbol lookup by name, we don't use RE everywhere we should. Moreover, when
* we're supposed to use RE, it doesn't make use of our hash tables. Therefore, * we're supposed to use RE, it doesn't make use of our hash tables. Therefore,
* we could use hash if name isn't a RE, and fall back to a full search when we * we could use hash if name isn't a RE, and fall back to a full search when we
* get a full RE * get a full RE
* - (un)decoration is not handled (should make winedump's code a (.a) library
* and link it to winedump, and potentially to msvcrt and dbghelp (check best
* way not to duplicate code in msvcrt & dbghelp)
* - msc: * - msc:
* + we should add parameters' types to the function's signature * + we should add parameters' types to the function's signature
* while processing a function's parameters * while processing a function's parameters
...@@ -59,6 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); ...@@ -59,6 +60,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
*/ */
unsigned dbghelp_options = SYMOPT_UNDNAME; unsigned dbghelp_options = SYMOPT_UNDNAME;
HANDLE hMsvcrt = NULL;
/*********************************************************************** /***********************************************************************
* DllMain (DEBUGHLP.@) * DllMain (DEBUGHLP.@)
...@@ -68,7 +70,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -68,7 +70,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
switch (fdwReason) switch (fdwReason)
{ {
case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_ATTACH: break;
case DLL_PROCESS_DETACH: break; case DLL_PROCESS_DETACH:
if (hMsvcrt) FreeLibrary(hMsvcrt);
break;
case DLL_THREAD_ATTACH: break; case DLL_THREAD_ATTACH: break;
case DLL_THREAD_DETACH: break; case DLL_THREAD_DETACH: break;
default: break; default: break;
......
...@@ -99,6 +99,8 @@ void* hash_table_iter_up(struct hash_table_iter* hti); ...@@ -99,6 +99,8 @@ void* hash_table_iter_up(struct hash_table_iter* hti);
extern unsigned dbghelp_options; extern unsigned dbghelp_options;
/* some more Wine extensions */
#define SYMOPT_WINE_WITH_ELF_MODULES 0x40000000
struct symt struct symt
{ {
...@@ -288,6 +290,7 @@ struct process ...@@ -288,6 +290,7 @@ struct process
/* dbghelp.c */ /* dbghelp.c */
extern struct process* process_find_by_handle(HANDLE hProcess); extern struct process* process_find_by_handle(HANDLE hProcess);
extern HANDLE hMsvcrt;
/* elf_module.c */ /* elf_module.c */
extern BOOL elf_load_debug_info(struct module* module); extern BOOL elf_load_debug_info(struct module* module);
...@@ -443,7 +446,3 @@ extern struct symt_pointer* ...@@ -443,7 +446,3 @@ extern struct symt_pointer*
extern struct symt_typedef* extern struct symt_typedef*
symt_new_typedef(struct module* module, struct symt* ref, symt_new_typedef(struct module* module, struct symt* ref,
const char* name); const char* name);
/* some more Wine extensions */
#define SYMOPT_WINE_WITH_ELF_MODULES 0x40000000
...@@ -529,11 +529,16 @@ static void symt_fill_sym_info(const struct module* module, ...@@ -529,11 +529,16 @@ static void symt_fill_sym_info(const struct module* module,
sym_info->Scope = 0; /* FIXME */ sym_info->Scope = 0; /* FIXME */
sym_info->Tag = sym->tag; sym_info->Tag = sym->tag;
name = symt_get_name(sym); name = symt_get_name(sym);
sym_info->NameLen = strlen(name) + 1;
if (sym_info->MaxNameLen) if (sym_info->MaxNameLen)
{ {
strncpy(sym_info->Name, name, min(sym_info->NameLen, sym_info->MaxNameLen)); if (sym->tag != SymTagPublicSymbol || !(dbghelp_options & SYMOPT_UNDNAME) ||
sym_info->Name[sym_info->MaxNameLen - 1] = '\0'; (sym_info->NameLen = UnDecorateSymbolName(sym_info->Name, sym_info->Name,
sym_info->MaxNameLen, UNDNAME_COMPLETE) == 0))
{
sym_info->NameLen = min(strlen(name), sym_info->MaxNameLen - 1);
strncpy(sym_info->Name, name, sym_info->NameLen);
sym_info->Name[sym_info->NameLen] = '\0';
}
} }
TRACE_(dbghelp_symt)("%p => %s %lu %s\n", TRACE_(dbghelp_symt)("%p => %s %lu %s\n",
sym, sym_info->Name, sym_info->Size, sym, sym_info->Name, sym_info->Size,
...@@ -1186,21 +1191,37 @@ PVOID WINAPI SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase) ...@@ -1186,21 +1191,37 @@ PVOID WINAPI SymFunctionTableAccess(HANDLE hProcess, DWORD AddrBase)
*/ */
BOOL WINAPI SymUnDName(PIMAGEHLP_SYMBOL sym, LPSTR UnDecName, DWORD UnDecNameLength) BOOL WINAPI SymUnDName(PIMAGEHLP_SYMBOL sym, LPSTR UnDecName, DWORD UnDecNameLength)
{ {
FIXME("(%p %s %lu): stub\n", sym, UnDecName, UnDecNameLength); TRACE("(%p %s %lu): stub\n", sym, UnDecName, UnDecNameLength);
return UnDecorateSymbolName(sym->Name, UnDecName, UnDecNameLength, return UnDecorateSymbolName(sym->Name, UnDecName, UnDecNameLength,
UNDNAME_COMPLETE); UNDNAME_COMPLETE) != 0;
} }
static void* und_alloc(size_t len) { return HeapAlloc(GetProcessHeap(), 0, len); }
static void und_free (void* ptr) { HeapFree(GetProcessHeap(), 0, ptr); }
/*********************************************************************** /***********************************************************************
* UnDecorateSymbolName (DBGHELP.@) * UnDecorateSymbolName (DBGHELP.@)
*/ */
DWORD WINAPI UnDecorateSymbolName(LPCSTR DecoratedName, LPSTR UnDecoratedName, DWORD WINAPI UnDecorateSymbolName(LPCSTR DecoratedName, LPSTR UnDecoratedName,
DWORD UndecoratedLength, DWORD Flags) DWORD UndecoratedLength, DWORD Flags)
{ {
FIXME("(%s, %p, %ld, 0x%08lx): stub\n", /* undocumented from msvcrt */
static char* (*p_undname)(char*, const char*, int, void* (*)(size_t), void (*)(void*), unsigned short);
static WCHAR szMsvcrt[] = {'m','s','v','c','r','t','.','d','l','l',0};
TRACE("(%s, %p, %ld, 0x%08lx): stub\n",
debugstr_a(DecoratedName), UnDecoratedName, UndecoratedLength, Flags); debugstr_a(DecoratedName), UnDecoratedName, UndecoratedLength, Flags);
strncpy(UnDecoratedName, DecoratedName, UndecoratedLength); if (!p_undname)
UnDecoratedName[UndecoratedLength - 1] = '\0'; {
return TRUE; if (!hMsvcrt) hMsvcrt = LoadLibraryW(szMsvcrt);
if (hMsvcrt) p_undname = (void*)GetProcAddress(hMsvcrt, "__unDName");
if (!p_undname) return 0;
}
if (!UnDecoratedName) return 0;
if (!p_undname(UnDecoratedName, DecoratedName, UndecoratedLength,
und_alloc, und_free, Flags))
return 0;
return strlen(UnDecoratedName);
} }
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