Index: /trunk/include/iprt/dbg.h
===================================================================
--- /trunk/include/iprt/dbg.h	(revision 49060)
+++ /trunk/include/iprt/dbg.h	(revision 49061)
@@ -461,4 +461,6 @@
 RTDECL(int) RTDbgCfgOpenDsymBundle(RTDBGCFG hDbgCfg, const char *pszFilename, PCRTUUID pUuid,
                                    PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
+RTDECL(int) RTDbgCfgOpenMachOImage(RTDBGCFG hDbgCfg, const char *pszFilename, PCRTUUID pUuid,
+                                   PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
 
 
Index: /trunk/include/iprt/mangling.h
===================================================================
--- /trunk/include/iprt/mangling.h	(revision 49060)
+++ /trunk/include/iprt/mangling.h	(revision 49061)
@@ -380,4 +380,5 @@
 # define RTDbgCfgOpenDbg                                RT_MANGLER(RTDbgCfgOpenDbg)
 # define RTDbgCfgOpenDsymBundle                         RT_MANGLER(RTDbgCfgOpenDsymBundle)
+# define RTDbgCfgOpenMachOImage                         RT_MANGLER(RTDbgCfgOpenMachOImage)
 # define RTDbgCfgOpenDwo                                RT_MANGLER(RTDbgCfgOpenDwo)
 # define RTDbgCfgOpenPdb70                              RT_MANGLER(RTDbgCfgOpenPdb70)
Index: /trunk/src/VBox/Debugger/DBGPlugInDarwin.cpp
===================================================================
--- /trunk/src/VBox/Debugger/DBGPlugInDarwin.cpp	(revision 49060)
+++ /trunk/src/VBox/Debugger/DBGPlugInDarwin.cpp	(revision 49061)
@@ -272,5 +272,5 @@
                     return VERR_INVALID_NAME;
                 if (!strcmp(uLCmd.pSeg32->segname, "__LINKEDIT"))
-                    continue; /* This usually is discarded or not loaded at all. */
+                    break; /* This usually is discarded or not loaded at all. */
                 if (cSegs >= RT_ELEMENTS(aSegs))
                     return VERR_BUFFER_OVERFLOW;
@@ -291,5 +291,5 @@
                     return VERR_INVALID_NAME;
                 if (!strcmp(uLCmd.pSeg64->segname, "__LINKEDIT"))
-                    continue; /* This usually is discarded or not loaded at all. */
+                    break; /* This usually is discarded or not loaded at all. */
                 if (cSegs >= RT_ELEMENTS(aSegs))
                     return VERR_BUFFER_OVERFLOW;
@@ -388,8 +388,22 @@
         uint64_t uRvaNext = 0;
         uint32_t cLinked  = 0;
-        for (iSeg = 0; iSeg < cSegs; iSeg++)
+        iSeg = cSegs;
+        while (iSeg-- > 0) /* HACK: Map in reverse order to avoid replacing __TEXT. */
             if (aSegs[iSeg].cb)
             {
-                int rc2 = RTDbgAsModuleLinkSeg(hAs, hMod, iSeg, aSegs[iSeg].Address, RTDBGASLINK_FLAGS_REPLACE /*fFlags*/);
+                /* Find matching segment in the debug module. */
+                uint32_t iDbgSeg = 0;
+                while (iDbgSeg < cSegs)
+                {
+                    RTDBGSEGMENT SegInfo;
+                    int rc3 = RTDbgModSegmentByIndex(hMod, iDbgSeg, &SegInfo);
+                    if (RT_SUCCESS(rc3) && !strcmp(SegInfo.szName, aSegs[iSeg].szName))
+                        break;
+                    iDbgSeg++;
+                }
+                AssertMsgStmt(iDbgSeg < cSegs, ("%s\n", aSegs[iSeg].szName), continue);
+
+                /* Map it. */
+                int rc2 = RTDbgAsModuleLinkSeg(hAs, hMod, iDbgSeg, aSegs[iSeg].Address, RTDBGASLINK_FLAGS_REPLACE /*fFlags*/);
                 if (RT_SUCCESS(rc2))
                     cLinked++;
Index: /trunk/src/VBox/Runtime/common/dbg/dbgcfg.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/dbg/dbgcfg.cpp	(revision 49060)
+++ /trunk/src/VBox/Runtime/common/dbg/dbgcfg.cpp	(revision 49061)
@@ -184,4 +184,64 @@
 
 
+/** Interesting bundle suffixes. */
+static const char * const g_apszBundleSuffixes[] =
+{
+    ".kext",
+    ".app",
+    ".framework",
+    ".component",
+    ".action",
+    ".caction",
+    ".bundle",
+    ".sourcebundle",
+    ".menu",
+    ".plugin",
+    ".ppp",
+    ".monitorpanel",
+    ".scripting",
+    ".prefPane",
+    ".qlgenerator",
+    ".brailledriver",
+    ".saver",
+    ".SpeechVoice",
+    ".SpeechRecognizer",
+    ".SpeechSynthesizer",
+    ".mdimporter",
+    ".spreporter",
+    ".xpc",
+    NULL
+};
+
+/** Debug bundle suffixes. (Same as above + .dSYM) */
+static const char * const g_apszDSymBundleSuffixes[] =
+{
+    ".dSYM",
+    ".kext.dSYM",
+    ".app.dSYM",
+    ".framework.dSYM",
+    ".component.dSYM",
+    ".action.dSYM",
+    ".caction.dSYM",
+    ".bundle.dSYM",
+    ".sourcebundle.dSYM",
+    ".menu.dSYM",
+    ".plugin.dSYM",
+    ".ppp.dSYM",
+    ".monitorpanel.dSYM",
+    ".scripting.dSYM",
+    ".prefPane.dSYM",
+    ".qlgenerator.dSYM",
+    ".brailledriver.dSYM",
+    ".saver.dSYM",
+    ".SpeechVoice.dSYM",
+    ".SpeechRecognizer.dSYM",
+    ".SpeechSynthesizer.dSYM",
+    ".mdimporter.dSYM",
+    ".spreporter.dSYM",
+    ".xpc.dSYM",
+    NULL
+};
+
+
 
 /**
@@ -374,4 +434,50 @@
     if (fCaseInsensitive)
         return rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, RTDIRENTRYTYPE_DIRECTORY);
+
+    pszPath[cchPath] = '\0';
+    return false;
+}
+
+
+/**
+ * Appends @a pszSubDir1 and @a pszSuffix to @a pszPath and check whether it
+ * exists and is a directory.
+ *
+ * If @a fCaseInsensitive is set, we will do a case insensitive search for a
+ * matching sub directory.
+ *
+ * @returns true / false
+ * @param   pszPath             The path buffer containing an existing
+ *                              directory.  RTPATH_MAX in size.
+ * @param   pszSubDir           The sub directory to append.
+ * @param   fCaseInsensitive    Whether case insensitive searching is required.
+ */
+static bool rtDbgCfgIsDirAndFixCase2(char *pszPath, const char *pszSubDir, const char *pszSuffix, bool fCaseInsensitive)
+{
+    Assert(!strpbrk(pszSuffix, ":/\\"));
+
+    /* Save the length of the input path so we can restore it in the case
+       insensitive branch further down. */
+    size_t const cchPath = strlen(pszPath);
+
+    /*
+     * Append the subdirectory and suffix, then check if we got a hit.
+     */
+    int rc = RTPathAppend(pszPath, RTPATH_MAX, pszSubDir);
+    if (RT_SUCCESS(rc))
+    {
+        rc = RTStrCat(pszPath, RTPATH_MAX, pszSuffix);
+        if (RT_SUCCESS(rc))
+        {
+            if (RTDirExists(pszPath))
+                return true;
+
+            /*
+             * Do case insensitive lookup if requested.
+             */
+            if (fCaseInsensitive)
+                return rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, RTDIRENTRYTYPE_DIRECTORY);
+        }
+    }
 
     pszPath[cchPath] = '\0';
@@ -1251,6 +1357,7 @@
  * Very similar to rtDbgCfgTryOpenDir.
  */
-static int rtDbgCfgTryOpenDsymBundleInDir(PRTDBGCFGINT pThis, char *pszPath, PRTPATHSPLIT pSplitFn, const char *pszDsymName,
-                                          uint32_t fFlags, PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
+static int rtDbgCfgTryOpenDsymBundleInDir(PRTDBGCFGINT pThis, char *pszPath, PRTPATHSPLIT pSplitFn,
+                                          const char * const *papszSuffixes, uint32_t fFlags,
+                                          PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
 {
     int rcRet = VWRN_NOT_FOUND;
@@ -1278,5 +1385,7 @@
     /*
      * Look for the file with less and less of the original path given.
-     */
+     * Also try out typical bundle extension variations.
+     */
+    const char *pszName = pSplitFn->apszComps[pSplitFn->cComps - 1];
     for (unsigned i = RTPATH_PROP_HAS_ROOT_SPEC(pSplitFn->fProps); i < pSplitFn->cComps; i++)
     {
@@ -1287,26 +1396,31 @@
             if (!rtDbgCfgIsDirAndFixCase(pszPath, pSplitFn->apszComps[i], fCaseInsensitive))
                 rc2 = VERR_FILE_NOT_FOUND;
-        if (    RT_SUCCESS(rc2)
-            && !rtDbgCfgIsDirAndFixCase(pszPath, pszDsymName, fCaseInsensitive)
-            && !rtDbgCfgIsDirAndFixCase(pszPath, "Contents", fCaseInsensitive)
-            && !rtDbgCfgIsDirAndFixCase(pszPath, "Resources", fCaseInsensitive)
-            && !rtDbgCfgIsDirAndFixCase(pszPath, "DWARF", fCaseInsensitive))
-        {
-            if (rtDbgCfgIsFileAndFixCase(pszPath, pSplitFn->apszComps[pSplitFn->cComps - 1], NULL /*pszSuffix*/,
-                                         fCaseInsensitive, false, NULL))
+        if (RT_SUCCESS(rc2))
+        {
+            size_t cchCurPath = cchPath + strlen(&pszPath[cchPath]);
+            for (uint32_t iSuffix = 0; papszSuffixes[iSuffix]; iSuffix++)
             {
-                rtDbgCfgLog1(pThis, "Trying '%s'...\n", pszPath);
-                rc2 = pfnCallback(pThis, pszPath, pvUser1, pvUser2);
-                if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN)
+                if (   !rtDbgCfgIsDirAndFixCase2(pszPath, pszName, papszSuffixes[iSuffix], fCaseInsensitive)
+                    && !rtDbgCfgIsDirAndFixCase(pszPath, "Contents", fCaseInsensitive)
+                    && !rtDbgCfgIsDirAndFixCase(pszPath, "Resources", fCaseInsensitive)
+                    && !rtDbgCfgIsDirAndFixCase(pszPath, "DWARF", fCaseInsensitive))
                 {
-                    if (rc2 == VINF_CALLBACK_RETURN)
-                        rtDbgCfgLog1(pThis, "Found '%s'.\n", pszPath);
-                    else
-                        rtDbgCfgLog1(pThis, "Error opening '%s'.\n", pszPath);
-                    return rc2;
+                    if (rtDbgCfgIsFileAndFixCase(pszPath, pszName, NULL /*pszSuffix*/, fCaseInsensitive, false, NULL))
+                    {
+                        rtDbgCfgLog1(pThis, "Trying '%s'...\n", pszPath);
+                        rc2 = pfnCallback(pThis, pszPath, pvUser1, pvUser2);
+                        if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN)
+                        {
+                            if (rc2 == VINF_CALLBACK_RETURN)
+                                rtDbgCfgLog1(pThis, "Found '%s'.\n", pszPath);
+                            else
+                                rtDbgCfgLog1(pThis, "Error opening '%s'.\n", pszPath);
+                            return rc2;
+                        }
+                        rtDbgCfgLog1(pThis, "Error %Rrc opening '%s'.\n", rc2, pszPath);
+                        if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet))
+                            rcRet = rc2;
+                    }
                 }
-                rtDbgCfgLog1(pThis, "Error %Rrc opening '%s'.\n", rc2, pszPath);
-                if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet))
-                    rcRet = rc2;
             }
         }
@@ -1330,8 +1444,9 @@
  * Very similar to rtDbgCfgTryOpenList.
  */
-static int rtDbgCfgTryOpenDsumBundleInList(PRTDBGCFGINT pThis, PRTLISTANCHOR pList, PRTPATHSPLIT pSplitFn,
-                                           const char *pszDsymName, const char *pszCacheSubDir, const char *pszCacheSuffix,
-                                           const char *pszUuidMappingSubDir, uint32_t fFlags, char *pszPath,
-                                           PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
+static int rtDbgCfgTryOpenBundleInList(PRTDBGCFGINT pThis, PRTLISTANCHOR pList, PRTPATHSPLIT pSplitFn,
+                                       const char * const *papszSuffixes, const char *pszCacheSubDir,
+                                       const char *pszCacheSuffix, const char *pszUuidMappingSubDir,
+                                       uint32_t fFlags, char *pszPath,
+                                       PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
 {
     int rcRet = VWRN_NOT_FOUND;
@@ -1459,5 +1574,5 @@
             RTPathChangeToUnixSlashes(pszPath, false);
 
-            rc2 = rtDbgCfgTryOpenDsymBundleInDir(pThis, pszPath, pSplitFn, pszDsymName, fFlagsDir,
+            rc2 = rtDbgCfgTryOpenDsymBundleInDir(pThis, pszPath, pSplitFn, papszSuffixes, fFlagsDir,
                                                  pfnCallback, pvUser1, pvUser2);
             if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN)
@@ -1523,12 +1638,15 @@
 
 
-RTDECL(int) RTDbgCfgOpenDsymBundle(RTDBGCFG hDbgCfg, const char *pszImage, PCRTUUID pUuid,
-                                   PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
+static int rtDbgCfgOpenBundleFile(RTDBGCFG hDbgCfg, const char *pszImage, const char * const *papszSuffixes,
+                                  const char *pszBundleSubDir, PCRTUUID pUuid, const char *pszUuidMapDirName,
+                                  const char *pszCacheSuffix, bool fOpenImage,
+                                  PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
 {
     /*
      * Bundles are directories, means we can forget about sharing code much
      * with the other RTDbgCfgOpenXXX methods.  Thus we're duplicating a lot of
-     * code from rtDbgCfgOpenWithSubDir with .dSYM related adjustments, so, a bug
-     * found here or there probably means the other version needs updating.
+     * code from rtDbgCfgOpenWithSubDir with .dSYM/.kext/.dylib/.app/.* related
+     * adjustments, so, a bug found here or there probably means the other
+     * version needs updating.
      */
     int rcRet = VINF_SUCCESS;
@@ -1561,6 +1679,5 @@
         pszCacheSubDir = szCacheSubDir;
 
-        rc2 = rtDbgCfgConstructUuidMappingSubDir(szUuidMappingSubDir, sizeof(szUuidMappingSubDir),
-                                                 RTDBG_CACHE_UUID_MAP_DIR_DSYMS, pUuid);
+        rc2 = rtDbgCfgConstructUuidMappingSubDir(szUuidMappingSubDir, sizeof(szUuidMappingSubDir), pszUuidMapDirName, pUuid);
         AssertRCReturn(rc2, rc2);
     }
@@ -1585,8 +1702,4 @@
     AssertReturnStmt(pSplitFn->fProps & RTPATH_PROP_FILENAME, RTPathSplitFree(pSplitFn), VERR_IS_A_DIRECTORY);
 
-
-/** @todo Extend this to look for pszFilename*.dSYM as well as detecting a
- *        bundle and looking for a .dSYM bundle outside the image bundle. */
-
     /*
      * Try the image directory first.
@@ -1596,10 +1709,13 @@
     {
         rc2 = RTPathSplitReassemble(pSplitFn, RTPATH_STR_F_STYLE_HOST, szPath, sizeof(szPath));
-        if (RT_SUCCESS(rc2))
-            rc2 = RTStrCat(szPath, sizeof(szPath),
-                           ".dSYM" RTPATH_SLASH_STR "Contents" RTPATH_SLASH_STR "Resources" RTPATH_SLASH_STR "DWARF");
-        if (RT_SUCCESS(rc2))
-            rc2 = RTPathAppend(szPath, sizeof(szPath), pSplitFn->apszComps[pSplitFn->cComps - 1]);
-        if (RT_SUCCESS(rc2))
+        if (fOpenImage && RT_SUCCESS(rc2))
+        {
+            rc2 = RTStrCat(szPath, sizeof(szPath), papszSuffixes[0]);
+            if (RT_SUCCESS(rc2))
+                rc2 = RTStrCat(szPath, sizeof(szPath), pszBundleSubDir);
+            if (RT_SUCCESS(rc2))
+                rc2 = RTPathAppend(szPath, sizeof(szPath), pSplitFn->apszComps[pSplitFn->cComps - 1]);
+        }
+        if (RT_SUCCESS(rc2) && RTPathExists(szPath))
         {
             RTPathChangeToUnixSlashes(szPath, false);
@@ -1617,7 +1733,4 @@
         && rc2 != VERR_CALLBACK_RETURN)
     {
-        char *pszDsymName = (char *)alloca(strlen(pSplitFn->apszComps[pSplitFn->cComps - 1]) + sizeof(".dSYM"));
-        strcat(strcpy(pszDsymName, pSplitFn->apszComps[pSplitFn->cComps - 1]), ".dSYM");
-
         /*
          * Try the current directory (will take cover relative paths
@@ -1629,5 +1742,6 @@
         RTPathChangeToUnixSlashes(szPath, false);
 
-        rc2 = rtDbgCfgTryOpenDsymBundleInDir(pThis, szPath, pSplitFn, pszDsymName, fFlags, pfnCallback, pvUser1, pvUser2);
+        rc2 = rtDbgCfgTryOpenDsymBundleInDir(pThis, szPath, pSplitFn, g_apszDSymBundleSuffixes,
+                                             fFlags, pfnCallback, pvUser1, pvUser2);
         if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet))
             rcRet = rc2;
@@ -1643,8 +1757,8 @@
                  * Run the applicable lists.
                  */
-                rc2 = rtDbgCfgTryOpenDsumBundleInList(pThis, &pThis->PathList, pSplitFn, pszDsymName,
-                                                      pszCacheSubDir, RTDBG_CACHE_DSYM_FILE_SUFFIX,
-                                                      pszUuidMappingSubDir, fFlags, szPath,
-                                                      pfnCallback, pvUser1, pvUser2);
+                rc2 = rtDbgCfgTryOpenBundleInList(pThis, &pThis->PathList, pSplitFn, g_apszDSymBundleSuffixes,
+                                                  pszCacheSubDir, pszCacheSuffix,
+                                                  pszUuidMappingSubDir, fFlags, szPath,
+                                                  pfnCallback, pvUser1, pvUser2);
                 if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet))
                     rcRet = rc2;
@@ -1664,4 +1778,24 @@
         rcRet = VERR_NOT_FOUND;
     return rcRet;
+}
+
+
+RTDECL(int) RTDbgCfgOpenDsymBundle(RTDBGCFG hDbgCfg, const char *pszImage, PCRTUUID pUuid,
+                                   PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
+{
+    return rtDbgCfgOpenBundleFile(hDbgCfg, pszImage, g_apszDSymBundleSuffixes,
+                                  "Contents" RTPATH_SLASH_STR "Resources" RTPATH_SLASH_STR "DWARF",
+                                  pUuid, RTDBG_CACHE_UUID_MAP_DIR_DSYMS, RTDBG_CACHE_DSYM_FILE_SUFFIX, false /* fOpenImage */,
+                                  pfnCallback, pvUser1, pvUser2);
+}
+
+
+RTDECL(int) RTDbgCfgOpenMachOImage(RTDBGCFG hDbgCfg, const char *pszImage, PCRTUUID pUuid,
+                                   PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2)
+{
+    return rtDbgCfgOpenBundleFile(hDbgCfg, pszImage, g_apszBundleSuffixes,
+                                  "Contents" RTPATH_SLASH_STR "MacOS",
+                                  pUuid, RTDBG_CACHE_UUID_MAP_DIR_IMAGES, NULL /*pszCacheSuffix*/, true /* fOpenImage */,
+                                  pfnCallback, pvUser1, pvUser2);
 }
 
Index: /trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp	(revision 49060)
+++ /trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp	(revision 49061)
@@ -1188,23 +1188,28 @@
  */
 
+
+/**
+ * Argument package used when opening Mach-O images and .dSYMs files.
+ */
+typedef struct RTDBGMODMACHOARGS
+{
+    /** For use more internal use in file locator callbacks. */
+    RTLDRARCH           enmArch;
+    /** For use more internal use in file locator callbacks. */
+    PCRTUUID            pUuid;
+    /** For use more internal use in file locator callbacks. */
+    bool                fOpenImage;
+} RTDBGMODMACHOARGS;
+/** Pointer to a const segment package. */
+typedef RTDBGMODMACHOARGS const *PCRTDBGMODMACHOARGS;
+
+
+
 /** @callback_method_impl{FNRTDBGCFGOPEN} */
 static DECLCALLBACK(int)
-rtDbgModFromMachOImageOpenMachOCallback(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2)
-{
-    PRTDBGMODINT        pDbgMod   = (PRTDBGMODINT)pvUser1;
-    PCRTDBGDWARFSEGPKG  pSegPkg   = (PCRTDBGDWARFSEGPKG)pvUser2;
-
-    /** @todo  */
-
-    return VERR_OPEN_FAILED;
-}
-
-
-/** @callback_method_impl{FNRTDBGCFGOPEN} */
-static DECLCALLBACK(int)
-rtDbgModFromMachOImageOpenDsymCallback(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2)
-{
-    PRTDBGMODINT        pDbgMod   = (PRTDBGMODINT)pvUser1;
-    PCRTDBGDWARFSEGPKG  pSegPkg   = (PCRTDBGDWARFSEGPKG)pvUser2;
+rtDbgModFromMachOImageOpenDsymMachOCallback(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2)
+{
+    PRTDBGMODINT        pDbgMod = (PRTDBGMODINT)pvUser1;
+    PCRTDBGMODMACHOARGS pArgs   = (PCRTDBGMODMACHOARGS)pvUser2;
 
     Assert(!pDbgMod->pDbgVt);
@@ -1236,5 +1241,5 @@
             pDbgMod->pImgVt    = pImg->pVt;
             pDbgMod->pvImgPriv = NULL;
-            rc = pImg->pVt->pfnTryOpen(pDbgMod, pSegPkg->enmArch);
+            rc = pImg->pVt->pfnTryOpen(pDbgMod, pArgs->enmArch);
             if (RT_SUCCESS(rc))
                 break;
@@ -1248,5 +1253,5 @@
              * Check the UUID if one was given.
              */
-            if (pSegPkg->pUuid)
+            if (pArgs->pUuid)
             {
                 RTUUID UuidOpened;
@@ -1254,5 +1259,5 @@
                 if (RT_SUCCESS(rc))
                 {
-                    if (RTUuidCompare(&UuidOpened, pSegPkg->pUuid) != 0)
+                    if (RTUuidCompare(&UuidOpened, pArgs->pUuid) != 0)
                         rc = VERR_DBG_FILE_MISMATCH;
                 }
@@ -1267,8 +1272,10 @@
                 for (PRTDBGMODREGDBG pDbg = g_pDbgHead; pDbg; pDbg = pDbg->pNext)
                 {
-                    if (pDbg->pVt->fSupports & RT_DBGTYPE_DWARF)
+                    if (   pArgs->fOpenImage
+                        || (pDbg->pVt->fSupports & RT_DBGTYPE_DWARF) )
+
                     {
                         pDbgMod->pDbgVt    = pDbg->pVt;
-                        pDbgMod->pvDbgPriv = pSegPkg->cSegs ? (void *)pSegPkg : NULL;
+                        pDbgMod->pvDbgPriv = NULL;
                         rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod));
                         if (RT_SUCCESS(rc))
@@ -1286,4 +1293,21 @@
                     }
                 }
+
+                /*
+                 * Likely fallback for when opening image.
+                 */
+                if (pArgs->fOpenImage)
+                {
+                    rc = rtDbgModCreateForExports(pDbgMod);
+                    if (RT_SUCCESS(rc))
+                    {
+                        /*
+                         * Done.
+                         */
+                        RTSemRWReleaseRead(g_hDbgModRWSem);
+                        RTStrCacheRelease(g_hDbgModStrCache, pszImgFileOrg);
+                        return VINF_CALLBACK_RETURN;
+                    }
+                }
             }
 
@@ -1307,9 +1331,8 @@
                                         uint32_t cSegs, PCRTDBGSEGMENT paSegs, PCRTUUID pUuid, RTDBGCFG hDbgCfg)
 {
-    RTDBGDWARFSEGPKG SegPkg;
-    SegPkg.cSegs    = cSegs;
-    SegPkg.paSegs   = paSegs;
-    SegPkg.enmArch  = enmArch;
-    SegPkg.pUuid    = pUuid && RTUuidIsNull(pUuid) ? pUuid : NULL;
+    RTDBGMODMACHOARGS Args;
+    Args.enmArch    = enmArch;
+    Args.pUuid      = pUuid && RTUuidIsNull(pUuid) ? pUuid : NULL;
+    Args.fOpenImage = false;
 
     /*
@@ -1317,5 +1340,5 @@
      */
     int rc = RTDbgCfgOpenDsymBundle(hDbgCfg, pDbgMod->pszImgFile, pUuid,
-                                    rtDbgModFromMachOImageOpenDsymCallback, pDbgMod, &SegPkg);
+                                    rtDbgModFromMachOImageOpenDsymMachOCallback, pDbgMod, &Args);
     if (RT_FAILURE(rc))
     {
@@ -1323,6 +1346,7 @@
          * If we cannot get at the .dSYM, try the executable image.
          */
-        //rc = RTDbgCfgOpenMachOImage(hDbgCfg, pDbgMod->pszImgFile, pUuid,
-        //                            rtDbgModFromMachOImageOpenMachOCallback, pDbgMod, &SegPkg);
+        Args.fOpenImage = true;
+        rc = RTDbgCfgOpenMachOImage(hDbgCfg, pDbgMod->pszImgFile, pUuid,
+                                    rtDbgModFromMachOImageOpenDsymMachOCallback, pDbgMod, &Args);
     }
     return rc;
@@ -1398,4 +1422,5 @@
                  */
                 if (   !(fDbgCfg & RTDBGCFG_FLAGS_DEFERRED)
+                    || cSegs /* for the time being. */
                     || (!cbImage && !cSegs)
                     || (fFlags & RTDBGMOD_F_NOT_DEFERRED) )
@@ -1406,16 +1431,6 @@
                      * Procrastinate.  Need image size atm.
                      */
-                    uint32_t uRvaMax = cbImage;
-                    if (!uRvaMax)
-                        for (uint32_t iSeg = 0; iSeg < cSegs; iSeg++)
-                        {
-                            if (   paSegs[iSeg].uRva > uRvaMax
-                                && paSegs[iSeg].uRva - uRvaMax < _1M)
-                                uRvaMax = paSegs[iSeg].uRva;
-                            uRvaMax += paSegs[iSeg].cb;
-                        }
-
                     PRTDBGMODDEFERRED pDeferred;
-                    rc = rtDbgModDeferredCreate(pDbgMod, rtDbgModFromMachOImageDeferredCallback, uRvaMax, hDbgCfg,
+                    rc = rtDbgModDeferredCreate(pDbgMod, rtDbgModFromMachOImageDeferredCallback, cbImage, hDbgCfg,
                                                 RT_OFFSETOF(RTDBGMODDEFERRED, u.MachO.aSegs[cSegs]),
                                                 &pDeferred);
@@ -1426,21 +1441,5 @@
                         pDeferred->u.MachO.cSegs   = cSegs;
                         if (cSegs)
-                        {
                             memcpy(&pDeferred->u.MachO.aSegs, paSegs, cSegs * sizeof(paSegs[0]));
-                            if (!cbImage)
-                            {
-                                /* If we calculated a cbImage above, do corresponding RVA adjustments. */
-                                uRvaMax = 0;
-                                for (uint32_t iSeg = 0; iSeg < cSegs; iSeg++)
-                                {
-                                    if (   paSegs[iSeg].uRva > uRvaMax
-                                        && paSegs[iSeg].uRva - uRvaMax < _1M)
-                                        uRvaMax = paSegs[iSeg].uRva;
-                                    else
-                                        pDeferred->u.MachO.aSegs[iSeg].uRva = uRvaMax;
-                                    uRvaMax += paSegs[iSeg].cb;
-                                }
-                            }
-                        }
                     }
                 }
Index: /trunk/src/VBox/Runtime/include/internal/dbgmod.h
===================================================================
--- /trunk/src/VBox/Runtime/include/internal/dbgmod.h	(revision 49060)
+++ /trunk/src/VBox/Runtime/include/internal/dbgmod.h	(revision 49061)
@@ -641,25 +641,4 @@
 
 
-/**
- * Special segment package used passing segment order information for mach-o
- * images (mainly mach_kernel, really).
- *
- * Passes to rtDbgModDwarf_TryOpen via RTDBGMODINF::pvDbgPriv.
- */
-typedef struct RTDBGDWARFSEGPKG
-{
-    /** Pointer to the segment array. */
-    PCRTDBGSEGMENT      paSegs;
-    /** Number of segments. */
-    uint32_t            cSegs;
-    /** For use more internal use in file locator callbacks. */
-    RTLDRARCH           enmArch;
-    /** For use more internal use in file locator callbacks. */
-    PCRTUUID            pUuid;
-} RTDBGDWARFSEGPKG;
-/** Pointer to a const segment package. */
-typedef RTDBGDWARFSEGPKG const *PCRTDBGDWARFSEGPKG;
-
-
 extern DECLHIDDEN(RTSTRCACHE)           g_hDbgModStrCache;
 extern DECLHIDDEN(RTDBGMODVTDBG const)  g_rtDbgModVtDbgCodeView;
