1 //=-- ubsan_signals_standalone.cc
2 //------------------------------------------------===//
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
7 //===----------------------------------------------------------------------===//
9 // Installs signal handlers and related interceptors for UBSan standalone.
11 //===----------------------------------------------------------------------===//
13 #include "ubsan_platform.h"
15 #include "interception/interception.h"
16 #include "sanitizer_common/sanitizer_stacktrace.h"
17 #include "ubsan_diag.h"
18 #include "ubsan_init.h"
20 #define COMMON_INTERCEPT_FUNCTION(name) INTERCEPT_FUNCTION(name)
21 #include "sanitizer_common/sanitizer_signal_interceptors.inc"
26 void InitializeDeadlySignals() {}
28 static void OnStackUnwind(const SignalContext
&sig
, const void *,
29 BufferedStackTrace
*stack
) {
30 GetStackTraceWithPcBpAndContext(stack
, kStackTraceMax
, sig
.pc
, sig
.bp
,
32 common_flags()->fast_unwind_on_fatal
);
35 static void UBsanOnDeadlySignal(int signo
, void *siginfo
, void *context
) {
36 HandleDeadlySignal(siginfo
, context
, GetTid(), &OnStackUnwind
, nullptr);
39 static bool is_initialized
= false;
41 void InitializeDeadlySignals() {
44 is_initialized
= true;
45 InitializeSignalInterceptors();
46 InstallDeadlySignalHandlers(&UBsanOnDeadlySignal
);
50 } // namespace __ubsan
52 #endif // CAN_SANITIZE_UB