Jacek Caban : dbghelp: Use loader_ops for fetch_file_info.

Alexandre Julliard julliard at winehq.org
Tue Mar 24 15:28:16 CDT 2020


Module: wine
Branch: master
Commit: 1bbd54409a546c26af8ac2a64f2603114d73a18c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1bbd54409a546c26af8ac2a64f2603114d73a18c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Mar 24 01:54:36 2020 +0100

dbghelp: Use loader_ops for fetch_file_info.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dbghelp/dbghelp_private.h |  3 +--
 dlls/dbghelp/elf_module.c      | 10 ++--------
 dlls/dbghelp/macho_module.c    | 19 +++++--------------
 dlls/dbghelp/minidump.c        | 36 +++++-------------------------------
 dlls/dbghelp/module.c          |  7 +++++++
 5 files changed, 20 insertions(+), 55 deletions(-)

diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index ab1644265f..a9138227ea 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -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;
diff --git a/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 2a4b349c49..dba4573afe 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/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/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 071d7bed5c..4847a434fd 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/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/dlls/dbghelp/minidump.c b/dlls/dbghelp/minidump.c
index c7c8561bf7..82516bf60c 100644
--- a/dlls/dbghelp/minidump.c
+++ b/dlls/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/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index 5ff7e02905..59c0a3c56c 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -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,
 };




More information about the wine-cvs mailing list