VirtualBox

Changeset 46164 in vbox for trunk/src


Ignore:
Timestamp:
May 19, 2013 4:58:01 PM (12 years ago)
Author:
vboxsync
Message:

More exteran .dSYM and .dwo bundles/files changes.

Location:
trunk/src/VBox/Runtime
Files:
14 edited

Legend:

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

    r46161 r46164  
    413413                            pDbgMod->pDbgVt = pCur->pVt;
    414414                            pDbgMod->pvDbgPriv = NULL;
    415                             rc = pCur->pVt->pfnTryOpen(pDbgMod);
     415                            rc = pCur->pVt->pfnTryOpen(pDbgMod, RTLDRARCH_WHATEVER);
    416416                            if (RT_SUCCESS(rc))
    417417                            {
     
    476476            pDbgMod->pDbgVt    = pDbg->pVt;
    477477            pDbgMod->pvDbgPriv = NULL;
    478             rc = pDbg->pVt->pfnTryOpen(pDbgMod);
     478            rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod));
    479479            if (RT_SUCCESS(rc))
    480480            {
     
    506506    Assert(!pDbgMod->pvDbgPriv);
    507507    Assert(!pDbgMod->pszDbgFile);
     508    Assert(pDbgMod->pImgVt);
    508509
    509510    /*
     
    519520            pDbgMod->pDbgVt    = pDbg->pVt;
    520521            pDbgMod->pvDbgPriv = NULL;
    521             rc = pDbg->pVt->pfnTryOpen(pDbgMod);
     522            rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod));
    522523            if (RT_SUCCESS(rc))
    523524            {
     
    674675    Assert(!pDbgMod->pvDbgPriv);
    675676    Assert(!pDbgMod->pszDbgFile);
     677    Assert(pDbgMod->pImgVt);
    676678
    677679    /*
     
    687689            pDbgMod->pDbgVt    = pDbg->pVt;
    688690            pDbgMod->pvDbgPriv = NULL;
    689             rc = pDbg->pVt->pfnTryOpen(pDbgMod);
     691            rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod));
    690692            if (RT_SUCCESS(rc))
    691693            {
     
    867869                            pDbgMod->pDbgVt = pDbg->pVt;
    868870                            pDbgMod->pvDbgPriv = NULL;
    869                             rc = pDbg->pVt->pfnTryOpen(pDbgMod);
     871                            rc = pDbg->pVt->pfnTryOpen(pDbgMod, enmArch);
    870872                            if (RT_SUCCESS(rc))
    871873                            {
  • trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp

    r46149 r46164  
    676676
    677677/** @copydoc RTDBGMODVTDBG::pfnTryOpen */
    678 static DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod)
    679 {
    680     NOREF(pMod);
     678static DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch)
     679{
     680    NOREF(pMod); NOREF(enmArch);
    681681    return VERR_INTERNAL_ERROR_5;
    682682}
  • trunk/src/VBox/Runtime/common/dbg/dbgmoddbghelp.cpp

    r46127 r46164  
    386386
    387387/** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */
    388 static DECLCALLBACK(int) rtDbgModDbgHelp_TryOpen(PRTDBGMODINT pMod)
    389 {
     388static DECLCALLBACK(int) rtDbgModDbgHelp_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch)
     389{
     390    NOREF(enmArch);
     391
    390392    /*
    391393     * Currently only support external files with a executable already present.
  • trunk/src/VBox/Runtime/common/dbg/dbgmoddeferred.cpp

    r46161 r46164  
    391391
    392392/** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */
    393 static DECLCALLBACK(int) rtDbgModDeferredDbg_TryOpen(PRTDBGMODINT pMod)
    394 {
     393static DECLCALLBACK(int) rtDbgModDeferredDbg_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch)
     394{
     395    NOREF(enmArch);
    395396    return rtDbgModDeferredDoIt(pMod, true /*fForceRetry*/);
    396397}
     
    438439 *
    439440 */
     441
     442
     443/** @interface_method_impl{RTDBGMODVTIMG,pfnGetArch} */
     444static DECLCALLBACK(RTLDRARCH) rtDbgModDeferredImg_GetArch(PRTDBGMODINT pMod)
     445{
     446    RTLDRARCH enmArch;
     447    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
     448    if (RT_SUCCESS(rc))
     449        enmArch = pMod->pImgVt->pfnGetArch(pMod);
     450    else
     451        enmArch = RTLDRARCH_WHATEVER;
     452    return enmArch;
     453}
    440454
    441455
     
    567581    /*.pfnUnmapPart = */                rtDbgModDeferredImg_UnmapPart,
    568582    /*.pfnGetFormat = */                rtDbgModDeferredImg_GetFormat,
     583    /*.pfnGetArch = */                  rtDbgModDeferredImg_GetArch,
    569584
    570585    /*.u32EndMagic = */                 RTDBGMODVTIMG_MAGIC
  • trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp

    r46149 r46164  
    4141#include <iprt/path.h>
    4242#include <iprt/string.h>
     43#include <iprt/strcache.h>
    4344#include "internal/dbgmod.h"
    4445
     
    420421    /** The debug container containing doing the real work. */
    421422    RTDBGMOD                hCnt;
    422     /** Pointer to back to the debug info module (no reference ofc). */
    423     PRTDBGMODINT            pMod;
     423    /** The image module (no reference). */
     424    PRTDBGMODINT            pImgMod;
     425    /** The debug info module (no reference). */
     426    PRTDBGMODINT            pDbgInfoMod;
     427    /** Nested image module (with reference ofc). */
     428    PRTDBGMODINT            pNestedMod;
    424429
    425430    /** DWARF debug info sections. */
     
    11921197 * @returns IPRT status code.
    11931198 * @param   pThis               The DWARF instance.
    1194  * @param   pMod                The debug module.
    1195  */
    1196 static int rtDbgModDwarfAddSegmentsFromImage(PRTDBGMODDWARF pThis, PRTDBGMODINT pMod)
    1197 {
    1198     AssertReturn(pMod->pImgVt, VERR_INTERNAL_ERROR_2);
     1199 */
     1200static int rtDbgModDwarfAddSegmentsFromImage(PRTDBGMODDWARF pThis)
     1201{
     1202    AssertReturn(pThis->pImgMod && pThis->pImgMod->pImgVt, VERR_INTERNAL_ERROR_2);
    11991203    Assert(!pThis->cSegs);
    1200     int rc = pMod->pImgVt->pfnEnumSegments(pMod, rtDbgModDwarfScanSegmentsCallback, pThis);
     1204    int rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfScanSegmentsCallback, pThis);
    12011205    if (RT_SUCCESS(rc))
    12021206    {
     
    12071211            pThis->cSegs = 0;
    12081212            pThis->iWatcomPass = -1;
    1209             rc = pMod->pImgVt->pfnEnumSegments(pMod, rtDbgModDwarfAddSegmentsCallback, pThis);
     1213            rc = pThis->pImgMod->pImgVt->pfnEnumSegments(pThis->pImgMod, rtDbgModDwarfAddSegmentsCallback, pThis);
    12101214        }
    12111215    }
     
    13821386     * Do the job.
    13831387     */
    1384     return pThis->pMod->pImgVt->pfnMapPart(pThis->pMod,
    1385                                            pThis->aSections[enmSect].iDbgInfo,
    1386                                            pThis->aSections[enmSect].offFile,
    1387                                            pThis->aSections[enmSect].cb,
    1388                                            &pThis->aSections[enmSect].pv);
     1388    return pThis->pDbgInfoMod->pImgVt->pfnMapPart(pThis->pDbgInfoMod,
     1389                                                  pThis->aSections[enmSect].iDbgInfo,
     1390                                                  pThis->aSections[enmSect].offFile,
     1391                                                  pThis->aSections[enmSect].cb,
     1392                                                  &pThis->aSections[enmSect].pv);
    13891393}
    13901394
     
    14031407        return VINF_SUCCESS;
    14041408
    1405     int rc = pThis->pMod->pImgVt->pfnUnmapPart(pThis->pMod, pThis->aSections[enmSect].cb, &pThis->aSections[enmSect].pv);
     1409    int rc = pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[enmSect].cb, &pThis->aSections[enmSect].pv);
    14061410    AssertRC(rc);
    14071411    return rc;
     
    14511455    }
    14521456
    1453     return pThis->pMod->pImgVt->pfnRvaToSegOffset(pThis->pMod, LinkAddress, piSeg, poffSeg);
    1454     //return pThis->pMod->pImgVt->pfnLinkAddressToSegOffset(pThis->pMod, LinkAddress, piSeg, poffSeg);
     1457    return pThis->pImgMod->pImgVt->pfnRvaToSegOffset(pThis->pImgMod, LinkAddress, piSeg, poffSeg);
     1458    //return pThis->pImgMod->pImgVt->pfnLinkAddressToSegOffset(pThis->pImgMod, LinkAddress, piSeg, poffSeg);
    14551459}
    14561460
     
    43014305    PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)pMod->pvDbgPriv;
    43024306    RTUINTPTR cb1 = RTDbgModImageSize(pThis->hCnt);
    4303     RTUINTPTR cb2 = pMod->pImgVt->pfnImageSize(pMod);
     4307    RTUINTPTR cb2 = pThis->pImgMod->pImgVt->pfnImageSize(pMod);
    43044308    return RT_MAX(cb1, cb2);
    43054309}
     
    43214325    for (unsigned iSect = 0; iSect < RT_ELEMENTS(pThis->aSections); iSect++)
    43224326        if (pThis->aSections[iSect].pv)
    4323             pThis->pMod->pImgVt->pfnUnmapPart(pThis->pMod, pThis->aSections[iSect].cb, &pThis->aSections[iSect].pv);
     4327            pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[iSect].cb, &pThis->aSections[iSect].pv);
    43244328
    43254329    RTDbgModRelease(pThis->hCnt);
    43264330    RTMemFree(pThis->paCachedAbbrevs);
     4331    if (pThis->pNestedMod)
     4332    {
     4333        pThis->pNestedMod->pImgVt->pfnClose(pThis->pNestedMod);
     4334        RTStrCacheRelease(g_hDbgModStrCache, pThis->pNestedMod->pszName);
     4335        RTStrCacheRelease(g_hDbgModStrCache, pThis->pNestedMod->pszDbgFile);
     4336        RTMemFree(pThis->pNestedMod);
     4337        pThis->pNestedMod = NULL;
     4338    }
    43274339    RTMemFree(pThis);
    43284340
     
    44014413
    44024414
     4415static int rtDbgModDwarfTryOpenDbgFile(PRTDBGMODINT pDbgMod, PRTDBGMODDWARF pThis, RTLDRARCH enmArch)
     4416{
     4417    if (   !pDbgMod->pszDbgFile
     4418        || RTPathIsSame(pDbgMod->pszDbgFile, pDbgMod->pszImgFile) == true /* returns VERR too */)
     4419        return VERR_DBG_NO_MATCHING_INTERPRETER;
     4420
     4421    /*
     4422     * Only open the image.
     4423     */
     4424    PRTDBGMODINT pDbgInfoMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgInfoMod));
     4425    if (!pDbgInfoMod)
     4426        return VERR_NO_MEMORY;
     4427
     4428    int rc;
     4429    pDbgInfoMod->u32Magic     = RTDBGMOD_MAGIC;
     4430    pDbgInfoMod->cRefs        = 1;
     4431    if (RTStrCacheRetain(pDbgMod->pszDbgFile) != UINT32_MAX)
     4432    {
     4433        pDbgInfoMod->pszImgFile = pDbgMod->pszDbgFile;
     4434        if (RTStrCacheRetain(pDbgMod->pszName) != UINT32_MAX)
     4435        {
     4436            pDbgInfoMod->pszName = pDbgMod->pszName;
     4437            pDbgInfoMod->pImgVt  = &g_rtDbgModVtImgLdr;
     4438            rc = pDbgInfoMod->pImgVt->pfnTryOpen(pDbgInfoMod, enmArch);
     4439            if (RT_SUCCESS(rc))
     4440            {
     4441                pThis->pDbgInfoMod = pDbgInfoMod;
     4442                pThis->pNestedMod  = pDbgInfoMod;
     4443                return VINF_SUCCESS;
     4444            }
     4445
     4446            RTStrCacheRelease(g_hDbgModStrCache, pDbgInfoMod->pszName);
     4447        }
     4448        else
     4449            rc = VERR_NO_STR_MEMORY;
     4450        RTStrCacheRelease(g_hDbgModStrCache,  pDbgInfoMod->pszImgFile);
     4451    }
     4452    else
     4453        rc = VERR_NO_STR_MEMORY;
     4454    RTMemFree(pDbgInfoMod);
     4455    return rc;
     4456}
     4457
     4458
    44034459/** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */
    4404 static DECLCALLBACK(int) rtDbgModDwarf_TryOpen(PRTDBGMODINT pMod)
     4460static DECLCALLBACK(int) rtDbgModDwarf_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch)
    44054461{
    44064462    /*
     
    44114467
    44124468    /*
    4413      * Enumerate the debug info in the module, looking for DWARF bits.
     4469     * Create the module instance data.
    44144470     */
    44154471    PRTDBGMODDWARF pThis = (PRTDBGMODDWARF)RTMemAllocZ(sizeof(*pThis));
    44164472    if (!pThis)
    44174473        return VERR_NO_MEMORY;
    4418     pThis->pMod = pMod;
     4474    pThis->pDbgInfoMod = pMod;
     4475    pThis->pImgMod     = pMod;
    44194476    RTListInit(&pThis->CompileUnitList);
    44204477
    4421     int rc = pMod->pImgVt->pfnEnumDbgInfo(pMod, rtDbgModDwarfEnumCallback, pThis);
     4478
     4479    /*
     4480     * If the debug file name is set, let's see if it's an ELF image with DWARF
     4481     * inside it. In that case we'll have to deal with two image modules, one
     4482     * for segments and address translation and one for the debug information.
     4483     */
     4484    if (pMod->pszDbgFile != NULL)
     4485        rtDbgModDwarfTryOpenDbgFile(pMod, pThis, enmArch);
     4486
     4487    /*
     4488     * Enumerate the debug info in the module, looking for DWARF bits.
     4489     */
     4490    int rc = pThis->pDbgInfoMod->pImgVt->pfnEnumDbgInfo(pThis->pDbgInfoMod, rtDbgModDwarfEnumCallback, pThis);
    44224491    if (RT_SUCCESS(rc))
    44234492    {
     
    44334502                pMod->pvDbgPriv = pThis;
    44344503
    4435                 rc = rtDbgModDwarfAddSegmentsFromImage(pThis, pMod);
     4504                rc = rtDbgModDwarfAddSegmentsFromImage(pThis);
    44364505                if (RT_SUCCESS(rc))
    44374506                    rc = rtDwarfInfo_LoadAll(pThis);
     
    44574526                    for (unsigned iSect = 0; iSect < RT_ELEMENTS(pThis->aSections); iSect++)
    44584527                        if (pThis->aSections[iSect].pv)
    4459                             pThis->pMod->pImgVt->pfnUnmapPart(pThis->pMod, pThis->aSections[iSect].cb,
    4460                                                               &pThis->aSections[iSect].pv);
     4528                            pThis->pDbgInfoMod->pImgVt->pfnUnmapPart(pThis->pDbgInfoMod, pThis->aSections[iSect].cb,
     4529                                                                     &pThis->aSections[iSect].pv);
    44614530
    44624531
  • trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp

    r46161 r46164  
    5959typedef RTDBGMODLDR *PRTDBGMODLDR;
    6060
     61
     62
     63/** @interface_method_impl{RTDBGMODVTIMG,pfnGetArch} */
     64static DECLCALLBACK(RTLDRARCH) rtDbgModLdr_GetArch(PRTDBGMODINT pMod)
     65{
     66    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     67    return RTLdrGetArch(pThis->hLdrMod);
     68}
    6169
    6270
     
    198206    /*.pfnUnmapPart = */                rtDbgModLdr_UnmapPart,
    199207    /*.pfnGetFormat = */                rtDbgModLdr_GetFormat,
     208    /*.pfnGetArch = */                  rtDbgModLdr_GetArch,
    200209
    201210    /*.u32EndMagic = */                 RTDBGMODVTIMG_MAGIC
  • trunk/src/VBox/Runtime/common/dbg/dbgmodnm.cpp

    r44529 r46164  
    478478
    479479/** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */
    480 static DECLCALLBACK(int) rtDbgModNm_TryOpen(PRTDBGMODINT pMod)
    481 {
     480static DECLCALLBACK(int) rtDbgModNm_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch)
     481{
     482    NOREF(enmArch);
     483
    482484    /*
    483485     * Fend off images.
  • trunk/src/VBox/Runtime/common/ldr/ldr.cpp

    r46161 r46164  
    121121
    122122
     123RTDECL(RTLDRARCH) RTLdrGetArch(RTLDRMOD hLdrMod)
     124{
     125    AssertMsgReturn(rtldrIsValid(hLdrMod), ("hLdrMod=%p\n", hLdrMod), RTLDRARCH_INVALID);
     126    PRTLDRMODINTERNAL pMod = (PRTLDRMODINTERNAL)hLdrMod;
     127    return pMod->enmArch;
     128}
     129RT_EXPORT_SYMBOL(RTLdrGetArch);
     130
     131
    123132RTDECL(int) RTLdrClose(RTLDRMOD hLdrMod)
    124133{
  • trunk/src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h

    r46161 r46164  
    14401440    pModElf->Core.enmType   = RTLDRTYPE_OBJECT;
    14411441    pModElf->Core.enmEndian = RTLDRENDIAN_LITTLE;
     1442#if ELF_MODE == 32
     1443    pModElf->Core.enmArch   = RTLDRARCH_X86_32;
     1444#else
     1445    pModElf->Core.enmArch   = RTLDRARCH_AMD64;
     1446#endif
    14421447    //pModElf->pvBits         = NULL;
    14431448    //pModElf->Ehdr           = {0};
  • trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp

    r46161 r46164  
    140140        pMod->Core.enmEndian    = RTLDRENDIAN_LITTLE;
    141141#endif
     142#ifdef RT_ARCH_AMD64
     143        pMod->Core.enmArch      = RTLDRARCH_AMD64;
     144#elif defined(RT_ARCH_X86)
     145        pMod->Core.enmArch      = RTLDRARCH_X86_32;
     146#else
     147        pMod->Core.enmArch      = RTLDRARCH_HOST;
     148#endif
    142149        pMod->hNative           = ~(uintptr_t)0;
    143150
  • trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp

    r46161 r46164  
    22932293                                        : RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE;
    22942294                pModPe->Core.enmEndian= RTLDRENDIAN_LITTLE;
     2295                pModPe->Core.enmArch  = FileHdr.Machine == IMAGE_FILE_MACHINE_I386
     2296                                      ? RTLDRARCH_X86_32
     2297                                      : FileHdr.Machine == IMAGE_FILE_MACHINE_AMD64
     2298                                      ? RTLDRARCH_AMD64
     2299                                      : RTLDRARCH_WHATEVER;
    22952300                pModPe->pvBits        = NULL;
    22962301                pModPe->offNtHdrs     = offNtHdrs;
  • trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp

    r46161 r46164  
    618618        case KLDRDBGINFOTYPE_DWARF:
    619619            DbgInfo.enmType = RTLDRDBGINFOTYPE_DWARF;
    620             if (pszExtFile)
     620            if (!pszExtFile)
     621                DbgInfo.u.Dwarf.pszSection = pszPartNm;
     622            else
     623            {
    621624                DbgInfo.enmType = RTLDRDBGINFOTYPE_DWARF_DWO;
     625                DbgInfo.u.Dwo.uCrc32 = 0;
     626            }
    622627            break;
    623628        case KLDRDBGINFOTYPE_CODEVIEW:
     
    922927                    break;
    923928            }
     929            switch (pMod->enmArch)
     930            {
     931                case KCPUARCH_X86_32:       pNewMod->Core.enmArch   = RTLDRARCH_X86_32; break;
     932                case KCPUARCH_AMD64:        pNewMod->Core.enmArch   = RTLDRARCH_AMD64; break;
     933                default:
     934                    AssertMsgFailed(("%d\n", pMod->enmArch));
     935                    pNewMod->Core.enmArch = RTLDRARCH_WHATEVER;
     936                    break;
     937            }
    924938            pNewMod->pMod          = pMod;
    925939            *phLdrMod = &pNewMod->Core;
  • trunk/src/VBox/Runtime/include/internal/dbgmod.h

    r46161 r46164  
    198198
    199199    /**
    200      * Gets the loader format.
    201      *
    202      * @returns Valid loader format on success, RTLDRFMT_INVALID if not supported.
     200     * Gets the image format.
     201     *
     202     * @returns Valid image format on success, RTLDRFMT_INVALID if not supported.
    203203     * @param   pMod            Pointer to the module structure.
    204204     */
    205205    DECLCALLBACKMEMBER(RTLDRFMT, pfnGetFormat)(PRTDBGMODINT pMod);
     206
     207    /**
     208     * Gets the image architecture.
     209     *
     210     * @returns Valid image architecutre on success, RTLDRARCH_WHATEVER if not
     211     *          supported.
     212     * @param   pMod            Pointer to the module structure.
     213     */
     214    DECLCALLBACKMEMBER(RTLDRARCH, pfnGetArch)(PRTDBGMODINT pMod);
    206215
    207216    /** For catching initialization errors (RTDBGMODVTIMG_MAGIC). */
     
    244253     *                      Upon successful return the method is expected to
    245254     *                      initialize pDbgOps and pvDbgPriv.
    246      */
    247     DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod);
     255     * @param   enmArch     The desired architecture.
     256     */
     257    DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod, RTLDRARCH enmArch);
    248258
    249259    /**
  • trunk/src/VBox/Runtime/include/internal/ldr.h

    r46161 r46164  
    429429    /** Image endianness.  */
    430430    RTLDRENDIAN             enmEndian;
     431    /** Image target architecture.  */
     432    RTLDRARCH               enmArch;
    431433} RTLDRMODINTERNAL;
    432434
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