dbgmod.cpp revision aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * IPRT - Debug Module Interpreter.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * available from http://www.virtualbox.org. This file is free software;
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * General Public License (GPL) as published by the Free Software
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * The contents of this file may alternatively be used under the terms
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * of the Common Development and Distribution License Version 1.0
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * VirtualBox OSE distribution, in which case the provisions of the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * CDDL are applicable instead of those of the GPL.
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * You may elect to license modified versions of this file under the
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * terms and conditions of either the GPL or the CDDL or both.
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * additional information or have any questions.
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/*******************************************************************************
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync* Header Files *
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync*******************************************************************************/
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/*******************************************************************************
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync* Structures and Typedefs *
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync*******************************************************************************/
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/** Debug info interpreter regisration record. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync /** Pointer to the next record. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync /** Pointer to the virtual function table for the interpreter. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync /** Usage counter. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/** Image interpreter regisration record. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync /** Pointer to the next record. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync /** Pointer to the virtual function table for the interpreter. */
65697a26b524640b83828b715160c798c43a0424vboxsync /** Usage counter. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/*******************************************************************************
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync* Defined Constants And Macros *
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync*******************************************************************************/
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/** Validates a debug module handle and returns rc if not valid. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync AssertReturn((pDbgMod)->u32Magic == RTDBGMOD_MAGIC, (rc)); \
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync } while (0)
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync/** Locks the debug module. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync int rcLock = RTCritSectEnter(&(pDbgMod)->CritSect); \
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync } while (0)
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/** Unlocks the debug module. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync int rcLock = RTCritSectLeave(&(pDbgMod)->CritSect); \
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync } while (0)
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/*******************************************************************************
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync* Global Variables *
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync*******************************************************************************/
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/** Init once object for lazy registration of the built-in image and debug
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync * info interpreters. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/** Read/Write semaphore protecting the list of registered interpreters. */
a4ba1fc5788b1fb4c078587d5f55936e1b83098dvboxsync/** List of registered image interpreters. */
static DECLCALLBACK(void) rtDbgModTermCallback(RTTERMREASON enmReason, int32_t iStatus, void *pvUser)
while (pCur)
return VERR_ALREADY_EXISTS;
return VERR_ALREADY_EXISTS;
if (!pReg)
return VERR_NO_MEMORY;
if (pPrev)
return VINF_SUCCESS;
return VINF_SUCCESS;
return rc;
RTDECL(int) RTDbgModCreate(PRTDBGMOD phDbgMod, const char *pszName, RTUINTPTR cbSeg, uint32_t fFlags)
return rc;
if (!pDbgMod)
return VERR_NO_MEMORY;
return rc;
return rc;
RTDECL(int) RTDbgModCreateDeferred(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTUINTPTR cb, uint32_t fFlags)
return VERR_NOT_IMPLEMENTED;
RTDECL(int) RTDbgModCreateFromImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t fFlags)
return VERR_NOT_IMPLEMENTED;
RTDECL(int) RTDbgModCreateFromMap(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTUINTPTR uSubtrahend, uint32_t fFlags)
return rc;
if (!pszName)
if (!pDbgMod)
return VERR_NO_MEMORY;
return rc;
return rc;
if (!cRefs)
return cRefs;
return iSeg;
return cbImage;
AssertMsgReturn(!piSeg || *piSeg == NIL_RTDBGSEGIDX || *piSeg <= RTDBGSEGIDX_LAST, ("%#x\n", *piSeg), VERR_DBG_SPECIAL_SEGMENT);
return rc;
return cSegs;
return rc;
RTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off,
return VERR_DBG_INVALID_RVA;
int rc = pDbgMod->pDbgVt->pfnSymbolAdd(pDbgMod, pszSymbol, cchSymbol, iSeg, off, cb, fFlags, piOrdinal);
return rc;
return cSymbols;
return rc;
if (!pSymInfo)
return VERR_NO_MEMORY;
return rc;
RTDECL(int) RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo)
return VERR_DBG_INVALID_RVA;
return rc;
RTDECL(int) RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo)
if (!pSymInfo)
return VERR_NO_MEMORY;
return rc;
return rc;
if (!pSymInfo)
return VERR_NO_MEMORY;
return rc;
return VERR_DBG_INVALID_RVA;
return rc;
return cLineNumbers;
return rc;
if (!pLineInfo)
return VERR_NO_MEMORY;
return rc;
RTDECL(int) RTDbgModLineByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE pLineInfo)
return VERR_DBG_INVALID_RVA;
return rc;
RTDECL(int) RTDbgModLineByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE *ppLineInfo)
if (!pLineInfo)
return VERR_NO_MEMORY;
return rc;