mirror of
https://github.com/dart-lang/sdk
synced 2024-09-23 01:33:53 +00:00
afe774a4c4
BUG=https://github.com/domokit/mojo/issues/79 R=asiva@google.com Review URL: https://codereview.chromium.org//1061033005 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44943 260f80e4-7a28-3924-810f-c04153c831b5
109 lines
2.6 KiB
C++
109 lines
2.6 KiB
C++
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/globals.h"
|
|
#include "vm/simulator.h"
|
|
#include "vm/signal_handler.h"
|
|
#if defined(TARGET_OS_ANDROID)
|
|
|
|
namespace dart {
|
|
|
|
uintptr_t SignalHandler::GetProgramCounter(const mcontext_t& mcontext) {
|
|
uintptr_t pc = 0;
|
|
|
|
#if defined(TARGET_ARCH_ARM)
|
|
pc = static_cast<uintptr_t>(mcontext.arm_pc);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
pc = static_cast<uintptr_t>(mcontext.pc);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
return pc;
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetFramePointer(const mcontext_t& mcontext) {
|
|
uintptr_t fp = 0;
|
|
|
|
#if defined(TARGET_ARCH_ARM)
|
|
fp = static_cast<uintptr_t>(mcontext.arm_fp);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
fp = static_cast<uintptr_t>(mcontext.regs[29]);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
|
|
return fp;
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetCStackPointer(const mcontext_t& mcontext) {
|
|
uintptr_t sp = 0;
|
|
|
|
#if defined(TARGET_ARCH_ARM)
|
|
sp = static_cast<uintptr_t>(mcontext.arm_sp);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
sp = static_cast<uintptr_t>(mcontext.sp);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
return sp;
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetDartStackPointer(const mcontext_t& mcontext) {
|
|
uintptr_t sp = 0;
|
|
|
|
#if defined(TARGET_ARCH_ARM)
|
|
sp = static_cast<uintptr_t>(mcontext.arm_sp);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
sp = static_cast<uintptr_t>(mcontext.regs[18]);
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
return sp;
|
|
}
|
|
|
|
|
|
uintptr_t SignalHandler::GetLinkRegister(const mcontext_t& mcontext) {
|
|
uintptr_t lr = 0;
|
|
#if defined(TARGET_ARCH_ARM)
|
|
lr = static_cast<uintptr_t>(mcontext.arm_lr);
|
|
#elif defined(TARGET_ARCH_ARM64)
|
|
lr = static_cast<uintptr_t>(mcontext.regs[30]);
|
|
UNIMPLEMENTED();
|
|
#else
|
|
UNIMPLEMENTED();
|
|
#endif // TARGET_ARCH_...
|
|
return lr;
|
|
}
|
|
|
|
|
|
void SignalHandler::Install(SignalAction action) {
|
|
struct sigaction act;
|
|
memset(&act, 0, sizeof(act));
|
|
act.sa_sigaction = action;
|
|
sigemptyset(&act.sa_mask);
|
|
act.sa_flags = SA_RESTART | SA_SIGINFO;
|
|
int r = sigaction(SIGPROF, &act, NULL);
|
|
ASSERT(r == 0);
|
|
}
|
|
|
|
|
|
void SignalHandler::Remove() {
|
|
// Ignore future SIGPROF signals because by default SIGPROF will terminate
|
|
// the process and we may have some signals in flight.
|
|
struct sigaction act;
|
|
memset(&act, 0, sizeof(act));
|
|
act.sa_handler = SIG_IGN;
|
|
sigemptyset(&act.sa_mask);
|
|
int r = sigaction(SIGPROF, &act, NULL);
|
|
ASSERT(r == 0);
|
|
}
|
|
|
|
|
|
} // namespace dart
|
|
|
|
#endif // defined(TARGET_OS_ANDROID)
|