VirtualBox

Changeset 88956 in vbox


Ignore:
Timestamp:
May 9, 2021 1:09:47 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144292
Message:

VBoxTpG,VBoxDD.d: Better warning diagnostic messages. Fixed warnings in VBoxDD.d

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/build/VBoxDD.d

    r88944 r88956  
    1818provider vboxdd
    1919{
    20     probe hgcmcall__enter(void *pvCmd, unsigned int idFunction, unsigned int idClient, unsigned int cbCmd);
     20    probe hgcmcall__enter(void *pvCmd, uint32_t idFunction, uint32_t idClient, uint32_t cbCmd);
    2121    probe hgcmcall__completed__req(void *pvCmd, int rc);
    2222    probe hgcmcall__completed__emt(void *pvCmd, int rc);
    23     probe hgcmcall__completed__done(void *pvCmd, unsigned int idFunction, unsigned int idClient, int rc);
     23    probe hgcmcall__completed__done(void *pvCmd, uint32_t idFunction, uint32_t idClient, int rc);
    2424
    2525    probe ahci__req__submit(void *pvReq, int iTxDir, uint64_t offStart, uint64_t cbXfer);
  • trunk/src/bldprogs/VBoxTpG.cpp

    r82968 r88956  
    4545*   Structures and Typedefs                                                                                                      *
    4646*********************************************************************************************************************************/
     47typedef struct VTGPROBE *PVTGPROBE;
    4748
    4849typedef struct VTGATTRS
     
    6970    /** The type flags. */
    7071    uint32_t        fType;
     72    /** The argument number (0-based) for complaining/whatever. */
     73    uint16_t        iArgNo;
     74    /** The probe the argument belongs to (for complaining/whatever). */
     75    PVTGPROBE       pProbe;
     76    /** The absolute source position. */
     77    size_t          offSrc;
    7178} VTGARG;
    7279typedef VTGARG *PVTGARG;
     
    8289    uint32_t        offArgList;
    8390    uint32_t        iProbe;
     91    size_t          iLine;
    8492} VTGPROBE;
    85 typedef VTGPROBE *PVTGPROBE;
    8693
    8794typedef struct VTGPROVIDER
     
    12941301 *
    12951302 * @returns RTEXITCODE_FAILURE.
    1296  * @param   pStrm               The stream.
    1297  * @param   cb                  The offset from the current position to the
    1298  *                              point of failure.
    1299  * @param   pszMsg              The message to display.
    1300  */
    1301 static RTEXITCODE parseError(PSCMSTREAM pStrm, size_t cb, const char *pszMsg)
    1302 {
    1303     if (cb)
    1304         ScmStreamSeekRelative(pStrm, -(ssize_t)cb);
     1303 * @param   pStrm       The stream.
     1304 * @param   fAbs        Absolute or relative offset.
     1305 * @param   offSeek     When @a fAbs is @c false, the offset from the current
     1306 *                      position to the point of failure.  When @a fAbs is @c
     1307 *                      true, it's the absolute position.
     1308 * @param   pszFormat   The message format string.
     1309 * @param   va          Format arguments.
     1310 */
     1311static RTEXITCODE parseErrorExV(PSCMSTREAM pStrm, bool fAbs, size_t offSeek, const char *pszFormat, va_list va)
     1312{
     1313    if (fAbs)
     1314        ScmStreamSeekAbsolute(pStrm, offSeek);
     1315    else if (offSeek != 0)
     1316        ScmStreamSeekRelative(pStrm, -(ssize_t)offSeek);
    13051317    size_t const off     = ScmStreamTell(pStrm);
    13061318    size_t const iLine   = ScmStreamTellLine(pStrm);
     
    13081320    size_t const offLine = ScmStreamTell(pStrm);
    13091321
    1310     RTPrintf("%s:%d:%zd: error: %s.\n", g_pszScript, iLine + 1, off - offLine + 1, pszMsg);
     1322    va_list va2;
     1323    va_copy(va2, va);
     1324    RTPrintf("%s:%d:%zd: error: %N.\n", g_pszScript, iLine + 1, off - offLine + 1, pszFormat, &va2);
     1325    va_end(va2);
    13111326
    13121327    size_t cchLine;
     
    13251340 *
    13261341 * @returns RTEXITCODE_FAILURE.
    1327  * @param   pStrm               The stream.
    1328  * @param   cb                  The offset from the current position to the
    1329  *                              point of failure.
    1330  * @param   pszMsg              The message to display.
    1331  */
    1332 static RTEXITCODE parseErrorAbs(PSCMSTREAM pStrm, size_t off, const char *pszMsg)
    1333 {
    1334     ScmStreamSeekAbsolute(pStrm, off);
    1335     return parseError(pStrm, 0, pszMsg);
     1342 * @param   pStrm       The stream.
     1343 * @param   off         The offset from the current position to the point of
     1344 *                      failure.
     1345 * @param   pszFormat   The message format string.
     1346 * @param   ...         Format arguments.
     1347 */
     1348static RTEXITCODE parseError(PSCMSTREAM pStrm, size_t off, const char *pszFormat, ...)
     1349{
     1350    va_list va;
     1351    va_start(va, pszFormat);
     1352    RTEXITCODE rcExit = parseErrorExV(pStrm, false, off, pszFormat, va);
     1353    va_end(va);
     1354    return rcExit;
     1355}
     1356
     1357
     1358/**
     1359 * Parser error with line and position, absolute version.
     1360 *
     1361 * @returns RTEXITCODE_FAILURE.
     1362 * @param   pStrm       The stream.
     1363 * @param   off         The offset from the current position to the point of
     1364 *                      failure.
     1365 * @param   pszFormat   The message format string.
     1366 * @param   ...         Format arguments.
     1367 */
     1368static RTEXITCODE parseErrorAbs(PSCMSTREAM pStrm, size_t off, const char *pszFormat, ...)
     1369{
     1370    va_list va;
     1371    va_start(va, pszFormat);
     1372    RTEXITCODE rcExit = parseErrorExV(pStrm, true /*fAbs*/, off, pszFormat, va);
     1373    va_end(va);
     1374    return rcExit;
     1375}
     1376
     1377
     1378/**
     1379 * Parser warning with line and position.
     1380 *
     1381 * @param   pStrm       The stream.
     1382 * @param   fAbs        Absolute or relative offset.
     1383 * @param   offSeek     When @a fAbs is @c false, the offset from the current
     1384 *                      position to the point of failure.  When @a fAbs is @c
     1385 *                      true, it's the absolute position.
     1386 * @param   pszFormat   The message format string.
     1387 * @param   va          Format arguments.
     1388 */
     1389static void parseWarnExV(PSCMSTREAM pStrm, bool fAbs, size_t offSeek, const char *pszFormat, va_list va)
     1390{
     1391    /* Save the stream position. */
     1392    size_t const offOrg = ScmStreamTell(pStrm);
     1393
     1394    if (fAbs)
     1395        ScmStreamSeekAbsolute(pStrm, offSeek);
     1396    else if (offSeek != 0)
     1397        ScmStreamSeekRelative(pStrm, -(ssize_t)offSeek);
     1398    size_t const off     = ScmStreamTell(pStrm);
     1399    size_t const iLine   = ScmStreamTellLine(pStrm);
     1400    ScmStreamSeekByLine(pStrm, iLine);
     1401    size_t const offLine = ScmStreamTell(pStrm);
     1402
     1403    va_list va2;
     1404    va_copy(va2, va);
     1405    RTPrintf("%s:%d:%zd: warning: %N.\n", g_pszScript, iLine + 1, off - offLine + 1, pszFormat, &va2);
     1406    va_end(va2);
     1407
     1408    size_t cchLine;
     1409    SCMEOL enmEof;
     1410    const char *pszLine = ScmStreamGetLineByNo(pStrm, iLine, &cchLine, &enmEof);
     1411    if (pszLine)
     1412        RTPrintf("  %.*s\n"
     1413                 "  %*s^\n",
     1414                 cchLine, pszLine, off - offLine, "");
     1415
     1416    /* restore the position. */
     1417    int rc = ScmStreamSeekAbsolute(pStrm, offOrg);
     1418    AssertRC(rc);
     1419}
     1420
     1421#if 0 /* unused */
     1422/**
     1423 * Parser warning with line and position.
     1424 *
     1425 * @param   pStrm       The stream.
     1426 * @param   off         The offset from the current position to the point of
     1427 *                      failure.
     1428 * @param   pszFormat   The message format string.
     1429 * @param   ...         Format arguments.
     1430 */
     1431static void parseWarn(PSCMSTREAM pStrm, size_t off, const char *pszFormat, ...)
     1432{
     1433    va_list va;
     1434    va_start(va, pszFormat);
     1435    parseWarnExV(pStrm, false, off, pszFormat, va);
     1436    va_end(va);
     1437}
     1438#endif /* unused */
     1439
     1440/**
     1441 * Parser warning with line and position, absolute version.
     1442 *
     1443 * @param   pStrm       The stream.
     1444 * @param   off         The offset from the current position to the point of
     1445 *                      failure.
     1446 * @param   pszFormat   The message format string.
     1447 * @param   ...         Format arguments.
     1448 */
     1449static void parseWarnAbs(PSCMSTREAM pStrm, size_t off, const char *pszFormat, ...)
     1450{
     1451    va_list va;
     1452    va_start(va, pszFormat);
     1453    parseWarnExV(pStrm, true /*fAbs*/, off, pszFormat, va);
     1454    va_end(va);
    13361455}
    13371456
     
    17051824 * @return  Type flags.
    17061825 * @param   pszType         The type expression.
    1707  */
    1708 static uint32_t parseTypeExpression(const char *pszType)
     1826 * @param   pStrm           The input stream (for errors + warnings).
     1827 * @param   offSrc          The absolute source position of this expression (for
     1828 *                          warnings).
     1829 */
     1830static uint32_t parseTypeExpression(const char *pszType, PSCMSTREAM pStrm, size_t offSrc)
    17091831{
    17101832    size_t cchType = strlen(pszType);
     
    17211843    if (pszType[cchType - 1] == '&')
    17221844    {
    1723         RTMsgWarning("Please avoid using references like '%s' for probe arguments!", pszType);
     1845        parseWarnAbs(pStrm, offSrc, "Please avoid using references like '%s' for probe arguments!", pszType);
    17241846        return VTG_TYPE_POINTER;
    17251847    }
     
    18231945        || MY_STRMATCH("unsigned short")
    18241946       )
    1825         RTMsgWarning("Please avoid using the type '%s' for probe arguments!", pszType);
     1947        parseWarnAbs(pStrm, offSrc, "Please avoid using the type '%s' for probe arguments!", pszType);
    18261948    if (MY_STRMATCH("unsigned"))        return VTG_TYPE_FIXED_SIZED | sizeof(int)   | VTG_TYPE_UNSIGNED;
    18271949    if (MY_STRMATCH("unsigned int"))    return VTG_TYPE_FIXED_SIZED | sizeof(int)   | VTG_TYPE_UNSIGNED;
     
    18581980 * @param   pProbe              The probe.
    18591981 * @param   pArg                The argument.
    1860  * @param   pStrm               The input stream (for errors).
     1982 * @param   pStrm               The input stream (for errors + warnings).
    18611983 * @param   pchType             The type.
    18621984 * @param   cchType             The type length.
     
    18741996    if (!pArg->pszTracerType || !pArg->pszName)
    18751997        return parseError(pStrm, 1, "Out of memory");
    1876     pArg->fType             = parseTypeExpression(pArg->pszTracerType);
     1998    pArg->fType             = parseTypeExpression(pArg->pszTracerType, pStrm, pArg->offSrc);
    18771999
    18782000    if (   (pArg->fType & VTG_TYPE_POINTER)
     
    19652087static RTEXITCODE parseProbe(PSCMSTREAM pStrm, PVTGPROVIDER pProv)
    19662088{
     2089    size_t const iProbeLine = ScmStreamTellLine(pStrm);
     2090
    19672091    /*
    19682092     * Next up is a name followed by an opening parenthesis.
     
    19852109    RTListAppend(&pProv->ProbeHead, &pProbe->ListEntry);
    19862110    pProbe->offArgList     = UINT32_MAX;
     2111    pProbe->iLine          = iProbeLine;
    19872112    pProbe->pszMangledName = RTStrDupN(pszProbe, cchProbe);
    19882113    if (!pProbe->pszMangledName)
     
    20472172                        return parseError(pStrm, 1, "Out of memory");
    20482173                    RTListAppend(&pProbe->ArgHead, &pArg->ListEntry);
    2049                     pProbe->cArgs++;
     2174                    pArg->iArgNo = pProbe->cArgs++;
     2175                    pArg->pProbe = pProbe;
     2176                    pArg->offSrc = ScmStreamTell(pStrm) - cchWord;
    20502177
    20512178                    if (cchWord + 1 > sizeof(szArg))
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