2019-08-01 02:51:27 +08:00
|
|
|
//===-- sanitizer_common_nolibc.cpp ---------------------------------------===//
|
2015-07-24 06:05:20 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-07-24 06:05:20 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains stubs for libc function to facilitate optional use of
|
|
|
|
// libc in no-libcdep sources.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "sanitizer_common.h"
|
2020-11-05 13:19:38 +08:00
|
|
|
#include "sanitizer_flags.h"
|
2015-08-28 04:40:24 +08:00
|
|
|
#include "sanitizer_libc.h"
|
2020-11-05 13:19:38 +08:00
|
|
|
#include "sanitizer_platform.h"
|
2015-07-24 06:05:20 +08:00
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
2016-09-09 00:46:06 +08:00
|
|
|
// The Windows implementations of these functions use the win32 API directly,
|
|
|
|
// bypassing libc.
|
|
|
|
#if !SANITIZER_WINDOWS
|
2015-07-24 06:37:39 +08:00
|
|
|
#if SANITIZER_LINUX
|
2016-01-07 17:14:41 +08:00
|
|
|
void LogMessageOnPrintf(const char *str) {}
|
2015-11-05 05:03:12 +08:00
|
|
|
#endif
|
Reapply: [asan] On OS X, log reports to syslog and os_trace
When ASan currently detects a bug, by default it will only print out the text
of the report to stderr. This patch changes this behavior and writes the full
text of the report to syslog before we terminate the process. It also calls
os_trace (Activity Tracing available on OS X and iOS) with a message saying
that the report is available in syslog. This is useful, because this message
will be shown in the crash log.
For this to work, the patch makes sure we store the full report into
error_message_buffer unconditionally, and it also strips out ANSI escape
sequences from the report (they are used when producing colored reports).
I've initially tried to log to syslog during printing, which is done on Android
right now. The advantage is that if we crash during error reporting or the
produced error does not go through ScopedInErrorReport, we would still get a
(partial) message in the syslog. However, that solution is very problematic on
OS X. One issue is that the logging routine uses GCD, which may spawn a new
thread on its behalf. In many cases, the reporting logic locks threadRegistry,
which leads to deadlocks.
Reviewed at http://reviews.llvm.org/D13452
(In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid
build failures on Linux.)
llvm-svn: 253688
2015-11-21 02:41:44 +08:00
|
|
|
void WriteToSyslog(const char *buffer) {}
|
2015-08-28 04:40:24 +08:00
|
|
|
void Abort() { internal__exit(1); }
|
2021-09-15 07:34:52 +08:00
|
|
|
bool CreateDir(const char *pathname) { return false; }
|
2016-09-09 00:46:06 +08:00
|
|
|
#endif // !SANITIZER_WINDOWS
|
2015-08-28 04:40:24 +08:00
|
|
|
|
2016-11-22 19:09:35 +08:00
|
|
|
#if !SANITIZER_WINDOWS && !SANITIZER_MAC
|
|
|
|
void ListOfModules::init() {}
|
2020-11-05 13:19:38 +08:00
|
|
|
void InitializePlatformCommonFlags(CommonFlags *cf) {}
|
2016-11-22 19:09:35 +08:00
|
|
|
#endif
|
|
|
|
|
2015-08-28 04:40:24 +08:00
|
|
|
} // namespace __sanitizer
|