[PATCH 11/11] [DbgHelp]: move the mach-o information into the modfmt structure

Eric Pouech eric.pouech at orange.fr
Thu Mar 18 15:32:02 CDT 2010




A+
---

 dlls/dbghelp/dbghelp_private.h |    4 ++--
 dlls/dbghelp/macho_module.c    |   42 +++++++++++++++++++++++++---------------
 2 files changed, 28 insertions(+), 18 deletions(-)


diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 5957804..5ea2e82 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -322,6 +322,7 @@ enum format_info
 {
     DFI_ELF,
     DFI_PE,
+    DFI_MACHO,
     DFI_DWARF,
     DFI_LAST
 };
@@ -339,6 +340,7 @@ struct module_format
         struct elf_module_info*         elf_info;
         struct dwarf2_module_info_s*    dwarf2_info;
         struct pe_module_info*          pe_info;
+        struct macho_module_info*	macho_info;
     } u;
 };
 
@@ -354,8 +356,6 @@ struct module
     /* specific information for debug types */
     struct module_format*       format_info[DFI_LAST];
 
-    struct macho_module_info*	macho_info;
-
     /* memory allocation pool */
     struct pool                 pool;
 
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 379596b..b5eafd0 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -655,9 +655,10 @@ static int macho_parse_symtab(struct macho_file_map* fmap,
             sc->stroff, sc->strsize, (const void**)&stab, (const void**)&stabstr))
         return 0;
 
-    if (!stabs_parse(mdi->module, mdi->module->macho_info->load_addr - fmap->segs_start,
-                       stab, sc->nsyms * sizeof(struct nlist),
-                       stabstr, sc->strsize, macho_stabs_def_cb, mdi))
+    if (!stabs_parse(mdi->module,
+                     mdi->module->format_info[DFI_MACHO]->u.macho_info->load_addr - fmap->segs_start,
+                     stab, sc->nsyms * sizeof(struct nlist),
+                     stabstr, sc->strsize, macho_stabs_def_cb, mdi))
         ret = -1;
 
     macho_unmap_ranges(fmap, sc->symoff, sc->nsyms * sizeof(struct nlist),
@@ -703,7 +704,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt
             {
             case SymTagFunction:
                 func = (struct symt_function*)sym;
-                if (func->address == module->macho_info->load_addr)
+                if (func->address == module->format_info[DFI_MACHO]->u.macho_info->load_addr)
                 {
                     TRACE("Adjusting function %p/%s!%s from 0x%08lx to 0x%08lx\n", func,
                           debugstr_w(module->module.ModuleName), sym->hash_elt.name,
@@ -720,7 +721,7 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt
                 {
                 case DataIsGlobal:
                 case DataIsFileStatic:
-                    if (data->u.var.offset == module->macho_info->load_addr)
+                    if (data->u.var.offset == module->format_info[DFI_MACHO]->u.macho_info->load_addr)
                     {
                         TRACE("Adjusting data symbol %p/%s!%s from 0x%08lx to 0x%08lx\n",
                               data, debugstr_w(module->module.ModuleName), sym->hash_elt.name,
@@ -879,7 +880,7 @@ BOOL macho_load_debug_info(struct module* module, struct macho_file_map* fmap)
 
     TRACE("(%p, %p/%d)\n", module, fmap, fmap ? fmap->fd : -1);
 
-    if (module->type != DMT_MACHO || !module->macho_info)
+    if (module->type != DMT_MACHO || !module->format_info[DFI_MACHO]->u.macho_info)
     {
         ERR("Bad Mach-O module '%s'\n", debugstr_w(module->module.LoadedImageName));
         return FALSE;
@@ -963,18 +964,26 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename,
 
     if (macho_info->flags & MACHO_INFO_MODULE)
     {
-        struct macho_module_info *macho_module_info =
-            HeapAlloc(GetProcessHeap(), 0, sizeof(struct macho_module_info));
-        if (!macho_module_info) goto leave;
+        struct macho_module_info *macho_module_info;
+        struct module_format*   modfmt =
+            HeapAlloc(GetProcessHeap(), 0, sizeof(struct module_format) + sizeof(struct macho_module_info));
+        if (!modfmt) goto leave;
         macho_info->module = module_new(pcs, filename, DMT_MACHO, FALSE, load_addr,
                                         fmap.segs_size, 0, calc_crc32(fmap.fd));
         if (!macho_info->module)
         {
-            HeapFree(GetProcessHeap(), 0, macho_module_info);
+            HeapFree(GetProcessHeap(), 0, modfmt);
             goto leave;
         }
-        macho_info->module->macho_info = macho_module_info;
-        macho_info->module->macho_info->load_addr = load_addr;
+        macho_module_info = (void*)(modfmt + 1);
+        macho_info->module->format_info[DFI_ELF] = modfmt;
+
+        modfmt->module       = macho_info->module;
+        modfmt->remove       = NULL;
+        modfmt->loc_compute  = NULL;
+        modfmt->u.macho_info = macho_module_info;
+
+        macho_module_info->load_addr = load_addr;
 
         if (dbghelp_options & SYMOPT_DEFERRED_LOADS)
             macho_info->module->module.SymType = SymDeferred;
@@ -1109,7 +1118,7 @@ static BOOL macho_search_and_load_file(struct process* pcs, const WCHAR* filenam
     if ((module = module_is_already_loaded(pcs, filename)))
     {
         macho_info->module = module;
-        module->macho_info->in_use = 1;
+        module->format_info[DFI_MACHO]->u.macho_info->in_use = 1;
         return module->module.SymType;
     }
 
@@ -1231,7 +1240,7 @@ BOOL    macho_synchronize_module_list(struct process* pcs)
     for (module = pcs->lmodules; module; module = module->next)
     {
         if (module->type == DMT_MACHO && !module->is_virtual)
-            module->macho_info->in_use = 0;
+            module->format_info[DFI_MACHO]->u.macho_info->in_use = 0;
     }
 
     ms.pcs = pcs;
@@ -1243,7 +1252,8 @@ BOOL    macho_synchronize_module_list(struct process* pcs)
     while (module)
     {
         if (module->type == DMT_MACHO && !module->is_virtual &&
-            !module->macho_info->in_use && !module->macho_info->is_loader)
+            !module->format_info[DFI_MACHO]->u.macho_info->in_use &&
+            !module->format_info[DFI_MACHO]->u.macho_info->is_loader)
         {
             module_remove(pcs, module);
             /* restart all over */
@@ -1297,7 +1307,7 @@ 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;
-    macho_info.module->macho_info->is_loader = 1;
+    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;
 }






More information about the wine-patches mailing list