https://git.reactos.org/?p=reactos.git;a=commitdiff;h=031700a760b278628e820…
commit 031700a760b278628e8200a0e4ef12be5596e14b
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Fri Sep 11 17:10:42 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Wed Sep 16 10:35:48 2020 +0200
[WINESYNC] dbghelp: Introduce loader_ops to abstract platform-specific loader and use
it to synchronize module list.
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id fec0157585e9d8bd03a8a71d1ed9b9d7ca59cb56 by Jacek Caban
<jacek(a)codeweavers.com>
---
dll/win32/dbghelp/dbghelp.c | 4 ++--
dll/win32/dbghelp/dbghelp_private.h | 9 +++++++--
dll/win32/dbghelp/elf_module.c | 18 ++++++++++--------
dll/win32/dbghelp/macho_module.c | 18 ++++++++++--------
dll/win32/dbghelp/module.c | 31 ++++++++++++-------------------
sdk/tools/winesync/dbghelp.cfg | 2 +-
6 files changed, 42 insertions(+), 40 deletions(-)
diff --git a/dll/win32/dbghelp/dbghelp.c b/dll/win32/dbghelp/dbghelp.c
index da1649b80a9..6e03cc3d385 100644
--- a/dll/win32/dbghelp/dbghelp.c
+++ b/dll/win32/dbghelp/dbghelp.c
@@ -352,6 +352,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath,
BOOL fInvadeP
pcs->handle = hProcess;
pcs->is_64bit = (sizeof(void *) == 8 || wow64) && !child_wow64;
+ pcs->loader = &no_loader_ops; /* platform-specific initialization will
override it if loader debug info can be found */
if (UserSearchPath)
{
@@ -398,8 +399,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath,
BOOL fInvadeP
{
if (fInvadeProcess)
EnumerateLoadedModulesW64(hProcess, process_invade_cb, hProcess);
- elf_synchronize_module_list(pcs);
- macho_synchronize_module_list(pcs);
+ pcs->loader->synchronize_module_list(pcs);
}
else if (fInvadeProcess)
{
diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h
index 7c164fce219..ccd488b8680 100644
--- a/dll/win32/dbghelp/dbghelp_private.h
+++ b/dll/win32/dbghelp/dbghelp_private.h
@@ -418,10 +418,16 @@ struct module
struct wine_rb_tree sources_offsets_tree;
};
+struct loader_ops
+{
+ BOOL (*synchronize_module_list)(struct process* process);
+};
+
struct process
{
struct process* next;
HANDLE handle;
+ const struct loader_ops* loader;
WCHAR* search_path;
PSYMBOL_REGISTERED_CALLBACK64 reg_cb;
@@ -632,7 +638,6 @@ extern BOOL elf_load_debug_info(struct module* module)
DECLSPEC_HIDDEN;
extern struct module*
elf_load_module(struct process* pcs, const WCHAR* name, unsigned
long) DECLSPEC_HIDDEN;
extern BOOL elf_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN;
-extern BOOL elf_synchronize_module_list(struct process* pcs) DECLSPEC_HIDDEN;
struct elf_thunk_area;
extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_thunk_area*
thunks) DECLSPEC_HIDDEN;
@@ -643,7 +648,6 @@ extern BOOL macho_load_debug_info(struct process *pcs, struct
module* mo
extern struct module*
macho_load_module(struct process* pcs, const WCHAR* name, unsigned
long) DECLSPEC_HIDDEN;
extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs)
DECLSPEC_HIDDEN;
-extern BOOL macho_synchronize_module_list(struct process* pcs) DECLSPEC_HIDDEN;
/* minidump.c */
void minidump_add_memory_block(struct dump_context* dc, ULONG64 base, ULONG size, ULONG
rva) DECLSPEC_HIDDEN;
@@ -652,6 +656,7 @@ void minidump_add_memory_block(struct dump_context* dc, ULONG64 base,
ULONG size
extern const WCHAR S_ElfW[] DECLSPEC_HIDDEN;
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 struct module*
module_find_by_addr(const struct process* pcs, DWORD64 addr,
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c
index 1c7a77650b1..2a4b349c49b 100644
--- a/dll/win32/dbghelp/elf_module.c
+++ b/dll/win32/dbghelp/elf_module.c
@@ -1623,7 +1623,7 @@ struct module* elf_load_module(struct process* pcs, const WCHAR*
name, unsigned
* - if a module is in debuggee and not in pcs, it's loaded into pcs
* - if a module is in pcs and not in debuggee, it's unloaded from pcs
*/
-BOOL elf_synchronize_module_list(struct process* pcs)
+static BOOL elf_synchronize_module_list(struct process* pcs)
{
struct module* module;
struct elf_load el;
@@ -1704,6 +1704,11 @@ static BOOL elf_search_loader(struct process* pcs, struct elf_info*
elf_info)
return ret;
}
+static const struct loader_ops elf_loader_ops =
+{
+ elf_synchronize_module_list,
+};
+
/******************************************************************
* elf_read_wine_loader_dbg_info
*
@@ -1714,10 +1719,12 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs)
struct elf_info elf_info;
elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE;
- if (!elf_search_loader(pcs, &elf_info)) return FALSE;
+ if (!elf_search_loader(pcs, &elf_info) || !elf_info.dbg_hdr_addr) return FALSE;
elf_info.module->format_info[DFI_ELF]->u.elf_info->elf_loader = 1;
module_set_module(elf_info.module, S_WineLoaderW);
- return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0;
+ pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr;
+ pcs->loader = &elf_loader_ops;
+ return TRUE;
}
#else /* !__ELF__ */
@@ -1727,11 +1734,6 @@ BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap)
return FALSE;
}
-BOOL elf_synchronize_module_list(struct process* pcs)
-{
- return FALSE;
-}
-
BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base,
DWORD* size, DWORD* checksum)
{
diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c
index 93135c71e79..071d7bed5c5 100644
--- a/dll/win32/dbghelp/macho_module.c
+++ b/dll/win32/dbghelp/macho_module.c
@@ -1694,7 +1694,7 @@ static BOOL macho_enum_sync_cb(const WCHAR* name, unsigned long
addr, void* user
* - if a module is in debuggee and not in pcs, it's loaded into pcs
* - if a module is in pcs and not in debuggee, it's unloaded from pcs
*/
-BOOL macho_synchronize_module_list(struct process* pcs)
+static BOOL macho_synchronize_module_list(struct process* pcs)
{
struct module* module;
struct macho_sync ms;
@@ -1908,6 +1908,11 @@ static BOOL macho_search_loader(struct process* pcs, struct
macho_info* macho_in
return ret;
}
+static const struct loader_ops macho_loader_ops =
+{
+ macho_synchronize_module_list,
+};
+
/******************************************************************
* macho_read_wine_loader_dbg_info
*
@@ -1919,19 +1924,16 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs)
TRACE("(%p/%p)\n", pcs, pcs->handle);
macho_info.flags = MACHO_INFO_DEBUG_HEADER | MACHO_INFO_MODULE;
- if (!macho_search_loader(pcs, &macho_info)) return FALSE;
+ if (!macho_search_loader(pcs, &macho_info) || !macho_info.dbg_hdr_addr) return
FALSE;
macho_info.module->format_info[DFI_MACHO]->u.macho_info->is_loader = 1;
module_set_module(macho_info.module, S_WineLoaderW);
- return (pcs->dbg_hdr_addr = macho_info.dbg_hdr_addr) != 0;
+ pcs->dbg_hdr_addr = macho_info.dbg_hdr_addr;
+ pcs->loader = &macho_loader_ops;
+ return TRUE;
}
#else /* HAVE_MACH_O_LOADER_H */
-BOOL macho_synchronize_module_list(struct process* pcs)
-{
- return FALSE;
-}
-
BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr,
DWORD_PTR* base,
DWORD* size, DWORD* checksum)
{
diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c
index c04224f9532..444eac4ad1d 100644
--- a/dll/win32/dbghelp/module.c
+++ b/dll/win32/dbghelp/module.c
@@ -548,17 +548,6 @@ enum module_type module_get_type_by_name(const WCHAR* name)
return DMT_PE;
}
-/******************************************************************
- * refresh_module_list
- */
-#ifndef DBGHELP_STATIC_LIB
-static BOOL refresh_module_list(struct process* pcs)
-{
- /* force transparent ELF and Mach-O loading / unloading */
- return elf_synchronize_module_list(pcs) || macho_synchronize_module_list(pcs);
-}
-#endif
-
static BOOL image_check_debug_link(const WCHAR* file, struct image_file_map* fmap, DWORD
link_crc)
{
DWORD read_bytes;
@@ -906,9 +895,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR
wImageNam
if (Flags & ~(SLMFLAG_VIRTUAL))
FIXME("Unsupported Flags %08x for %s\n", Flags,
debugstr_w(wImageName));
-#ifndef DBGHELP_STATIC_LIB
- refresh_module_list(pcs);
-#endif
+ pcs->loader->synchronize_module_list(pcs);
/* this is a Wine extension to the API just to redo the synchronisation */
if (!wImageName && !hFile) return 0;
@@ -1447,11 +1434,7 @@ BOOL WINAPI SymRefreshModuleList(HANDLE hProcess)
if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
-#ifndef DBGHELP_STATIC_LIB
- return refresh_module_list(pcs);
-#else
- return TRUE;
-#endif
+ return pcs->loader->synchronize_module_list(pcs);
}
/***********************************************************************
@@ -1476,3 +1459,13 @@ PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64
AddrBase)
return dbghelp_current_cpu->find_runtime_function(module, AddrBase);
}
+
+static BOOL native_synchronize_module_list(struct process* pcs)
+{
+ return FALSE;
+}
+
+const struct loader_ops no_loader_ops =
+{
+ native_synchronize_module_list,
+};
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index 7e3c49cd25b..59039add5d6 100644
--- a/sdk/tools/winesync/dbghelp.cfg
+++ b/sdk/tools/winesync/dbghelp.cfg
@@ -4,4 +4,4 @@ files:
include/dbghelp.h: sdk/include/psdk/dbghelp.h
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
tags:
- wine: f30fdd1822462326d3339a21b838d28b623e6486
+ wine: fec0157585e9d8bd03a8a71d1ed9b9d7ca59cb56