xref: /freebsd/contrib/llvm-project/compiler-rt/lib/gwp_asan/optional/segv_handler.h (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
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 
9 #ifndef GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
10 #define GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
11 
12 #include "gwp_asan/guarded_pool_allocator.h"
13 #include "gwp_asan/optional/backtrace.h"
14 #include "gwp_asan/optional/printf.h"
15 
16 namespace gwp_asan {
17 namespace segv_handler {
18 // Install the SIGSEGV crash handler for printing use-after-free and heap-
19 // buffer-{under|over}flow exceptions if the user asked for it. This is platform
20 // specific as even though POSIX and Windows both support registering handlers
21 // through signal(), we have to use platform-specific signal handlers to obtain
22 // the address that caused the SIGSEGV exception. GPA->init() must be called
23 // before this function.
24 void installSignalHandlers(gwp_asan::GuardedPoolAllocator *GPA, Printf_t Printf,
25                            gwp_asan::backtrace::PrintBacktrace_t PrintBacktrace,
26                            gwp_asan::backtrace::SegvBacktrace_t SegvBacktrace);
27 
28 // Uninistall the signal handlers, test-only.
29 void uninstallSignalHandlers();
30 } // namespace segv_handler
31 } // namespace gwp_asan
32 
33 #endif // GWP_ASAN_OPTIONAL_SEGV_HANDLER_H_
34