From 101820d01a1c776e4b6ff42e661ac3a1380f10c7 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 6 Jun 2019 23:44:31 +0000 Subject: [PATCH] dbghelp: Use internal flag for loading native files. Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Alexandre Julliard --- dlls/dbghelp/dbghelp_private.h | 3 --- dlls/dbghelp/module.c | 2 +- dlls/dbghelp/symbol.c | 4 ++-- programs/winedbg/info.c | 6 +++--- programs/winedbg/symbol.c | 20 ++++++++++---------- programs/winedbg/tgt_module.c | 7 +++++-- programs/winedbg/winedbg.c | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 9e76d2dd4b0..d0831024321 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -116,9 +116,6 @@ void* hash_table_iter_up(struct hash_table_iter* hti) DECLSPEC_HIDDEN; extern unsigned dbghelp_options DECLSPEC_HIDDEN; extern BOOL dbghelp_opt_native DECLSPEC_HIDDEN; -/* some more Wine extensions */ -#define SYMOPT_WINE_WITH_NATIVE_MODULES 0x40000000 - enum location_kind {loc_error, /* reg is the error code */ loc_unavailable, /* location is not available */ loc_absolute, /* offset is the location */ diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index d9d8417e843..fe8ed351081 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -832,7 +832,7 @@ BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess, for (module = pcs->lmodules; module; module = module->next) { - if (!(dbghelp_options & SYMOPT_WINE_WITH_NATIVE_MODULES) && + if (!dbghelp_opt_native && (module->type == DMT_ELF || module->type == DMT_MACHO)) continue; if (!EnumModulesCallback(module->modulename, diff --git a/dlls/dbghelp/symbol.c b/dlls/dbghelp/symbol.c index f59e322fef2..25169043b62 100644 --- a/dlls/dbghelp/symbol.c +++ b/dlls/dbghelp/symbol.c @@ -1062,7 +1062,7 @@ static BOOL sym_enum(HANDLE hProcess, ULONG64 BaseOfDll, PCWSTR Mask, } /* not found in PE modules, retry on the ELF ones */ - if (!pair.requested && (dbghelp_options & SYMOPT_WINE_WITH_NATIVE_MODULES)) + if (!pair.requested && dbghelp_opt_native) { for (pair.requested = pair.pcs->lmodules; pair.requested; pair.requested = pair.requested->next) { @@ -1393,7 +1393,7 @@ BOOL WINAPI SymFromName(HANDLE hProcess, PCSTR Name, PSYMBOL_INFO Symbol) } /* not found in PE modules, retry on the ELF ones */ - if (dbghelp_options & SYMOPT_WINE_WITH_NATIVE_MODULES) + if (dbghelp_opt_native) { for (module = pcs->lmodules; module; module = module->next) { diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index 72c57a29b48..bf5ba4f6e34 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -214,7 +214,7 @@ void info_win32_module(DWORD64 base) { struct info_modules im; UINT i, j, num_printed = 0; - DWORD opt; + BOOL opt; if (!dbg_curr_process) { @@ -228,9 +228,9 @@ void info_win32_module(DWORD64 base) /* this is a wine specific options to return also ELF modules in the * enumeration */ - SymSetOptions((opt = SymGetOptions()) | 0x40000000); + opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); SymEnumerateModules64(dbg_curr_process->handle, info_mod_cb, &im); - SymSetOptions(opt); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); qsort(im.modules, im.num_used, sizeof(im.modules[0]), module_compare); diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c index aa88ffcbc74..372ae76c33f 100644 --- a/programs/winedbg/symbol.c +++ b/programs/winedbg/symbol.c @@ -366,7 +366,7 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno, struct sgv_data sgv; int i; char buffer[512]; - DWORD opt; + BOOL opt; IMAGEHLP_STACK_FRAME ihsf; if (strlen(name) + 4 > sizeof(buffer)) @@ -394,7 +394,7 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno, /* this is a wine specific options to return also ELF modules in the * enumeration */ - SymSetOptions((opt = SymGetOptions()) | 0x40000000); + opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv); if (!sgv.num) @@ -419,7 +419,7 @@ enum sym_get_lval symbol_get_lvalue(const char* name, const int lineno, SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv); } } - SymSetOptions(opt); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); /* now grab local symbols */ if (stack_get_current_frame(&ihsf) && sgv.num < NUMDBGV) @@ -655,10 +655,10 @@ BOOL symbol_get_line(const char* filename, const char* name, /* this is a wine specific options to return also ELF modules in the * enumeration */ - SymSetOptions((opt = SymGetOptions()) | 0x40000000); + opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv)) { - SymSetOptions(opt); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); return FALSE; } @@ -668,11 +668,11 @@ BOOL symbol_get_line(const char* filename, const char* name, strcpy(&buffer[3], name); if (!SymEnumSymbols(dbg_curr_process->handle, 0, buffer, sgv_cb, (void*)&sgv)) { - SymSetOptions(opt); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); return FALSE; } } - SymSetOptions(opt); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); for (i = 0; i < sgv.num; i++) { @@ -795,7 +795,7 @@ static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx) void symbol_info(const char* str) { char buffer[512]; - DWORD opt; + BOOL opt; if (strlen(str) + 3 >= sizeof(buffer)) { @@ -808,7 +808,7 @@ void symbol_info(const char* str) /* this is a wine specific options to return also ELF modules in the * enumeration */ - SymSetOptions((opt = SymGetOptions()) | 0x40000000); + opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); SymEnumSymbols(dbg_curr_process->handle, 0, buffer, symbols_info_cb, NULL); - SymSetOptions(opt); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); } diff --git a/programs/winedbg/tgt_module.c b/programs/winedbg/tgt_module.c index 58c42826897..2fdebc94ed1 100644 --- a/programs/winedbg/tgt_module.c +++ b/programs/winedbg/tgt_module.c @@ -45,13 +45,15 @@ static BOOL tgt_process_module_write(HANDLE hProcess, void* addr, enum dbg_start tgt_module_load(const char* name, BOOL keep) { DWORD opts = SymGetOptions(); + BOOL native; HANDLE hDummy = (HANDLE)0x87654321; enum dbg_start ret = start_ok; WCHAR* nameW; unsigned len; SymSetOptions((opts & ~(SYMOPT_UNDNAME|SYMOPT_DEFERRED_LOADS)) | - SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS | 0x40000000); + SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS); + native = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); if (!dbg_init(hDummy, NULL, FALSE)) return start_error_init; len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0); @@ -76,7 +78,7 @@ enum dbg_start tgt_module_load(const char* name, BOOL keep) { dbg_printf("Non supported mode... errors may occur\n" "Use at your own risks\n"); - SymSetOptions(SymGetOptions() | 0x40000000); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); dbg_curr_process = dbg_add_process(&be_process_module_io, 1, hDummy); dbg_curr_pid = 1; dbg_curr_thread = dbg_add_thread(dbg_curr_process, 2, NULL, NULL); @@ -87,6 +89,7 @@ enum dbg_start tgt_module_load(const char* name, BOOL keep) { SymCleanup(hDummy); SymSetOptions(opts); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, native); } return ret; diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 5aeaa0d4a21..92d248c918e 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -436,7 +436,7 @@ static BOOL CALLBACK mod_loader_cb(PCSTR mod_name, DWORD64 base, PVOID ctx) BOOL dbg_get_debuggee_info(HANDLE hProcess, IMAGEHLP_MODULE64* imh_mod) { struct mod_loader_info mli; - DWORD opt; + BOOL opt; /* this will resynchronize builtin dbghelp's internal ELF module list */ SymLoadModule(hProcess, 0, 0, 0, 0, 0); @@ -447,9 +447,9 @@ BOOL dbg_get_debuggee_info(HANDLE hProcess, IMAGEHLP_MODULE64* imh_mod) /* this is a wine specific options to return also ELF modules in the * enumeration */ - SymSetOptions((opt = SymGetOptions()) | 0x40000000); + opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE); SymEnumerateModules64(hProcess, mod_loader_cb, &mli); - SymSetOptions(opt); + SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt); return imh_mod->BaseOfImage != 0; }