From ba7ee56d528f59505ad034bdde3100a3c60f1ac3 Mon Sep 17 00:00:00 2001 From: winesync Date: Fri, 11 Sep 2020 17:14:18 +0200 Subject: [PATCH] [WINESYNC] dbghelp: Use loader_ops for fetch_file_info. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard wine commit id 1bbd54409a546c26af8ac2a64f2603114d73a18c by Jacek Caban --- dll/win32/dbghelp/dbghelp_private.h | 3 +-- dll/win32/dbghelp/elf_module.c | 10 ++------ dll/win32/dbghelp/macho_module.c | 19 ++++----------- dll/win32/dbghelp/minidump.c | 36 ++++------------------------- dll/win32/dbghelp/module.c | 7 ++++++ sdk/tools/winesync/dbghelp.cfg | 2 +- 6 files changed, 21 insertions(+), 56 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index ccd488b8680..80add9ef9c9 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -421,6 +421,7 @@ struct module struct loader_ops { BOOL (*synchronize_module_list)(struct process* process); + BOOL (*fetch_file_info)(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum); }; struct process @@ -632,7 +633,6 @@ typedef BOOL (*enum_modules_cb)(const WCHAR*, unsigned long addr, void* user); /* elf_module.c */ extern BOOL elf_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; -extern BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, DWORD* size, DWORD* checksum) DECLSPEC_HIDDEN; struct image_file_map; extern BOOL elf_load_debug_info(struct module* module) DECLSPEC_HIDDEN; extern struct module* @@ -643,7 +643,6 @@ extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_th /* macho_module.c */ extern BOOL macho_enum_modules(struct process*, enum_modules_cb, void*) DECLSPEC_HIDDEN; -extern BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) DECLSPEC_HIDDEN; extern BOOL macho_load_debug_info(struct process *pcs, struct module* module) DECLSPEC_HIDDEN; extern struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 2a4b349c49b..dba4573afee 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1068,8 +1068,7 @@ BOOL elf_load_debug_info(struct module* module) * * Gathers some more information for an ELF module from a given file */ -BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, - DWORD* size, DWORD* checksum) +static BOOL elf_fetch_file_info(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) { struct image_file_map fmap; @@ -1707,6 +1706,7 @@ static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info) static const struct loader_ops elf_loader_ops = { elf_synchronize_module_list, + elf_fetch_file_info, }; /****************************************************************** @@ -1734,12 +1734,6 @@ BOOL elf_map_handle(HANDLE handle, struct image_file_map* fmap) return FALSE; } -BOOL elf_fetch_file_info(const WCHAR* name, DWORD_PTR* base, - DWORD* size, DWORD* checksum) -{ - return FALSE; -} - BOOL elf_read_wine_loader_dbg_info(struct process* pcs) { return FALSE; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 071d7bed5c5..4847a434fda 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1343,20 +1343,16 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module) * * Gathers some more information for a Mach-O module from a given file */ -BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, - DWORD* size, DWORD* checksum) +static BOOL macho_fetch_file_info(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, + DWORD* size, DWORD* checksum) { struct image_file_map fmap; - struct process *pcs; BOOL split_segs; TRACE("(%s, %p, %p, %p)\n", debugstr_w(name), base, size, checksum); - pcs = process_find_by_handle(process); - if (!pcs) return FALSE; - - split_segs = image_uses_split_segs(process, load_addr); - if (!macho_map_file(pcs, name, split_segs, &fmap)) return FALSE; + split_segs = image_uses_split_segs(process->handle, load_addr); + if (!macho_map_file(process, name, split_segs, &fmap)) return FALSE; if (base) *base = fmap.u.macho.segs_start; *size = fmap.u.macho.segs_size; *checksum = calc_crc32(fmap.u.macho.handle); @@ -1911,6 +1907,7 @@ static BOOL macho_search_loader(struct process* pcs, struct macho_info* macho_in static const struct loader_ops macho_loader_ops = { macho_synchronize_module_list, + macho_fetch_file_info, }; /****************************************************************** @@ -1934,12 +1931,6 @@ BOOL macho_read_wine_loader_dbg_info(struct process* pcs) #else /* HAVE_MACH_O_LOADER_H */ -BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, - DWORD* size, DWORD* checksum) -{ - return FALSE; -} - BOOL macho_read_wine_loader_dbg_info(struct process* pcs) { return FALSE; diff --git a/dll/win32/dbghelp/minidump.c b/dll/win32/dbghelp/minidump.c index 899a88b8d15..27e3a8708ed 100644 --- a/dll/win32/dbghelp/minidump.c +++ b/dll/win32/dbghelp/minidump.c @@ -253,9 +253,9 @@ static BOOL WINAPI fetch_pe_module_info_cb(PCWSTR name, DWORD64 base, ULONG size /****************************************************************** * fetch_elf_module_info_cb * - * Callback for accumulating in dump_context an ELF modules set + * Callback for accumulating in dump_context an host modules set */ -static BOOL fetch_elf_module_info_cb(const WCHAR* name, unsigned long base, +static BOOL fetch_host_module_info_cb(const WCHAR* name, unsigned long base, void* user) { struct dump_context* dc = user; @@ -263,33 +263,7 @@ static BOOL fetch_elf_module_info_cb(const WCHAR* name, unsigned long base, DWORD size, checksum; /* FIXME: there's no relevant timestamp on ELF modules */ - /* NB: if we have a non-null base from the live-target use it (whenever - * the ELF module is relocatable or not). If we have a null base (ELF - * module isn't relocatable) then grab its base address from ELF file - */ - if (!elf_fetch_file_info(name, &rbase, &size, &checksum)) - size = checksum = 0; - add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE); - return TRUE; -} - -/****************************************************************** - * fetch_macho_module_info_cb - * - * Callback for accumulating in dump_context a Mach-O modules set - */ -static BOOL fetch_macho_module_info_cb(const WCHAR* name, unsigned long base, - void* user) -{ - struct dump_context* dc = (struct dump_context*)user; - DWORD_PTR rbase; - DWORD size, checksum; - - /* FIXME: there's no relevant timestamp on Mach-O modules */ - /* NB: if we have a non-null base from the live-target use it. If we have - * a null base, then grab its base address from Mach-O file. - */ - if (!macho_fetch_file_info(dc->process->handle, name, base, &rbase, &size, &checksum)) + if (!dc->process->loader->fetch_file_info(dc->process, name, base, &rbase, &size, &checksum)) size = checksum = 0; add_module(dc, name, base ? base : rbase, size, 0 /* FIXME */, checksum, TRUE); return TRUE; @@ -348,8 +322,8 @@ static void fetch_modules_info(struct dump_context* dc) */ if (dc->process->dbg_hdr_addr) { - elf_enum_modules(dc->process, fetch_elf_module_info_cb, dc); - macho_enum_modules(dc->process, fetch_macho_module_info_cb, dc); + elf_enum_modules(dc->process, fetch_host_module_info_cb, dc); + macho_enum_modules(dc->process, fetch_host_module_info_cb, dc); } } diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 444eac4ad1d..7d7b101ac1c 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -1465,7 +1465,14 @@ static BOOL native_synchronize_module_list(struct process* pcs) return FALSE; } +static BOOL native_fetch_file_info(struct process* process, const WCHAR* name, ULONG_PTR load_addr, DWORD_PTR* base, + DWORD* size, DWORD* checksum) +{ + return FALSE; +} + const struct loader_ops no_loader_ops = { native_synchronize_module_list, + native_fetch_file_info, }; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 528e63fee11..44688198f3d 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: adecdb1d01487af16f5f708ae92a05ba4707187e + wine: 1bbd54409a546c26af8ac2a64f2603114d73a18c