Changeset 49053 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Oct 11, 2013 2:16:18 PM (11 years ago)
- Location:
- trunk/src/VBox/Runtime/common/dbg
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgcfg.cpp
r49044 r49053 257 257 * 258 258 * @returns true / false. 259 * @param pszPath The path buffer containing an existing directory. 260 * RTPATH_MAX in size. On success, this will contain 261 * the combined path with @a pszName case correct. 259 * @param pszPath The path buffer containing an existing directory and 260 * at @a offLastComp the name we're looking for. 261 * RTPATH_MAX in size. On success, this last component 262 * will have the correct case. On failure, the last 263 * component is stripped off. 262 264 * @param offLastComp The offset of the last component (for chopping it 263 265 * off). 264 * @param pszName What we're looking for.265 266 * @param enmType What kind of thing we're looking for. 266 267 */ 267 static bool rtDbgCfgIsXxxxAndFixCaseWorker(char *pszPath, size_t offLastComp, const char *pszName, 268 RTDIRENTRYTYPE enmType) 268 static bool rtDbgCfgIsXxxxAndFixCaseWorker(char *pszPath, size_t offLastComp, RTDIRENTRYTYPE enmType) 269 269 { 270 270 /** @todo IPRT should generalize this so we can use host specific tricks to 271 271 * speed it up. */ 272 272 273 char *pszName = &pszPath[offLastComp]; 274 273 275 /* Return straight away if the name isn't case foldable. */ 274 276 if (!RTStrIsCaseFoldable(pszName)) 277 { 278 *pszName = '\0'; 275 279 return false; 280 } 276 281 277 282 /* 278 283 * Try some simple case folding games. 279 284 */ 280 RTStrToLower( &pszPath[offLastComp]);285 RTStrToLower(pszName); 281 286 if (RTFileExists(pszPath)) 282 287 return true; 283 288 284 RTStrToUpper( &pszPath[offLastComp]);289 RTStrToUpper(pszName); 285 290 if (RTFileExists(pszPath)) 286 291 return true; … … 289 294 * Open the directory and check each entry in it. 290 295 */ 291 pszPath[offLastComp] = '\0'; 296 char chSaved = *pszName; 297 *pszName = '\0'; 298 292 299 PRTDIR pDir; 293 300 int rc = RTDirOpen(&pDir, pszPath); 294 301 if (RT_FAILURE(rc)) 295 302 return false; 303 304 *pszName = chSaved; 296 305 297 306 for (;;) … … 313 322 || u.Entry.enmType == RTDIRENTRYTYPE_SYMLINK) ) 314 323 { 315 pszPath[offLastComp] = '\0'; 316 rc = RTPathAppend(pszPath, RTPATH_MAX, u.Entry.szName); 317 if ( u.Entry.enmType != enmType 318 && RT_SUCCESS(rc)) 324 strcpy(pszName, u.Entry.szName); 325 if (u.Entry.enmType != enmType) 319 326 RTDirQueryUnknownType(pszPath, true /*fFollowSymlinks*/, &u.Entry.enmType); 320 321 if ( u.Entry.enmType == enmType 322 || RT_FAILURE(rc)) 327 if (u.Entry.enmType == enmType) 323 328 { 324 329 RTDirClose(pDir); 325 if (RT_FAILURE(rc))326 {327 pszPath[offLastComp] = '\0';328 return false;329 }330 330 return true; 331 331 } … … 334 334 335 335 RTDirClose(pDir); 336 pszPath[offLastComp]= '\0';336 *pszName = '\0'; 337 337 338 338 return false; … … 373 373 */ 374 374 if (fCaseInsensitive) 375 return rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, pszSubDir,RTDIRENTRYTYPE_DIRECTORY);375 return rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, RTDIRENTRYTYPE_DIRECTORY); 376 376 377 377 pszPath[cchPath] = '\0'; … … 390 390 * @param pszPath The path buffer containing an existing 391 391 * directory. RTPATH_MAX in size. 392 * @param pszFilename The file name to append. 392 * @param pszFilename The filename to append. 393 * @param pszSuffix Optional filename suffix to append. 393 394 * @param fCaseInsensitive Whether case insensitive searching is required. 394 395 * @param fMsCompressed Whether to look for the MS compressed file name … … 397 398 * filename variant is returned. Optional. 398 399 */ 399 static bool rtDbgCfgIsFileAndFixCase(char *pszPath, const char *pszFilename, bool fCaseInsensitive,400 static bool rtDbgCfgIsFileAndFixCase(char *pszPath, const char *pszFilename, const char *pszSuffix, bool fCaseInsensitive, 400 401 bool fMsCompressed, bool *pfProbablyCompressed) 401 402 { … … 407 408 408 409 /* 409 * Append the filename and check if we got a hit.410 * Append the filename and optionally suffix, then check if we got a hit. 410 411 */ 411 412 int rc = RTPathAppend(pszPath, RTPATH_MAX, pszFilename); 412 413 if (RT_FAILURE(rc)) 413 414 return false; 415 if (pszSuffix) 416 { 417 Assert(!fMsCompressed); 418 rc = RTStrCat(pszPath, RTPATH_MAX, pszSuffix); 419 if (RT_FAILURE(rc)) 420 return false; 421 } 414 422 415 423 if (RTFileExists(pszPath)) … … 421 429 if (fCaseInsensitive) 422 430 { 423 if (rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, pszFilename,RTDIRENTRYTYPE_FILE))431 if (rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, RTDIRENTRYTYPE_FILE)) 424 432 return true; 425 433 } … … 439 447 *pfProbablyCompressed = true; 440 448 441 if (RTFileExists(pszPath)) 449 if ( RTFileExists(pszPath) 450 || ( fCaseInsensitive 451 && rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, RTDIRENTRYTYPE_FILE) )) 442 452 return true; 443 444 if (fCaseInsensitive)445 {446 /* Note! Ugly hack here, the pszName parameter points into pszPath! */447 if (rtDbgCfgIsXxxxAndFixCaseWorker(pszPath, cchPath, RTPathFilename(pszPath), RTDIRENTRYTYPE_FILE))448 return true;449 }450 453 451 454 if (pfProbablyCompressed) … … 497 500 if (RT_SUCCESS(rc2)) 498 501 { 499 if (rtDbgCfgIsFileAndFixCase(pszPath, pSplitFn->apszComps[pSplitFn->cComps - 1], fCaseInsensitive, false, NULL)) 502 if (rtDbgCfgIsFileAndFixCase(pszPath, pSplitFn->apszComps[pSplitFn->cComps - 1], NULL /*pszSuffix*/, 503 fCaseInsensitive, false, NULL)) 500 504 { 501 505 rtDbgCfgLog1(pThis, "Trying '%s'...\n", pszPath); … … 620 624 } 621 625 622 static int rtDbgCfgTryDownloadAndOpen(PRTDBGCFGINT pThis, const char *pszServer, 623 char *pszPath, const char *pszCacheSubDir, PRTPATHSPLIT pSplitFn, 624 uint32_t fFlags, PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 626 627 static int rtDbgCfgTryDownloadAndOpen(PRTDBGCFGINT pThis, const char *pszServer, char *pszPath, 628 const char *pszCacheSubDir, const char *pszUuidMappingSubDir, 629 PRTPATHSPLIT pSplitFn, const char *pszCacheSuffix, uint32_t fFlags, 630 PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 625 631 { 626 632 #ifdef IPRT_WITH_HTTP 633 NOREF(pszUuidMappingSubDir); /** @todo do we bother trying pszUuidMappingSubDir? */ 634 NOREF(pszCacheSuffix); /** @todo do we bother trying pszUuidMappingSubDir? */ 635 627 636 if (pThis->fFlags & RTDBGCFG_FLAGS_NO_SYM_SRV) 628 637 return VWRN_NOT_FOUND; … … 725 734 RTHttpDestroy(hHttp); 726 735 727 /*728 * If we succeeded, give it a try.729 */730 736 if (RT_SUCCESS(rc)) 731 737 { 738 /* 739 * Succeeded in downloading it. Add UUID mapping? 740 */ 741 if (pszUuidMappingSubDir) 742 { 743 /** @todo UUID mapping when downloading. */ 744 } 745 746 /* 747 * Give the file a try. 748 */ 732 749 Assert(RTFileExists(pszPath)); 733 750 rtDbgCfgLog1(pThis, "Trying '%s'...\n", pszPath); … … 750 767 751 768 static int rtDbgCfgCopyFileToCache(PRTDBGCFGINT pThis, char const *pszSrc, const char *pchCache, size_t cchCache, 752 const char *pszCacheSubDir, PRTPATHSPLIT pSplitFn)769 const char *pszCacheSubDir, const char *pszUuidMappingSubDir, PRTPATHSPLIT pSplitFn) 753 770 { 754 771 if (!pszCacheSubDir || !*pszCacheSubDir) … … 760 777 761 778 762 static int rtDbgCfgTryOpenCache(PRTDBGCFGINT pThis, char *pszPath, const char *pszCacheSubDir, PRTPATHSPLIT pSplitFn, 763 uint32_t fFlags, PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 764 { 779 static int rtDbgCfgTryOpenCache(PRTDBGCFGINT pThis, char *pszPath, size_t cchCachePath, 780 const char *pszCacheSubDir, const char *pszUuidMappingSubDir, 781 PCRTPATHSPLIT pSplitFn, const char *pszCacheSuffix, uint32_t fFlags, 782 PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 783 { 784 Assert(pszPath[cchCachePath] == '\0'); 785 765 786 /* 766 787 * If the cache doesn't exist, fail right away. … … 777 798 778 799 /* 800 * If we got a UUID mapping option, try it first as we can hopefully 801 * dispense with case folding. 802 */ 803 if (pszUuidMappingSubDir) 804 { 805 int rc = RTPathAppend(pszPath, RTPATH_MAX, pszUuidMappingSubDir); 806 if ( RT_SUCCESS(rc) 807 && RTFileExists(pszPath)) 808 { 809 rtDbgCfgLog1(pThis, "Trying '%s'...\n", pszPath); 810 int rc2 = pfnCallback(pThis, pszPath, pvUser1, pvUser2); 811 if (rc2 == VINF_CALLBACK_RETURN) 812 rtDbgCfgLog1(pThis, "Found '%s'.\n", pszPath); 813 else if (rc2 == VERR_CALLBACK_RETURN) 814 rtDbgCfgLog1(pThis, "Error opening '%s'.\n", pszPath); 815 else 816 rtDbgCfgLog1(pThis, "Error %Rrc opening '%s'.\n", rc2, pszPath); 817 if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN) 818 return rc2; 819 } 820 pszPath[cchCachePath] = '\0'; 821 } 822 823 /* 779 824 * Carefully construct the cache path with case insensitivity in mind. 780 825 */ … … 790 835 791 836 bool fProbablyCompressed = false; 792 if (!rtDbgCfgIsFileAndFixCase(pszPath, pszFilename, fCaseInsensitive,837 if (!rtDbgCfgIsFileAndFixCase(pszPath, pszFilename, pszCacheSuffix, fCaseInsensitive, 793 838 RT_BOOL(fFlags & RTDBGCFG_O_MAYBE_COMPRESSED_MS), &fProbablyCompressed)) 794 839 return VWRN_NOT_FOUND; … … 813 858 814 859 static int rtDbgCfgTryOpenList(PRTDBGCFGINT pThis, PRTLISTANCHOR pList, PRTPATHSPLIT pSplitFn, const char *pszCacheSubDir, 815 uint32_t fFlags, char *pszPath, PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 860 const char *pszUuidMappingSubDir, uint32_t fFlags, char *pszPath, 861 PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 816 862 { 817 863 int rcRet = VWRN_NOT_FOUND; … … 854 900 else if (pszServer == pszDir) 855 901 continue; 902 else 856 903 { 857 904 fSearchCache = true; … … 872 919 RTPathChangeToUnixSlashes(pszPath, false); 873 920 874 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, pszCacheSubDir, pSplitFn, fFlags,875 p fnCallback, pvUser1, pvUser2);921 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, cchCache, pszCacheSubDir, pszUuidMappingSubDir, 922 pSplitFn, NULL /*pszCacheSuffix*/, fFlags, pfnCallback, pvUser1, pvUser2); 876 923 if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN) 877 924 return rc2; … … 885 932 RTPathChangeToUnixSlashes(pszPath, false); 886 933 887 rc2 = rtDbgCfgTryDownloadAndOpen(pThis, pszServer, pszPath, pszCacheSubDir, p SplitFn, fFlags,888 p fnCallback, pvUser1, pvUser2);934 rc2 = rtDbgCfgTryDownloadAndOpen(pThis, pszServer, pszPath, pszCacheSubDir, pszUuidMappingSubDir, 935 pSplitFn, NULL /*pszCacheSuffix*/, fFlags, pfnCallback, pvUser1, pvUser2); 889 936 if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN) 890 937 return rc2; … … 907 954 RTPathChangeToUnixSlashes(pszPath, false); 908 955 909 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, pszCacheSubDir, pSplitFn, fFlags,910 p fnCallback, pvUser1, pvUser2);956 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, cchCache, pszCacheSubDir, pszUuidMappingSubDir, 957 pSplitFn, NULL /*pszCacheSuffix*/, fFlags, pfnCallback, pvUser1, pvUser2); 911 958 if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN) 912 959 return rc2; … … 942 989 if ( rc2 == VINF_CALLBACK_RETURN 943 990 && cchCache > 0) 944 rtDbgCfgCopyFileToCache(pThis, pszPath, pchCache, cchCache, pszCacheSubDir, pSplitFn); 991 rtDbgCfgCopyFileToCache(pThis, pszPath, pchCache, cchCache, 992 pszCacheSubDir, pszUuidMappingSubDir, pSplitFn); 945 993 return rc2; 946 994 } … … 962 1010 * 963 1011 * @returns IPRT status code. 964 * @param hDbgCfg The debugging configuration handle. NIL_RTDBGCFG is 965 * accepted, but the result is that no paths will be 966 * searched beyond the given and the current directory. 967 * @param pszFilename The filename to search for. This may or may not 968 * include a full or partial path. 969 * @param pszCacheSubDir The cache subdirectory to look in. 970 * @param fFlags Flags and hints. 971 * @param pfnCallback The open callback routine. 972 * @param pvUser1 User parameter 1. 973 * @param pvUser2 User parameter 2. 1012 * @param hDbgCfg The debugging configuration handle. 1013 * NIL_RTDBGCFG is accepted, but the result is 1014 * that no paths will be searched beyond the 1015 * given and the current directory. 1016 * @param pszFilename The filename to search for. This may or may 1017 * not include a full or partial path. 1018 * @param pszCacheSubDir The cache subdirectory to look in. 1019 * @param pszUuidMappingSubDir UUID mapping subdirectory to check, NULL if 1020 * no mapping wanted. 1021 * @param fFlags Flags and hints. 1022 * @param pfnCallback The open callback routine. 1023 * @param pvUser1 User parameter 1. 1024 * @param pvUser2 User parameter 2. 974 1025 */ 975 1026 static int rtDbgCfgOpenWithSubDir(RTDBGCFG hDbgCfg, const char *pszFilename, const char *pszCacheSubDir, 976 uint32_t fFlags, PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 1027 const char *pszUuidMappingSubDir, uint32_t fFlags, 1028 PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 977 1029 { 978 1030 int rcRet = VINF_SUCCESS; … … 1056 1108 * Run the applicable lists. 1057 1109 */ 1058 rc2 = rtDbgCfgTryOpenList(pThis, &pThis->PathList, pSplitFn, pszCacheSubDir, fFlags, szPath,1059 p fnCallback, pvUser1, pvUser2);1110 rc2 = rtDbgCfgTryOpenList(pThis, &pThis->PathList, pSplitFn, pszCacheSubDir, 1111 pszUuidMappingSubDir, fFlags, szPath, pfnCallback, pvUser1, pvUser2); 1060 1112 if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet)) 1061 1113 rcRet = rc2; … … 1067 1119 && !(pThis->fFlags & RTDBGCFG_FLAGS_NO_SYSTEM_PATHS) ) 1068 1120 { 1069 rc2 = rtDbgCfgTryOpenList(pThis, &pThis->NtExecutablePathList, pSplitFn, pszCacheSubDir, fFlags, szPath,1070 p fnCallback, pvUser1, pvUser2);1121 rc2 = rtDbgCfgTryOpenList(pThis, &pThis->NtExecutablePathList, pSplitFn, pszCacheSubDir, 1122 pszUuidMappingSubDir, fFlags, szPath, pfnCallback, pvUser1, pvUser2); 1071 1123 if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet)) 1072 1124 rcRet = rc2; … … 1077 1129 && !(pThis->fFlags & RTDBGCFG_FLAGS_NO_SYSTEM_PATHS) ) 1078 1130 { 1079 rc2 = rtDbgCfgTryOpenList(pThis, &pThis->NtSymbolPathList, pSplitFn, pszCacheSubDir, fFlags, szPath,1080 p fnCallback, pvUser1, pvUser2);1131 rc2 = rtDbgCfgTryOpenList(pThis, &pThis->NtSymbolPathList, pSplitFn, pszCacheSubDir, 1132 pszUuidMappingSubDir, fFlags, szPath, pfnCallback, pvUser1, pvUser2); 1081 1133 if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet)) 1082 1134 rcRet = rc2; … … 1105 1157 char szSubDir[32]; 1106 1158 RTStrPrintf(szSubDir, sizeof(szSubDir), "%08X%x", uTimestamp, cbImage); 1107 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, 1159 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, NULL, 1108 1160 RT_OPSYS_WINDOWS /* approx */ | RTDBGCFG_O_SYMSRV | RTDBGCFG_O_CASE_INSENSITIVE 1109 1161 | RTDBGCFG_O_MAYBE_COMPRESSED_MS | RTDBGCFG_O_EXECUTABLE_IMAGE, … … 1134 1186 } 1135 1187 1136 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, 1188 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, NULL, 1137 1189 RT_OPSYS_WINDOWS /* approx */ | RTDBGCFG_O_SYMSRV | RTDBGCFG_O_CASE_INSENSITIVE 1138 1190 | RTDBGCFG_O_MAYBE_COMPRESSED_MS | RTDBGCFG_O_EXT_DEBUG_FILE, … … 1147 1199 char szSubDir[32]; 1148 1200 RTStrPrintf(szSubDir, sizeof(szSubDir), "%08X%x", uTimestamp, uAge); 1149 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, 1201 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, NULL, 1150 1202 RT_OPSYS_WINDOWS /* approx */ | RTDBGCFG_O_SYMSRV | RTDBGCFG_O_CASE_INSENSITIVE 1151 1203 | RTDBGCFG_O_MAYBE_COMPRESSED_MS | RTDBGCFG_O_EXT_DEBUG_FILE, … … 1159 1211 char szSubDir[32]; 1160 1212 RTStrPrintf(szSubDir, sizeof(szSubDir), "%08X%x", uTimestamp, cbImage); 1161 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, 1213 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, NULL, 1162 1214 RT_OPSYS_WINDOWS /* approx */ | RTDBGCFG_O_SYMSRV | RTDBGCFG_O_CASE_INSENSITIVE 1163 1215 | RTDBGCFG_O_MAYBE_COMPRESSED_MS | RTDBGCFG_O_EXT_DEBUG_FILE, … … 1171 1223 char szSubDir[32]; 1172 1224 RTStrPrintf(szSubDir, sizeof(szSubDir), "%08x", uCrc32); 1173 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, 1225 return rtDbgCfgOpenWithSubDir(hDbgCfg, pszFilename, szSubDir, NULL, 1174 1226 RT_OPSYS_UNKNOWN | RTDBGCFG_O_EXT_DEBUG_FILE, 1175 1227 pfnCallback, pvUser1, pvUser2); … … 1231 1283 && !rtDbgCfgIsDirAndFixCase(pszPath, "DWARF", fCaseInsensitive)) 1232 1284 { 1233 if (rtDbgCfgIsFileAndFixCase(pszPath, pSplitFn->apszComps[pSplitFn->cComps - 1], fCaseInsensitive, false, NULL)) 1285 if (rtDbgCfgIsFileAndFixCase(pszPath, pSplitFn->apszComps[pSplitFn->cComps - 1], NULL /*pszSuffix*/, 1286 fCaseInsensitive, false, NULL)) 1234 1287 { 1235 1288 rtDbgCfgLog1(pThis, "Trying '%s'...\n", pszPath); … … 1268 1321 */ 1269 1322 static int rtDbgCfgTryOpenDsumBundleInList(PRTDBGCFGINT pThis, PRTLISTANCHOR pList, PRTPATHSPLIT pSplitFn, 1270 const char *pszDsymName, const char *pszCacheSubDir, uint32_t fFlags, char *pszPath, 1323 const char *pszDsymName, const char *pszCacheSubDir, const char *pszCacheSuffix, 1324 const char *pszUuidMappingSubDir, uint32_t fFlags, char *pszPath, 1271 1325 PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 1272 1326 { … … 1310 1364 else if (pszServer == pszDir) 1311 1365 continue; 1366 else 1312 1367 { 1313 1368 fSearchCache = true; … … 1328 1383 RTPathChangeToUnixSlashes(pszPath, false); 1329 1384 1330 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, pszCacheSubDir, pSplitFn, fFlags,1331 p fnCallback, pvUser1, pvUser2);1385 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, cchCache, pszCacheSubDir, pszUuidMappingSubDir, 1386 pSplitFn, pszCacheSuffix, fFlags, pfnCallback, pvUser1, pvUser2); 1332 1387 if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN) 1333 1388 return rc2; … … 1341 1396 RTPathChangeToUnixSlashes(pszPath, false); 1342 1397 1343 rc2 = rtDbgCfgTryDownloadAndOpen(pThis, pszServer, pszPath, pszCacheSubDir, p SplitFn, fFlags,1344 p fnCallback, pvUser1, pvUser2);1398 rc2 = rtDbgCfgTryDownloadAndOpen(pThis, pszServer, pszPath, pszCacheSubDir, pszUuidMappingSubDir, 1399 pSplitFn, pszCacheSuffix, fFlags, pfnCallback, pvUser1, pvUser2); 1345 1400 if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN) 1346 1401 return rc2; … … 1363 1418 RTPathChangeToUnixSlashes(pszPath, false); 1364 1419 1365 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, pszCacheSubDir, pSplitFn, fFlags,1366 p fnCallback, pvUser1, pvUser2);1420 rcCache = rc2 = rtDbgCfgTryOpenCache(pThis, pszPath, cchCache, pszCacheSubDir, pszUuidMappingSubDir, 1421 pSplitFn, pszCacheSuffix, fFlags, pfnCallback, pvUser1, pvUser2); 1367 1422 if (rc2 == VINF_CALLBACK_RETURN || rc2 == VERR_CALLBACK_RETURN) 1368 1423 return rc2; … … 1399 1454 if ( rc2 == VINF_CALLBACK_RETURN 1400 1455 && cchCache > 0) 1401 rtDbgCfgCopyFileToCache(pThis, pszPath, pchCache, cchCache, pszCacheSubDir, pSplitFn); 1456 rtDbgCfgCopyFileToCache(pThis, pszPath, pchCache, cchCache, 1457 pszCacheSubDir, pszUuidMappingSubDir, pSplitFn); 1402 1458 return rc2; 1403 1459 } … … 1410 1466 1411 1467 return rcRet; 1468 } 1469 1470 1471 /** 1472 * Creating a UUID mapping subdirectory path for use in caches. 1473 * 1474 * @returns IPRT status code. 1475 * @param pszSubDir The output buffer. 1476 * @param cbSubDir The size of the output buffer. (Top dir length + 1477 * slash + UUID string len + extra dash.) 1478 * @param pszTopDir The top level cache directory name. No slashes 1479 * or other directory separators, please. 1480 * @param pUuid The UUID. 1481 */ 1482 static int rtDbgCfgConstructUuidMappingSubDir(char *pszSubDir, size_t cbSubDir, const char *pszTopDir, PCRTUUID pUuid) 1483 { 1484 Assert(!strpbrk(pszTopDir, ":/\\")); 1485 1486 size_t cchTopDir = strlen(pszTopDir); 1487 if (cchTopDir + 1 + 1 + RTUUID_STR_LENGTH + 1 > cbSubDir) 1488 return VERR_BUFFER_OVERFLOW; 1489 memcpy(pszSubDir, pszTopDir, cchTopDir); 1490 1491 pszSubDir += cchTopDir; 1492 *pszSubDir++ = RTPATH_SLASH; 1493 cbSubDir -= cchTopDir + 1; 1494 1495 /* ed5a8336-35c2-4892-9122-21d5572924a3 -> ED5A/8336/35C2/4892/9122/21D5572924A3 */ 1496 int rc = RTUuidToStr(pUuid, pszSubDir + 1, cbSubDir - 1); AssertRCReturn(rc, rc); 1497 RTStrToUpper(pszSubDir + 1); 1498 memmove(pszSubDir, pszSubDir + 1, 4); 1499 pszSubDir += 4; 1500 *pszSubDir = RTPATH_SLASH; 1501 pszSubDir += 5; 1502 *pszSubDir = RTPATH_SLASH; 1503 pszSubDir += 5; 1504 *pszSubDir = RTPATH_SLASH; 1505 pszSubDir += 5; 1506 *pszSubDir = RTPATH_SLASH; 1507 pszSubDir += 5; 1508 *pszSubDir = RTPATH_SLASH; 1509 1510 return VINF_SUCCESS; 1412 1511 } 1413 1512 … … 1437 1536 1438 1537 /* 1439 * Set up rtDbgCfgOpenWithSubDir parameters.1538 * Set up rtDbgCfgOpenWithSubDir and uuid map parameters. 1440 1539 */ 1441 1540 uint32_t fFlags = RTDBGCFG_O_EXT_DEBUG_FILE | RT_OPSYS_DARWIN; 1442 1541 const char *pszCacheSubDir = NULL; 1443 1542 char szCacheSubDir[RTUUID_STR_LENGTH]; 1543 const char *pszUuidMappingSubDir = NULL; 1544 char szUuidMappingSubDir[RTUUID_STR_LENGTH + 16]; 1444 1545 if (pUuid) 1445 1546 { 1547 /* Since Mac debuggers uses UUID mappings, we just the slashing default 1548 UUID string representation instead of stripping dashes like for PDB. */ 1446 1549 RTUuidToStr(pUuid, szCacheSubDir, sizeof(szCacheSubDir)); 1447 1550 pszCacheSubDir = szCacheSubDir; 1551 1552 rc2 = rtDbgCfgConstructUuidMappingSubDir(szUuidMappingSubDir, sizeof(szUuidMappingSubDir), 1553 RTDBG_CACHE_UUID_MAP_DIR_DSYMS, pUuid); 1554 AssertRCReturn(rc2, rc2); 1448 1555 } 1449 1556 … … 1466 1573 return rc2; 1467 1574 AssertReturnStmt(pSplitFn->fProps & RTPATH_PROP_FILENAME, RTPathSplitFree(pSplitFn), VERR_IS_A_DIRECTORY); 1575 1576 1577 /** @todo Extend this to look for pszFilename*.dSYM as well as detecting a 1578 * bundle and looking for a .dSYM bundle outside the image bundle. */ 1468 1579 1469 1580 /* … … 1522 1633 */ 1523 1634 rc2 = rtDbgCfgTryOpenDsumBundleInList(pThis, &pThis->PathList, pSplitFn, pszDsymName, 1524 pszCacheSubDir, fFlags, szPath, 1635 pszCacheSubDir, RTDBG_CACHE_DSYM_FILE_SUFFIX, 1636 pszUuidMappingSubDir, fFlags, szPath, 1525 1637 pfnCallback, pvUser1, pvUser2); 1526 1638 if (RT_FAILURE(rc2) && RT_SUCCESS_NP(rcRet)) -
trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp
r49044 r49053 739 739 case RTLDRFMT_MACHO: 740 740 { 741 rc = RTDbgCfgOpenDsymBundle(hDbgCfg, pDbgMod->pszImgFile, NULL /**@todo pUuid*/, 741 RTUUID Uuid; 742 PRTUUID pUuid = &Uuid; 743 rc = pDbgMod->pImgVt->pfnQueryProp(pDbgMod, RTLDRPROP_UUID, &Uuid, sizeof(Uuid)); 744 if (RT_FAILURE(rc)) 745 pUuid = NULL; 746 747 rc = RTDbgCfgOpenDsymBundle(hDbgCfg, pDbgMod->pszImgFile, pUuid, 742 748 rtDbgModExtDbgInfoOpenCallback2, pDbgMod, NULL /*pvUser2*/); 743 749 if (RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.