Commit a89975f7 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Expose the real path to the module in SymGetModuleInfo*().

Expose the real path of a loaded module (potentially read from WINEDLLDIR or WINEBUILDDIR or overriden load order or ...). This improves gdb integration by passing the real path to the loaded modules (instead of the paths in c:\windows\ system subdirectories). Introduce new Wine only dbghelp's extended option to enable the feature. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54250Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent 70b8461b
......@@ -67,6 +67,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
unsigned dbghelp_options = SYMOPT_UNDNAME;
BOOL dbghelp_opt_native = FALSE;
BOOL dbghelp_opt_real_path = FALSE;
SYSTEM_INFO sysinfo;
static struct process* process_first /* = NULL */;
......@@ -602,6 +603,10 @@ BOOL WINAPI SymSetExtendedOption(IMAGEHLP_EXTENDED_OPTIONS option, BOOL value)
old = dbghelp_opt_native;
dbghelp_opt_native = value;
break;
case SYMOPT_EX_WINE_MODULE_REAL_PATH:
old = dbghelp_opt_real_path;
dbghelp_opt_real_path = value;
break;
default:
FIXME("Unsupported option %d with value %d\n", option, value);
}
......@@ -619,6 +624,8 @@ BOOL WINAPI SymGetExtendedOption(IMAGEHLP_EXTENDED_OPTIONS option)
{
case SYMOPT_EX_WINE_NATIVE_MODULES:
return dbghelp_opt_native;
case SYMOPT_EX_WINE_MODULE_REAL_PATH:
return dbghelp_opt_real_path;
default:
FIXME("Unsupported option %d\n", option);
}
......
......@@ -111,6 +111,7 @@ 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;
extern BOOL dbghelp_opt_real_path DECLSPEC_HIDDEN;
extern SYSTEM_INFO sysinfo DECLSPEC_HIDDEN;
/* FIXME: this could be optimized later on by using relative offsets and smaller integral sizes */
......
......@@ -1439,6 +1439,9 @@ BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr,
miw64 = module->module;
if (dbghelp_opt_real_path && module->real_path)
lstrcpynW(miw64.LoadedImageName, module->real_path, ARRAY_SIZE(miw64.LoadedImageName));
/* update debug information from container if any */
if (module->module.SymType == SymNone)
{
......
......@@ -1098,6 +1098,7 @@ typedef enum
#ifdef __WINESRC__
SYMOPT_EX_WINE_NATIVE_MODULES = 1000,
SYMOPT_EX_WINE_MODULE_REAL_PATH,
#endif
} IMAGEHLP_EXTENDED_OPTIONS;
......
......@@ -1765,7 +1765,7 @@ static BOOL CALLBACK packet_query_libraries_cb(PCSTR mod_name, DWORD64 base, PVO
static enum packet_return packet_query_libraries(struct gdb_context* gdbctx)
{
struct reply_buffer* reply = &gdbctx->qxfer_buffer;
BOOL opt;
BOOL opt_native, opt_real_path;
if (!gdbctx->process) return packet_error;
......@@ -1776,9 +1776,12 @@ static enum packet_return packet_query_libraries(struct gdb_context* gdbctx)
SymLoadModule(gdbctx->process->handle, 0, 0, 0, 0, 0);
reply_buffer_append_str(reply, "<library-list>");
opt = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
/* request also ELF modules, and also real path to loaded modules */
opt_native = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
opt_real_path = SymSetExtendedOption(SYMOPT_EX_WINE_MODULE_REAL_PATH, TRUE);
SymEnumerateModules64(gdbctx->process->handle, packet_query_libraries_cb, gdbctx);
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt);
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, opt_native);
SymSetExtendedOption(SYMOPT_EX_WINE_MODULE_REAL_PATH, opt_real_path);
reply_buffer_append_str(reply, "</library-list>");
return packet_send_buffer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment