dbgmod.cpp revision 1d60675cffb20abae52309979c000a96766906f4
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*******************************************************************************/
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync#define LOG_GROUP RTLOGGROUP_DBG
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync#include <iprt/dbg.h>
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync#include "internal/iprt.h"
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync#include <iprt/alloca.h>
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>
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync#include <iprt/log.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
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
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);
e36f03470adaee73199dcdddd8eb9cf39bbdf7advboxsync#ifdef RT_OS_WINDOWS
e36f03470adaee73199dcdddd8eb9cf39bbdf7advboxsync if (RT_SUCCESS(rc))
e36f03470adaee73199dcdddd8eb9cf39bbdf7advboxsync rc = rtDbgModDebugInterpreterRegister(&g_rtDbgModVtDbgDbgHelp);
e36f03470adaee73199dcdddd8eb9cf39bbdf7advboxsync#endif
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
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync/**
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * Performs lazy init of our global variables.
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @returns IPRT status code.
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsyncDECLINLINE(int) rtDbgModLazyInit(void)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync{
a438caaf732f7839dc66b4f8dad672527845a003vboxsync return RTOnce(&g_rtDbgModOnce, rtDbgModInitOnce, NULL);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync}
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
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 {
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pDbgMod->pszImgFileSpecified = RTStrCacheEnter(g_hDbgModStrCache, pszName);
fd66a4782980b7567eb181f809b629e74e4fd697vboxsync pDbgMod->pszName = RTStrCacheEnterLower(g_hDbgModStrCache, RTPathFilenameEx(pszName, RTPATH_STR_F_STYLE_DOS));
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (pDbgMod->pszName)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync {
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync rc = rtDbgModContainerCreate(pDbgMod, cbSeg);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync if (RT_SUCCESS(rc))
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync {
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync *phDbgMod = pDbgMod;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync return rc;
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync }
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFile);
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
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)
fd66a4782980b7567eb181f809b629e74e4fd697vboxsync pszName = RTPathFilenameEx(pszFilename, RTPATH_STR_F_STYLE_DOS);
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 {
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pDbgMod->pszName = RTStrCacheEnterLower(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;
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync rc = pCur->pVt->pfnTryOpen(pDbgMod, RTLDRARCH_WHATEVER);
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 }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = VERR_NO_STR_MEMORY;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = VERR_NO_STR_MEMORY;
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTCritSectDelete(&pDbgMod->CritSect);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync }
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync RTMemFree(pDbgMod);
72a6fe3989272cb2d409b50caca25e1edbca9398vboxsync return rc;
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncRT_EXPORT_SYMBOL(RTDbgModCreateFromMap);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/*
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync *
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * E x e c u t a b l e I m a g e F i l e s
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * E x e c u t a b l e I m a g e F i l e s
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * E x e c u t a b l e I m a g e F i l e s
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync *
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/**
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Opens debug information for an image.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync *
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * @returns IPRT status code
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * @param pDbgMod The debug module structure.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync *
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * @note This will generally not look for debug info stored in external
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * files. rtDbgModFromPeImageExtDbgInfoCallback can help with that.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncstatic int rtDbgModOpenDebugInfoInsideImage(PRTDBGMODINT pDbgMod)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertReturn(!pDbgMod->pDbgVt, VERR_DBG_MOD_IPE);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertReturn(pDbgMod->pImgVt, VERR_DBG_MOD_IPE);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync int rc = RTSemRWRequestRead(g_hDbgModRWSem, RT_INDEFINITE_WAIT);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync for (PRTDBGMODREGDBG pDbg = g_pDbgHead; pDbg; pDbg = pDbg->pNext)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pDbgVt = pDbg->pVt;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pvDbgPriv = NULL;
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * That's it!
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync ASMAtomicIncU32(&pDbg->cUsers);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VINF_SUCCESS;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
682342827b0e80c493c820603508e79e76c42658vboxsync
682342827b0e80c493c820603508e79e76c42658vboxsync pDbgMod->pDbgVt = NULL;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pvDbgPriv == NULL);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VERR_DBG_NO_MATCHING_INTERPRETER;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync}
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/** @callback_method_impl{FNRTDBGCFGOPEN} */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncstatic DECLCALLBACK(int) rtDbgModExtDbgInfoOpenCallback(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)pvUser1;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync PCRTLDRDBGINFO pDbgInfo = (PCRTLDRDBGINFO)pvUser2;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync NOREF(pDbgInfo); /** @todo consider a more direct search for a interpreter. */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(!pDbgMod->pDbgVt);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(!pDbgMod->pvDbgPriv);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(!pDbgMod->pszDbgFile);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync Assert(pDbgMod->pImgVt);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Set the debug file name and try possible interpreters.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pszDbgFile = RTStrCacheEnter(g_hDbgModStrCache, pszFilename);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync int rc = RTSemRWRequestRead(g_hDbgModRWSem, RT_INDEFINITE_WAIT);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync for (PRTDBGMODREGDBG pDbg = g_pDbgHead; pDbg; pDbg = pDbg->pNext)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pDbgVt = pDbg->pVt;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pvDbgPriv = NULL;
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Got it!
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync ASMAtomicIncU32(&pDbg->cUsers);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VINF_CALLBACK_RETURN;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
682342827b0e80c493c820603508e79e76c42658vboxsync
682342827b0e80c493c820603508e79e76c42658vboxsync pDbgMod->pDbgVt = NULL;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pvDbgPriv == NULL);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
682342827b0e80c493c820603508e79e76c42658vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /* No joy. */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pszDbgFile = NULL;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync}
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/**
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Argument package used by rtDbgModOpenDebugInfoExternalToImage.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsynctypedef struct RTDBGMODOPENDIETI
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync PRTDBGMODINT pDbgMod;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTDBGCFG hDbgCfg;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync} RTDBGMODOPENDIETI;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/** @callback_method_impl{FNRTLDRENUMDBG} */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncstatic DECLCALLBACK(int)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncrtDbgModOpenDebugInfoExternalToImageCallback(RTLDRMOD hLdrMod, PCRTLDRDBGINFO pDbgInfo, void *pvUser)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTDBGMODOPENDIETI *pArgs = (RTDBGMODOPENDIETI *)pvUser;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync Assert(pDbgInfo->enmType > RTLDRDBGINFOTYPE_INVALID && pDbgInfo->enmType < RTLDRDBGINFOTYPE_END);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync const char *pszExtFile = pDbgInfo->pszExtFile;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync if (!pszExtFile)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync {
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync /*
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * If a external debug type comes without a file name, calculate a
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * likely debug filename for it. (Hack for NT4 drivers.)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync */
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync const char *pszExt = NULL;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync if (pDbgInfo->enmType == RTLDRDBGINFOTYPE_CODEVIEW_DBG)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pszExt = ".dbg";
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync else if ( pDbgInfo->enmType == RTLDRDBGINFOTYPE_CODEVIEW_PDB20
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync || pDbgInfo->enmType == RTLDRDBGINFOTYPE_CODEVIEW_PDB70)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pszExt = ".pdb";
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync if (pszExt && pArgs->pDbgMod->pszName)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync {
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync size_t cchName = strlen(pArgs->pDbgMod->pszName);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync char *psz = (char *)alloca(cchName + strlen(pszExt) + 1);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync if (psz)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync {
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync memcpy(psz, pArgs->pDbgMod->pszName, cchName + 1);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTPathStripExt(psz);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pszExtFile = strcat(psz, pszExt);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync }
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync }
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync if (!pszExtFile)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync {
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync Log2(("rtDbgModOpenDebugInfoExternalToImageCallback: enmType=%d\n", pDbgInfo->enmType));
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync return VINF_SUCCESS;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync }
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync /*
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * Switch on type and call the appropriate search function.
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync int rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync switch (pDbgInfo->enmType)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync case RTLDRDBGINFOTYPE_CODEVIEW_PDB70:
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync rc = RTDbgCfgOpenPdb70(pArgs->hDbgCfg, pszExtFile,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync &pDbgInfo->u.Pdb70.Uuid,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgInfo->u.Pdb70.uAge,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rtDbgModExtDbgInfoOpenCallback, pArgs->pDbgMod, (void *)pDbgInfo);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync break;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync case RTLDRDBGINFOTYPE_CODEVIEW_PDB20:
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync rc = RTDbgCfgOpenPdb20(pArgs->hDbgCfg, pszExtFile,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgInfo->u.Pdb20.cbImage,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgInfo->u.Pdb20.uTimestamp,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgInfo->u.Pdb20.uAge,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rtDbgModExtDbgInfoOpenCallback, pArgs->pDbgMod, (void *)pDbgInfo);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync break;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync case RTLDRDBGINFOTYPE_CODEVIEW_DBG:
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync rc = RTDbgCfgOpenDbg(pArgs->hDbgCfg, pszExtFile,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgInfo->u.Dbg.cbImage,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgInfo->u.Dbg.uTimestamp,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rtDbgModExtDbgInfoOpenCallback, pArgs->pDbgMod, (void *)pDbgInfo);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync break;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync case RTLDRDBGINFOTYPE_DWARF_DWO:
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync rc = RTDbgCfgOpenDwo(pArgs->hDbgCfg, pszExtFile,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgInfo->u.Dwo.uCrc32,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rtDbgModExtDbgInfoOpenCallback, pArgs->pDbgMod, (void *)pDbgInfo);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync break;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync default:
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Log(("rtDbgModOpenDebugInfoExternalToImageCallback: Don't know how to handle enmType=%d and pszFileExt=%s\n",
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pDbgInfo->enmType, pszExtFile));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VERR_DBG_TODO;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync LogFlow(("RTDbgMod: Successfully opened external debug info '%s' for '%s'\n",
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pArgs->pDbgMod->pszDbgFile, pArgs->pDbgMod->pszImgFile));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VINF_CALLBACK_RETURN;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Log(("rtDbgModOpenDebugInfoExternalToImageCallback: '%s' (enmType=%d) for '%s' -> %Rrc\n",
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pszExtFile, pDbgInfo->enmType, pArgs->pDbgMod->pszImgFile, rc));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync}
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/**
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Opens debug info listed in the image that is stored in a separate file.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync *
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * @returns IPRT status code
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * @param pDbgMod The debug module.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * @param hDbgCfg The debug config. Can be NIL.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncstatic int rtDbgModOpenDebugInfoExternalToImage(PRTDBGMODINT pDbgMod, RTDBGCFG hDbgCfg)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync Assert(!pDbgMod->pDbgVt);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTDBGMODOPENDIETI Args;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Args.pDbgMod = pDbgMod;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Args.hDbgCfg = hDbgCfg;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync int rc = pDbgMod->pImgVt->pfnEnumDbgInfo(pDbgMod, rtDbgModOpenDebugInfoExternalToImageCallback, &Args);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc) && pDbgMod->pDbgVt)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VINF_SUCCESS;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync LogFlow(("rtDbgModOpenDebugInfoExternalToImage: rc=%Rrc\n", rc));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VERR_NOT_FOUND;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync}
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync/** @callback_method_impl{FNRTDBGCFGOPEN} */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsyncstatic DECLCALLBACK(int) rtDbgModExtDbgInfoOpenCallback2(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync{
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)pvUser1;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync NOREF(pvUser2); /** @todo image matching string or smth. */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync Assert(!pDbgMod->pDbgVt);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync Assert(!pDbgMod->pvDbgPriv);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync Assert(!pDbgMod->pszDbgFile);
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync Assert(pDbgMod->pImgVt);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Set the debug file name and try possible interpreters.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszDbgFile = RTStrCacheEnter(g_hDbgModStrCache, pszFilename);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync int rc = RTSemRWRequestRead(g_hDbgModRWSem, RT_INDEFINITE_WAIT);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync for (PRTDBGMODREGDBG pDbg = g_pDbgHead; pDbg; pDbg = pDbg->pNext)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pDbgVt = pDbg->pVt;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pvDbgPriv = NULL;
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync rc = pDbg->pVt->pfnTryOpen(pDbgMod, pDbgMod->pImgVt->pfnGetArch(pDbgMod));
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Got it!
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync ASMAtomicIncU32(&pDbg->cUsers);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return VINF_CALLBACK_RETURN;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pDbgVt = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync Assert(pDbgMod->pvDbgPriv == NULL);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /* No joy. */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszDbgFile = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return rc;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync}
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync/**
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Opens external debug info that is not listed in the image.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync *
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * @returns IPRT status code
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * @param pDbgMod The debug module.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * @param hDbgCfg The debug config. Can be NIL.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsyncstatic int rtDbgModOpenDebugInfoExternalToImage2(PRTDBGMODINT pDbgMod, RTDBGCFG hDbgCfg)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync{
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync int rc;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync Assert(!pDbgMod->pDbgVt);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync Assert(pDbgMod->pImgVt);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Figure out what to search for based on the image format.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync const char *pszzExts = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTLDRFMT enmFmt = pDbgMod->pImgVt->pfnGetFormat(pDbgMod);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync switch (enmFmt)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync case RTLDRFMT_MACHO:
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = RTDbgCfgOpenDsymBundle(hDbgCfg, pDbgMod->pszImgFile, NULL /**@todo pUuid*/,
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rtDbgModExtDbgInfoOpenCallback2, pDbgMod, NULL /*pvUser2*/);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return VINF_SUCCESS;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync break;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync#if 0 /* Will be links in the image if these apply. .map readers for PE or ELF we don't have. */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync case RTLDRFMT_ELF:
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pszzExts = ".debug\0.dwo\0";
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync break;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync case RTLDRFMT_PE:
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pszzExts = ".map\0";
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync break;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync#endif
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync#if 0 /* Haven't implemented .sym or .map file readers for OS/2 yet. */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync case RTLDRFMT_LX:
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pszzExts = ".sym\0.map\0";
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync break;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync#endif
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync default:
1d60675cffb20abae52309979c000a96766906f4vboxsync rc = VERR_NOT_IMPLEMENTED;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync break;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync NOREF(pszzExts);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync#if 0 /* Later */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (pszzExts)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync#endif
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync LogFlow(("rtDbgModOpenDebugInfoExternalToImage2: rc=%Rrc\n", rc));
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return VERR_NOT_FOUND;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync}
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsyncRTDECL(int) RTDbgModCreateFromImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName,
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTLDRARCH enmArch, RTDBGCFG hDbgCfg)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync{
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Input validation and lazy initialization.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync AssertPtrReturn(phDbgMod, VERR_INVALID_POINTER);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync *phDbgMod = NIL_RTDBGMOD;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync AssertReturn(*pszFilename, VERR_INVALID_PARAMETER);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync AssertPtrNullReturn(pszName, VERR_INVALID_POINTER);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync AssertReturn(enmArch > RTLDRARCH_INVALID && enmArch < RTLDRARCH_END, VERR_INVALID_PARAMETER);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync int rc = rtDbgModLazyInit();
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_FAILURE(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return rc;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (!pszName)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pszName = RTPathFilenameEx(pszFilename, RTPATH_STR_F_STYLE_DOS);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Allocate a new module instance.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgMod));
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (!pDbgMod)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return VERR_NO_MEMORY;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->u32Magic = RTDBGMOD_MAGIC;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->cRefs = 1;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = RTCritSectInit(&pDbgMod->CritSect);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszName = RTStrCacheEnterLower(g_hDbgModStrCache, pszName);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (pDbgMod->pszName)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszImgFile = RTStrCacheEnter(g_hDbgModStrCache, pszFilename);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (pDbgMod->pszImgFile)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTStrCacheRetain(pDbgMod->pszImgFile);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszImgFileSpecified = pDbgMod->pszImgFile;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Find an image reader which groks the file.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = RTSemRWRequestRead(g_hDbgModRWSem, RT_INDEFINITE_WAIT);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = VERR_DBG_NO_MATCHING_INTERPRETER;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync PRTDBGMODREGIMG pImg;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync for (pImg = g_pImgHead; pImg; pImg = pImg->pNext)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pImgVt = pImg->pVt;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pvImgPriv = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /** @todo need to specify some arch stuff here. */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = pImg->pVt->pfnTryOpen(pDbgMod, enmArch);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Image detected, but found no debug info we were
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * able to understand.
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /** @todo some generic way of matching image and debug info, flexible signature
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * of some kind. Apple uses UUIDs, microsoft uses a UUID+age or a
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * size+timestamp, and GNU a CRC32 (last time I checked). */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = rtDbgModOpenDebugInfoExternalToImage(pDbgMod, hDbgCfg);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_FAILURE(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = rtDbgModOpenDebugInfoInsideImage(pDbgMod);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_FAILURE(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = rtDbgModOpenDebugInfoExternalToImage2(pDbgMod, hDbgCfg);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_FAILURE(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = rtDbgModCreateForExports(pDbgMod);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
682342827b0e80c493c820603508e79e76c42658vboxsync /*
682342827b0e80c493c820603508e79e76c42658vboxsync * We're done!
682342827b0e80c493c820603508e79e76c42658vboxsync */
682342827b0e80c493c820603508e79e76c42658vboxsync ASMAtomicIncU32(&pImg->cUsers);
682342827b0e80c493c820603508e79e76c42658vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
682342827b0e80c493c820603508e79e76c42658vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync *phDbgMod = pDbgMod;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return VINF_SUCCESS;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /* Failed, close up the shop. */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pImgVt->pfnClose(pDbgMod);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pImgVt = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pvImgPriv = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync break;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * Could it be a file containing raw debug info?
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (!pImg)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pImgVt = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pvImgPriv = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszDbgFile = pDbgMod->pszImgFile;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszImgFile = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync for (PRTDBGMODREGDBG pDbg = g_pDbgHead; pDbg; pDbg = pDbg->pNext)
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pDbgVt = pDbg->pVt;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pvDbgPriv = NULL;
d1e9999d55e7ac80a28692c161710be98071fc00vboxsync rc = pDbg->pVt->pfnTryOpen(pDbgMod, enmArch);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync if (RT_SUCCESS(rc))
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync {
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * That's it!
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync ASMAtomicIncU32(&pDbg->cUsers);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync *phDbgMod = pDbgMod;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return rc;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszImgFile = pDbgMod->pszDbgFile;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync pDbgMod->pszDbgFile = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync /* bail out */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFileSpecified);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFile);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync else
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = VERR_NO_STR_MEMORY;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync else
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = VERR_NO_STR_MEMORY;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTCritSectDelete(&pDbgMod->CritSect);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync }
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync RTMemFree(pDbgMod);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync return rc;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync}
6ba706e9f431401d425d16817fdcd6316f83b584vboxsyncRT_EXPORT_SYMBOL(RTDbgModCreateFromImage);
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync/*
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync *
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * P E I M A G E
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * P E I M A G E
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync * P E I M A G E
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync *
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync */
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/** @callback_method_impl{FNRTDBGCFGOPEN} */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncstatic DECLCALLBACK(int) rtDbgModFromPeImageOpenCallback(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)pvUser1;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync PRTDBGMODDEFERRED pDeferred = (PRTDBGMODDEFERRED)pvUser2;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync LogFlow(("rtDbgModFromPeImageOpenCallback: %s\n", pszFilename));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pImgVt == NULL);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pvImgPriv == NULL);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pDbgVt == NULL);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pvDbgPriv == NULL);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
fa6dbd9c9e9645298cca864aa561382469907905vboxsync /*
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * Replace the image file name while probing it.
fa6dbd9c9e9645298cca864aa561382469907905vboxsync */
fa6dbd9c9e9645298cca864aa561382469907905vboxsync const char *pszNewImgFile = RTStrCacheEnter(g_hDbgModStrCache, pszFilename);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync if (!pszNewImgFile)
fa6dbd9c9e9645298cca864aa561382469907905vboxsync return VERR_NO_STR_MEMORY;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync const char *pszOldImgFile = pDbgMod->pszImgFile;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync pDbgMod->pszImgFile = pszNewImgFile;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Find an image reader which groks the file.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync int rc = RTSemRWRequestRead(g_hDbgModRWSem, RT_INDEFINITE_WAIT);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = VERR_DBG_NO_MATCHING_INTERPRETER;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync PRTDBGMODREGIMG pImg;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync for (pImg = g_pImgHead; pImg; pImg = pImg->pNext)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pImgVt = pImg->pVt;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pvImgPriv = NULL;
6ba706e9f431401d425d16817fdcd6316f83b584vboxsync rc = pImg->pVt->pfnTryOpen(pDbgMod, RTLDRARCH_WHATEVER);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync break;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pImgVt = NULL;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pvImgPriv == NULL);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
fa6dbd9c9e9645298cca864aa561382469907905vboxsync RTSemRWReleaseRead(g_hDbgModRWSem);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * Check the deferred info.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
fa6dbd9c9e9645298cca864aa561382469907905vboxsync RTUINTPTR cbImage = pDbgMod->pImgVt->pfnImageSize(pDbgMod);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync if ( pDeferred->cbImage == 0
fa6dbd9c9e9645298cca864aa561382469907905vboxsync || pDeferred->cbImage == cbImage)
fa6dbd9c9e9645298cca864aa561382469907905vboxsync {
fa6dbd9c9e9645298cca864aa561382469907905vboxsync uint32_t uTimestamp = pDeferred->u.PeImage.uTimestamp; /** @todo add method for getting the timestamp. */
fa6dbd9c9e9645298cca864aa561382469907905vboxsync if ( pDeferred->u.PeImage.uTimestamp == 0
fa6dbd9c9e9645298cca864aa561382469907905vboxsync || pDeferred->u.PeImage.uTimestamp == uTimestamp)
fa6dbd9c9e9645298cca864aa561382469907905vboxsync {
fa6dbd9c9e9645298cca864aa561382469907905vboxsync Log(("RTDbgMod: Found matching PE image '%s'\n", pszFilename));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
fa6dbd9c9e9645298cca864aa561382469907905vboxsync /*
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * We found the executable image we need, now go find any
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * debug info associated with it. For PE images, this is
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * generally found in an external file, so we do a sweep
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * for that first.
fa6dbd9c9e9645298cca864aa561382469907905vboxsync *
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * Then try open debug inside the module, and finally
fa6dbd9c9e9645298cca864aa561382469907905vboxsync * falling back on exports.
fa6dbd9c9e9645298cca864aa561382469907905vboxsync */
fa6dbd9c9e9645298cca864aa561382469907905vboxsync rc = rtDbgModOpenDebugInfoExternalToImage(pDbgMod, pDeferred->hDbgCfg);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync if (RT_FAILURE(rc))
fa6dbd9c9e9645298cca864aa561382469907905vboxsync rc = rtDbgModOpenDebugInfoInsideImage(pDbgMod);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync if (RT_FAILURE(rc))
fa6dbd9c9e9645298cca864aa561382469907905vboxsync rc = rtDbgModCreateForExports(pDbgMod);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync if (RT_SUCCESS(rc))
fa6dbd9c9e9645298cca864aa561382469907905vboxsync {
fa6dbd9c9e9645298cca864aa561382469907905vboxsync RTStrCacheRelease(g_hDbgModStrCache, pszOldImgFile);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync return VINF_CALLBACK_RETURN;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
fa6dbd9c9e9645298cca864aa561382469907905vboxsync /* Something bad happened, just give up. */
fa6dbd9c9e9645298cca864aa561382469907905vboxsync Log(("rtDbgModFromPeImageOpenCallback: rtDbgModCreateForExports failed: %Rrc\n", rc));
fa6dbd9c9e9645298cca864aa561382469907905vboxsync }
fa6dbd9c9e9645298cca864aa561382469907905vboxsync else
fa6dbd9c9e9645298cca864aa561382469907905vboxsync {
fa6dbd9c9e9645298cca864aa561382469907905vboxsync LogFlow(("rtDbgModFromPeImageOpenCallback: uTimestamp mismatch (found %#x, expected %#x) - %s\n",
fa6dbd9c9e9645298cca864aa561382469907905vboxsync uTimestamp, pDeferred->u.PeImage.uTimestamp, pszFilename));
fa6dbd9c9e9645298cca864aa561382469907905vboxsync rc = VERR_DBG_FILE_MISMATCH;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync }
fa6dbd9c9e9645298cca864aa561382469907905vboxsync }
fa6dbd9c9e9645298cca864aa561382469907905vboxsync else
fa6dbd9c9e9645298cca864aa561382469907905vboxsync {
fa6dbd9c9e9645298cca864aa561382469907905vboxsync LogFlow(("rtDbgModFromPeImageOpenCallback: cbImage mismatch (found %#x, expected %#x) - %s\n",
fa6dbd9c9e9645298cca864aa561382469907905vboxsync cbImage, pDeferred->cbImage, pszFilename));
fa6dbd9c9e9645298cca864aa561382469907905vboxsync rc = VERR_DBG_FILE_MISMATCH;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync }
fa6dbd9c9e9645298cca864aa561382469907905vboxsync
fa6dbd9c9e9645298cca864aa561382469907905vboxsync pDbgMod->pImgVt->pfnClose(pDbgMod);
fa6dbd9c9e9645298cca864aa561382469907905vboxsync pDbgMod->pImgVt = NULL;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync pDbgMod->pvImgPriv = NULL;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else
fa6dbd9c9e9645298cca864aa561382469907905vboxsync LogFlow(("rtDbgModFromPeImageOpenCallback: Failed %Rrc - %s\n", rc, pszFilename));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
fa6dbd9c9e9645298cca864aa561382469907905vboxsync /* Restore image name. */
fa6dbd9c9e9645298cca864aa561382469907905vboxsync pDbgMod->pszImgFile = pszOldImgFile;
fa6dbd9c9e9645298cca864aa561382469907905vboxsync RTStrCacheRelease(g_hDbgModStrCache, pszNewImgFile);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync}
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync/** @callback_method_impl{FNRTDBGMODDEFERRED} */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsyncstatic DECLCALLBACK(int) rtDbgModFromPeImageDeferredCallback(PRTDBGMODINT pDbgMod, PRTDBGMODDEFERRED pDeferred)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync int rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync Assert(pDbgMod->pszImgFile);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (!pDbgMod->pImgVt)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = RTDbgCfgOpenPeImage(pDeferred->hDbgCfg, pDbgMod->pszImgFile,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDeferred->cbImage, pDeferred->u.PeImage.uTimestamp,
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rtDbgModFromPeImageOpenCallback, pDbgMod, pDeferred);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync {
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync rc = rtDbgModOpenDebugInfoExternalToImage(pDbgMod, pDeferred->hDbgCfg);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (RT_FAILURE(rc))
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync rc = rtDbgModOpenDebugInfoInsideImage(pDbgMod);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (RT_FAILURE(rc))
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync rc = rtDbgModCreateForExports(pDbgMod);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync}
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsyncRTDECL(int) RTDbgModCreateFromPeImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTLDRMOD hLdrMod,
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync uint32_t cbImage, uint32_t uTimestamp, RTDBGCFG hDbgCfg)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync{
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Input validation and lazy initialization.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertPtrReturn(phDbgMod, VERR_INVALID_POINTER);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync *phDbgMod = NIL_RTDBGMOD;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertReturn(*pszFilename, VERR_INVALID_PARAMETER);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (!pszName)
fd66a4782980b7567eb181f809b629e74e4fd697vboxsync pszName = RTPathFilenameEx(pszFilename, RTPATH_STR_F_STYLE_DOS);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertPtrReturn(pszName, VERR_INVALID_POINTER);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync AssertReturn(hLdrMod == NIL_RTLDRMOD || RTLdrSize(hLdrMod) != ~(size_t)0, VERR_INVALID_HANDLE);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync int rc = rtDbgModLazyInit();
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_FAILURE(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync uint64_t fDbgCfg = 0;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (hDbgCfg)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = RTDbgCfgQueryUInt(hDbgCfg, RTDBGCFGPROP_FLAGS, &fDbgCfg);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync AssertRCReturn(rc, rc);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync * Allocate a new module instance.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync PRTDBGMODINT pDbgMod = (PRTDBGMODINT)RTMemAllocZ(sizeof(*pDbgMod));
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (!pDbgMod)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return VERR_NO_MEMORY;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->u32Magic = RTDBGMOD_MAGIC;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->cRefs = 1;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = RTCritSectInit(&pDbgMod->CritSect);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
b1eb97eca02d27edf670107fb160f4a06e055f1evboxsync pDbgMod->pszName = RTStrCacheEnterLower(g_hDbgModStrCache, pszName);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (pDbgMod->pszName)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync pDbgMod->pszImgFile = RTStrCacheEnter(g_hDbgModStrCache, pszFilename);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (pDbgMod->pszImgFile)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTStrCacheRetain(pDbgMod->pszImgFile);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync pDbgMod->pszImgFileSpecified = pDbgMod->pszImgFile;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync /*
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync * If we have a loader module, we must instantiate the loader
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync * side of things regardless of the deferred setting.
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync */
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (hLdrMod != NIL_RTLDRMOD)
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (!cbImage)
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync cbImage = (uint32_t)RTLdrSize(hLdrMod);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync pDbgMod->pImgVt = &g_rtDbgModVtImgLdr;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync rc = rtDbgModLdrOpenFromHandle(pDbgMod, hLdrMod);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync if (RT_SUCCESS(rc))
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync {
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync /*
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync * Do it now or procrastinate?
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync */
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (!(fDbgCfg & RTDBGCFG_FLAGS_DEFERRED) || !cbImage)
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync {
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync RTDBGMODDEFERRED Deferred;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync Deferred.cbImage = cbImage;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync Deferred.hDbgCfg = hDbgCfg;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync Deferred.u.PeImage.uTimestamp = uTimestamp;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync rc = rtDbgModFromPeImageDeferredCallback(pDbgMod, &Deferred);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync }
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync else
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync {
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync PRTDBGMODDEFERRED pDeferred;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync rc = rtDbgModDeferredCreate(pDbgMod, rtDbgModFromPeImageDeferredCallback, cbImage, hDbgCfg, &pDeferred);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (RT_SUCCESS(rc))
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync pDeferred->u.PeImage.uTimestamp = uTimestamp;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync }
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (RT_SUCCESS(rc))
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync {
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync *phDbgMod = pDbgMod;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync return VINF_SUCCESS;
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync /* Failed, bail out. */
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync if (hLdrMod != NIL_RTLDRMOD)
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync {
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync Assert(pDbgMod->pImgVt);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync pDbgMod->pImgVt->pfnClose(pDbgMod);
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync }
830a019ad79a45e6bf7a5419efd5a729a36e599evboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszName);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = VERR_NO_STR_MEMORY;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFileSpecified);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFile);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync else
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync rc = VERR_NO_STR_MEMORY;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTCritSectDelete(&pDbgMod->CritSect);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync }
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync RTMemFree(pDbgMod);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync return rc;
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync}
6ba706e9f431401d425d16817fdcd6316f83b584vboxsyncRT_EXPORT_SYMBOL(RTDbgModCreateFromPeImage);
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
daa94352f51be2329ac8660f70396e03a7cb983bvboxsync
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);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszImgFileSpecified);
c0e27f622f9bd6d9e77d2d959aab71d69dabf0d3vboxsync RTStrCacheRelease(g_hDbgModStrCache, pDbgMod->pszDbgFile);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTCritSectLeave(&pDbgMod->CritSect); /* paranoia */
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTCritSectDelete(&pDbgMod->CritSect);
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync RTMemFree(pDbgMod);
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync}
8b4a8db7768e94d025f1216ecfcd50d727fa2b7cvboxsync
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
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
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
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncRTDECL(const char *) RTDbgModDebugFile(RTDBGMOD hDbgMod)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync{
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, NULL);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync if (pDbgMod->fDeferred || pDbgMod->fExports)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync return NULL;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync return pDbgMod->pszDbgFile;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync}
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncRT_EXPORT_SYMBOL(RTDbgModDebugFile);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncRTDECL(const char *) RTDbgModImageFile(RTDBGMOD hDbgMod)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync{
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, NULL);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync return pDbgMod->pszImgFileSpecified;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync}
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncRT_EXPORT_SYMBOL(RTDbgModImageFile);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncRTDECL(const char *) RTDbgModImageFileUsed(RTDBGMOD hDbgMod)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync{
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync PRTDBGMODINT pDbgMod = hDbgMod;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, NULL);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync return pDbgMod->pszImgFile == pDbgMod->pszImgFileSpecified ? NULL : pDbgMod->pszImgFile;
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync}
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncRT_EXPORT_SYMBOL(RTDbgModImageFileUsed);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsyncRTDECL(bool) RTDbgModIsDeferred(RTDBGMOD hDbgMod)
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync{
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync PRTDBGMODINT pDbgMod = hDbgMod;
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, false);
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync return pDbgMod->fDeferred;
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync}
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsyncRTDECL(bool) RTDbgModIsExports(RTDBGMOD hDbgMod)
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync{
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync PRTDBGMODINT pDbgMod = hDbgMod;
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, false);
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync return pDbgMod->fExports;
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync}
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync
d90eec53c9dcaa0f3d1054e8734ed46875b9093avboxsync
31771163041e3661403a806eb3382d2a165c003bvboxsyncRTDECL(int) RTDbgModRemoveAll(RTDBGMOD hDbgMod, bool fLeaveSegments)
31771163041e3661403a806eb3382d2a165c003bvboxsync{
31771163041e3661403a806eb3382d2a165c003bvboxsync PRTDBGMODINT pDbgMod = hDbgMod;
31771163041e3661403a806eb3382d2a165c003bvboxsync RTDBGMOD_VALID_RETURN_RC(pDbgMod, VERR_INVALID_HANDLE);
31771163041e3661403a806eb3382d2a165c003bvboxsync
31771163041e3661403a806eb3382d2a165c003bvboxsync RTDBGMOD_LOCK(pDbgMod);
31771163041e3661403a806eb3382d2a165c003bvboxsync
31771163041e3661403a806eb3382d2a165c003bvboxsync /* Only possible on container modules. */
31771163041e3661403a806eb3382d2a165c003bvboxsync int rc = VINF_SUCCESS;
31771163041e3661403a806eb3382d2a165c003bvboxsync if (pDbgMod->pDbgVt != &g_rtDbgModVtDbgContainer)
31771163041e3661403a806eb3382d2a165c003bvboxsync {
31771163041e3661403a806eb3382d2a165c003bvboxsync if (fLeaveSegments)
31771163041e3661403a806eb3382d2a165c003bvboxsync {
31771163041e3661403a806eb3382d2a165c003bvboxsync rc = rtDbgModContainer_LineRemoveAll(pDbgMod);
31771163041e3661403a806eb3382d2a165c003bvboxsync if (RT_SUCCESS(rc))
31771163041e3661403a806eb3382d2a165c003bvboxsync rc = rtDbgModContainer_SymbolRemoveAll(pDbgMod);
31771163041e3661403a806eb3382d2a165c003bvboxsync }
31771163041e3661403a806eb3382d2a165c003bvboxsync else
31771163041e3661403a806eb3382d2a165c003bvboxsync rc = rtDbgModContainer_RemoveAll(pDbgMod);
31771163041e3661403a806eb3382d2a165c003bvboxsync }
31771163041e3661403a806eb3382d2a165c003bvboxsync else
31771163041e3661403a806eb3382d2a165c003bvboxsync rc = VERR_ACCESS_DENIED;
31771163041e3661403a806eb3382d2a165c003bvboxsync
31771163041e3661403a806eb3382d2a165c003bvboxsync RTDBGMOD_UNLOCK(pDbgMod);
31771163041e3661403a806eb3382d2a165c003bvboxsync return rc;
31771163041e3661403a806eb3382d2a165c003bvboxsync}
31771163041e3661403a806eb3382d2a165c003bvboxsync
31771163041e3661403a806eb3382d2a165c003bvboxsync
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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