VirtualBox

Changeset 61572 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 8, 2016 12:03:35 PM (9 years ago)
Author:
vboxsync
Message:

Debugger/Digger/Linux: Use an alternative needle (kobjec) to get at the kernel symbol table as seen on older x86 kernels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGPlugInLinux.cpp

    r61558 r61572  
    14111411}
    14121412
    1413 
    1414 /**
    1415  * @copydoc DBGFOSREG::pfnInit
    1416  */
    1417 static DECLCALLBACK(int)  dbgDiggerLinuxInit(PUVM pUVM, void *pvData)
    1418 {
    1419     PDBGDIGGERLINUX pThis = (PDBGDIGGERLINUX)pvData;
    1420     Assert(!pThis->fValid);
    1421 
    1422     /*
    1423      * Assume 64-bit kernels all live way beyond 32-bit address space.
    1424      */
    1425     pThis->f64Bit = pThis->AddrLinuxBanner.FlatPtr > UINT32_MAX;
     1413/**
     1414 * Tries to find and load the kernel symbol table with the given needle.
     1415 *
     1416 * @returns VBox status code.
     1417 * @param   pThis               The Linux digger data.
     1418 * @param   pUVM                The user mode VM handle.
     1419 * @param   pabNeedle           The needle to use for searching.
     1420 * @param   cbNeedle            Size of the needle in bytes.
     1421 */
     1422static int dbgDiggerLinuxFindSymbolTableFromNeedle(PDBGDIGGERLINUX pThis, PUVM pUVM, uint8_t const *pabNeedle, size_t cbNeedle)
     1423{
     1424    int rc = VINF_SUCCESS;
    14261425
    14271426    /*
     
    14331432    while (cbLeft > 4096)
    14341433    {
    1435         static const uint8_t s_abNeedle[] = "kobj";
    14361434        DBGFADDRESS          HitAddr;
    1437         int rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, &CurAddr, cbLeft, 1 /*uAlign*/,
    1438                                s_abNeedle, sizeof(s_abNeedle) - 1, &HitAddr);
     1435        rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, &CurAddr, cbLeft, 1 /*uAlign*/,
     1436                           pabNeedle, cbNeedle, &HitAddr);
    14391437        if (RT_FAILURE(rc))
    14401438            break;
    1441         if (dbgDiggerLinuxIsLikelyNameFragment(pUVM, &HitAddr, s_abNeedle, sizeof(s_abNeedle) - 1))
     1439        if (dbgDiggerLinuxIsLikelyNameFragment(pUVM, &HitAddr, pabNeedle, cbNeedle))
    14421440        {
    14431441            /* There will be another hit near by. */
    14441442            DBGFR3AddrAdd(&HitAddr, 1);
    14451443            rc = DBGFR3MemScan(pUVM, 0 /*idCpu*/, &HitAddr, LNX_MAX_KALLSYMS_NAMES_SIZE, 1 /*uAlign*/,
    1446                                s_abNeedle, sizeof(s_abNeedle) - 1, &HitAddr);
     1444                               pabNeedle, cbNeedle, &HitAddr);
    14471445            if (   RT_SUCCESS(rc)
    1448                 && dbgDiggerLinuxIsLikelyNameFragment(pUVM, &HitAddr, s_abNeedle, sizeof(s_abNeedle) - 1))
     1446                && dbgDiggerLinuxIsLikelyNameFragment(pUVM, &HitAddr, pabNeedle, cbNeedle))
    14491447            {
    14501448                /*
     
    14681466         * Advance.
    14691467         */
    1470         RTGCUINTPTR cbDistance = HitAddr.FlatPtr - CurAddr.FlatPtr + sizeof(s_abNeedle) - 1;
     1468        RTGCUINTPTR cbDistance = HitAddr.FlatPtr - CurAddr.FlatPtr + cbNeedle;
    14711469        if (RT_UNLIKELY(cbDistance >= cbLeft))
    14721470        {
     
    14771475        DBGFR3AddrAdd(&CurAddr, cbDistance);
    14781476
     1477    }
     1478
     1479    return rc;
     1480}
     1481/**
     1482 * @copydoc DBGFOSREG::pfnInit
     1483 */
     1484static DECLCALLBACK(int)  dbgDiggerLinuxInit(PUVM pUVM, void *pvData)
     1485{
     1486    PDBGDIGGERLINUX pThis = (PDBGDIGGERLINUX)pvData;
     1487    Assert(!pThis->fValid);
     1488
     1489    /*
     1490     * Assume 64-bit kernels all live way beyond 32-bit address space.
     1491     */
     1492    pThis->f64Bit = pThis->AddrLinuxBanner.FlatPtr > UINT32_MAX;
     1493
     1494    static const uint8_t s_abNeedle[] = "kobj";
     1495    int rc = dbgDiggerLinuxFindSymbolTableFromNeedle(pThis, pUVM, s_abNeedle, sizeof(s_abNeedle) - 1);
     1496    if (RT_FAILURE(rc))
     1497    {
     1498        /* Try alternate needle (seen on older x86 Linux kernels). */
     1499        static const uint8_t s_abNeedleAlt[] = "kobjec";
     1500        dbgDiggerLinuxFindSymbolTableFromNeedle(pThis, pUVM, s_abNeedleAlt, sizeof(s_abNeedleAlt) - 1);
    14791501    }
    14801502
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