tstX86-1.cpp revision d62febb39dd135fb36e4a6cc8347a8fbb32740da
/* $Id$ */
/** @file
* X86 instruction set exploration/testcase #1.
*/
/*
* Copyright (C) 2011-2012 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 *
*******************************************************************************/
#ifdef RT_OS_WINDOWS
# include <Windows.h>
#else
# ifdef RT_OS_DARWIN
# define _XOPEN_SOURCE
# endif
# include <signal.h>
# include <ucontext.h>
# define USE_SIGNAL
#endif
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
typedef struct TRAPINFO
{
} TRAPINFO;
typedef TRAPINFO const *PCTRAPINFO;
/*******************************************************************************
* Global Variables *
*******************************************************************************/
extern TRAPINFO g_aTrapInfo[];
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
{
/* Search by trap program counter. */
for (unsigned i = 0; g_aTrapInfo[i].uTrapPC; i++)
return &g_aTrapInfo[i];
/* Search by return address. */
for (unsigned i = 0; g_aTrapInfo[i].uTrapPC; i++)
return &g_aTrapInfo[i];
return NULL;
}
#ifdef USE_SIGNAL
{
# if defined(RT_ARCH_AMD64) && defined(RT_OS_DARWIN)
# elif defined(RT_ARCH_AMD64)
# elif defined(RT_ARCH_X86)
# ifdef REG_CR2 /** @todo ... */
# else
# endif
# else
# endif
if (uTrapNo == X86_XCPT_PF)
else
if (pTrapInfo)
{
else
{
return;
}
}
else
RTAssertMsg2("tstX86-1: Unexpected trap!\n");
/* die */
}
#else
#endif
int main()
{
/*
* Set up the test environment.
*/
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
RTTESTI_CHECK_RC(RTMemProtect(g_pbEfExecPage + PAGE_SIZE, PAGE_SIZE, RTMEM_PROT_NONE), VINF_SUCCESS);
#ifdef USE_SIGNAL
for (unsigned i = 0; i < RT_ELEMENTS(s_aiSigs); i++)
{
}
#else
/** @todo implement me. */
#endif
if (!RTTestErrorCount(hTest))
{
/*
* Do the testing.
*/
#if 1
rc = x861_Test1();
if (rc != 0)
rc = x861_Test2();
if (rc != 0)
#endif
rc = x861_Test3();
if (rc != 0)
}
return RTTestSummaryAndDestroy(hTest);
}