diff options
author | Dave Allison <dallison@google.com> | 2014-08-20 14:29:39 -0700 |
---|---|---|
committer | Dave Allison <dallison@google.com> | 2014-08-21 11:41:18 -0700 |
commit | 49ddae71638eee2d653a5030a6763e8c506f9469 (patch) | |
tree | 4fc106d373bb0d23e79c8f1a827030b9fa656853 /test/004-SignalTest | |
parent | 00b3024b350afef115bddea712705bdb4877ac11 (diff) | |
download | art-49ddae71638eee2d653a5030a6763e8c506f9469.tar.gz art-49ddae71638eee2d653a5030a6763e8c506f9469.tar.bz2 art-49ddae71638eee2d653a5030a6763e8c506f9469.zip |
Add supported architectures to signal test.
This adds ARM, AARCH64, i386 and x86_64 to the supported architectures
in 004-SignalTest
Bug: 16948053
(cherry picked from commit d4af31aa69fe8786a291c566c375bbac04da9ced)
Change-Id: I17a992b2cf47f8744f867b8e3f1c360aa345093d
Diffstat (limited to 'test/004-SignalTest')
-rw-r--r-- | test/004-SignalTest/signaltest.cc | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/test/004-SignalTest/signaltest.cc b/test/004-SignalTest/signaltest.cc index c05dc22b8b..3c87b4871b 100644 --- a/test/004-SignalTest/signaltest.cc +++ b/test/004-SignalTest/signaltest.cc @@ -21,29 +21,51 @@ #include "jni.h" -#ifdef __arm__ +#if defined(__arm__) || defined(__aarch64__) #include <sys/ucontext.h> #endif static int signal_count; static const int kMaxSignal = 2; +#if defined(__i386__) || defined(__x86_64__) +#if defined(__APPLE__) +#define ucontext __darwin_ucontext + +#if defined(__x86_64__) +// 64 bit mac build. +#define CTX_EIP uc_mcontext->__ss.__rip +#else +// 32 bit mac build. +#define CTX_EIP uc_mcontext->__ss.__eip +#endif + +#elif defined(__x86_64__) +// 64 bit linux build. +#define CTX_EIP uc_mcontext.gregs[REG_RIP] +#else +// 32 bit linux build. +#define CTX_EIP uc_mcontext.gregs[REG_EIP] +#endif +#endif + static void signalhandler(int sig, siginfo_t* info, void* context) { printf("signal caught\n"); ++signal_count; if (signal_count > kMaxSignal) { abort(); } -#ifdef __arm__ - // On ARM we do a more exhaustive test to make sure the signal - // context is OK. - // We can do this because we know that the instruction causing - // the signal is 2 bytes long (thumb mov instruction). On - // other architectures this is more difficult. - // TODO: we could do this on other architectures too if necessary, it's just harder. +#if defined(__arm__) struct ucontext *uc = reinterpret_cast<struct ucontext*>(context); struct sigcontext *sc = reinterpret_cast<struct sigcontext*>(&uc->uc_mcontext); sc->arm_pc += 2; // Skip instruction causing segv. +#elif defined(__aarch64__) + struct ucontext *uc = reinterpret_cast<struct ucontext*>(context); + struct sigcontext *sc = reinterpret_cast<struct sigcontext*>(&uc->uc_mcontext); + sc->pc += 4; // Skip instruction causing segv. +#elif defined(__i386__) || defined(__x86_64__) + struct ucontext *uc = reinterpret_cast<struct ucontext*>(context); + uc->CTX_EIP += 3; #endif } @@ -70,8 +92,8 @@ extern "C" JNIEXPORT void JNICALL Java_Main_terminateSignalTest(JNIEnv*, jclass) char *p = nullptr; extern "C" JNIEXPORT jint JNICALL Java_Main_testSignal(JNIEnv*, jclass) { -#ifdef __arm__ - // On ARM we cause a real SEGV. +#if defined(__arm__) || defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) + // On supported architectures we cause a real SEGV. *p = 'a'; #else // On other architectures we simulate SEGV. |