dbghelp: Use loader_ops for fetch_file_info.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Jacek Caban 2020-03-24 01:54:36 +01:00 committed by Alexandre Julliard
parent adecdb1d01
commit 1bbd54409a
5 changed files with 20 additions and 55 deletions

View File

@ -390,6 +390,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
@ -601,7 +602,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*
@ -612,7 +612,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;

View File

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

View File

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

View File

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

View File

@ -1431,7 +1431,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,
};