Chromium Code Reviews| Index: src/trap-handler/v8-api.cc |
| diff --git a/src/trap-handler/v8-api.cc b/src/trap-handler/v8-api.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d1c99ff718acc9e30ae3e32f44fdda1b70aef903 |
| --- /dev/null |
| +++ b/src/trap-handler/v8-api.cc |
| @@ -0,0 +1,34 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <signal.h> |
| +#include <stdlib.h> |
| + |
| +#include "include/v8.h" |
| +#include "src/trap-handler/trap-handler-internal.h" |
|
jochen (gone - plz use gerrit)
2017/01/02 07:35:08
this should either go into src/api.cc or src/api/t
Eric Holk
2017/01/10 23:10:48
I'd like to keep the signal handling code all unde
|
| + |
| +namespace { |
| + |
| +void HandleSignal(int signum, siginfo_t* info, void* arg) { |
| + if (!v8::V8::MaybeHandleFault(signum, info, arg)) { |
| + abort(); |
| + } |
| +} |
| +} // namespace |
| + |
| +namespace v8 { |
| + |
| +bool V8::MaybeHandleFault(int signum, void* info, void* context) { |
| + return v8::internal::trap_handler::MaybeHandleFault(signum, info, context); |
| +} |
| + |
| +bool V8::RegisterDefaultSignalHandler() { |
| + struct sigaction action; |
| + action.sa_sigaction = HandleSignal; |
| + action.sa_flags = SA_SIGINFO; |
| + sigemptyset(&action.sa_mask); |
| + return sigaction(SIGSEGV, &action, nullptr) == 0; |
| +} |
| + |
| +} // namespace v8 |