dbgmod.cpp revision b7a07b07543924f45c1fffd2f90de582038b8ba6
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync/* $Id$ */
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync/** @file
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * IPRT - Debug Module Interpreter.
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync */
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2009-2012 Oracle Corporation
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync *
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * available from http://www.virtualbox.org. This file is free software;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * General Public License (GPL) as published by the Free Software
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync *
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * The contents of this file may alternatively be used under the terms
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * of the Common Development and Distribution License Version 1.0
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * VirtualBox OSE distribution, in which case the provisions of the
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * CDDL are applicable instead of those of the GPL.
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync *
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * You may elect to license modified versions of this file under the
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync * terms and conditions of either the GPL or the CDDL or both.
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync */
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync/*******************************************************************************
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync* Header Files *
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync*******************************************************************************/
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include <iprt/dbg.h>
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync#include "internal/iprt.h"
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include <iprt/asm.h>
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#include <iprt/assert.h>
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include <iprt/avl.h>
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include <iprt/err.h>
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#include <iprt/initterm.h>
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#include <iprt/mem.h>
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#include <iprt/once.h>
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include <iprt/param.h>
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync#include <iprt/path.h>
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#include <iprt/semaphore.h>
7af218a7441de38fc9e814919db04bae3e917664vboxsync#include <iprt/strcache.h>
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#include <iprt/string.h>
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include "internal/dbgmod.h"
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include "internal/magics.h"
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/*******************************************************************************
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync* Structures and Typedefs *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync*******************************************************************************/
1c822ec4298d5d20b0fb1cc20346c5d4e4e596bfvboxsync/** Debug info interpreter registration record. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsynctypedef struct RTDBGMODREGDBG
9939c713bffcfc4305d99d994552aa2ad9bce097vboxsync{
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /** Pointer to the next record. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync struct RTDBGMODREGDBG *pNext;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /** Pointer to the virtual function table for the interpreter. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync PCRTDBGMODVTDBG pVt;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /** Usage counter. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync uint32_t volatile cUsers;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync} RTDBGMODREGDBG;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsynctypedef RTDBGMODREGDBG *PRTDBGMODREGDBG;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
1c822ec4298d5d20b0fb1cc20346c5d4e4e596bfvboxsync/** Image interpreter registration record. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsynctypedef struct RTDBGMODREGIMG
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync{
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /** Pointer to the next record. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync struct RTDBGMODREGIMG *pNext;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /** Pointer to the virtual function table for the interpreter. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync PCRTDBGMODVTIMG pVt;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /** Usage counter. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync uint32_t volatile cUsers;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync} RTDBGMODREGIMG;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsynctypedef RTDBGMODREGIMG *PRTDBGMODREGIMG;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/*******************************************************************************
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync* Defined Constants And Macros *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync*******************************************************************************/
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** Validates a debug module handle and returns rc if not valid. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#define RTDBGMOD_VALID_RETURN_RC(pDbgMod, rc) \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync do { \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertPtrReturn((pDbgMod), (rc)); \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertReturn((pDbgMod)->u32Magic == RTDBGMOD_MAGIC, (rc)); \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertReturn((pDbgMod)->cRefs > 0, (rc)); \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync } while (0)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** Locks the debug module. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#define RTDBGMOD_LOCK(pDbgMod) \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync do { \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync int rcLock = RTCritSectEnter(&(pDbgMod)->CritSect); \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertRC(rcLock); \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync } while (0)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** Unlocks the debug module. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync#define RTDBGMOD_UNLOCK(pDbgMod) \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync do { \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync int rcLock = RTCritSectLeave(&(pDbgMod)->CritSect); \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertRC(rcLock); \
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync } while (0)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/*******************************************************************************
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync* Global Variables *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync*******************************************************************************/
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** Init once object for lazy registration of the built-in image and debug
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * info interpreters. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsyncstatic RTONCE g_rtDbgModOnce = RTONCE_INITIALIZER;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** Read/Write semaphore protecting the list of registered interpreters. */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsyncstatic RTSEMRW g_hDbgModRWSem = NIL_RTSEMRW;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** List of registered image interpreters. */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsyncstatic PRTDBGMODREGIMG g_pImgHead;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** List of registered debug infor interpreters. */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsyncstatic PRTDBGMODREGDBG g_pDbgHead;
7af218a7441de38fc9e814919db04bae3e917664vboxsync/** String cache for the debug info interpreters.
7af218a7441de38fc9e814919db04bae3e917664vboxsync * RTSTRCACHE is thread safe. */
7af218a7441de38fc9e814919db04bae3e917664vboxsyncDECLHIDDEN(RTSTRCACHE) g_hDbgModStrCache = NIL_RTSTRCACHE;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
7af218a7441de38fc9e814919db04bae3e917664vboxsync/**
7af218a7441de38fc9e814919db04bae3e917664vboxsync * Cleanup debug info interpreter globals.
7af218a7441de38fc9e814919db04bae3e917664vboxsync *
7af218a7441de38fc9e814919db04bae3e917664vboxsync * @param enmReason The cause of the termination.
7af218a7441de38fc9e814919db04bae3e917664vboxsync * @param iStatus The meaning of this depends on enmReason.
7af218a7441de38fc9e814919db04bae3e917664vboxsync * @param pvUser User argument, unused.
7af218a7441de38fc9e814919db04bae3e917664vboxsync */
7af218a7441de38fc9e814919db04bae3e917664vboxsyncstatic DECLCALLBACK(void) rtDbgModTermCallback(RTTERMREASON enmReason, int32_t iStatus, void *pvUser)
7af218a7441de38fc9e814919db04bae3e917664vboxsync{
4e47bb772df0d04d1ded3e06354de547d52e2d06vboxsync NOREF(iStatus); NOREF(pvUser);
7af218a7441de38fc9e814919db04bae3e917664vboxsync if (enmReason == RTTERMREASON_UNLOAD)
7af218a7441de38fc9e814919db04bae3e917664vboxsync {
7af218a7441de38fc9e814919db04bae3e917664vboxsync RTSemRWDestroy(g_hDbgModRWSem);
7af218a7441de38fc9e814919db04bae3e917664vboxsync g_hDbgModRWSem = NIL_RTSEMRW;
7af218a7441de38fc9e814919db04bae3e917664vboxsync
7af218a7441de38fc9e814919db04bae3e917664vboxsync RTStrCacheDestroy(g_hDbgModStrCache);
7af218a7441de38fc9e814919db04bae3e917664vboxsync g_hDbgModStrCache = NIL_RTSTRCACHE;
7af218a7441de38fc9e814919db04bae3e917664vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODREGDBG pDbg = g_pDbgHead;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync g_pDbgHead = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync while (pDbg)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODREGDBG pNext = pDbg->pNext;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync AssertMsg(pDbg->cUsers == 0, ("%#x %s\n", pDbg->cUsers, pDbg->pVt->pszName));
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTMemFree(pDbg);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbg = pNext;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODREGIMG pImg = g_pImgHead;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync g_pImgHead = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync while (pImg)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODREGIMG pNext = pImg->pNext;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync AssertMsg(pImg->cUsers == 0, ("%#x %s\n", pImg->cUsers, pImg->pVt->pszName));
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTMemFree(pImg);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pImg = pNext;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync}
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync/**
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * Internal worker for register a debug interpreter.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync *
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * Called while owning the write lock or when locking isn't required.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync *
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * @returns IPRT status code.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * @retval VERR_NO_MEMORY
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * @retval VERR_ALREADY_EXISTS
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync *
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * @param pVt The virtual function table of the debug
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * module interpreter.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsyncstatic int rtDbgModDebugInterpreterRegister(PCRTDBGMODVTDBG pVt)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync{
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync /*
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * Search or duplicate registration.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync PRTDBGMODREGDBG pPrev = NULL;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync for (PRTDBGMODREGDBG pCur = g_pDbgHead; pCur; pCur = pCur->pNext)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (pCur->pVt == pVt)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return VERR_ALREADY_EXISTS;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (!strcmp(pCur->pVt->pszName, pVt->pszName))
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return VERR_ALREADY_EXISTS;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pPrev = pCur;
7af218a7441de38fc9e814919db04bae3e917664vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync /*
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * Create a new record and add it to the end of the list.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync PRTDBGMODREGDBG pReg = (PRTDBGMODREGDBG)RTMemAlloc(sizeof(*pReg));
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (!pReg)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return VERR_NO_MEMORY;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pReg->pVt = pVt;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pReg->cUsers = 0;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pReg->pNext = NULL;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (pPrev)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pPrev->pNext = pReg;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync else
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync g_pDbgHead = pReg;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return VINF_SUCCESS;
7af218a7441de38fc9e814919db04bae3e917664vboxsync}
7af218a7441de38fc9e814919db04bae3e917664vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync/**
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Internal worker for register a image interpreter.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync *
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Called while owning the write lock or when locking isn't required.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync *
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * @returns IPRT status code.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * @retval VERR_NO_MEMORY
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * @retval VERR_ALREADY_EXISTS
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync *
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * @param pVt The virtual function table of the image
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * interpreter.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsyncstatic int rtDbgModImageInterpreterRegister(PCRTDBGMODVTIMG pVt)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync{
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Search or duplicate registration.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODREGIMG pPrev = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync for (PRTDBGMODREGIMG pCur = g_pImgHead; pCur; pCur = pCur->pNext)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (pCur->pVt == pVt)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return VERR_ALREADY_EXISTS;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (!strcmp(pCur->pVt->pszName, pVt->pszName))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return VERR_ALREADY_EXISTS;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pPrev = pCur;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Create a new record and add it to the end of the list.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODREGIMG pReg = (PRTDBGMODREGIMG)RTMemAlloc(sizeof(*pReg));
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (!pReg)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return VERR_NO_MEMORY;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pReg->pVt = pVt;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pReg->cUsers = 0;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pReg->pNext = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (pPrev)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pPrev->pNext = pReg;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync else
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync g_pImgHead = pReg;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return VINF_SUCCESS;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync}
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/**
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Do-once callback that initializes the read/write semaphore and registers
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * the built-in interpreters.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @returns IPRT status code.
a438caaf732f7839dc66b4f8dad672527845a003vboxsync * @param pvUser NULL.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
a438caaf732f7839dc66b4f8dad672527845a003vboxsyncstatic DECLCALLBACK(int) rtDbgModInitOnce(void *pvUser)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync{
a438caaf732f7839dc66b4f8dad672527845a003vboxsync NOREF(pvUser);
4e47bb772df0d04d1ded3e06354de547d52e2d06vboxsync
7af218a7441de38fc9e814919db04bae3e917664vboxsync /*
7af218a7441de38fc9e814919db04bae3e917664vboxsync * Create the semaphore and string cache.
7af218a7441de38fc9e814919db04bae3e917664vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync int rc = RTSemRWCreate(&g_hDbgModRWSem);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertRCReturn(rc, rc);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
7af218a7441de38fc9e814919db04bae3e917664vboxsync rc = RTStrCacheCreate(&g_hDbgModStrCache, "RTDBGMOD");
7af218a7441de38fc9e814919db04bae3e917664vboxsync if (RT_SUCCESS(rc))
7af218a7441de38fc9e814919db04bae3e917664vboxsync {
7af218a7441de38fc9e814919db04bae3e917664vboxsync /*
7af218a7441de38fc9e814919db04bae3e917664vboxsync * Register the interpreters.
7af218a7441de38fc9e814919db04bae3e917664vboxsync */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync rc = rtDbgModDebugInterpreterRegister(&g_rtDbgModVtDbgNm);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_SUCCESS(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = rtDbgModDebugInterpreterRegister(&g_rtDbgModVtDbgDwarf);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_SUCCESS(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = rtDbgModImageInterpreterRegister(&g_rtDbgModVtImgLdr);
7af218a7441de38fc9e814919db04bae3e917664vboxsync if (RT_SUCCESS(rc))
7af218a7441de38fc9e814919db04bae3e917664vboxsync {
7af218a7441de38fc9e814919db04bae3e917664vboxsync /*
7af218a7441de38fc9e814919db04bae3e917664vboxsync * Finally, register the IPRT cleanup callback.
7af218a7441de38fc9e814919db04bae3e917664vboxsync */
7af218a7441de38fc9e814919db04bae3e917664vboxsync rc = RTTermRegisterCallback(rtDbgModTermCallback, NULL);
7af218a7441de38fc9e814919db04bae3e917664vboxsync if (RT_SUCCESS(rc))
7af218a7441de38fc9e814919db04bae3e917664vboxsync return VINF_SUCCESS;
7af218a7441de38fc9e814919db04bae3e917664vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync /* bail out: use the termination callback. */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
7af218a7441de38fc9e814919db04bae3e917664vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync else
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync g_hDbgModStrCache = NIL_RTSTRCACHE;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync rtDbgModTermCallback(RTTERMREASON_UNLOAD, 0, NULL);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return rc;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync}
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsyncDECLINLINE(int) rtDbgModLazyInit(void)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync{
a438caaf732f7839dc66b4f8dad672527845a003vboxsync return RTOnce(&g_rtDbgModOnce, rtDbgModInitOnce, NULL);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync}
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
20593760b116c90f3e439552763eef632a3bbb17vboxsync/**
20593760b116c90f3e439552763eef632a3bbb17vboxsync * Creates a module based on the default debug info container.
20593760b116c90f3e439552763eef632a3bbb17vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * This can be used to manually load a module and its symbol. The primary user
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * group is the debug info interpreters, which use this API to create an
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * efficient debug info container behind the scenes and forward all queries to
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * it once the info has been loaded.
20593760b116c90f3e439552763eef632a3bbb17vboxsync *
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @returns IPRT status code.
20593760b116c90f3e439552763eef632a3bbb17vboxsync *
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param phDbgMod Where to return the module handle.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pszName The name of the module (mandatory).
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param cbSeg The size of initial segment. If zero, segments will
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * have to be added manually using RTDbgModSegmentAdd.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param fFlags Flags reserved for future extensions, MBZ for now.
20593760b116c90f3e439552763eef632a3bbb17vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncRTDECL(int) RTDbgModCreate(PRTDBGMOD phDbgMod, const char *pszName, RTUINTPTR cbSeg, uint32_t fFlags)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync{
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Input validation and lazy initialization.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertPtrReturn(phDbgMod, VERR_INVALID_POINTER);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *phDbgMod = NIL_RTDBGMOD;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertPtrReturn(pszName, VERR_INVALID_POINTER);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertReturn(*pszName, VERR_INVALID_PARAMETER);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync int rc = rtDbgModLazyInit();
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (RT_FAILURE(rc))
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return rc;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Allocate a new module instance.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgMod));
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (!pDbgMod)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return VERR_NO_MEMORY;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync pDbgMod->u32Magic = RTDBGMOD_MAGIC;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync pDbgMod->cRefs = 1;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync rc = RTCritSectInit(&pDbgMod->CritSect);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (RT_SUCCESS(rc))
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync {
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync pDbgMod->pszName = RTStrCacheEnter(g_hDbgModStrCache, pszName);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (pDbgMod->pszName)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync {
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync rc = rtDbgModContainerCreate(pDbgMod, cbSeg);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (RT_SUCCESS(rc))
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync {
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *phDbgMod = pDbgMod;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return rc;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync }
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync }
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTCritSectDelete(&pDbgMod->CritSect);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync }
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTMemFree(pDbgMod);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return rc;
9939c713bffcfc4305d99d994552aa2ad9bce097vboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModCreate);
9939c713bffcfc4305d99d994552aa2ad9bce097vboxsync
db55f7b1060a6a72704b5369a8e776c59e5e4f64vboxsync
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsyncRTDECL(int) RTDbgModCreateFromImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTDBGCFG hDbgCfg)
9939c713bffcfc4305d99d994552aa2ad9bce097vboxsync{
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Input validation and lazy initialization.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync AssertPtrReturn(phDbgMod, VERR_INVALID_POINTER);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync *phDbgMod = NIL_RTDBGMOD;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync AssertReturn(*pszFilename, VERR_INVALID_PARAMETER);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync AssertPtrNullReturn(pszName, VERR_INVALID_POINTER);
1c822ec4298d5d20b0fb1cc20346c5d4e4e596bfvboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync int rc = rtDbgModLazyInit();
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_FAILURE(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return rc;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (!pszName)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pszName = RTPathFilename(pszFilename);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Allocate a new module instance.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgMod));
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (!pDbgMod)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return VERR_NO_MEMORY;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->u32Magic = RTDBGMOD_MAGIC;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->cRefs = 1;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = RTCritSectInit(&pDbgMod->CritSect);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_SUCCESS(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pszName = RTStrCacheEnter(g_hDbgModStrCache, pszName);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (pDbgMod->pszName)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pszImgFile = RTStrCacheEnter(g_hDbgModStrCache, pszFilename);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (pDbgMod->pszImgFile)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Find an image reader which groks the file.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = RTSemRWRequestRead(g_hDbgModRWSem, RT_INDEFINITE_WAIT);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_SUCCESS(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = VERR_DBG_NO_MATCHING_INTERPRETER;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync PRTDBGMODREGIMG pImg;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync for (pImg = g_pImgHead; pImg; pImg = pImg->pNext)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pImgVt = pImg->pVt;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pvImgPriv = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = pImg->pVt->pfnTryOpen(pDbgMod);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_SUCCESS(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Find a debug info interpreter.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = VERR_DBG_NO_MATCHING_INTERPRETER;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync for (PRTDBGMODREGDBG pDbg = g_pDbgHead; pDbg; pDbg = pDbg->pNext)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pDbgVt = pDbg->pVt;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pvDbgPriv = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = pDbg->pVt->pfnTryOpen(pDbgMod);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_SUCCESS(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * That's it!
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync ASMAtomicIncU32(&pDbg->cUsers);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync ASMAtomicIncU32(&pImg->cUsers);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync *phDbgMod = pDbgMod;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return rc;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Image detected, but found no debug info we were
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * able to understand.
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /** @todo Fall back on exported symbols! */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pImgVt->pfnClose(pDbgMod);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync break;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * Could it be a file containing raw debug info?
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (!pImg)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pImgVt = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pvImgPriv = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pszDbgFile = pDbgMod->pszImgFile;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pszImgFile = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync for (PRTDBGMODREGDBG pDbg = g_pDbgHead; pDbg; pDbg = pDbg->pNext)
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pDbgVt = pDbg->pVt;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pvDbgPriv = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync rc = pDbg->pVt->pfnTryOpen(pDbgMod);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync if (RT_SUCCESS(rc))
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync {
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /*
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync * That's it!
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync ASMAtomicIncU32(&pDbg->cUsers);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync *phDbgMod = pDbgMod;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return rc;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pszImgFile = pDbgMod->pszDbgFile;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync pDbgMod->pszDbgFile = NULL;
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync /* bail out */
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFile);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTCritSectDelete(&pDbgMod->CritSect);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync }
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync RTMemFree(pDbgMod);
c58c758d3642ac45d3f12356c406c631fcd8f538vboxsync return rc;
9939c713bffcfc4305d99d994552aa2ad9bce097vboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModCreateFromImage);
9939c713bffcfc4305d99d994552aa2ad9bce097vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync
4e47bb772df0d04d1ded3e06354de547d52e2d06vboxsyncRTDECL(int) RTDbgModCreateFromMap(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName,
b7a07b07543924f45c1fffd2f90de582038b8ba6vboxsync RTUINTPTR uSubtrahend, RTDBGCFG hDbgCfg)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync /*
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * Input validation and lazy initialization.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync AssertPtrReturn(phDbgMod, VERR_INVALID_POINTER);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync *phDbgMod = NIL_RTDBGMOD;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync AssertReturn(*pszFilename, VERR_INVALID_PARAMETER);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync AssertPtrNullReturn(pszName, VERR_INVALID_POINTER);
4e47bb772df0d04d1ded3e06354de547d52e2d06vboxsync AssertReturn(uSubtrahend == 0, VERR_NOT_IMPLEMENTED); /** @todo implement uSubtrahend. */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync int rc = rtDbgModLazyInit();
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (RT_FAILURE(rc))
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return rc;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (!pszName)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pszName = RTPathFilename(pszFilename);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync /*
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * Allocate a new module instance.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgMod));
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (!pDbgMod)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return VERR_NO_MEMORY;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pDbgMod->u32Magic = RTDBGMOD_MAGIC;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pDbgMod->cRefs = 1;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync rc = RTCritSectInit(&pDbgMod->CritSect);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (RT_SUCCESS(rc))
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pDbgMod->pszName = RTStrCacheEnter(g_hDbgModStrCache, pszName);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (pDbgMod->pszName)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pDbgMod->pszDbgFile = RTStrCacheEnter(g_hDbgModStrCache, pszFilename);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (pDbgMod->pszDbgFile)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync /*
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync * Try the map file readers.
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync rc = RTSemRWRequestRead(g_hDbgModRWSem, RT_INDEFINITE_WAIT);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (RT_SUCCESS(rc))
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync rc = VERR_DBG_NO_MATCHING_INTERPRETER;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync for (PRTDBGMODREGDBG pCur = g_pDbgHead; pCur; pCur = pCur->pNext)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (pCur->pVt->fSupports & RT_DBGTYPE_MAP)
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pDbgMod->pDbgVt = pCur->pVt;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync pDbgMod->pvDbgPriv = NULL;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync rc = pCur->pVt->pfnTryOpen(pDbgMod);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync if (RT_SUCCESS(rc))
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync {
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync ASMAtomicIncU32(&pCur->cUsers);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync *phDbgMod = pDbgMod;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return rc;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync /* bail out */
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTCritSectDelete(&pDbgMod->CritSect);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTMemFree(pDbgMod);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModCreateFromMap);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/**
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Destroys an module after the reference count has reached zero.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @param pDbgMod The module instance.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncstatic void rtDbgModDestroy(PRTDBGMODINT pDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Close the debug info interpreter first, then the image interpret.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTCritSectEnter(&pDbgMod->CritSect); /* paranoia */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (pDbgMod->pDbgVt)
de6e321f351aa489a6a62bed474390a0056e8093vboxsync {
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync pDbgMod->pDbgVt->pfnClose(pDbgMod);
de6e321f351aa489a6a62bed474390a0056e8093vboxsync pDbgMod->pDbgVt = NULL;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync pDbgMod->pvDbgPriv = NULL;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync }
de6e321f351aa489a6a62bed474390a0056e8093vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (pDbgMod->pImgVt)
de6e321f351aa489a6a62bed474390a0056e8093vboxsync {
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync pDbgMod->pImgVt->pfnClose(pDbgMod);
de6e321f351aa489a6a62bed474390a0056e8093vboxsync pDbgMod->pImgVt = NULL;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync pDbgMod->pvImgPriv = NULL;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync }
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Free the resources.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync ASMAtomicWriteU32(&pDbgMod->u32Magic, ~RTDBGMOD_MAGIC);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFile);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTCritSectLeave(&pDbgMod->CritSect); /* paranoia */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTCritSectDelete(&pDbgMod->CritSect);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTMemFree(pDbgMod);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/**
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Retains another reference to the module.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @returns New reference count, UINT32_MAX on invalid handle (asserted).
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @param hDbgMod The module handle.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @remarks Will not take any locks.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsyncRTDECL(uint32_t) RTDbgModRetain(RTDBGMOD hDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return ASMAtomicIncU32(&pDbgMod->cRefs);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModRetain);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/**
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Release a reference to the module.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * When the reference count reaches zero, the module is destroyed.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @returns New reference count, UINT32_MAX on invalid handle (asserted).
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @param hDbgMod The module handle. The NIL handle is quietly ignored
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * and 0 is returned.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @remarks Will not take any locks.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsyncRTDECL(uint32_t) RTDbgModRelease(RTDBGMOD hDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (hDbgMod == NIL_RTDBGMOD)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return 0;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync uint32_t cRefs = ASMAtomicDecU32(&pDbgMod->cRefs);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (!cRefs)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync rtDbgModDestroy(pDbgMod);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return cRefs;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModRelease);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/**
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * Gets the module name.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync * @returns Pointer to a read only string containing the name.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync */
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsyncRTDECL(const char *) RTDbgModName(RTDBGMOD hDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, NULL);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return pDbgMod->pszName;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModName);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync/**
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Converts an image relative address to a segment:offset address.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @returns Segment index on success.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * NIL_RTDBGSEGIDX is returned if the module handle or the RVA are
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * invalid.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param uRva The image relative address to convert.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param poffSeg Where to return the segment offset. Optional.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncRTDECL(RTDBGSEGIDX) RTDbgModRvaToSegOff(RTDBGMOD hDbgMod, RTUINTPTR uRva, PRTUINTPTR poffSeg)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, NIL_RTDBGSEGIDX);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_LOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGSEGIDX iSeg = pDbgMod->pDbgVt->pfnRvaToSegOff(pDbgMod, uRva, poffSeg);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_UNLOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync return iSeg;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModRvaToSegOff);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync/**
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * Image size when mapped if segments are mapped adjacently.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * For ELF, PE, and Mach-O images this is (usually) a natural query, for LX and
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * NE and such it's a bit odder and the answer may not make much sense for them.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @returns Image mapped size.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * RTUINTPTR_MAX is returned if the handle is invalid.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncRTDECL(RTUINTPTR) RTDbgModImageSize(RTDBGMOD hDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, RTUINTPTR_MAX);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_LOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTUINTPTR cbImage = pDbgMod->pDbgVt->pfnImageSize(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_UNLOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync return cbImage;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModImageSize);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync/**
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * Gets the module tag value if any.
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync *
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * @returns The tag. 0 if hDbgMod is invalid.
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync *
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * @param hDbgMod The module handle.
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync */
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsyncRTDECL(uint64_t) RTDbgModGetTag(RTDBGMOD hDbgMod)
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync{
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync PRTDBGMODINT pDbgMod = hDbgMod;
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, 0);
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync return pDbgMod->uTag;
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync}
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsyncRT_EXPORT_SYMBOL(RTDbgModGetTag);
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync/**
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * Tags or untags the module.
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync *
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * @returns IPRT status code.
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync *
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * @param hDbgMod The module handle.
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * @param uTag The tag value. The convention is that 0 is no tag
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * and any other value means it's tagged. It's adviced
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * to use some kind of unique number like an address
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * (global or string cache for instance) to avoid
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync * collisions with other users
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync */
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsyncRTDECL(int) RTDbgModSetTag(RTDBGMOD hDbgMod, uint64_t uTag)
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync{
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync PRTDBGMODINT pDbgMod = hDbgMod;
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync RTDBGMOD_LOCK(pDbgMod);
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync pDbgMod->uTag = uTag;
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync RTDBGMOD_UNLOCK(pDbgMod);
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync return VINF_SUCCESS;
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync}
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsyncRT_EXPORT_SYMBOL(RTDbgModSetTag);
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync
bbb4c0bfd5ea55e99591d8811771257a437053eevboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync/**
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Adds a segment to the module. Optional feature.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * This method is intended used for manually constructing debug info for a
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * module. The main usage is from other debug info interpreters that want to
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * avoid writing a debug info database and instead uses the standard container
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * behind the scenes.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @returns IPRT status code.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_NOT_SUPPORTED if this feature isn't support by the debug info
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * interpreter. This is a common return code.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_DBG_ADDRESS_WRAP if uRva+cb wraps around.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_DBG_SEGMENT_NAME_OUT_OF_RANGE if pszName is too short or long.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_INVALID_PARAMETER if fFlags contains undefined flags.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_DBG_SPECIAL_SEGMENT if *piSeg is a special segment.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if *piSeg doesn't meet expectations.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param uRva The image relative address of the segment.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param cb The size of the segment.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param pszName The segment name. Does not normally need to be
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * unique, although this is somewhat up to the
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * debug interpreter to decide.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param fFlags Segment flags. Reserved for future used, MBZ.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param piSeg The segment index or NIL_RTDBGSEGIDX on input.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * The assigned segment index on successful return.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Optional.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncRTDECL(int) RTDbgModSegmentAdd(RTDBGMOD hDbgMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName,
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync uint32_t fFlags, PRTDBGSEGIDX piSeg)
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync{
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync /*
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Validate input.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync AssertMsgReturn(uRva + cb >= uRva, ("uRva=%RTptr cb=%RTptr\n", uRva, cb), VERR_DBG_ADDRESS_WRAP);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync Assert(*pszName);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync size_t cchName = strlen(pszName);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync AssertReturn(cchName > 0, VERR_DBG_SEGMENT_NAME_OUT_OF_RANGE);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync AssertReturn(cchName < RTDBG_SEGMENT_NAME_LENGTH, VERR_DBG_SEGMENT_NAME_OUT_OF_RANGE);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync AssertMsgReturn(!fFlags, ("%#x\n", fFlags), VERR_INVALID_PARAMETER);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync AssertPtrNull(piSeg);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync AssertMsgReturn(!piSeg || *piSeg == NIL_RTDBGSEGIDX || *piSeg <= RTDBGSEGIDX_LAST, ("%#x\n", *piSeg), VERR_DBG_SPECIAL_SEGMENT);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync /*
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Do the deed.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_LOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync int rc = pDbgMod->pDbgVt->pfnSegmentAdd(pDbgMod, uRva, cb, pszName, cchName, fFlags, piSeg);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_UNLOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync return rc;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSegmentAdd);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync/**
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Gets the number of segments in the module.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * This is can be used to determine the range which can be passed to
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * RTDbgModSegmentByIndex and derivatives.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @returns The segment relative address.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * NIL_RTDBGSEGIDX if the handle is invalid.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsyncRTDECL(RTDBGSEGIDX) RTDbgModSegmentCount(RTDBGMOD hDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, NIL_RTDBGSEGIDX);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_LOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGSEGIDX cSegs = pDbgMod->pDbgVt->pfnSegmentCount(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_UNLOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync return cSegs;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSegmentCount);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync/**
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Query information about a segment.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * This can be used together with RTDbgModSegmentCount to enumerate segments.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * The index starts a 0 and stops one below RTDbgModSegmentCount.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @returns IPRT status code.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if iSeg is too high.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_DBG_SPECIAL_SEGMENT if iSeg indicates a special segment.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param iSeg The segment index. No special segments.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param pSegInfo Where to return the segment info. The
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * RTDBGSEGMENT::Address member will be set to
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * RTUINTPTR_MAX or the load address used at link time.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncRTDECL(int) RTDbgModSegmentByIndex(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo)
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync{
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync AssertMsgReturn(iSeg <= RTDBGSEGIDX_LAST, ("%#x\n", iSeg), VERR_DBG_SPECIAL_SEGMENT);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_LOCK(pDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync int rc = pDbgMod->pDbgVt->pfnSegmentByIndex(pDbgMod, iSeg, pSegInfo);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGMOD_UNLOCK(pDbgMod);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return rc;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSegmentByIndex);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync/**
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Gets the size of a segment.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * This is a just a wrapper around RTDbgModSegmentByIndex.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @returns The segment size.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * RTUINTPTR_MAX is returned if either the handle and segment index are
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * invalid.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param iSeg The segment index. RTDBGSEGIDX_ABS is not allowed.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * If RTDBGSEGIDX_RVA is used, the functions returns
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * the same value as RTDbgModImageSize.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncRTDECL(RTUINTPTR) RTDbgModSegmentSize(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg)
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync{
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync if (iSeg == RTDBGSEGIDX_RVA)
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync return RTDbgModImageSize(hDbgMod);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGSEGMENT SegInfo;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync int rc = RTDbgModSegmentByIndex(hDbgMod, iSeg, &SegInfo);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync return RT_SUCCESS(rc) ? SegInfo.cb : RTUINTPTR_MAX;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSegmentSize);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync/**
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * Gets the image relative address of a segment.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * This is a just a wrapper around RTDbgModSegmentByIndex.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @returns The segment relative address.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * RTUINTPTR_MAX is returned if either the handle and segment index are
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * invalid.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync *
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param hDbgMod The module handle.
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * @param iSeg The segment index. No special segment indexes
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync * allowed (asserted).
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync */
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsyncRTDECL(RTUINTPTR) RTDbgModSegmentRva(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg)
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync{
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTDBGSEGMENT SegInfo;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync int rc = RTDbgModSegmentByIndex(hDbgMod, iSeg, &SegInfo);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync return RT_SUCCESS(rc) ? SegInfo.uRva : RTUINTPTR_MAX;
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSegmentRva);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync/**
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Adds a line number to the module.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync *
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @returns IPRT status code.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * custom symbols. This is a common place occurrence.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * short.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * it's not inside any of the segments defined by the module.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * end of the segment.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_ADDRESS_WRAP if off+cb wraps around.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_INVALID_PARAMETER if the symbol flags sets undefined bits.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync *
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @param hDbgMod The module handle.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @param pszSymbol The symbol name.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @param iSeg The segment index.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @param off The segment offset.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param cb The size of the symbol. Can be zero, although this
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * may depend somewhat on the debug interpreter.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param fFlags Symbol flags. Reserved for the future, MBZ.
044af0d1e6474076366759db86f101778c5f20ccvboxsync * @param piOrdinal Where to return the symbol ordinal on success. If
044af0d1e6474076366759db86f101778c5f20ccvboxsync * the interpreter doesn't do ordinals, this will be set to
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * UINT32_MAX. Optional.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsyncRTDECL(int) RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off,
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTUINTPTR cb, uint32_t fFlags, uint32_t *piOrdinal)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /*
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Validate input.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertPtr(pszSymbol);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync size_t cchSymbol = strlen(pszSymbol);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertReturn(cchSymbol, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertReturn(cchSymbol < RTDBG_SYMBOL_NAME_LENGTH, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertMsgReturn( iSeg <= RTDBGSEGIDX_LAST
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync || ( iSeg >= RTDBGSEGIDX_SPECIAL_FIRST
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync && iSeg <= RTDBGSEGIDX_SPECIAL_LAST),
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync ("%#x\n", iSeg),
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync VERR_DBG_INVALID_SEGMENT_INDEX);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertMsgReturn(off + cb >= off, ("off=%RTptr cb=%RTptr\n", off, cb), VERR_DBG_ADDRESS_WRAP);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertReturn(!fFlags, VERR_INVALID_PARAMETER); /* currently reserved. */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_LOCK(pDbgMod);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /*
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Convert RVAs.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync if (iSeg == RTDBGSEGIDX_RVA)
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync {
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync iSeg = pDbgMod->pDbgVt->pfnRvaToSegOff(pDbgMod, off, &off);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync if (iSeg == NIL_RTDBGSEGIDX)
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync {
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_UNLOCK(pDbgMod);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync return VERR_DBG_INVALID_RVA;
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync }
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync }
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /*
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Get down to business.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
044af0d1e6474076366759db86f101778c5f20ccvboxsync int rc = pDbgMod->pDbgVt->pfnSymbolAdd(pDbgMod, pszSymbol, cchSymbol, iSeg, off, cb, fFlags, piOrdinal);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_UNLOCK(pDbgMod);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolAdd);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync/**
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Gets the symbol count.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * This can be used together wtih RTDbgModSymbolByOrdinal or
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * RTDbgModSymbolByOrdinalA to enumerate all the symbols.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @returns The number of symbols in the module.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * UINT32_MAX is returned if the module handle is invalid or some other
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * error occurs.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param hDbgMod The module handle.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsyncRTDECL(uint32_t) RTDbgModSymbolCount(RTDBGMOD hDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
a1df400bbe9d64aad400442e56eb637019300a5evboxsync PRTDBGMODINT pDbgMod = hDbgMod;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_LOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync uint32_t cSymbols = pDbgMod->pDbgVt->pfnSymbolCount(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_UNLOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return cSymbols;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolCount);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync/**
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Queries symbol information by ordinal number.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @returns IPRT status code.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param hDbgMod The module handle.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param iOrdinal The symbol ordinal number. 0-based. The highest
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * number is RTDbgModSymbolCount() - 1.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param pSymInfo Where to store the symbol information.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsyncRTDECL(int) RTDbgModSymbolByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
a1df400bbe9d64aad400442e56eb637019300a5evboxsync PRTDBGMODINT pDbgMod = hDbgMod;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_LOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync int rc = pDbgMod->pDbgVt->pfnSymbolByOrdinal(pDbgMod, iOrdinal, pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_UNLOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolByOrdinal);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync/**
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Queries symbol information by ordinal number.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @returns IPRT status code.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at the given number.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param hDbgMod The module handle.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param iOrdinal The symbol ordinal number. 0-based. The highest
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * number is RTDbgModSymbolCount() - 1.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param ppSymInfo Where to store the pointer to the returned
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * symbol information. Always set. Free with
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * RTDbgSymbolFree.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsyncRTDECL(int) RTDbgModSymbolByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGSYMBOL *ppSymInfo)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertPtr(ppSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *ppSymInfo = NULL;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc();
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (!pSymInfo)
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return VERR_NO_MEMORY;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync int rc = RTDbgModSymbolByOrdinal(hDbgMod, iOrdinal, pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (RT_SUCCESS(rc))
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *ppSymInfo = pSymInfo;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync else
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDbgSymbolFree(pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolByOrdinalA);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync/**
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Queries symbol information by address.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * The returned symbol is what the debug info interpreter considers the symbol
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * most applicable to the specified address. This usually means a symbol with an
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * address equal or lower than the requested.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @returns IPRT status code.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * it's not inside any of the segments defined by the module.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * end of the segment.
2d8870843ff566fee9bd3a6a5942414254106479vboxsync * @retval VERR_INVALID_PARAMETER if incorrect flags.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param hDbgMod The module handle.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param iSeg The segment number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param off The offset into the segment.
2d8870843ff566fee9bd3a6a5942414254106479vboxsync * @param fFlags Symbol search flags, see RTDBGSYMADDR_FLAGS_XXX.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param poffDisp Where to store the distance between the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * specified address and the returned symbol.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Optional.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param pSymInfo Where to store the symbol information.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
2d8870843ff566fee9bd3a6a5942414254106479vboxsyncRTDECL(int) RTDbgModSymbolByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
2d8870843ff566fee9bd3a6a5942414254106479vboxsync PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /*
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Validate input.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsync PRTDBGMODINT pDbgMod = hDbgMod;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertPtrNull(poffDisp);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertPtr(pSymInfo);
2d8870843ff566fee9bd3a6a5942414254106479vboxsync AssertReturn(!(fFlags & ~RTDBGSYMADDR_FLAGS_VALID_MASK), VERR_INVALID_PARAMETER);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_LOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /*
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Convert RVAs.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (iSeg == RTDBGSEGIDX_RVA)
a1df400bbe9d64aad400442e56eb637019300a5evboxsync {
a1df400bbe9d64aad400442e56eb637019300a5evboxsync iSeg = pDbgMod->pDbgVt->pfnRvaToSegOff(pDbgMod, off, &off);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (iSeg == NIL_RTDBGSEGIDX)
a1df400bbe9d64aad400442e56eb637019300a5evboxsync {
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_UNLOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return VERR_DBG_INVALID_RVA;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync }
a1df400bbe9d64aad400442e56eb637019300a5evboxsync }
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /*
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Get down to business.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
2d8870843ff566fee9bd3a6a5942414254106479vboxsync int rc = pDbgMod->pDbgVt->pfnSymbolByAddr(pDbgMod, iSeg, off, fFlags, poffDisp, pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_UNLOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolByAddr);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync/**
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Queries symbol information by address.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * The returned symbol is what the debug info interpreter considers the symbol
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * most applicable to the specified address. This usually means a symbol with an
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * address equal or lower than the requested.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @returns IPRT status code.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * it's not inside any of the segments defined by the module.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * end of the segment.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
2d8870843ff566fee9bd3a6a5942414254106479vboxsync * @retval VERR_INVALID_PARAMETER if incorrect flags.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param hDbgMod The module handle.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param iSeg The segment index.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param off The offset into the segment.
2d8870843ff566fee9bd3a6a5942414254106479vboxsync * @param fFlags Symbol search flags, see RTDBGSYMADDR_FLAGS_XXX.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param poffDisp Where to store the distance between the
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * specified address and the returned symbol. Optional.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param ppSymInfo Where to store the pointer to the returned
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * symbol information. Always set. Free with
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * RTDbgSymbolFree.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
2d8870843ff566fee9bd3a6a5942414254106479vboxsyncRTDECL(int) RTDbgModSymbolByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
2d8870843ff566fee9bd3a6a5942414254106479vboxsync PRTINTPTR poffDisp, PRTDBGSYMBOL *ppSymInfo)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertPtr(ppSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *ppSymInfo = NULL;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc();
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (!pSymInfo)
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return VERR_NO_MEMORY;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
2d8870843ff566fee9bd3a6a5942414254106479vboxsync int rc = RTDbgModSymbolByAddr(hDbgMod, iSeg, off, fFlags, poffDisp, pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (RT_SUCCESS(rc))
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *ppSymInfo = pSymInfo;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync else
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDbgSymbolFree(pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolByAddrA);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync/**
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Queries symbol information by symbol name.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @returns IPRT status code.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * short.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param hDbgMod The module handle.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param pszSymbol The symbol name.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param pSymInfo Where to store the symbol information.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsyncRTDECL(int) RTDbgModSymbolByName(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL pSymInfo)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /*
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Validate input.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsync PRTDBGMODINT pDbgMod = hDbgMod;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertPtr(pszSymbol);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync size_t cchSymbol = strlen(pszSymbol);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertReturn(cchSymbol, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertReturn(cchSymbol < RTDBG_SYMBOL_NAME_LENGTH, VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertPtr(pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync /*
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Make the query.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_LOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync int rc = pDbgMod->pDbgVt->pfnSymbolByName(pDbgMod, pszSymbol, cchSymbol, pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDBGMOD_UNLOCK(pDbgMod);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return rc;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolByName);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync/**
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * Queries symbol information by symbol name.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @returns IPRT status code.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE if the symbol name is too long or
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * short.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @retval VERR_NO_MEMORY if RTDbgSymbolAlloc fails.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param hDbgMod The module handle.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param pszSymbol The symbol name.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * @param ppSymInfo Where to store the pointer to the returned
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * symbol information. Always set. Free with
a1df400bbe9d64aad400442e56eb637019300a5evboxsync * RTDbgSymbolFree.
a1df400bbe9d64aad400442e56eb637019300a5evboxsync */
a1df400bbe9d64aad400442e56eb637019300a5evboxsyncRTDECL(int) RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymInfo)
a1df400bbe9d64aad400442e56eb637019300a5evboxsync{
a1df400bbe9d64aad400442e56eb637019300a5evboxsync AssertPtr(ppSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *ppSymInfo = NULL;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync PRTDBGSYMBOL pSymInfo = RTDbgSymbolAlloc();
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (!pSymInfo)
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return VERR_NO_MEMORY;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync int rc = RTDbgModSymbolByName(hDbgMod, pszSymbol, pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync
a1df400bbe9d64aad400442e56eb637019300a5evboxsync if (RT_SUCCESS(rc))
a1df400bbe9d64aad400442e56eb637019300a5evboxsync *ppSymInfo = pSymInfo;
a1df400bbe9d64aad400442e56eb637019300a5evboxsync else
a1df400bbe9d64aad400442e56eb637019300a5evboxsync RTDbgSymbolFree(pSymInfo);
a1df400bbe9d64aad400442e56eb637019300a5evboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModSymbolByNameA);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync/**
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Adds a line number to the module.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync *
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @returns IPRT status code.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * custom symbols. This should be consider a normal response.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_FILE_NAME_OUT_OF_RANGE if the file name is too longer or
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * empty.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * it's not inside any of the segments defined by the module.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * end of the segment.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_INVALID_PARAMETER if the line number flags sets undefined bits.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param hDbgMod The module handle.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param pszFile The file name.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param uLineNo The line number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param iSeg The segment index.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param off The segment offset.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param piOrdinal Where to return the line number ordinal on
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * success. If the interpreter doesn't do ordinals,
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * this will be set to UINT32_MAX. Optional.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsyncRTDECL(int) RTDbgModLineAdd(RTDBGMOD hDbgMod, const char *pszFile, uint32_t uLineNo,
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t *piOrdinal)
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync{
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /*
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Validate input.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertPtr(pszFile);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync size_t cchFile = strlen(pszFile);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertReturn(cchFile, VERR_DBG_FILE_NAME_OUT_OF_RANGE);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertReturn(cchFile < RTDBG_FILE_NAME_LENGTH, VERR_DBG_FILE_NAME_OUT_OF_RANGE);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertMsgReturn( iSeg <= RTDBGSEGIDX_LAST
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync || iSeg == RTDBGSEGIDX_RVA,
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync ("%#x\n", iSeg),
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync VERR_DBG_INVALID_SEGMENT_INDEX);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync AssertReturn(uLineNo > 0 && uLineNo < UINT32_MAX, VERR_INVALID_PARAMETER);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_LOCK(pDbgMod);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /*
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Convert RVAs.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync if (iSeg == RTDBGSEGIDX_RVA)
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync {
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync iSeg = pDbgMod->pDbgVt->pfnRvaToSegOff(pDbgMod, off, &off);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync if (iSeg == NIL_RTDBGSEGIDX)
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync {
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_UNLOCK(pDbgMod);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync return VERR_DBG_INVALID_RVA;
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync }
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync }
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync /*
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync * Get down to business.
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync */
044af0d1e6474076366759db86f101778c5f20ccvboxsync int rc = pDbgMod->pDbgVt->pfnLineAdd(pDbgMod, pszFile, cchFile, uLineNo, iSeg, off, piOrdinal);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync RTDBGMOD_UNLOCK(pDbgMod);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync return rc;
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModLineAdd);
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
ca3da10d05961c339b5180fbd40a54587d6bad35vboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync/**
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Gets the line number count.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * This can be used together wtih RTDbgModLineByOrdinal or RTDbgModSymbolByLineA
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * to enumerate all the line number information.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @returns The number of line numbers in the module.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * UINT32_MAX is returned if the module handle is invalid or some other
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * error occurs.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param hDbgMod The module handle.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsyncRTDECL(uint32_t) RTDbgModLineCount(RTDBGMOD hDbgMod)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync PRTDBGMODINT pDbgMod = hDbgMod;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, UINT32_MAX);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_LOCK(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync uint32_t cLineNumbers = pDbgMod->pDbgVt->pfnLineCount(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_UNLOCK(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return cLineNumbers;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModLineCount);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync/**
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Queries line number information by ordinal number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * This can be used to enumerate the line numbers for the module. Use
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * RTDbgModLineCount() to figure the end of the ordinals.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @returns IPRT status code.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_LINE_NOT_FOUND if there is no line number with that
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * ordinal.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param hDbgMod The module handle.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param iOrdinal The line number ordinal number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param pLineInfo Where to store the information about the line
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsyncRTDECL(int) RTDbgModLineByOrdinal(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo)
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync{
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync PRTDBGMODINT pDbgMod = hDbgMod;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_LOCK(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync int rc = pDbgMod->pDbgVt->pfnLineByOrdinal(pDbgMod, iOrdinal, pLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_UNLOCK(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return rc;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModLineByOrdinal);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync/**
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Queries line number information by ordinal number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * This can be used to enumerate the line numbers for the module. Use
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * RTDbgModLineCount() to figure the end of the ordinals.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @returns IPRT status code.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_LINE_NOT_FOUND if there is no line number with that
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * ordinal.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_NO_MEMORY if RTDbgLineAlloc fails.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param hDbgMod The module handle.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param iOrdinal The line number ordinal number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param ppLineInfo Where to store the pointer to the returned line
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * number information. Always set. Free with
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * RTDbgLineFree.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsyncRTDECL(int) RTDbgModLineByOrdinalA(RTDBGMOD hDbgMod, uint32_t iOrdinal, PRTDBGLINE *ppLineInfo)
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync{
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync AssertPtr(ppLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *ppLineInfo = NULL;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync PRTDBGLINE pLineInfo = RTDbgLineAlloc();
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync if (!pLineInfo)
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return VERR_NO_MEMORY;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync int rc = RTDbgModLineByOrdinal(hDbgMod, iOrdinal, pLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync if (RT_SUCCESS(rc))
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *ppLineInfo = pLineInfo;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync else
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDbgLineFree(pLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return rc;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModLineByOrdinalA);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync/**
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Queries line number information by address.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * The returned line number is what the debug info interpreter considers the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * one most applicable to the specified address. This usually means a line
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * number with an address equal or lower than the requested.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @returns IPRT status code.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_LINE_NOT_FOUND if no suitable line number was found.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * it's not inside any of the segments defined by the module.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * end of the segment.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param hDbgMod The module handle.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param iSeg The segment number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param off The offset into the segment.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param poffDisp Where to store the distance between the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * specified address and the returned symbol.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Optional.
88acfa6629a7976c0583c1712d2b5b22a87a5121vboxsync * @param pLineInfo Where to store the line number information.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsyncRTDECL(int) RTDbgModLineByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE pLineInfo)
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync{
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync /*
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Validate input.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync PRTDBGMODINT pDbgMod = hDbgMod;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync AssertPtrNull(poffDisp);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync AssertPtr(pLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_LOCK(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync /*
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Convert RVAs.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync if (iSeg == RTDBGSEGIDX_RVA)
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync {
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync iSeg = pDbgMod->pDbgVt->pfnRvaToSegOff(pDbgMod, off, &off);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync if (iSeg == NIL_RTDBGSEGIDX)
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync {
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_UNLOCK(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return VERR_DBG_INVALID_RVA;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync }
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync }
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync int rc = pDbgMod->pDbgVt->pfnLineByAddr(pDbgMod, iSeg, off, poffDisp, pLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDBGMOD_UNLOCK(pDbgMod);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return rc;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModLineByAddr);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync/**
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Queries line number information by address.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * The returned line number is what the debug info interpreter considers the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * one most applicable to the specified address. This usually means a line
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * number with an address equal or lower than the requested.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @returns IPRT status code.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_LINE_NOT_FOUND if no suitable line number was found.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_INVALID_HANDLE if hDbgMod is invalid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_RVA if an image relative address is specified and
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * it's not inside any of the segments defined by the module.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_SEGMENT_INDEX if the segment index isn't valid.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_DBG_INVALID_SEGMENT_OFFSET if the segment offset is beyond the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * end of the segment.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @retval VERR_NO_MEMORY if RTDbgLineAlloc fails.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param hDbgMod The module handle.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param iSeg The segment number.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param off The offset into the segment.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param poffDisp Where to store the distance between the
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * specified address and the returned symbol.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * Optional.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * @param ppLineInfo Where to store the pointer to the returned line
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * number information. Always set. Free with
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync * RTDbgLineFree.
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync */
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsyncRTDECL(int) RTDbgModLineByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE *ppLineInfo)
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync{
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync AssertPtr(ppLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *ppLineInfo = NULL;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync PRTDBGLINE pLineInfo = RTDbgLineAlloc();
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync if (!pLineInfo)
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return VERR_NO_MEMORY;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync int rc = RTDbgModLineByAddr(hDbgMod, iSeg, off, poffDisp, pLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync if (RT_SUCCESS(rc))
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync *ppLineInfo = pLineInfo;
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync else
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync RTDbgLineFree(pLineInfo);
df8e6a449f00e1884fbf4a1fc67143614d7d528dvboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModLineByAddrA);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync