VirtualBox

Changeset 21110 in vbox


Ignore:
Timestamp:
Jul 1, 2009 1:02:58 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49373
Message:

RTDbg: Some adjustments and fixes.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/dbg.h

    r20801 r21110  
    473473 *                          and address. Optional.
    474474 * @param   pSymInfo        Where to return the symbol info.
    475  */
    476 RTDECL(int) RTDbgAsSymbolByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo);
     475 * @param   phMod           Where to return the module handle. Optional.
     476 */
     477RTDECL(int) RTDbgAsSymbolByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo, PRTDBGMOD phMod);
    477478
    478479/**
     
    489490 * @param   ppSymInfo       Where to return the pointer to the allocated symbol
    490491 *                          info. Always set. Free with RTDbgSymbolFree.
    491  */
    492 RTDECL(int) RTDbgAsSymbolByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo);
     492 * @param   phMod           Where to return the module handle. Optional.
     493 */
     494RTDECL(int) RTDbgAsSymbolByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo, PRTDBGMOD phMod);
    493495
    494496/**
     
    499501 *
    500502 * @param   hDbgAs          The address space handle.
    501  * @param   pszSymbol       The symbol name.
    502  * @param   pSymInfo        Where to return the symbol info.
    503  */
    504 RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymInfo);
    505 
    506 /**
    507  * Query a symbol by name.
     503 * @param   pszSymbol       The symbol name. It is possible to limit the scope
     504 *                          of the search by prefixing the symbol with a module
     505 *                          name pattern followed by a bang (!) character.
     506 *                          RTStrSimplePatternNMatch is used for the matching.
     507 * @param   pSymbol         Where to return the symbol info.
     508 * @param   phMod           Where to return the module handle. Optional.
     509 */
     510RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod);
     511
     512/**
     513 * Query a symbol by name, allocating the returned symbol structure.
    508514 *
    509515 * @returns IPRT status code.
     
    511517 *
    512518 * @param   hDbgAs          The address space handle.
    513  * @param   pszSymbol       The symbol name.
    514  * @param   ppSymInfo       Where to return the pointer to the allocated symbol
    515  *                          info. Always set. Free with RTDbgSymbolFree.
    516  */
    517 RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymInfo);
     519 * @param   pszSymbol       The symbol name. See RTDbgAsSymbolByName for more.
     520 * @param   ppSymbol        Where to return the pointer to the allocated
     521 *                          symbol info. Always set. Free with RTDbgSymbolFree.
     522 * @param   phMod           Where to return the module handle. Optional.
     523 */
     524RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol, PRTDBGMOD phMod);
    518525
    519526/**
  • trunk/src/VBox/Runtime/common/dbg/dbgas.cpp

    r20744 r21110  
    11831183 *                          and address. Optional.
    11841184 * @param   pSymbol         Where to return the symbol info.
    1185  */
    1186 RTDECL(int) RTDbgAsSymbolByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
     1185 * @param   phMod           Where to return the module handle. Optional.
     1186 */
     1187RTDECL(int) RTDbgAsSymbolByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod)
    11871188{
    11881189    /*
     
    11971198    RTDBGMOD    hMod = rtDbgAsModuleByAddr(pDbgAs, Addr, &iSeg, &offSeg, &MapAddr);
    11981199    if (hMod == NIL_RTDBGMOD)
     1200    {
     1201        if (phMod)
     1202            *phMod = NIL_RTDBGMOD;
    11991203        return VERR_NOT_FOUND;
     1204    }
    12001205
    12011206    /*
     
    12051210    if (RT_SUCCESS(rc))
    12061211        rtDbgAsAdjustSymbolValue(pSymbol, hMod, MapAddr, iSeg);
    1207     RTDbgModRelease(hMod);
     1212    if (phMod)
     1213        *phMod = hMod;
     1214    else
     1215        RTDbgModRelease(hMod);
    12081216    return rc;
    12091217}
     
    12231231 * @param   ppSymbol        Where to return the pointer to the allocated
    12241232 *                          symbol info. Always set. Free with RTDbgSymbolFree.
    1225  */
    1226 RTDECL(int) RTDbgAsSymbolByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymbol)
     1233 * @param   phMod           Where to return the module handle. Optional.
     1234 */
     1235RTDECL(int) RTDbgAsSymbolByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymbol, PRTDBGMOD phMod)
    12271236{
    12281237    /*
     
    12371246    RTDBGMOD    hMod = rtDbgAsModuleByAddr(pDbgAs, Addr, &iSeg, &offSeg, &MapAddr);
    12381247    if (hMod == NIL_RTDBGMOD)
     1248    {
     1249        if (phMod)
     1250            *phMod = NIL_RTDBGMOD;
    12391251        return VERR_NOT_FOUND;
     1252    }
    12401253
    12411254    /*
     
    12451258    if (RT_SUCCESS(rc))
    12461259        rtDbgAsAdjustSymbolValue(*ppSymbol, hMod, MapAddr, iSeg);
    1247     RTDbgModRelease(hMod);
     1260    if (phMod)
     1261        *phMod = hMod;
     1262    else
     1263        RTDbgModRelease(hMod);
    12481264    return rc;
    12491265}
     
    12701286        while (iMod-- > 0)
    12711287        {
    1272             RTDBGMOD hMod = paModules[iMod];
     1288            RTDBGMOD hMod = (RTDBGMOD)pDbgAs->paModules[iMod].Core.Key;
    12731289            paModules[iMod] = hMod;
    12741290            RTDbgModRetain(hMod);
     
    13551371 *
    13561372 * @param   hDbgAs          The address space handle.
    1357  * @param   pszSymbol       The symbol name.
     1373 * @param   pszSymbol       The symbol name. It is possible to limit the scope
     1374 *                          of the search by prefixing the symbol with a module
     1375 *                          name pattern followed by a bang (!) character.
     1376 *                          RTStrSimplePatternNMatch is used for the matching.
    13581377 * @param   pSymbol         Where to return the symbol info.
    1359  */
    1360 RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol)
     1378 * @param   phMod           Where to return the module handle. Optional.
     1379 */
     1380RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod)
    13611381{
    13621382    /*
     
    13671387    AssertPtrReturn(pszSymbol, VERR_INVALID_POINTER);
    13681388    AssertPtrReturn(pSymbol, VERR_INVALID_POINTER);
     1389
     1390    /*
     1391     * Look for module pattern.
     1392     */
     1393    const char *pachModPat = NULL;
     1394    size_t      cchModPat  = 0;
     1395    const char *pszBang    = strchr(pszSymbol, '!');
     1396    if (pszBang)
     1397    {
     1398        pachModPat = pszSymbol;
     1399        cchModPat = pszBang - pszSymbol;
     1400        pszSymbol = pszBang + 1;
     1401        if (!*pszSymbol)
     1402            return VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE;
     1403        /* Note! Zero length module -> no pattern -> escape for symbol with '!'. */
     1404    }
    13691405
    13701406    /*
     
    13781414    for (uint32_t i = 0; i < cModules; i++)
    13791415    {
    1380         int rc = RTDbgModSymbolByName(paModules[i], pszSymbol, pSymbol);
    1381         if (RT_SUCCESS(rc))
     1416        if (    cchModPat == 0
     1417            ||  RTStrSimplePatternNMatch(pachModPat, cchModPat, RTDbgModName(paModules[i]), RTSTR_MAX))
    13821418        {
    1383             if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, paModules[i], pSymbol))
     1419            int rc = RTDbgModSymbolByName(paModules[i], pszSymbol, pSymbol);
     1420            if (RT_SUCCESS(rc))
    13841421            {
    1385                 for (; i < cModules; i++)
    1386                     RTDbgModRelease(paModules[i]);
    1387                 RTMemTmpFree(paModules);
    1388                 return rc;
     1422                if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, paModules[i], pSymbol))
     1423                {
     1424                    if (phMod)
     1425                        RTDbgModRetain(*phMod = paModules[i]);
     1426                    for (; i < cModules; i++)
     1427                        RTDbgModRelease(paModules[i]);
     1428                    RTMemTmpFree(paModules);
     1429                    return rc;
     1430                }
    13891431            }
    13901432        }
     
    13981440
    13991441/**
    1400  * Query a symbol by name.
     1442 * Query a symbol by name, allocating the returned symbol structure.
    14011443 *
    14021444 * @returns IPRT status code.
     
    14041446 *
    14051447 * @param   hDbgAs          The address space handle.
    1406  * @param   pszSymbol       The symbol name.
     1448 * @param   pszSymbol       The symbol name. See RTDbgAsSymbolByName for more.
    14071449 * @param   ppSymbol        Where to return the pointer to the allocated
    14081450 *                          symbol info. Always set. Free with RTDbgSymbolFree.
    1409  */
    1410 RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol)
     1451 * @param   phMod           Where to return the module handle. Optional.
     1452 */
     1453RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol, PRTDBGMOD phMod)
    14111454{
    14121455    /*
     
    14181461    RTDBGAS_VALID_RETURN_RC(pDbgAs, VERR_INVALID_HANDLE);
    14191462    AssertPtrReturn(pszSymbol, VERR_INVALID_POINTER);
     1463
     1464    /*
     1465     * Look for module pattern.
     1466     */
     1467    const char *pachModPat = NULL;
     1468    size_t      cchModPat  = 0;
     1469    const char *pszBang    = strchr(pszSymbol, '!');
     1470    if (pszBang)
     1471    {
     1472        pachModPat = pszSymbol;
     1473        cchModPat = pszBang - pszSymbol;
     1474        pszSymbol = pszBang + 1;
     1475        if (!*pszSymbol)
     1476            return VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE;
     1477        /* Note! Zero length module -> no pattern -> escape for symbol with '!'. */
     1478    }
    14201479
    14211480    /*
     
    14291488    for (uint32_t i = 0; i < cModules; i++)
    14301489    {
    1431         int rc = RTDbgModSymbolByNameA(paModules[i], pszSymbol, ppSymbol);
    1432         if (RT_SUCCESS(rc))
     1490        if (    cchModPat == 0
     1491            ||  RTStrSimplePatternNMatch(pachModPat, cchModPat, RTDbgModName(paModules[i]), RTSTR_MAX))
    14331492        {
    1434             if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, paModules[i], *ppSymbol))
     1493            int rc = RTDbgModSymbolByNameA(paModules[i], pszSymbol, ppSymbol);
     1494            if (RT_SUCCESS(rc))
    14351495            {
    1436                 for (; i < cModules; i++)
    1437                     RTDbgModRelease(paModules[i]);
    1438                 RTMemTmpFree(paModules);
    1439                 return rc;
     1496                if (rtDbgAsFindMappingAndAdjustSymbolValue(pDbgAs, paModules[i], *ppSymbol))
     1497                {
     1498                    if (phMod)
     1499                        RTDbgModRetain(*phMod = paModules[i]);
     1500                    for (; i < cModules; i++)
     1501                        RTDbgModRelease(paModules[i]);
     1502                    RTMemTmpFree(paModules);
     1503                    return rc;
     1504                }
    14401505            }
    1441 
    1442             RTDbgSymbolFree(*ppSymbol);
    1443             *ppSymbol = NULL;
    14441506        }
    14451507        RTDbgModRelease(paModules[i]);
  • trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp

    r21046 r21110  
    176176                    ("iSeg=%#x cSegs=%#x\n", pThis->cSegs),
    177177                    VERR_DBG_INVALID_SEGMENT_INDEX);
    178     AssertMsgReturn(pThis->paSegs[iSeg].cb < off,
     178    AssertMsgReturn(off < pThis->paSegs[iSeg].cb,
    179179                    ("off=%RTptr cbSeg=%RTptr\n", off, pThis->paSegs[iSeg].cb),
    180180                    VERR_DBG_INVALID_SEGMENT_OFFSET);
     
    303303                    VERR_DBG_INVALID_SEGMENT_INDEX);
    304304    AssertMsgReturn(    iSeg >= RTDBGSEGIDX_SPECIAL_FIRST
    305                     ||  pThis->paSegs[iSeg].cb <= off,
     305                    ||  off <= pThis->paSegs[iSeg].cb,
    306306                    ("off=%RTptr cbSeg=%RTptr\n", off, pThis->paSegs[iSeg].cb),
    307307                    VERR_DBG_INVALID_SEGMENT_OFFSET);
     
    541541    PRTDBGMODCTN          pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
    542542    PCRTDBGMODCTNSEGMENT  paSeg = pThis->paSegs;
    543     uint32_t const              cSegs = pThis->cSegs;
     543    uint32_t const        cSegs = pThis->cSegs;
    544544    if (cSegs <= 7)
    545545    {
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