VirtualBox

Ignore:
Timestamp:
Mar 31, 2016 9:54:27 AM (9 years ago)
Author:
vboxsync
Message:

dbgmodcodeview.cpp: CV8 string table and source info tables may come after the line numbers, so do two passes of the sstSymbols subsection to increase our chances of catching them. (Doesn't necessiarly work with /Z7 + /Gy, but works fine with /Gy-. The /Gy option enables function level linking, creating lots of small text section with associated bits of debug info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/dbg/dbgmodcodeview.cpp

    r60266 r60269  
    823823static int rtDbgModCvSsProcessV8SrcStrings(PRTDBGMODCV pThis, void const *pvSrcStrings, size_t cbSrcStrings, uint32_t fFlags)
    824824{
     825    if (pThis->cbSrcStrings)
     826        Log(("\n!!More than one source file string table for this module!!\n\n"));
     827
    825828    if (cbSrcStrings >= pThis->cbSrcStringsAlloc)
    826829    {
     
    865868static int rtDbgModCvSsProcessV8SrcInfo(PRTDBGMODCV pThis, void const *pvSrcInfo, size_t cbSrcInfo, uint32_t fFlags)
    866869{
     870    if (pThis->cbSrcInfo)
     871        Log(("\n!!More than one source file info table for this module!!\n\n"));
     872
    867873    if (cbSrcInfo + sizeof(RTCV8SRCINFO) > pThis->cbSrcInfoAlloc)
    868874    {
     
    876882    pThis->cbSrcInfo = cbSrcInfo;
    877883    Log2(("    saved %#x bytes of CV8 source file info\n", cbSrcInfo));
    878 
    879     if (LogIs3Enabled())
    880     {
    881         size_t iFile = 0;
    882         size_t off   = 0;
    883         while (off + 4 <= cbSrcInfo)
    884         {
    885             PCRTCV8SRCINFO pSrcInfo = (PCRTCV8SRCINFO)&pThis->pbSrcInfo[off];
    886             const char *pszName;
    887             if (pSrcInfo->offSourceName < pThis->cbDbgInfo)
    888                 pszName = &pThis->pchSrcStrings[pSrcInfo->offSourceName];
    889             else
    890                 pszName = "out-of-bounds.c!";
    891             if (pSrcInfo->uDigestType == RTCV8SRCINFO_DIGEST_TYPE_MD5)
    892             {
    893                 Log3(("  %010zx #%03zu: %RTuuid %#x=%s\n", off, iFile, &pSrcInfo->Digest.md5, pSrcInfo->offSourceName, pszName));
    894                 off += sizeof(*pSrcInfo);
    895             }
    896             else
    897             {
    898                 if (pSrcInfo->uDigestType == RTCV8SRCINFO_DIGEST_TYPE_NONE)
    899                     Log3(("  %010zx #%03zu: <none> %#x=%s\n", off, iFile, pSrcInfo->offSourceName, pszName));
    900                 else
    901                     Log3(("  %010zx #%03zu: !%#x! %#x=%s\n", off, iFile, pSrcInfo->uDigestType, pSrcInfo->offSourceName, pszName));
    902                 off += 8;
    903             }
    904             iFile++;
    905         }
    906     }
    907 
    908884    return VINF_SUCCESS;
    909885}
     
    996972static int rtDbgModCvSsProcessV8SymTab(PRTDBGMODCV pThis, void const *pvSymTab, size_t cbSymTab, uint32_t fFlags)
    997973{
    998     int         rc = VINF_SUCCESS;
     974    size_t const    cbSymTabSaved = cbSymTab;
     975    int             rc = VINF_SUCCESS;
     976
     977    /*
     978     * First pass looks for source information and source strings tables.
     979     * Microsoft puts the 0xf3 and 0xf4 last, usually with 0xf4 first.
     980     *
     981     * We ASSUME one string and one info table per module!
     982     */
    999983    RTCPTRUNION uCursor;
    1000984    uCursor.pv = pvSymTab;
    1001 
    1002985    for (;;)
    1003986    {
    1004987        RTDBGMODCV_CHECK_RET_BF(cbSymTab > sizeof(RTCV8SYMBOLSBLOCK), ("cbSymTab=%zu\n", cbSymTab));
    1005988        PCRTCV8SYMBOLSBLOCK pBlockHdr = (PCRTCV8SYMBOLSBLOCK)uCursor.pv;
    1006         Log3(("  %p: uType=%#04x LB %#x\n", (uint8_t *)pBlockHdr - (uint8_t *)pvSymTab, pBlockHdr->uType, pBlockHdr->cb));
     989        Log3(("  %p: pass #1 uType=%#04x LB %#x\n", (uint8_t *)pBlockHdr - (uint8_t *)pvSymTab, pBlockHdr->uType, pBlockHdr->cb));
     990        RTDBGMODCV_CHECK_RET_BF(pBlockHdr->cb <= cbSymTab - sizeof(RTCV8SYMBOLSBLOCK),
     991                                ("cb=%#u cbSymTab=%zu\n", pBlockHdr->cb, cbSymTab));
     992
     993        switch (pBlockHdr->uType)
     994        {
     995            case RTCV8SYMBLOCK_TYPE_SRC_STR:
     996                rc = rtDbgModCvSsProcessV8SrcStrings(pThis, pBlockHdr + 1, pBlockHdr->cb, fFlags);
     997                break;
     998
     999            case RTCV8SYMBLOCK_TYPE_SRC_INFO:
     1000                rc = rtDbgModCvSsProcessV8SrcInfo(pThis, pBlockHdr + 1, pBlockHdr->cb, fFlags);
     1001                break;
     1002
     1003            case RTCV8SYMBLOCK_TYPE_SECT_LINES:
     1004            case RTCV8SYMBLOCK_TYPE_SYMBOLS:
     1005                break;
     1006            default:
     1007                Log(("rtDbgModCvSsProcessV8SymTab: Unknown block type %#x (LB %#x)\n", pBlockHdr->uType, pBlockHdr->cb));
     1008                break;
     1009        }
     1010        uint32_t cbAligned = RT_ALIGN_32(sizeof(*pBlockHdr) + pBlockHdr->cb, 4);
     1011        if (RT_SUCCESS(rc) && cbSymTab > cbAligned)
     1012        {
     1013            uCursor.pu8 += cbAligned;
     1014            cbSymTab    -= cbAligned;
     1015        }
     1016        else
     1017            break;
     1018    }
     1019
     1020    /*
     1021     * Log the source info now that we've gathered both it and the strings.
     1022     */
     1023    if (LogIs3Enabled() && pThis->cbSrcInfo)
     1024    {
     1025        Log3(("    Source file info table:\n"));
     1026        size_t iFile = 0;
     1027        size_t off   = 0;
     1028        while (off + 4 <= pThis->cbSrcInfo)
     1029        {
     1030            PCRTCV8SRCINFO pSrcInfo = (PCRTCV8SRCINFO)&pThis->pbSrcInfo[off];
     1031            const char    *pszName  = pSrcInfo->offSourceName < pThis->cbSrcStrings
     1032                                    ? &pThis->pchSrcStrings[pSrcInfo->offSourceName] : "out-of-bounds.c!";
     1033            if (pSrcInfo->uDigestType == RTCV8SRCINFO_DIGEST_TYPE_MD5)
     1034                Log3(("    %010zx #%03zu: %RTuuid %#x=%s\n", off, iFile, &pSrcInfo->Digest.md5, pSrcInfo->offSourceName, pszName));
     1035            else if (pSrcInfo->uDigestType == RTCV8SRCINFO_DIGEST_TYPE_NONE)
     1036                Log3(("    %010zx #%03zu: <none> %#x=%s\n", off, iFile, pSrcInfo->offSourceName, pszName));
     1037            else
     1038                Log3(("    %010zx #%03zu: !%#x! %#x=%s\n", off, iFile, pSrcInfo->uDigestType, pSrcInfo->offSourceName, pszName));
     1039            off += pSrcInfo->uDigestType == RTCV8SRCINFO_DIGEST_TYPE_MD5 ? sizeof(*pSrcInfo) : 8;
     1040            iFile++;
     1041        }
     1042    }
     1043
     1044    /*
     1045     * Second pass, process symbols and line numbers.
     1046     */
     1047    uCursor.pv = pvSymTab;
     1048    cbSymTab = cbSymTabSaved;
     1049    for (;;)
     1050    {
     1051        RTDBGMODCV_CHECK_RET_BF(cbSymTab > sizeof(RTCV8SYMBOLSBLOCK), ("cbSymTab=%zu\n", cbSymTab));
     1052        PCRTCV8SYMBOLSBLOCK pBlockHdr = (PCRTCV8SYMBOLSBLOCK)uCursor.pv;
     1053        Log3(("  %p: pass #2 uType=%#04x LB %#x\n", (uint8_t *)pBlockHdr - (uint8_t *)pvSymTab, pBlockHdr->uType, pBlockHdr->cb));
    10071054        RTDBGMODCV_CHECK_RET_BF(pBlockHdr->cb <= cbSymTab - sizeof(RTCV8SYMBOLSBLOCK),
    10081055                                ("cb=%#u cbSymTab=%zu\n", pBlockHdr->cb, cbSymTab));
     
    10141061                break;
    10151062
    1016             case RTCV8SYMBLOCK_TYPE_SRC_STR:
    1017                 rc = rtDbgModCvSsProcessV8SrcStrings(pThis, pBlockHdr + 1, pBlockHdr->cb, fFlags);
    1018                 break;
    1019 
    10201063            case RTCV8SYMBLOCK_TYPE_SECT_LINES:
    10211064                rc = rtDbgModCvSsProcessV8SectLines(pThis, pBlockHdr + 1, pBlockHdr->cb, fFlags);
     
    10231066
    10241067            case RTCV8SYMBLOCK_TYPE_SRC_INFO:
    1025                 rc = rtDbgModCvSsProcessV8SrcInfo(pThis, pBlockHdr + 1, pBlockHdr->cb, fFlags);
     1068            case RTCV8SYMBLOCK_TYPE_SRC_STR:
    10261069                break;
    10271070            default:
Note: See TracChangeset for help on using the changeset viewer.

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