segv_handler.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. //===-- segv_handler.h ------------------------------------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
  9. #define GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
  10. #include "gwp_asan/guarded_pool_allocator.h"
  11. #include "gwp_asan/optional/backtrace.h"
  12. #include "gwp_asan/optional/printf.h"
  13. namespace gwp_asan {
  14. namespace segv_handler {
  15. // Install the SIGSEGV crash handler for printing use-after-free and heap-
  16. // buffer-{under|over}flow exceptions if the user asked for it. This is platform
  17. // specific as even though POSIX and Windows both support registering handlers
  18. // through signal(), we have to use platform-specific signal handlers to obtain
  19. // the address that caused the SIGSEGV exception. GPA->init() must be called
  20. // before this function.
  21. void installSignalHandlers(gwp_asan::GuardedPoolAllocator *GPA, Printf_t Printf,
  22. gwp_asan::backtrace::PrintBacktrace_t PrintBacktrace,
  23. gwp_asan::backtrace::SegvBacktrace_t SegvBacktrace,
  24. bool Recoverable = false);
  25. // Uninistall the signal handlers, test-only.
  26. void uninstallSignalHandlers();
  27. } // namespace segv_handler
  28. } // namespace gwp_asan
  29. #endif // GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_