VirtualBox

Changeset 49076 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Oct 14, 2013 2:13:11 AM (11 years ago)
Author:
vboxsync
Message:

IPRT: DWARF reader, enum the image symbols and add what's missing (or we did'n't implement loading yet) in the debug info.

File:
1 edited

Legend:

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

    r48693 r49076  
    44034403
    44044404
     4405/*
     4406 *
     4407 * Public and image level symbol handling.
     4408 * Public and image level symbol handling.
     4409 * Public and image level symbol handling.
     4410 * Public and image level symbol handling.
     4411 *
     4412 *
     4413 */
     4414
     4415#define RTDBGDWARF_SYM_ENUM_BASE_ADDRESS  UINT32_C(0x200000)
     4416
     4417/** @callback_method_impl{FNRTLDRENUMSYMS,
     4418 *  Adds missing symbols from the image symbol table.} */
     4419static DECLCALLBACK(int) rtDwarfSyms_EnumSymbolsCallback(RTLDRMOD hLdrMod, const char *pszSymbol, unsigned uSymbol,
     4420                                                         RTLDRADDR Value, void *pvUser)
     4421{
     4422    PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pvUser;
     4423    NOREF(hLdrMod);
     4424    Assert(pThis->iWatcomPass != 1);
     4425
     4426    RTLDRADDR uRva = Value - RTDBGDWARF_SYM_ENUM_BASE_ADDRESS;
     4427    if (   Value >= RTDBGDWARF_SYM_ENUM_BASE_ADDRESS
     4428        && uRva  <  _1G)
     4429    {
     4430        RTDBGSYMBOL SymInfo;
     4431        RTINTPTR    offDisp;
     4432        int rc = RTDbgModSymbolByAddr(pThis->hCnt, RTDBGSEGIDX_RVA, uRva, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDisp, &SymInfo);
     4433        if (   RT_FAILURE(rc)
     4434            || offDisp != 0)
     4435        {
     4436            rc = RTDbgModSymbolAdd(pThis->hCnt, pszSymbol, RTDBGSEGIDX_RVA, uRva, 1, 0 /*fFlags*/, NULL /*piOrdinal*/);
     4437            Log6(("Dwarf: Symbol #%05u %#018x %s [%Rrc]\n", uSymbol, Value, pszSymbol, rc)); NOREF(rc);
     4438        }
     4439    }
     4440    else
     4441        Log6(("Dwarf: Symbol #%05u %#018x %s [SKIPPED - INVALID ADDRESS]\n", uSymbol, Value, pszSymbol));
     4442    return VINF_SUCCESS;
     4443}
     4444
     4445
     4446
     4447/**
     4448 * Loads additional symbols from the pubnames section and the executable image.
     4449 *
     4450 * The symbols are insered into the debug info container.
     4451 *
     4452 * @returns IPRT status code
     4453 * @param   pThis               The DWARF instance.
     4454 */
     4455static int rtDwarfSyms_LoadAll(PRTDBGMODDWARF pThis)
     4456{
     4457    /*
     4458     * pubnames.
     4459     */
     4460    int rc = VINF_SUCCESS;
     4461    if (pThis->aSections[krtDbgModDwarfSect_pubnames].fPresent)
     4462    {
     4463//        RTDWARFCURSOR Cursor;
     4464//        int rc = rtDwarfCursor_Init(&Cursor, pThis, krtDbgModDwarfSect_info);
     4465//        if (RT_SUCCESS(rc))
     4466//        {
     4467//            while (   !rtDwarfCursor_IsAtEnd(&Cursor)
     4468//                   && RT_SUCCESS(rc))
     4469//                rc = rtDwarfInfo_LoadUnit(pThis, &Cursor, false /* fKeepDies */);
     4470//
     4471//            rc = rtDwarfCursor_Delete(&Cursor, rc);
     4472//        }
     4473//        return rc;
     4474    }
     4475
     4476    /*
     4477     * The executable image.
     4478     */
     4479    if (   pThis->pImgMod
     4480        && pThis->pImgMod->pImgVt->pfnEnumSymbols
     4481        && pThis->iWatcomPass != 1
     4482        && RT_SUCCESS(rc))
     4483    {
     4484        rc = pThis->pImgMod->pImgVt->pfnEnumSymbols(pThis->pImgMod,
     4485                                                    RTLDR_ENUM_SYMBOL_FLAGS_ALL | RTLDR_ENUM_SYMBOL_FLAGS_NO_FWD,
     4486                                                    RTDBGDWARF_SYM_ENUM_BASE_ADDRESS,
     4487                                                    rtDwarfSyms_EnumSymbolsCallback,
     4488                                                    pThis);
     4489    }
     4490
     4491    return rc;
     4492}
     4493
     4494
     4495
    44054496
    44064497/*
     
    47674858                    rc = rtDwarfInfo_LoadAll(pThis);
    47684859                if (RT_SUCCESS(rc))
     4860                    rc = rtDwarfSyms_LoadAll(pThis);
     4861                if (RT_SUCCESS(rc))
    47694862                    rc = rtDwarfLine_ExplodeAll(pThis);
    47704863                if (RT_SUCCESS(rc) && pThis->iWatcomPass == 1)
     
    47744867                    if (RT_SUCCESS(rc))
    47754868                        rc = rtDwarfInfo_LoadAll(pThis);
     4869                    if (RT_SUCCESS(rc))
     4870                        rc = rtDwarfSyms_LoadAll(pThis);
    47764871                    if (RT_SUCCESS(rc))
    47774872                        rc = rtDwarfLine_ExplodeAll(pThis);
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