1*7c3d14c8STreehugger Robot //===-- scudo_termination.cpp -----------------------------------*- C++ -*-===//
2*7c3d14c8STreehugger Robot //
3*7c3d14c8STreehugger Robot // The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot //
5*7c3d14c8STreehugger Robot // This file is distributed under the University of Illinois Open Source
6*7c3d14c8STreehugger Robot // License. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot //
8*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
9*7c3d14c8STreehugger Robot ///
10*7c3d14c8STreehugger Robot /// This file contains bare-bones termination functions to replace the
11*7c3d14c8STreehugger Robot /// __sanitizer ones, in order to avoid any potential abuse of the callbacks
12*7c3d14c8STreehugger Robot /// functionality.
13*7c3d14c8STreehugger Robot ///
14*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
15*7c3d14c8STreehugger Robot
16*7c3d14c8STreehugger Robot #include "sanitizer_common/sanitizer_common.h"
17*7c3d14c8STreehugger Robot
18*7c3d14c8STreehugger Robot namespace __sanitizer {
19*7c3d14c8STreehugger Robot
AddDieCallback(DieCallbackType callback)20*7c3d14c8STreehugger Robot bool AddDieCallback(DieCallbackType callback) { return true; }
21*7c3d14c8STreehugger Robot
RemoveDieCallback(DieCallbackType callback)22*7c3d14c8STreehugger Robot bool RemoveDieCallback(DieCallbackType callback) { return true; }
23*7c3d14c8STreehugger Robot
SetUserDieCallback(DieCallbackType callback)24*7c3d14c8STreehugger Robot void SetUserDieCallback(DieCallbackType callback) {}
25*7c3d14c8STreehugger Robot
Die()26*7c3d14c8STreehugger Robot void NORETURN Die() {
27*7c3d14c8STreehugger Robot if (common_flags()->abort_on_error)
28*7c3d14c8STreehugger Robot Abort();
29*7c3d14c8STreehugger Robot internal__exit(common_flags()->exitcode);
30*7c3d14c8STreehugger Robot }
31*7c3d14c8STreehugger Robot
SetCheckFailedCallback(CheckFailedCallbackType callback)32*7c3d14c8STreehugger Robot void SetCheckFailedCallback(CheckFailedCallbackType callback) {}
33*7c3d14c8STreehugger Robot
CheckFailed(const char * file,int line,const char * cond,u64 v1,u64 v2)34*7c3d14c8STreehugger Robot void NORETURN CheckFailed(const char *file, int line, const char *cond,
35*7c3d14c8STreehugger Robot u64 v1, u64 v2) {
36*7c3d14c8STreehugger Robot Report("Sanitizer CHECK failed: %s:%d %s (%lld, %lld)\n", file, line, cond,
37*7c3d14c8STreehugger Robot v1, v2);
38*7c3d14c8STreehugger Robot Die();
39*7c3d14c8STreehugger Robot }
40*7c3d14c8STreehugger Robot
41*7c3d14c8STreehugger Robot } // namespace __sanitizer
42