dbghelp: Use internal flag for loading native files.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
stable
Alistair Leslie-Hughes 2019-06-06 23:44:31 +00:00 committed by Alexandre Julliard
parent fa5e5df71d
commit 101820d01a
7 changed files with 24 additions and 24 deletions

View File

@ -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 */

View File

@ -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,

View File

@ -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)
{

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}