Signed-off-by: Eric Pouech eric.pouech@gmail.com
--- dlls/dbghelp/dbghelp_private.h | 2 ++ dlls/dbghelp/dwarf.c | 5 +---- dlls/dbghelp/module.c | 7 +++++++ dlls/dbghelp/msc.c | 5 +---- dlls/dbghelp/symbol.c | 30 ++++++------------------------ dlls/dbghelp/type.c | 20 +++----------------- 6 files changed, 20 insertions(+), 49 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 14c4336e205..fda6714c332 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -629,6 +629,8 @@ extern const WCHAR S_WineLoaderW[] DECLSPEC_HIDDEN; extern const WCHAR S_SlashW[] DECLSPEC_HIDDEN; extern const struct loader_ops no_loader_ops DECLSPEC_HIDDEN;
+extern BOOL module_init_pair(struct module_pair* pair, HANDLE hProcess, + DWORD64 addr) DECLSPEC_HIDDEN; extern struct module* module_find_by_addr(const struct process* pcs, DWORD64 addr, enum module_type type) DECLSPEC_HIDDEN; diff --git a/dlls/dbghelp/dwarf.c b/dlls/dbghelp/dwarf.c index c15b59b57c3..50f47548810 100644 --- a/dlls/dbghelp/dwarf.c +++ b/dlls/dbghelp/dwarf.c @@ -3652,10 +3652,7 @@ BOOL dwarf2_virtual_unwind(struct cpu_stack_walk *csw, ULONG_PTR ip, struct module_pair pair; struct frame_info info;
- if (!(pair.pcs = process_find_by_handle(csw->hProcess)) || - !(pair.requested = module_find_by_addr(pair.pcs, ip, DMT_UNKNOWN)) || - !module_get_debug(&pair)) - return FALSE; + if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE; if (!dwarf2_fetch_frame_info(pair.effective, csw->cpu, ip, &info)) return FALSE;
/* if at very beginning of function, return and use default unwinder */ diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 254bbb297d7..488ed1a3bd6 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -262,6 +262,13 @@ struct module* module_new(struct process* pcs, const WCHAR* name, return module; }
+BOOL module_init_pair(struct module_pair* pair, HANDLE hProcess, DWORD64 addr) +{ + if (!(pair->pcs = process_find_by_handle(hProcess))) return FALSE; + pair->requested = module_find_by_addr(pair->pcs, addr, DMT_UNKNOWN); + return module_get_debug(pair); +} + /*********************************************************************** * module_find_by_nameW * diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index c3e243879b2..bf6266af9ce 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -3200,10 +3200,7 @@ BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, char* strbase; BOOL ret = TRUE;
- if (!(pair.pcs = process_find_by_handle(csw->hProcess)) || - !(pair.requested = module_find_by_addr(pair.pcs, ip, DMT_UNKNOWN)) || - !module_get_debug(&pair)) - return FALSE; + if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE; if (!pair.effective->format_info[DFI_PDB]) return FALSE; pdb_info = pair.effective->format_info[DFI_PDB]->u.pdb_info; TRACE("searching %lx => %lx\n", ip, ip - (DWORD_PTR)pair.effective->module.BaseOfImage); diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index 991aa9bd165..f565fcf8437 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1363,10 +1363,7 @@ BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, struct module_pair pair; struct symt_ht* sym;
- pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; - pair.requested = module_find_by_addr(pair.pcs, Address, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; + if (!module_init_pair(&pair, hProcess, Address)) return FALSE; if ((sym = symt_find_nearest(pair.effective, Address)) == NULL) return FALSE;
symt_fill_sym_info(&pair, NULL, &sym->symt, Symbol); @@ -1717,10 +1714,7 @@ static BOOL get_line_from_addr(HANDLE hProcess, DWORD64 addr, struct symt_ht* symt; struct symt_function* func;
- pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; - pair.requested = module_find_by_addr(pair.pcs, addr, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; + if (!module_init_pair(&pair, hProcess, addr)) return FALSE; if ((symt = symt_find_nearest(pair.effective, addr)) == NULL) return FALSE;
if (symt->symt.tag != SymTagFunction) return FALSE; @@ -1862,10 +1856,7 @@ static BOOL symt_get_func_line_prev(HANDLE hProcess, struct internal_line_t* int struct line_info* li; struct line_info* srcli;
- pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; - pair.requested = module_find_by_addr(pair.pcs, addr, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; + if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
if (key == NULL) return FALSE;
@@ -1944,10 +1935,7 @@ static BOOL symt_get_func_line_next(HANDLE hProcess, struct internal_line_t* int struct line_info* srcli;
if (key == NULL) return FALSE; - pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; - pair.requested = module_find_by_addr(pair.pcs, addr, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; + if (!module_init_pair(&pair, hProcess, addr)) return FALSE;
/* search current source file */ for (srcli = key; !srcli->is_source_file; srcli--); @@ -2344,10 +2332,7 @@ BOOL WINAPI SymAddSymbol(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR name,
TRACE("(%p %s %s %u)\n", hProcess, wine_dbgstr_a(name), wine_dbgstr_longlong(addr), size);
- pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; - pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; + if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE;
return symt_new_custom(pair.effective, name, addr, size) != NULL; } @@ -2400,11 +2385,8 @@ BOOL WINAPI SymEnumLines(HANDLE hProcess, ULONG64 base, PCSTR compiland, if (!cb) return FALSE; if (!(dbghelp_options & SYMOPT_LOAD_LINES)) return TRUE;
- pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; + if (!module_init_pair(&pair, hProcess, base)) return FALSE; if (compiland) FIXME("Unsupported yet (filtering on compiland %s)\n", compiland); - pair.requested = module_find_by_addr(pair.pcs, base, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; if (!(srcmask = file_regex(srcfile))) return FALSE;
sci.SizeOfStruct = sizeof(sci); diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index d41e13ef79e..0891c98df85 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -483,9 +483,7 @@ BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll, hProcess, wine_dbgstr_longlong(BaseOfDll), EnumSymbolsCallback, UserContext);
- if (!(pair.pcs = process_find_by_handle(hProcess))) return FALSE; - pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; + if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE;
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO); sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO); @@ -1007,16 +1005,7 @@ BOOL WINAPI SymGetTypeInfo(HANDLE hProcess, DWORD64 ModBase, { struct module_pair pair;
- pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; - - pair.requested = module_find_by_addr(pair.pcs, ModBase, DMT_UNKNOWN); - if (!module_get_debug(&pair)) - { - FIXME("Someone didn't properly set ModBase (%s)\n", wine_dbgstr_longlong(ModBase)); - return FALSE; - } - + if (!module_init_pair(&pair, hProcess, ModBase)) return FALSE; return symt_get_info(pair.effective, symt_index2ptr(pair.effective, TypeId), GetType, pInfo); }
@@ -1031,10 +1020,7 @@ BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll, struct symt* type; DWORD64 size;
- pair.pcs = process_find_by_handle(hProcess); - if (!pair.pcs) return FALSE; - pair.requested = module_find_by_addr(pair.pcs, BaseOfDll, DMT_UNKNOWN); - if (!module_get_debug(&pair)) return FALSE; + if (!module_init_pair(&pair, hProcess, BaseOfDll)) return FALSE; type = symt_find_type_by_name(pair.effective, SymTagNull, Name); if (!type) return FALSE; Symbol->Index = Symbol->TypeIndex = symt_ptr2index(pair.effective, type);