VirtualBox

Changeset 100913 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 19, 2023 11:03:51 AM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158850
Message:

IPRT: Moved the PDB cache subdir string composition to the pdbvfs and expose it via RTVFSQIEX_VOL_LABEL. Extended the RTVFSQIEX_VOL_LABEL_ALT with the compiler date/version.

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/fs/pdbvfs.cpp

    r100912 r100913  
    798798    RT_NOREF(pThis, pvInfo, cbInfo, pcbRet);
    799799
     800    ssize_t cchRet;
    800801    switch (enmInfo)
    801802    {
     803        /* This is the same as the symbol chache subdir name: */
    802804        case RTVFSQIEX_VOL_LABEL:
    803             /** @todo return the UUID + age. */
    804             return VERR_NOT_SUPPORTED;
    805 
     805            if (   pThis->enmVersion == RTFSPDBVER_2
     806                || RTUuidIsNull(&pThis->Uuid))
     807                cchRet = RTStrPrintf2((char *)pvInfo, cbInfo, "%08X%x", pThis->uTimestamp, pThis->uAge);
     808            else
     809                cchRet = RTStrPrintf2((char *)pvInfo, cbInfo, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%x",
     810                                      pThis->Uuid.Gen.u32TimeLow,
     811                                      pThis->Uuid.Gen.u16TimeMid,
     812                                      pThis->Uuid.Gen.u16TimeHiAndVersion,
     813                                      pThis->Uuid.Gen.u8ClockSeqHiAndReserved,
     814                                      pThis->Uuid.Gen.u8ClockSeqLow,
     815                                      pThis->Uuid.Gen.au8Node[0],
     816                                      pThis->Uuid.Gen.au8Node[1],
     817                                      pThis->Uuid.Gen.au8Node[2],
     818                                      pThis->Uuid.Gen.au8Node[3],
     819                                      pThis->Uuid.Gen.au8Node[4],
     820                                      pThis->Uuid.Gen.au8Node[5],
     821                                      pThis->uAge);
     822            break;
     823
     824        /* This exposes the PDB and VC versions: */
    806825        case RTVFSQIEX_VOL_LABEL_ALT:
    807             return RTStrCopy((char *)pvInfo, cbInfo, pThis->enmVersion == RTFSPDBVER_2 ? "pdb-v2" : "pdb-v7");
     826            cchRet = RTStrPrintf2((char *)pvInfo, cbInfo,
     827                                  "pdb-v%u-%u", pThis->enmVersion == RTFSPDBVER_2 ? 2 : 7, pThis->uVcDate);
     828            break;
    808829
    809830        case RTVFSQIEX_VOL_SERIAL:
    810             /** @todo return the UUID. */
    811             return VERR_NOT_SUPPORTED;
     831            if (cbInfo == sizeof(uint64_t) || cbInfo == sizeof(uint32_t))
     832            {
     833                *pcbRet = cbInfo;
     834                ((uint32_t *)pvInfo)[0] = pThis->uTimestamp;
     835                if (cbInfo == sizeof(uint64_t))
     836                    ((uint32_t *)pvInfo)[1] = pThis->uAge;
     837                return VINF_SUCCESS;
     838            }
     839            if (   pThis->enmVersion != RTFSPDBVER_2
     840                && !RTUuidIsNull(&pThis->Uuid))
     841            {
     842                *pcbRet = sizeof(RTUUID);
     843                if (cbInfo == sizeof(RTUUID))
     844                {
     845                    *(PRTUUID)pvInfo = pThis->Uuid;
     846                    return VINF_SUCCESS;
     847                }
     848            }
     849            else
     850                *pcbRet = sizeof(uint64_t);
     851            return cbInfo < *pcbRet ? VERR_BUFFER_OVERFLOW : VERR_BUFFER_UNDERFLOW;
    812852
    813853        default:
    814854            return VERR_NOT_SUPPORTED;
    815 
    816     }
     855    }
     856
     857    if (cchRet > 0)
     858    {
     859        *pcbRet = (size_t)cchRet;
     860        return VINF_SUCCESS;
     861    }
     862    *pcbRet = (size_t)-cchRet;
     863    return VERR_BUFFER_OVERFLOW;
    817864}
    818865
  • trunk/src/VBox/Runtime/tools/RTDbgSymCache.cpp

    r100911 r100913  
    755755        {
    756756            /*
    757              * Get the version.
     757             * The cache subdirectory name can be retrieved via RTVFSQIEX_VOL_LABEL,
     758             * the primary volume label.  Then we just add it to the cache.
    758759             */
    759             char szPdbVer[16];
    760             rc = RTVfsQueryLabel(hVfsPdb, true /*fAlternative*/, szPdbVer, sizeof(szPdbVer), NULL);
     760            char szSubDir[64];
     761            rc = RTVfsQueryLabel(hVfsPdb, false /*fAlternative*/, szSubDir, sizeof(szSubDir), NULL);
    761762            if (RT_SUCCESS(rc))
    762             {
    763                 /*
    764                  * Read the PDB metadata header.
    765                  */
    766                 RTVFSFILE hVfsFileHdr = NIL_RTVFSFILE;
    767                 rc = RTVfsFileOpen(hVfsPdb, "1", RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileHdr);
    768                 if (RT_SUCCESS(rc))
    769                 {
    770                     union
    771                     {
    772                         uint8_t         abHdr[128];
    773                         RTPDB70NAMES    Hdr70;
    774                         RTPDB20NAMES    Hdr20;
    775                     } uBuf = {{0}};
    776                     size_t  cbHdr      = 0;
    777                     rc = RTVfsFileRead(hVfsFileHdr, &uBuf, sizeof(uBuf), &cbHdr);
    778                     RTVfsFileRelease(hVfsFileHdr);
    779                     if (RT_SUCCESS(rc))
    780                     {
    781                         /*
    782                          * Use the header to determine the subdirectory name.
    783                          */
    784                         char szSubDir[48];
    785                         if (strcmp(szPdbVer, "pdb-v7") == 0)
    786                             RTStrPrintf(szSubDir, sizeof(szSubDir), "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%x",
    787                                         uBuf.Hdr70.Uuid.Gen.u32TimeLow,
    788                                         uBuf.Hdr70.Uuid.Gen.u16TimeMid,
    789                                         uBuf.Hdr70.Uuid.Gen.u16TimeHiAndVersion,
    790                                         uBuf.Hdr70.Uuid.Gen.u8ClockSeqHiAndReserved,
    791                                         uBuf.Hdr70.Uuid.Gen.u8ClockSeqLow,
    792                                         uBuf.Hdr70.Uuid.Gen.au8Node[0],
    793                                         uBuf.Hdr70.Uuid.Gen.au8Node[1],
    794                                         uBuf.Hdr70.Uuid.Gen.au8Node[2],
    795                                         uBuf.Hdr70.Uuid.Gen.au8Node[3],
    796                                         uBuf.Hdr70.Uuid.Gen.au8Node[4],
    797                                         uBuf.Hdr70.Uuid.Gen.au8Node[5],
    798                                         uBuf.Hdr70.uAge);
    799                         else if (strcmp(szPdbVer, "pdb-v2") == 0)
    800                             RTStrPrintf(szSubDir, sizeof(szSubDir), "%08X%x", uBuf.Hdr20.uTimestamp, uBuf.Hdr20.uAge);
    801                         else
    802                         {
    803                             szSubDir[0] = '\0';
    804                             rc = RTMsgErrorRc(VERR_VERSION_MISMATCH, "Unsupported PDB version string: %s", szPdbVer);
    805                         }
    806 
    807                         /*
    808                          * Add it to the symbol cache if that went well.
    809                          */
    810                         if (RT_SUCCESS(rc))
    811                             rc = rtDbgSymCacheAddOneFile(pszPath, pszDstName, NULL, szSubDir, NULL, NULL, pCfg);
    812                     }
    813                     else
    814                         RTMsgErrorRc(rc, "RTVfsFileRead('1',) failed on '%s': %Rrc", pszPath, rc);
    815                 }
    816                 else
    817                     RTMsgErrorRc(rc, "RTVfsFileOpen('1',) failed on '%s': %Rrc", pszPath, rc);
    818             }
     763                rc = rtDbgSymCacheAddOneFile(pszPath, pszDstName, NULL, szSubDir, NULL, NULL, pCfg);
    819764            else
    820765                RTMsgErrorRc(rc, "RTVfsQueryLabel failed on '%s': %Rrc", pszPath, rc);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette