VirtualBox

Changeset 20800 in vbox


Ignore:
Timestamp:
Jun 22, 2009 11:47:37 PM (15 years ago)
Author:
vboxsync
Message:

IPRT: More RTDbgMod code.

Location:
trunk
Files:
5 edited

Legend:

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

    r20799 r20800  
    137137 * @returns Pointer to duplicate on success, NULL on failure.
    138138 *
    139  * @param   pSymbol         The symbol to duplicate.
    140  */
    141 RTDECL(PRTDBGSYMBOL)    RTDbgSymbolDup(PCRTDBGSYMBOL pSymbol);
     139 * @param   pSymInfo        The symbol info to duplicate.
     140 */
     141RTDECL(PRTDBGSYMBOL)    RTDbgSymbolDup(PCRTDBGSYMBOL pSymInfo);
    142142
    143143/**
    144144 * Free a symbol structure previously allocated by a RTDbg method.
    145145 *
    146  * @param   pSymbol         The symbol to free. NULL is ignored.
    147  */
    148 RTDECL(void)            RTDbgSymbolFree(PRTDBGSYMBOL pSymbol);
     146 * @param   pSymInfo        The symbol info to free. NULL is ignored.
     147 */
     148RTDECL(void)            RTDbgSymbolFree(PRTDBGSYMBOL pSymInfo);
    149149
    150150
     
    472472 * @param   poffDisp        Where to return the distance between the symbol
    473473 *                          and address. Optional.
    474  * @param   pSymbol         Where to return the symbol info.
    475  */
    476 RTDECL(int) RTDbgAsSymbolByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol);
     474 * @param   pSymInfo        Where to return the symbol info.
     475 */
     476RTDECL(int) RTDbgAsSymbolByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo);
    477477
    478478/**
     
    487487 * @param   poffDisp        Where to return the distance between the symbol
    488488 *                          and address. Optional.
    489  * @param   ppSymbol        Where to return the pointer to the allocated
    490  *                          symbol info. Always set. Free with RTDbgSymbolFree.
    491  */
    492 RTDECL(int) RTDbgAsSymbolByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymbol);
     489 * @param   ppSymInfo       Where to return the pointer to the allocated symbol
     490 *                          info. Always set. Free with RTDbgSymbolFree.
     491 */
     492RTDECL(int) RTDbgAsSymbolByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo);
    493493
    494494/**
     
    500500 * @param   hDbgAs          The address space handle.
    501501 * @param   pszSymbol       The symbol name.
    502  * @param   pSymbol         Where to return the symbol info.
    503  */
    504 RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymbol);
     502 * @param   pSymInfo        Where to return the symbol info.
     503 */
     504RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL pSymInfo);
    505505
    506506/**
     
    512512 * @param   hDbgAs          The address space handle.
    513513 * @param   pszSymbol       The symbol name.
    514  * @param   ppSymbol        Where to return the pointer to the allocated
    515  *                          symbol info. Always set. Free with RTDbgSymbolFree.
    516  */
    517 RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol);
     514 * @param   ppSymInfo       Where to return the pointer to the allocated symbol
     515 *                          info. Always set. Free with RTDbgSymbolFree.
     516 */
     517RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymInfo);
    518518
    519519/**
     
    653653 *
    654654 * @returns Image mapped size.
    655  *          UINTPTR_MAX is returned if the handle is invalid.
     655 *          RTUINTPTR_MAX is returned if the handle is invalid.
    656656 *
    657657 * @param   hDbgMod         The module handle.
     
    730730 *
    731731 * @returns The segment size.
    732  *          UINTPTR_MAX is returned if either the handle and segment index are
     732 *          RTUINTPTR_MAX is returned if either the handle and segment index are
    733733 *          invalid.
    734734 *
     
    746746 *
    747747 * @returns The segment relative address.
    748  *          UINTPTR_MAX is returned if either the handle and segment index are
     748 *          RTUINTPTR_MAX is returned if either the handle and segment index are
    749749 *          invalid.
    750750 *
     
    757757RTDECL(int)         RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal);
    758758RTDECL(uint32_t)    RTDbgModSymbolCount(RTDBGMOD hDbgMod);
    759 RTDECL(int)         RTDbgModSymbolByIndex(RTDBGMOD hDbgMod, uint32_t iSymbol, PRTDBGSYMBOL pSymbol);
    760 RTDECL(int)         RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol);
    761 RTDECL(int)         RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymbol);
    762 RTDECL(int)         RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol);
    763 RTDECL(int)         RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol);
     759RTDECL(int)         RTDbgModSymbolByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo);
     760RTDECL(int)         RTDbgModSymbolByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL *ppSymInfo);
     761RTDECL(int)         RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo);
     762RTDECL(int)         RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo);
     763RTDECL(int)         RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymInfo);
     764RTDECL(int)         RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymInfo);
    764765
    765766RTDECL(int)         RTDbgModLineAdd(RTDBGMOD hDbgMod, const char *pszFile, uint32_t uLineNo, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t *piOrdinal);
     767RTDECL(uint32_t)    RTDbgModLineCount(RTDBGMOD hDbgMod);
     768RTDECL(int)         RTDbgModLineByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGLINE pLine);
     769RTDECL(int)         RTDbgModLineByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGLINE *ppLine);
    766770RTDECL(int)         RTDbgModLineByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE pLine);
    767771RTDECL(int)         RTDbgModLineByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE *ppLine);
  • trunk/src/VBox/Runtime/common/dbg/dbg.cpp

    r20741 r20800  
    5353 * @returns Pointer to duplicate on success, NULL on failure.
    5454 *
    55  * @param   pSymbol         The symbol to duplicate.
     55 * @param   pSymInfo        The symbol info to duplicate.
    5656 */
    57 RTDECL(PRTDBGSYMBOL) RTDbgSymbolDup(PCRTDBGSYMBOL pSymbol)
     57RTDECL(PRTDBGSYMBOL) RTDbgSymbolDup(PCRTDBGSYMBOL pSymInfo)
    5858{
    59     return (PRTDBGSYMBOL)RTMemDup(pSymbol, sizeof(*pSymbol));
     59    return (PRTDBGSYMBOL)RTMemDup(pSymInfo, sizeof(*pSymInfo));
    6060}
    6161
     
    6464 * Free a symbol structure previously allocated by a RTDbg method.
    6565 *
    66  * @param   pSymbol         The symbol to free. NULL is ignored.
     66 * @param   pSymInfo        The symbol info to free. NULL is ignored.
    6767 */
    68 RTDECL(void) RTDbgSymbolFree(PRTDBGSYMBOL pSymbol)
     68RTDECL(void) RTDbgSymbolFree(PRTDBGSYMBOL pSymInfo)
    6969{
    70     RTMemFree(pSymbol);
     70    RTMemFree(pSymInfo);
    7171}
    7272
  • trunk/src/VBox/Runtime/common/dbg/dbgmod.cpp

    r20799 r20800  
    399399 *
    400400 * @returns Image mapped size.
    401  *          UINTPTR_MAX is returned if the handle is invalid.
     401 *          RTUINTPTR_MAX is returned if the handle is invalid.
    402402 *
    403403 * @param   hDbgMod         The module handle.
     
    406406{
    407407    PRTDBGMODINT pDbgMod = hDbgMod;
    408     RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINTPTR_MAX);
     408    RTDBGMOD_VALID_RETURN_RC(pDbgMod, RTUINTPTR_MAX);
    409409    RTDBGMOD_LOCK(pDbgMod);
    410410
     
    535535 *
    536536 * @returns The segment size.
    537  *          UINTPTR_MAX is returned if either the handle and segment index are
     537 *          RTUINTPTR_MAX is returned if either the handle and segment index are
    538538 *          invalid.
    539539 *
     
    559559 *
    560560 * @returns The segment relative address.
    561  *          UINTPTR_MAX is returned if either the handle and segment index are
     561 *          RTUINTPTR_MAX is returned if either the handle and segment index are
    562562 *          invalid.
    563563 *
     
    574574
    575575
    576 
    577 
    578576/**
    579577 * Adds a line number to the module.
    580578 *
    581579 * @returns IPRT status code.
     580 * @retval  VERR_NOT_SUPPORTED if the module interpret doesn't support adding
     581 *          custom symbols. This is a common place occurance.
    582582 * @retval  VERR_INVALID_HANDLE if hDbgMod is invalid.
    583  * @retval  VERR_NOT_SUPPORTED if the module interpret doesn't support adding
    584  *          custom symbols.
    585  * @retval  VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE
    586  * @retval  VERR_DBG_INVALID_RVA
    587  * @retval  VERR_DBG_INVALID_SEGMENT_INDEX
    588  * @retval  VERR_DBG_INVALID_SEGMENT_OFFSET
    589  * @retval  VERR_INVALID_PARAMETER
     583 * @retval  VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
     584 *          short.
     585 * @retval  VERR_DBG_INVALID_RVA if an image relative address is specified and
     586 *          it's not inside any of the segments defined by the module.
     587 * @retval  VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
     588 * @retval  VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
     589 *          end of the segment.
     590 * @retval  VERR_DBG_ADDRESS_WRAP if off+cb wraps around.
     591 * @retval  VERR_INVALID_PARAMETER if the symbol flags sets undefined bits.
    590592 *
    591593 * @param   hDbgMod         The module handle.
     
    593595 * @param   iSeg            The segment index.
    594596 * @param   off             The segment offset.
    595  * @param   cb              The size of the symbol.
    596  * @param   fFlags          Symbol flags.
     597 * @param   cb              The size of the symbol. Can be zero, although this
     598 *                          may depend somewhat on the debug interpreter.
     599 * @param   fFlags          Symbol flags. Reserved for the future, MBZ.
    597600 * @param   piOrdinal       Where to return the symbol ordinal on success. If
    598601 *                          the interpreter doesn't do ordinals, this will be set to
    599  *                          UINT32_MAX. Optional
    600  */
    601 RTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal)
     602 *                          UINT32_MAX. Optional.
     603 */
     604RTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off,
     605                              RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal)
    602606{
    603607    /*
     
    615619                    ("%#x\n", iSeg),
    616620                    VERR_DBG_INVALID_SEGMENT_INDEX);
     621    AssertMsgReturn(off + cb >= off, ("off=%RTptr cb=%RTptr\n", off, cb), VERR_DBG_ADDRESS_WRAP);
    617622    AssertReturn(!fFlags, VERR_INVALID_PARAMETER); /* currently reserved. */
    618623
     
    642647
    643648
    644 RTDECL(uint32_t)    RTDbgModSymbolCount(RTDBGMOD hDbgMod)
    645 {
    646     return 1;
    647 }
    648 
    649 RTDECL(int)         RTDbgModSymbolByIndex(RTDBGMOD hDbgMod, uint32_t iSymbol, PRTDBGSYMBOL pSymbol)
    650 {
    651     return VERR_NOT_IMPLEMENTED;
    652 }
    653 
    654 RTDECL(int)         RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
    655 {
    656     return VERR_NOT_IMPLEMENTED;
    657 }
    658 
    659 RTDECL(int)         RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymbol)
    660 {
    661     return VERR_NOT_IMPLEMENTED;
    662 }
    663 
    664 RTDECL(int)         RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol)
    665 {
    666     return VERR_NOT_IMPLEMENTED;
    667 }
    668 
    669 RTDECL(int)         RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol)
    670 {
    671     return VERR_NOT_IMPLEMENTED;
     649/**
     650 * Gets the symbol count.
     651 *
     652 * This can be used together wtih RTDbgModSymbolByOrdinal or
     653 * RTDbgModSymbolByOrdinalA to enumerate all the symbols.
     654 *
     655 * @returns The number of symbols in the module.
     656 *          UINT32_MAX is returned if the module handle is invalid or some other
     657 *          error occurs.
     658 *
     659 * @param   hDbgMod             The module handle.
     660 */
     661RTDECL(uint32_t) RTDbgModSymbolCount(RTDBGMOD hDbgMod)
     662{
     663    PRTDBGMODINT pDbgMod = hDbgMod;
     664    RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX);
     665    RTDBGMOD_LOCK(pDbgMod);
     666
     667    uint32_t cSymbols = pDbgMod->pDbgVt->pfnSymbolCount(pDbgMod);
     668
     669    RTDBGMOD_UNLOCK(pDbgMod);
     670    return cSymbols;
     671}
     672
     673
     674/**
     675 * Queries symbol information by ordinal number.
     676 *
     677 * @returns IPRT status code.
     678 * @retval  VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number.
     679 * @retval  VERR_DBG_NO_SYMBOLS if there aren't any symbols.
     680 * @retval  VERR_INVALID_HANDLE if hDbgMod is invalid.
     681 * @retval  VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
     682 *
     683 * @param   hDbgMod             The module handle.
     684 * @param   iOrdinal            The symbol ordinal number. 0-based. The highest
     685 *                              number is RTDbgModSymbolCount() - 1.
     686 * @param   pSymInfo            Where to store the symbol information.
     687 */
     688RTDECL(int) RTDbgModSymbolByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
     689{
     690    PRTDBGMODINT pDbgMod = hDbgMod;
     691    RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
     692    RTDBGMOD_LOCK(pDbgMod);
     693
     694    int rc = pDbgMod->pDbgVt->pfnSymbolByOrdinal(pDbgMod, iOrdinal, pSymInfo);
     695
     696    RTDBGMOD_UNLOCK(pDbgMod);
     697    return rc;
     698}
     699
     700
     701/**
     702 * Queries symbol information by ordinal number.
     703 *
     704 * @returns IPRT status code.
     705 * @retval  VERR_DBG_NO_SYMBOLS if there aren't any symbols.
     706 * @retval  VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
     707 * @retval  VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number.
     708 * @retval  VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
     709 *
     710 * @param   hDbgMod             The module handle.
     711 * @param   iOrdinal            The symbol ordinal number. 0-based. The highest
     712 *                              number is RTDbgModSymbolCount() - 1.
     713 * @param   ppSymInfo           Where to store the pointer to the returned
     714 *                              symbol information. Always set. Free with
     715 *                              RTDbgSymbolFree.
     716 */
     717RTDECL(int) RTDbgModSymbolByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL *ppSymInfo)
     718{
     719    AssertPtr(ppSymInfo);
     720    *ppSymInfo = NULL;
     721
     722    PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc();
     723    if (!pSymInfo)
     724        return VERR_NO_MEMORY;
     725
     726    int rc = RTDbgModSymbolByOrdinal(hDbgMod, iOrdinal, pSymInfo);
     727
     728    if (RT_SUCCESS(rc))
     729        *ppSymInfo = pSymInfo;
     730    else
     731        RTDbgSymbolFree(pSymInfo);
     732    return rc;
     733}
     734
     735
     736/**
     737 * Queries symbol information by address.
     738 *
     739 * The returned symbol is what the debug info interpreter consideres the symbol
     740 * most applicable to the specified address. This usually means a symbol with an
     741 * address equal or lower than the requested.
     742 *
     743 * @returns IPRT status code.
     744 * @retval  VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
     745 * @retval  VERR_DBG_NO_SYMBOLS if there aren't any symbols.
     746 * @retval  VERR_INVALID_HANDLE if hDbgMod is invalid.
     747 * @retval  VERR_DBG_INVALID_RVA if an image relative address is specified and
     748 *          it's not inside any of the segments defined by the module.
     749 * @retval  VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
     750 * @retval  VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
     751 *          end of the segment.
     752 *
     753 * @param   pMod        Pointer to the module structure.
     754 * @param   iSeg        The segment number (0-based) or RTDBGSEGIDX_ABS.
     755 * @param   off         The offset into the segment.
     756 * @param   poffDisp    Where to store the distance between the specified address
     757 *                      and the returned symbol. Optional.
     758 * @param   pSymInfo    Where to store the symbol information.
     759 */
     760RTDECL(int) RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo)
     761{
     762    /*
     763     * Validate input.
     764     */
     765    PRTDBGMODINT pDbgMod = hDbgMod;
     766    RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX);
     767    AssertPtrNull(poffDisp);
     768    AssertPtr(pSymInfo);
     769
     770    RTDBGMOD_LOCK(pDbgMod);
     771
     772    /*
     773     * Convert RVAs.
     774     */
     775    if (iSeg == RTDBGSEGIDX_RVA)
     776    {
     777        iSeg = pDbgMod->pDbgVt->pfnRvaToSegOff(pDbgMod, off, &off);
     778        if (iSeg == NIL_RTDBGSEGIDX)
     779        {
     780            RTDBGMOD_UNLOCK(pDbgMod);
     781            return VERR_DBG_INVALID_RVA;
     782        }
     783    }
     784
     785    /*
     786     * Get down to business.
     787     */
     788    int rc = pDbgMod->pDbgVt->pfnSymbolByAddr(pDbgMod, iSeg, off, poffDisp, pSymInfo);
     789
     790    RTDBGMOD_UNLOCK(pDbgMod);
     791    return rc;
     792}
     793
     794
     795/**
     796 * Queries symbol information by address.
     797 *
     798 * The returned symbol is what the debug info interpreter consideres the symbol
     799 * most applicable to the specified address. This usually means a symbol with an
     800 * address equal or lower than the requested.
     801 *
     802 * @returns IPRT status code.
     803 * @retval  VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
     804 * @retval  VERR_DBG_NO_SYMBOLS if there aren't any symbols.
     805 * @retval  VERR_INVALID_HANDLE if hDbgMod is invalid.
     806 * @retval  VERR_DBG_INVALID_RVA if an image relative address is specified and
     807 *          it's not inside any of the segments defined by the module.
     808 * @retval  VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
     809 * @retval  VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
     810 *          end of the segment.
     811 * @retval  VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
     812 *
     813 * @param   hDbgMod             The module handle.
     814 * @param   iSeg                The segment index.
     815 * @param   off                 The offset into the segment.
     816 * @param   poffDisp            Where to store the distance between the
     817 *                              specified address and the returned symbol. Optional.
     818 * @param   ppSymInfo           Where to store the pointer to the returned
     819 *                              symbol information. Always set. Free with
     820 *                              RTDbgSymbolFree.
     821 */
     822RTDECL(int) RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo)
     823{
     824    AssertPtr(ppSymInfo);
     825    *ppSymInfo = NULL;
     826
     827    PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc();
     828    if (!pSymInfo)
     829        return VERR_NO_MEMORY;
     830
     831    int rc = RTDbgModSymbolByAddr(hDbgMod, iSeg, off, poffDisp, pSymInfo);
     832
     833    if (RT_SUCCESS(rc))
     834        *ppSymInfo = pSymInfo;
     835    else
     836        RTDbgSymbolFree(pSymInfo);
     837    return rc;
     838}
     839
     840
     841/**
     842 * Queries symbol information by symbol name.
     843 *
     844 * @returns IPRT status code.
     845 * @retval  VERR_DBG_NO_SYMBOLS if there aren't any symbols.
     846 * @retval  VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
     847 * @retval  VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
     848 *          short.
     849 *
     850 * @param   hDbgMod             The module handle.
     851 * @param   pszSymbol           The symbol name.
     852 * @param   pSymInfo            Where to store the symbol information.
     853 */
     854RTDECL(int) RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymInfo)
     855{
     856    /*
     857     * Validate input.
     858     */
     859    PRTDBGMODINT pDbgMod = hDbgMod;
     860    RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX);
     861    AssertPtr(pszSymbol);
     862    size_t cchSymbol = strlen(pszSymbol);
     863    AssertReturn(cchSymbol, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE);
     864    AssertReturn(cchSymbol < RTDBG_SYMBOL_NAME_LENGTH, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE);
     865    AssertPtr(pSymInfo);
     866
     867    /*
     868     * Make the query.
     869     */
     870    RTDBGMOD_LOCK(pDbgMod);
     871    int rc = pDbgMod->pDbgVt->pfnSymbolByName(pDbgMod, pszSymbol, cchSymbol, pSymInfo);
     872    RTDBGMOD_UNLOCK(pDbgMod);
     873
     874    return rc;
     875}
     876
     877
     878/**
     879 * Queries symbol information by symbol name.
     880 *
     881 * @returns IPRT status code.
     882 * @retval  VERR_DBG_NO_SYMBOLS if there aren't any symbols.
     883 * @retval  VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
     884 * @retval  VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
     885 *          short.
     886 *
     887 * @retval  VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
     888 * @param   hDbgMod             The module handle.
     889 * @param   pszSymbol           The symbol name.
     890 * @param   ppSymInfo           Where to store the pointer to the returned
     891 *                              symbol information. Always set. Free with
     892 *                              RTDbgSymbolFree.
     893 */
     894RTDECL(int) RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymInfo)
     895{
     896    AssertPtr(ppSymInfo);
     897    *ppSymInfo = NULL;
     898
     899    PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc();
     900    if (!pSymInfo)
     901        return VERR_NO_MEMORY;
     902
     903    int rc = RTDbgModSymbolByName(hDbgMod, pszSymbol, pSymInfo);
     904
     905    if (RT_SUCCESS(rc))
     906        *ppSymInfo = pSymInfo;
     907    else
     908        RTDbgSymbolFree(pSymInfo);
     909    return rc;
    672910}
    673911
  • trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp

    r20799 r20800  
    262262/** @copydoc RTDBGMODVTDBG::pfnSymbolByAddr */
    263263static DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off,
    264                                                         PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
     264                                                        PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo)
    265265{
    266266    PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
     
    291291    if (poffDisp)
    292292        *poffDisp = off - pMySym->AddrCore.Key;
    293     return rtDbgModContainerReturnSymbol(pMySym, pSymbol);
     293    return rtDbgModContainerReturnSymbol(pMySym, pSymInfo);
    294294}
    295295
    296296
    297297/** @copydoc RTDBGMODVTDBG::pfnSymbolByName */
    298 static DECLCALLBACK(int) rtDbgModContainer_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol)
    299 {
    300     PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
     298static DECLCALLBACK(int) rtDbgModContainer_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol, PRTDBGSYMBOL pSymInfo)
     299{
     300    PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
     301    NOREF(cchSymbol);
    301302
    302303    /*
     
    307308        return VERR_SYMBOL_NOT_FOUND;
    308309    PCRTDBGMODCTNSYMBOL pMySym = RT_FROM_MEMBER(pStrCore, RTDBGMODCTNSYMBOL const, NameCore);
    309     return rtDbgModContainerReturnSymbol(pMySym, pSymbol);
     310    return rtDbgModContainerReturnSymbol(pMySym, pSymInfo);
    310311}
    311312
    312313
    313314/** @copydoc RTDBGMODVTDBG::pfnSymbolByOrdinal */
    314 static DECLCALLBACK(int) rtDbgModContainer_SymbolByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymbol)
     315static DECLCALLBACK(int) rtDbgModContainer_SymbolByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
    315316{
    316317    PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
     
    326327    AssertReturn(pAvlCore, VERR_SYMBOL_NOT_FOUND);
    327328    PCRTDBGMODCTNSYMBOL pMySym = RT_FROM_MEMBER(pAvlCore, RTDBGMODCTNSYMBOL const, OrdinalCore);
    328     return rtDbgModContainerReturnSymbol(pMySym, pSymbol);
     329    return rtDbgModContainerReturnSymbol(pMySym, pSymInfo);
    329330}
    330331
  • trunk/src/VBox/Runtime/include/internal/dbgmod.h

    r20799 r20800  
    254254     *
    255255     * @param   pMod        Pointer to the module structure.
    256      * @param   iSymbol     The symbol ordinal number.
    257      * @param   pSymbol     Where to store the symbol information.
    258      */
    259     DECLCALLBACKMEMBER(int, pfnSymbolByOrdinal)(PRTDBGMODINT pMod, uint32_t iSymbol, PRTDBGSYMBOL pSymbol);
     256     * @param   iOrdinal    The symbol ordinal number.
     257     * @param   pSymInfo    Where to store the symbol information.
     258     */
     259    DECLCALLBACKMEMBER(int, pfnSymbolByOrdinal)(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo);
    260260
    261261    /**
     
    269269     * @param   pMod        Pointer to the module structure.
    270270     * @param   pszSymbol   The symbol name.
    271      * @para    pSymbol     Where to store the symbol information.
    272      */
    273     DECLCALLBACKMEMBER(int, pfnSymbolByName)(PRTDBGMODINT pMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol);
     271     * @param   cchSymbol   The length of the symbol name.
     272     * @param   pSymInfo    Where to store the symbol information.
     273     */
     274    DECLCALLBACKMEMBER(int, pfnSymbolByName)(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol, PRTDBGSYMBOL pSymInfo);
    274275
    275276    /**
     
    290291     * @param   poffDisp    Where to store the distance between the specified address
    291292     *                      and the returned symbol. Optional.
    292      * @param   pSymbol     Where to store the symbol information.
    293      */
    294     DECLCALLBACKMEMBER(int, pfnSymbolByAddr)(PRTDBGMODINT pMod, uint32_t iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymbol);
     293     * @param   pSymInfo    Where to store the symbol information.
     294     */
     295    DECLCALLBACKMEMBER(int, pfnSymbolByAddr)(PRTDBGMODINT pMod, uint32_t iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo);
    295296
    296297
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