PATMR3Dbg.cpp revision acb0ddeac7f624f263afe1c42c8e35655aa59181
/* $Id$ */
/** @file
* PATM - Dynamic Guest OS Patching Manager, Debugger Related Parts.
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_PATM
#include "PATMInternal.h"
#include "PATMA.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** Adds a structure member to a debug (pseudo) module as a symbol. */
do { \
} while (0)
/** Adds a structure member to a debug (pseudo) module as a symbol. */
do { \
} while (0)
/**
* Called by PATMR3Init.
*
* @param pVM The cross context VM structure.
*/
{
}
/**
* Called by PATMR3Term.
*
* @param pVM The cross context VM structure.
*/
{
{
}
}
/**
* Called by when the patch memory is reinitialized.
*
* @param pVM The cross context VM structure.
*/
{
{
}
}
/**
* Called when a new patch is added or when first populating the address space.
*
* @param pVM The cross context VM structure.
* @param pPatchRec The patch record.
*/
{
{
/** @todo find a cheap way of checking whether we've already added the patch.
* Using a flag would be nice, except I don't want to consider saved
* state considerations right now (I don't recall if we're still
* depending on structure layout there or not). */
int rc;
char szName[256];
do { \
{ \
}\
} while (0)
/* Start the name off with the address of the guest code. */
/* Append flags. */
if (fFlags & PATMFL_INTHANDLER)
ADD_SZ("_IntHandler");
if (fFlags & PATMFL_SYSENTER)
ADD_SZ("_SysEnter");
if (fFlags & PATMFL_GUEST_SPECIFIC)
ADD_SZ("_GuestSpecific");
if (fFlags & PATMFL_USER_MODE)
ADD_SZ("_UserMode");
if (fFlags & PATMFL_IDTHANDLER)
ADD_SZ("_IdtHandler");
if (fFlags & PATMFL_TRAPHANDLER)
ADD_SZ("_TrapHandler");
if (fFlags & PATMFL_DUPLICATE_FUNCTION)
ADD_SZ("_DupFunc");
ADD_SZ("_ReplFunc");
ADD_SZ("_TrapHandlerErrCd");
if (fFlags & PATMFL_MMIO_ACCESS)
ADD_SZ("_MmioAccess");
if (fFlags & PATMFL_SYSENTER_XP)
ADD_SZ("_SysEnterXP");
if (fFlags & PATMFL_INT3_REPLACEMENT)
ADD_SZ("_Int3Replacement");
if (fFlags & PATMFL_SUPPORT_CALLS)
ADD_SZ("_SupportCalls");
ADD_SZ("_SupportIndirectCalls");
ADD_SZ("_IdtHandlerWE");
if (fFlags & PATMFL_INHIBIT_IRQS)
ADD_SZ("_InhibitIrqs");
if (fFlags & PATMFL_RECOMPILE_NEXT)
ADD_SZ("_RecompileNext");
ADD_SZ("_Callable");
if (fFlags & PATMFL_TRAMPOLINE)
ADD_SZ("_Trampoline");
if (fFlags & PATMFL_PATCHED_GUEST_CODE)
ADD_SZ("_PatchedGuestCode");
ADD_SZ("_MustInstallPatchJmp");
ADD_SZ("_Int3ReplacementBlock");
ADD_SZ("_ExtJmp");
if (fFlags & PATMFL_CODE_REFERENCED)
ADD_SZ("_CodeRefed");
/* If we have a symbol near the guest address, append that. */
if (cbLeft > 8)
{
if (RT_SUCCESS(rc))
{
ADD_SZ("__");
}
}
}
}
/**
* Enumeration callback used by patmR3DbgAddPatches
*
* @returns 0 (continue enum)
* @param pNode The patch record node.
* @param pvUser The cross context VM structure.
*/
{
return 0;
}
/**
* Populates an empty "patches" (hDbgModPatchMem) module with patch symbols.
*
* @param pVM The cross context VM structure.
* @param hDbgMod The debug module handle.
*/
{
/*
* Global functions.
*/
ADD_FUNC(hDbgMod, pVM->patm.s.pPatchMemGC, pVM->patm.s.pfnHelperCallGC, PATMLookupAndCallRecord.size, "PATMLookupAndCall");
ADD_FUNC(hDbgMod, pVM->patm.s.pPatchMemGC, pVM->patm.s.pfnHelperRetGC, PATMRetFunctionRecord.size, "PATMRetFunction");
ADD_FUNC(hDbgMod, pVM->patm.s.pPatchMemGC, pVM->patm.s.pfnHelperJumpGC, PATMLookupAndJumpRecord.size, "PATMLookupAndJump");
ADD_FUNC(hDbgMod, pVM->patm.s.pPatchMemGC, pVM->patm.s.pfnHelperIretGC, PATMIretFunctionRecord.size, "PATMIretFunction");
/*
* The patches.
*/
RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true /*fFromLeft*/, patmR3DbgAddPatchCallback, pVM);
}
/**
* Populate DBGF_AS_RC with PATM symbols.
*
* Called by dbgfR3AsLazyPopulate when DBGF_AS_RC or DBGF_AS_RC_AND_GC_GLOBAL is
* accessed for the first time.
*
* @param pVM The cross context VM structure.
* @param hDbgAs The DBGF_AS_RC address space handle.
*/
{
/*
* Add a fake debug module for the PATMGCSTATE structure.
*/
if (RT_SUCCESS(rc))
{
}
/*
* Add a fake debug module for the patches.
*/
if (RT_SUCCESS(rc))
{
}
}