* config/i386/i386.c (ix86_finalize_stack_frame_flags): Do not overrule
[official-gcc.git] / libsanitizer / ubsan / ubsan_signals_standalone.cc
blobeb9b99ce9ac0a4391fbd8cc78a9b8af068a4d456
1 //=-- ubsan_signals_standalone.cc
2 //------------------------------------------------===//
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Installs signal handlers and related interceptors for UBSan standalone.
11 //===----------------------------------------------------------------------===//
13 #include "ubsan_platform.h"
14 #if CAN_SANITIZE_UB
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"
23 namespace __ubsan {
25 #if SANITIZER_FUCHSIA
26 void InitializeDeadlySignals() {}
27 #else
28 static void OnStackUnwind(const SignalContext &sig, const void *,
29 BufferedStackTrace *stack) {
30 GetStackTraceWithPcBpAndContext(stack, kStackTraceMax, sig.pc, sig.bp,
31 sig.context,
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() {
42 if (is_initialized)
43 return;
44 is_initialized = true;
45 InitializeSignalInterceptors();
46 InstallDeadlySignalHandlers(&UBsanOnDeadlySignal);
48 #endif
50 } // namespace __ubsan
52 #endif // CAN_SANITIZE_UB