#include "include/v8config.h"
#if V8_OS_LINUX || V8_OS_FREEBSD
#include <signal.h>
#include <ucontext.h>
#elif V8_OS_DARWIN
#include <signal.h>
#include <sys/ucontext.h>
#elif V8_OS_WIN
#include <windows.h>
#endif
#include "testing/gtest/include/gtest/gtest.h"
#if V8_OS_POSIX
#include "include/v8-wasm-trap-handler-posix.h"
#elif V8_OS_WIN
#include "include/v8-wasm-trap-handler-win.h"
#endif
#include "src/base/page-allocator.h"
#include "src/base/vector.h"
#include "src/codegen/assembler-inl.h"
#include "src/codegen/macro-assembler-inl.h"
#include "src/execution/simulator.h"
#include "src/objects/backing-store.h"
#include "src/trap-handler/trap-handler.h"
#include "src/utils/allocation.h"
#include "src/wasm/wasm-engine.h"
#include "test/common/assembler-tester.h"
#include "test/unittests/test-utils.h"
#if V8_TRAP_HANDLER_SUPPORTED
#if V8_HOST_ARCH_ARM64 && (!V8_OS_LINUX && !V8_OS_DARWIN)
#error Unsupported platform
#endif
namespace v8 {
namespace internal {
namespace wasm {
namespace {
#if V8_HOST_ARCH_X64
constexpr Register scratch = …;
#endif
bool g_test_handler_executed = …;
#if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD
struct sigaction g_old_segv_action;
struct sigaction g_old_other_action;
struct sigaction g_old_bus_action;
#elif V8_OS_WIN
void* g_registered_handler = nullptr;
#endif
Address g_recovery_address;
bool g_use_as_first_chance_handler = …;
}
#define __ …
enum TrapHandlerStyle : int { … };
std::string PrintTrapHandlerTestParam(
::testing::TestParamInfo<TrapHandlerStyle> info) { … }
class TrapHandlerTest : public TestWithIsolate,
public ::testing::WithParamInterface<TrapHandlerStyle> { … };
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST_P(TrapHandlerTest, TestTrapHandlerRecovery) { … }
TEST_P(TrapHandlerTest, TestReleaseHandlerData) { … }
TEST_P(TrapHandlerTest, TestNoThreadInWasmFlag) { … }
TEST_P(TrapHandlerTest, TestCrashInWasmNoProtectedInstruction) { … }
TEST_P(TrapHandlerTest, TestCrashInWasmWrongCrashType) { … }
#endif
class CodeRunner : public v8::base::Thread { … };
#if !defined(V8_TARGET_OS_FUCHSIA)
TEST_P(TrapHandlerTest, TestCrashInOtherThread) { … }
#endif
#if !V8_OS_FUCHSIA
INSTANTIATE_TEST_SUITE_P(…);
#endif
#undef __
}
}
}
#endif