From 3792b1add3870e6f7112884604f15d0b133f3add Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 23 Jan 2006 16:26:57 +0100 Subject: [PATCH] dbghelp: Symbol info. - better coding for SYMBOL_INFO filling - some fixes on some fields (parameters) - now using the max size for symbol info --- dlls/dbghelp/symbol.c | 26 ++++++++++++++------------ include/dbghelp.h | 2 ++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 704c8e42e0a..4fdf134fb28 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -448,13 +448,16 @@ static void symt_fill_sym_info(const struct module* module, if (!symt_get_info(sym, TI_GET_TYPE, &sym_info->TypeIndex)) sym_info->TypeIndex = 0; sym_info->info = (DWORD)sym; + sym_info->Reserved[0] = sym_info->Reserved[1] = 0; if (!symt_get_info(sym, TI_GET_LENGTH, &size) && - sym_info->TypeIndex && - !symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size)) + (!sym_info->TypeIndex || + !symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size))) size = 0; sym_info->Size = (DWORD)size; sym_info->ModBase = module->module.BaseOfImage; sym_info->Flags = 0; + sym_info->Value = 0; + switch (sym->tag) { case SymTagData: @@ -472,10 +475,9 @@ static void symt_fill_sym_info(const struct module* module, } else { - if (data->u.s.offset < 0) - sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_FRAMEREL; - else - sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_PARAMETER | SYMFLAG_FRAMEREL; + sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_REGREL; + /* FIXME: this is i386 dependent */ + if (data->u.s.offset >= 0) sym_info->Flags |= SYMFLAG_PARAMETER; /* FIXME: needed ? moreover, it's i386 dependent !!! */ sym_info->Register = CV_REG_EBP; sym_info->Address = data->u.s.offset / 8; @@ -544,7 +546,7 @@ static void symt_fill_sym_info(const struct module* module, static BOOL symt_enum_module(struct module* module, regex_t* regex, PSYM_ENUMERATESYMBOLS_CALLBACK cb, PVOID user) { - char buffer[sizeof(SYMBOL_INFO) + 256]; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer; void* ptr; struct symt_ht* sym = NULL; @@ -720,7 +722,7 @@ static BOOL symt_enum_locals(struct process* pcs, const char* mask, { struct module* module; struct symt_ht* sym; - char buffer[sizeof(SYMBOL_INFO) + 256]; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer; DWORD pc = pcs->ctx_frame.InstructionOffset; int idx; @@ -898,14 +900,14 @@ BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, BOOL WINAPI SymGetSymFromAddr(HANDLE hProcess, DWORD Address, PDWORD Displacement, PIMAGEHLP_SYMBOL Symbol) { - char buffer[sizeof(SYMBOL_INFO) + 256]; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; SYMBOL_INFO*si = (SYMBOL_INFO*)buffer; size_t len; DWORD64 Displacement64; if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE; si->SizeOfStruct = sizeof(*si); - si->MaxNameLen = 256; + si->MaxNameLen = MAX_SYM_NAME; if (!SymFromAddr(hProcess, Address, &Displacement64, si)) return FALSE; @@ -977,13 +979,13 @@ BOOL WINAPI SymFromName(HANDLE hProcess, LPSTR Name, PSYMBOL_INFO Symbol) */ BOOL WINAPI SymGetSymFromName(HANDLE hProcess, LPSTR Name, PIMAGEHLP_SYMBOL Symbol) { - char buffer[sizeof(SYMBOL_INFO) + 256]; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME]; SYMBOL_INFO*si = (SYMBOL_INFO*)buffer; size_t len; if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE; si->SizeOfStruct = sizeof(*si); - si->MaxNameLen = 256; + si->MaxNameLen = MAX_SYM_NAME; if (!SymFromName(hProcess, Name, si)) return FALSE; Symbol->Address = si->Address; diff --git a/include/dbghelp.h b/include/dbghelp.h index c70ca155791..9ef700c76cb 100644 --- a/include/dbghelp.h +++ b/include/dbghelp.h @@ -726,6 +726,8 @@ BOOL WINAPI SymUnloadModule64(HANDLE, DWORD64); #define SYMFLAG_THUNK 0x00002000 #define SYMFLAG_TLSREL 0x00004000 +#define MAX_SYM_NAME 2000 + typedef struct _SYMBOL_INFO { ULONG SizeOfStruct;