v8-wasm-trap-handler-posix.h 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2018 the V8 project authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef V8_WASM_TRAP_HANDLER_POSIX_H_
  5. #define V8_WASM_TRAP_HANDLER_POSIX_H_
  6. #include <signal.h>
  7. #include "v8config.h" // NOLINT(build/include_directory)
  8. namespace v8 {
  9. /**
  10. * This function determines whether a memory access violation has been an
  11. * out-of-bounds memory access in WebAssembly. If so, it will modify the context
  12. * parameter and add a return address where the execution can continue after the
  13. * signal handling, and return true. Otherwise, false will be returned.
  14. *
  15. * The parameters to this function correspond to those passed to a Posix signal
  16. * handler. Use this function only on Linux and Mac.
  17. *
  18. * \param sig_code The signal code, e.g. SIGSEGV.
  19. * \param info A pointer to the siginfo_t struct provided to the signal handler.
  20. * \param context A pointer to a ucontext_t struct provided to the signal
  21. * handler.
  22. */
  23. V8_EXPORT bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info,
  24. void* context);
  25. } // namespace v8
  26. #endif // V8_WASM_TRAP_HANDLER_POSIX_H_