The following series implements various bug fixes, as well as improved support for various debug info (enum types, compiland, module...).
---
Eric Pouech (11): dbghelp: fix NameLen usage in SYMBOL_INFO(W) dbghelp: fills more fields in SYMBOL_INFO in SymGetTypeFromName dbghelp: fix two internal buffer allocations dbghelp: correctly store and report bitfield information dbghelp: introducing internal type (symt_module) to match SymTagExe dbghelp: now returning the stored name for a compiland dbghelp: return the symt_module when requesting lexical parent of an UDT dbghelp: enum:s should be found by name (as UDT:s are) dbghelp: return the correct length for an enumeration dbghelp: return a lexical parent for enums (as we do for UDT:s) dbghelp: added missing break statement
dlls/dbghelp/dbghelp_private.h | 17 +++++++++-- dlls/dbghelp/dwarf.c | 2 +- dlls/dbghelp/module.c | 3 ++ dlls/dbghelp/msc.c | 8 +++--- dlls/dbghelp/stabs.c | 12 ++------ dlls/dbghelp/symbol.c | 25 ++++++++++++---- dlls/dbghelp/type.c | 52 +++++++++++++++++++++++++++------- 7 files changed, 84 insertions(+), 35 deletions(-)
SYMBOL_INFO.NameLen should be the actual length of the symbol, not the length of the (potentially truncated) string returned in SYMBOL_INFO.Name
Added an helper (symbol_setname) to set those fields properly
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 1 + dlls/dbghelp/symbol.c | 47 ++++++++++++++++++++++++++++++---------- dlls/dbghelp/type.c | 11 +-------- 3 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 3415fc1557c..035d5b2b495 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -704,6 +704,7 @@ extern WCHAR* symt_get_nameW(const struct symt* sym) DECLSPEC_HIDDEN; extern BOOL symt_get_address(const struct symt* type, ULONG64* addr) DECLSPEC_HIDDEN; extern int __cdecl symt_cmp_addr(const void* p1, const void* p2) DECLSPEC_HIDDEN; extern void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si) DECLSPEC_HIDDEN; +extern void symbol_setname(SYMBOL_INFO* si, const char* name) DECLSPEC_HIDDEN; extern struct symt_ht* symt_find_nearest(struct module* module, DWORD_PTR addr) DECLSPEC_HIDDEN; extern struct symt_compiland* diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 570e2adb8b6..3fc3438eeba 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -35,6 +35,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
+extern char * CDECL __unDName(char *buffer, const char *mangled, int len, + void * (CDECL *pfn_alloc)(size_t), void (CDECL *pfn_free)(void *), unsigned short flags); + static const WCHAR starW[] = {'*','\0'};
static inline int cmp_addr(ULONG64 a1, ULONG64 a2) @@ -561,6 +564,7 @@ static void symt_fill_sym_info(struct module_pair* pair, { const char* name; DWORD64 size; + char* tmp;
if (!symt_get_info(pair->effective, sym, TI_GET_TYPE, &sym_info->TypeIndex)) sym_info->TypeIndex = 0; @@ -697,17 +701,16 @@ static void symt_fill_sym_info(struct module_pair* pair, sym_info->Scope = 0; /* FIXME */ sym_info->Tag = sym->tag; name = symt_get_name(sym); - if (sym_info->MaxNameLen) + if (sym_info->MaxNameLen && + sym->tag == SymTagPublicSymbol && (dbghelp_options & SYMOPT_UNDNAME) && + (tmp = __unDName(NULL, name, 0, malloc, free, UNDNAME_NAME_ONLY)) != NULL) { - if (sym->tag != SymTagPublicSymbol || !(dbghelp_options & SYMOPT_UNDNAME) || - ((sym_info->NameLen = UnDecorateSymbolName(name, sym_info->Name, - sym_info->MaxNameLen, UNDNAME_NAME_ONLY)) == 0)) - { - sym_info->NameLen = min(strlen(name), sym_info->MaxNameLen - 1); - memcpy(sym_info->Name, name, sym_info->NameLen); - sym_info->Name[sym_info->NameLen] = '\0'; - } + symbol_setname(sym_info, tmp); + free(tmp); } + else + symbol_setname(sym_info, name); + TRACE_(dbghelp_symt)("%p => %s %u %s\n", sym, sym_info->Name, sym_info->Size, wine_dbgstr_longlong(sym_info->Address)); @@ -992,6 +995,29 @@ static BOOL symt_enum_locals(struct process* pcs, const WCHAR* mask, return FALSE; }
+/********************************************************** + * symbol_setname + * + * Properly sets Name and NameLen in SYMBOL_INFO + * according to MaxNameLen value + */ +void symbol_setname(SYMBOL_INFO* sym_info, const char* name) +{ + SIZE_T len = 0; + if (name) + { + sym_info->NameLen = strlen(name); + if (sym_info->MaxNameLen) + { + len = min(sym_info->NameLen, sym_info->MaxNameLen - 1); + memcpy(sym_info->Name, name, len); + } + } + else + sym_info->NameLen = 0; + sym_info->Name[len] = '\0'; +} + /****************************************************************** * copy_symbolW * @@ -1811,9 +1837,6 @@ BOOL WINAPI SymUnDName64(PIMAGEHLP_SYMBOL64 sym, PSTR UnDecName, DWORD UnDecName UNDNAME_COMPLETE) != 0; }
-extern char * CDECL __unDName(char *buffer, const char *mangled, int len, - void * (CDECL *pfn_alloc)(size_t), void (CDECL *pfn_free)(void *), unsigned short flags); - /*********************************************************************** * UnDecorateSymbolName (DBGHELP.@) */ diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 374b69aeb08..1a76ec70bbb 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -450,7 +450,6 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll, struct module_pair pair; char buffer[sizeof(SYMBOL_INFO) + 256]; SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer; - const char* tmp; struct symt* type; DWORD64 size; unsigned int i; @@ -480,15 +479,7 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll, sym_info->Register = 0; /* FIXME */ sym_info->Scope = 0; /* FIXME */ sym_info->Tag = type->tag; - tmp = symt_get_name(type); - if (tmp) - { - sym_info->NameLen = min(strlen(tmp),sym_info->MaxNameLen-1); - memcpy(sym_info->Name, tmp, sym_info->NameLen); - sym_info->Name[sym_info->NameLen] = '\0'; - } - else - sym_info->Name[sym_info->NameLen = 0] = '\0'; + symbol_setname(sym_info, symt_get_name(type)); if (!EnumSymbolsCallback(sym_info, sym_info->Size, UserContext)) break; } return TRUE;
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/type.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 1a76ec70bbb..4621c3f3638 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -914,6 +914,7 @@ BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll, { struct module_pair pair; struct symt* type; + DWORD64 size;
pair.pcs = process_find_by_handle(hProcess); if (!pair.pcs) return FALSE; @@ -921,7 +922,12 @@ BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll, if (!module_get_debug(&pair)) return FALSE; type = symt_find_type_by_name(pair.effective, SymTagNull, Name); if (!type) return FALSE; - Symbol->TypeIndex = symt_ptr2index(pair.effective, type); + Symbol->Index = Symbol->TypeIndex = symt_ptr2index(pair.effective, type); + symbol_setname(Symbol, symt_get_name(type)); + symt_get_info(pair.effective, type, TI_GET_LENGTH, &size); + Symbol->Size = size; + Symbol->ModBase = pair.requested->module.BaseOfImage; + Symbol->Tag = type->tag;
return TRUE; }
The first one is harmful (when symbol name's length is > 1000 characters), the second one is harmless (overallocation).
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/symbol.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 3fc3438eeba..8189f6a175e 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1170,8 +1170,7 @@ struct sym_enumW PSYM_ENUMERATESYMBOLS_CALLBACKW cb; void* ctx; PSYMBOL_INFOW sym_info; - char buffer[sizeof(SYMBOL_INFOW) + MAX_SYM_NAME]; - + char buffer[sizeof(SYMBOL_INFOW) + MAX_SYM_NAME * sizeof(WCHAR)]; };
static BOOL CALLBACK sym_enumW(PSYMBOL_INFO si, ULONG size, PVOID ctx) @@ -1438,7 +1437,7 @@ BOOL WINAPI SymFromNameW(HANDLE process, const WCHAR *name, SYMBOL_INFOW *symbol
TRACE("(%p, %s, %p)\n", process, debugstr_w(name), symbol);
- len = sizeof(*si) + symbol->MaxNameLen * sizeof(WCHAR); + len = sizeof(*si) + symbol->MaxNameLen; if (!(si = HeapAlloc(GetProcessHeap(), 0, len))) return FALSE;
len = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
Bitfield information must be stored relative to first byte of underlying integral type. We were storing the information always relative to the first containing byte.
So: - remove the length for an UDT element (even if we did store values for non bitfields, we didn't retrieve them...) as dbghelp rather forces to use the size from the field's type - replaced by two fields: one for bit_position, the second for bit_offset, both relative to start of underlying integral type (for bitfields). - both fields are 0 for non bitfields
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 5 +++-- dlls/dbghelp/dwarf.c | 2 +- dlls/dbghelp/msc.c | 7 +++---- dlls/dbghelp/stabs.c | 12 ++---------- dlls/dbghelp/type.c | 15 ++++++++------- 5 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 035d5b2b495..daf35fd655a 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -194,7 +194,8 @@ struct symt_data struct { LONG_PTR offset; - ULONG_PTR length; + ULONG_PTR bit_length; + ULONG_PTR bit_offset; } member; /* DataIsConstant */ VARIANT value; @@ -793,7 +794,7 @@ extern BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type, const char* name, struct symt* elt_type, unsigned offset, - unsigned size) DECLSPEC_HIDDEN; + unsigned bit_offset, unsigned bit_size) DECLSPEC_HIDDEN; extern struct symt_enum* symt_new_enum(struct module* module, const char* typename, struct symt* basetype) DECLSPEC_HIDDEN; diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index 53274c4f597..6c441d5115c 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -1422,7 +1422,7 @@ static void dwarf2_parse_udt_member(dwarf2_parse_context_t* ctx, } else bit_offset.u.uvalue = 0; symt_add_udt_element(ctx->module, parent, name.u.string, elt_type, - (loc.offset << 3) + bit_offset.u.uvalue, + loc.offset, bit_offset.u.uvalue, bit_size.u.uvalue);
if (dwarf2_get_di_children(ctx, di)) FIXME("Unsupported children\n"); diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 72b03960803..6886c613b1b 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -736,13 +736,13 @@ static void codeview_add_udt_element(struct codeview_type_parse* ctp, case LF_BITFIELD_V1: symt_add_udt_element(ctp->module, symt, name, codeview_fetch_type(ctp, cv_type->bitfield_v1.type, FALSE), - (value << 3) + cv_type->bitfield_v1.bitoff, + value, cv_type->bitfield_v1.bitoff, cv_type->bitfield_v1.nbits); return; case LF_BITFIELD_V2: symt_add_udt_element(ctp->module, symt, name, codeview_fetch_type(ctp, cv_type->bitfield_v2.type, FALSE), - (value << 3) + cv_type->bitfield_v2.bitoff, + value, cv_type->bitfield_v2.bitoff, cv_type->bitfield_v2.nbits); return; } @@ -753,8 +753,7 @@ static void codeview_add_udt_element(struct codeview_type_parse* ctp, { DWORD64 elem_size = 0; symt_get_info(ctp->module, subtype, TI_GET_LENGTH, &elem_size); - symt_add_udt_element(ctp->module, symt, name, subtype, - value << 3, (DWORD)elem_size << 3); + symt_add_udt_element(ctp->module, symt, name, subtype, value, 0, 0); } }
diff --git a/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c index 517299897c4..f51ba962186 100644 --- a/dlls/dbghelp/stabs.c +++ b/dlls/dbghelp/stabs.c @@ -615,19 +615,11 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, if (doadd && adt) { char tmp[256]; - DWORD64 size;
strcpy(tmp, "__inherited_class_"); strcat(tmp, symt_get_name(adt));
- /* FIXME: TI_GET_LENGTH will not always work, especially when adt - * has just been seen as a forward definition and not the real stuff - * yet. - * As we don't use much the size of members in structs, this may not - * be much of a problem - */ - symt_get_info(ptd->module, adt, TI_GET_LENGTH, &size); - symt_add_udt_element(ptd->module, sdt, tmp, adt, ofs, (DWORD)size * 8); + symt_add_udt_element(ptd->module, sdt, tmp, adt, ofs, 0, 0); } PTS_ABORTIF(ptd, *ptd->ptr++ != ';'); } @@ -701,7 +693,7 @@ static inline int stabs_pts_read_aggregate(struct ParseTypedefData* ptd, PTS_ABORTIF(ptd, stabs_pts_read_number(ptd, &sz) == -1); PTS_ABORTIF(ptd, *ptd->ptr++ != ';');
- if (doadd) symt_add_udt_element(ptd->module, sdt, ptd->buf + idx, adt, ofs, sz); + if (doadd) symt_add_udt_element(ptd->module, sdt, ptd->buf + idx, adt, ofs, 0, 0); break; case ':': { diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 4621c3f3638..7506d1ab574 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -261,7 +261,7 @@ BOOL symt_set_udt_size(struct module* module, struct symt_udt* udt, unsigned siz */ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type, const char* name, struct symt* elt_type, - unsigned offset, unsigned size) + unsigned offset, unsigned bit_offset, unsigned bit_size) { struct symt_data* m; struct symt** p; @@ -292,7 +292,8 @@ BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type, m->container = &udt_type->symt; m->type = elt_type; m->u.member.offset = offset; - m->u.member.length = ((offset & 7) || (size & 7)) ? size : 0; + m->u.member.bit_offset = bit_offset; + m->u.member.bit_length = bit_size; p = vector_add(&udt_type->vchildren, &module->pool); *p = &m->symt;
@@ -580,8 +581,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type, case TI_GET_BITPOSITION: if (type->tag == SymTagData && ((const struct symt_data*)type)->kind == DataIsMember && - ((const struct symt_data*)type)->u.member.length != 0) - X(DWORD) = ((const struct symt_data*)type)->u.member.offset & 7; + ((const struct symt_data*)type)->u.member.bit_length != 0) + X(DWORD) = ((const struct symt_data*)type)->u.member.bit_offset; else return FALSE; break;
@@ -657,9 +658,9 @@ BOOL symt_get_info(struct module* module, const struct symt* type, break; case SymTagData: if (((const struct symt_data*)type)->kind != DataIsMember || - !((const struct symt_data*)type)->u.member.length) + !((const struct symt_data*)type)->u.member.bit_length) return FALSE; - X(DWORD64) = ((const struct symt_data*)type)->u.member.length; + X(DWORD64) = ((const struct symt_data*)type)->u.member.bit_length; break; case SymTagArrayType: if (!symt_get_info(module, ((const struct symt_array*)type)->base_type, @@ -735,7 +736,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(ULONG) = ((const struct symt_data*)type)->u.var.offset; break; case DataIsMember: - X(ULONG) = ((const struct symt_data*)type)->u.member.offset >> 3; + X(ULONG) = ((const struct symt_data*)type)->u.member.offset; break; default: FIXME("Unknown kind (%u) for get-offset\n",
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 9 +++++++++ dlls/dbghelp/module.c | 3 +++ dlls/dbghelp/symbol.c | 13 +++++++++++++ dlls/dbghelp/type.c | 9 +++++++++ 4 files changed, 34 insertions(+)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index daf35fd655a..763d04a16a3 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -161,6 +161,12 @@ struct symt_block struct vector vchildren; /* sub-blocks & local variables */ };
+struct symt_module /* in fact any of .exe, .dll... */ +{ + struct symt symt; /* module */ + struct module* module; +}; + struct symt_compiland { struct symt symt; @@ -375,6 +381,7 @@ struct module unsigned sorttab_size; struct symt_ht** addr_sorttab; struct hash_table ht_symbols; + struct symt_module* top;
/* types */ struct hash_table ht_types; @@ -708,6 +715,8 @@ extern void copy_symbolW(SYMBOL_INFOW* siw, const SYMBOL_INFO* si) DECLS extern void symbol_setname(SYMBOL_INFO* si, const char* name) DECLSPEC_HIDDEN; extern struct symt_ht* symt_find_nearest(struct module* module, DWORD_PTR addr) DECLSPEC_HIDDEN; +extern struct symt_module* + symt_new_module(struct module* module) DECLSPEC_HIDDEN; extern struct symt_compiland* symt_new_compiland(struct module* module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN; diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 247aadcef0e..b93cbceba79 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -233,6 +233,9 @@ struct module* module_new(struct process* pcs, const WCHAR* name, module->sources = 0; wine_rb_init(&module->sources_offsets_tree, source_rb_compare);
+ /* add top level symbol */ + module->top = symt_new_module(module); + return module; }
diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 8189f6a175e..286dc17310c 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -183,6 +183,19 @@ static WCHAR* file_regex(const char* srcfile) return mask; }
+struct symt_module* symt_new_module(struct module* module) +{ + struct symt_module* sym; + + TRACE_(dbghelp_symt)("Adding toplevel exe symbol %s\n", debugstr_w(module->module.ModuleName)); + if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) + { + sym->symt.tag = SymTagExe; + sym->module = module; + } + return sym; +} + struct symt_compiland* symt_new_compiland(struct module* module, ULONG_PTR address, unsigned src_idx) { diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 7506d1ab574..10a2ff7a718 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -752,6 +752,15 @@ BOOL symt_get_info(struct module* module, const struct symt* type, break;
case TI_GET_SYMNAME: + if (type->tag == SymTagExe) + { + DWORD len = (lstrlenW(module->modulename) + 1) * sizeof(WCHAR); + WCHAR* wname = HeapAlloc(GetProcessHeap(), 0, len); + if (!wname) return FALSE; + memcpy(wname, module->modulename, len); + X(WCHAR*) = wname; + } + else { const char* name = symt_get_name(type); if (!name) return FALSE;
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 1 + dlls/dbghelp/symbol.c | 7 ++++--- dlls/dbghelp/type.c | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 763d04a16a3..0e5c1826108 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -170,6 +170,7 @@ struct symt_module /* in fact any of .exe, .dll... */ struct symt_compiland { struct symt symt; + struct symt_module* container; /* symt_module */ ULONG_PTR address; unsigned source; struct vector vchildren; /* global variables & functions */ diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 286dc17310c..9863a736299 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -205,9 +205,10 @@ struct symt_compiland* symt_new_compiland(struct module* module, debugstr_w(module->module.ModuleName), source_get(module, src_idx)); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { - sym->symt.tag = SymTagCompiland; - sym->address = address; - sym->source = src_idx; + sym->symt.tag = SymTagCompiland; + sym->container = module->top; + sym->address = address; + sym->source = src_idx; vector_init(&sym->vchildren, sizeof(struct symt*), 32); } return sym; diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 10a2ff7a718..ad88ac629df 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -91,6 +91,8 @@ const char* symt_get_name(const struct symt* sym) case SymTagEnum: return ((const struct symt_enum*)sym)->name; case SymTagTypedef: return ((const struct symt_typedef*)sym)->hash_elt.name; case SymTagUDT: return ((const struct symt_udt*)sym)->hash_elt.name; + case SymTagCompiland: return source_get(((const struct symt_compiland*)sym)->container->module, + ((const struct symt_compiland*)sym)->source); default: FIXME("Unsupported sym-tag %s\n", symt_get_tag_str(sym->tag)); /* fall through */
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/type.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index ad88ac629df..56673a7e4c4 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -708,6 +708,9 @@ BOOL symt_get_info(struct module* module, const struct symt* type, case SymTagFunctionArgType: X(DWORD) = symt_ptr2index(module, ((const struct symt_function_arg_type*)type)->container); break; + case SymTagUDT: + X(DWORD) = symt_ptr2index(module, &module->top->symt); + break; default: FIXME("Unsupported sym-tag %s for get-lexical-parent\n", symt_get_tag_str(type->tag));
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 2 +- dlls/dbghelp/type.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 0e5c1826108..2906a5df6c3 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -270,8 +270,8 @@ struct symt_basic struct symt_enum { struct symt symt; + struct hash_table_elt hash_elt; struct symt* base_type; - const char* name; struct vector vchildren; };
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 56673a7e4c4..da4fc1a0a9d 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -88,7 +88,7 @@ const char* symt_get_name(const struct symt* sym) case SymTagLabel: return ((const struct symt_hierarchy_point*)sym)->hash_elt.name; case SymTagThunk: return ((const struct symt_thunk*)sym)->hash_elt.name; /* hierarchy tree */ - case SymTagEnum: return ((const struct symt_enum*)sym)->name; + case SymTagEnum: return ((const struct symt_enum*)sym)->hash_elt.name; case SymTagTypedef: return ((const struct symt_typedef*)sym)->hash_elt.name; case SymTagUDT: return ((const struct symt_udt*)sym)->hash_elt.name; case SymTagCompiland: return source_get(((const struct symt_compiland*)sym)->container->module, @@ -307,12 +307,19 @@ struct symt_enum* symt_new_enum(struct module* module, const char* typename, { struct symt_enum* sym;
+ TRACE_(dbghelp_symt)("Adding enum %s:%s\n", + debugstr_w(module->module.ModuleName), typename); if ((sym = pool_alloc(&module->pool, sizeof(*sym)))) { sym->symt.tag = SymTagEnum; - sym->name = (typename) ? pool_strdup(&module->pool, typename) : NULL; + if (typename) + { + sym->hash_elt.name = pool_strdup(&module->pool, typename); + hash_table_add(&module->ht_types, &sym->hash_elt); + } else sym->hash_elt.name = NULL; sym->base_type = basetype; vector_init(&sym->vchildren, sizeof(struct symt*), 8); + symt_add_type(module, &sym->symt); } return sym; }
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/type.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index da4fc1a0a9d..08fa8bad95e 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -663,7 +663,8 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(DWORD64) = ((const struct symt_udt*)type)->size; break; case SymTagEnum: - X(DWORD64) = sizeof(int); /* FIXME: should be size of base-type of enum !!! */ + if (!symt_get_info(module, ((const struct symt_enum*)type)->base_type, TI_GET_LENGTH, pInfo)) + return FALSE; break; case SymTagData: if (((const struct symt_data*)type)->kind != DataIsMember ||
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/type.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 08fa8bad95e..0fa3b669467 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -717,6 +717,7 @@ BOOL symt_get_info(struct module* module, const struct symt* type, X(DWORD) = symt_ptr2index(module, ((const struct symt_function_arg_type*)type)->container); break; case SymTagUDT: + case SymTagEnum: X(DWORD) = symt_ptr2index(module, &module->top->symt); break; default:
spotted by coverity *** CID 1490841
Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/msc.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index 6886c613b1b..18535b9d151 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -1850,6 +1850,7 @@ static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg, const BYTE* roo compiland = symt_new_compiland(msc_dbg->module, 0 /* FIXME */, source_new(msc_dbg->module, NULL, sym->objname_v3.name)); + break;
case S_OBJNAME_ST: TRACE("S-ObjName-V1 %s\n", terminate_string(&sym->objname_v1.p_name));