2015-02-03 07:14:46 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-07-06 00:18:28 +08:00
|
|
|
set -e
|
|
|
|
|
|
|
|
SRCS="
|
|
|
|
tsan_go.cc
|
|
|
|
../rtl/tsan_clock.cc
|
|
|
|
../rtl/tsan_flags.cc
|
2014-07-18 22:54:02 +08:00
|
|
|
../rtl/tsan_interface_atomic.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
../rtl/tsan_md5.cc
|
|
|
|
../rtl/tsan_mutex.cc
|
|
|
|
../rtl/tsan_report.cc
|
|
|
|
../rtl/tsan_rtl.cc
|
|
|
|
../rtl/tsan_rtl_mutex.cc
|
|
|
|
../rtl/tsan_rtl_report.cc
|
|
|
|
../rtl/tsan_rtl_thread.cc
|
2016-04-27 16:23:02 +08:00
|
|
|
../rtl/tsan_rtl_proc.cc
|
2014-05-29 21:50:54 +08:00
|
|
|
../rtl/tsan_stack_trace.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
../rtl/tsan_stat.cc
|
|
|
|
../rtl/tsan_suppressions.cc
|
|
|
|
../rtl/tsan_sync.cc
|
|
|
|
../../sanitizer_common/sanitizer_allocator.cc
|
|
|
|
../../sanitizer_common/sanitizer_common.cc
|
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
|
|
|
../../sanitizer_common/sanitizer_common_libcdep.cc
|
2014-03-19 20:50:47 +08:00
|
|
|
../../sanitizer_common/sanitizer_deadlock_detector2.cc
|
2015-01-31 07:04:57 +08:00
|
|
|
../../sanitizer_common/sanitizer_flag_parser.cc
|
2012-07-16 18:36:39 +08:00
|
|
|
../../sanitizer_common/sanitizer_flags.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
../../sanitizer_common/sanitizer_libc.cc
|
2014-05-21 17:42:56 +08:00
|
|
|
../../sanitizer_common/sanitizer_persistent_allocator.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
../../sanitizer_common/sanitizer_printf.cc
|
2013-06-27 15:57:53 +08:00
|
|
|
../../sanitizer_common/sanitizer_suppressions.cc
|
2013-03-18 16:52:46 +08:00
|
|
|
../../sanitizer_common/sanitizer_thread_registry.cc
|
2014-03-19 20:50:47 +08:00
|
|
|
../../sanitizer_common/sanitizer_stackdepot.cc
|
2014-11-19 18:43:11 +08:00
|
|
|
../../sanitizer_common/sanitizer_stacktrace.cc
|
2014-12-03 03:48:40 +08:00
|
|
|
../../sanitizer_common/sanitizer_symbolizer.cc
|
[sanitizer] Move termination functions in their own file
Summary:
As suggested by kcc@ in http://reviews.llvm.org/D20084#441418, move the CheckFailed and Die functions, and their associated callback functionalities in their own separate file.
I expended the build rules to include a new rule that would not include those termination functions, so that another project can define their own.
The tests check-{a,t,m,ub,l,e,df}san are all passing.
Reviewers: llvm-commits, kcc
Subscribers: kubabrecka
Differential Revision: http://reviews.llvm.org/D20742
llvm-svn: 271055
2016-05-28 05:57:17 +08:00
|
|
|
../../sanitizer_common/sanitizer_termination.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
"
|
|
|
|
|
2012-11-06 21:32:53 +08:00
|
|
|
if [ "`uname -a | grep Linux`" != "" ]; then
|
|
|
|
SUFFIX="linux_amd64"
|
2015-02-22 20:20:05 +08:00
|
|
|
OSCFLAGS="-fPIC -ffreestanding -Wno-maybe-uninitialized -Wno-unused-const-variable -Werror -Wno-unknown-warning-option"
|
2015-11-12 19:54:25 +08:00
|
|
|
OSLDFLAGS="-lpthread -fPIC -fpie"
|
2015-02-03 06:07:39 +08:00
|
|
|
SRCS="
|
|
|
|
$SRCS
|
2012-07-16 21:02:40 +08:00
|
|
|
../rtl/tsan_platform_linux.cc
|
2012-11-06 21:32:53 +08:00
|
|
|
../../sanitizer_common/sanitizer_posix.cc
|
2013-05-21 18:27:07 +08:00
|
|
|
../../sanitizer_common/sanitizer_posix_libcdep.cc
|
2014-08-07 07:13:23 +08:00
|
|
|
../../sanitizer_common/sanitizer_procmaps_common.cc
|
2013-12-25 16:56:08 +08:00
|
|
|
../../sanitizer_common/sanitizer_procmaps_linux.cc
|
2012-07-16 21:02:40 +08:00
|
|
|
../../sanitizer_common/sanitizer_linux.cc
|
2015-07-24 06:05:20 +08:00
|
|
|
../../sanitizer_common/sanitizer_linux_libcdep.cc
|
2013-10-04 01:14:35 +08:00
|
|
|
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
|
2012-07-16 21:02:40 +08:00
|
|
|
"
|
2014-06-21 06:53:43 +08:00
|
|
|
elif [ "`uname -a | grep FreeBSD`" != "" ]; then
|
2016-02-14 08:26:32 +08:00
|
|
|
SUFFIX="freebsd_amd64"
|
|
|
|
OSCFLAGS="-fno-strict-aliasing -fPIC -Werror"
|
|
|
|
OSLDFLAGS="-lpthread -fPIC -fpie"
|
|
|
|
SRCS="
|
|
|
|
$SRCS
|
|
|
|
../rtl/tsan_platform_linux.cc
|
|
|
|
../../sanitizer_common/sanitizer_posix.cc
|
|
|
|
../../sanitizer_common/sanitizer_posix_libcdep.cc
|
|
|
|
../../sanitizer_common/sanitizer_procmaps_common.cc
|
|
|
|
../../sanitizer_common/sanitizer_procmaps_freebsd.cc
|
|
|
|
../../sanitizer_common/sanitizer_linux.cc
|
|
|
|
../../sanitizer_common/sanitizer_linux_libcdep.cc
|
|
|
|
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
|
|
|
|
"
|
2012-11-06 21:32:53 +08:00
|
|
|
elif [ "`uname -a | grep Darwin`" != "" ]; then
|
|
|
|
SUFFIX="darwin_amd64"
|
2016-06-05 23:15:36 +08:00
|
|
|
OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -mmacosx-version-min=10.7"
|
|
|
|
OSLDFLAGS="-lpthread -fPIC -fpie -mmacosx-version-min=10.7"
|
2015-02-03 06:07:39 +08:00
|
|
|
SRCS="
|
|
|
|
$SRCS
|
2012-08-14 02:44:44 +08:00
|
|
|
../rtl/tsan_platform_mac.cc
|
|
|
|
../../sanitizer_common/sanitizer_mac.cc
|
2013-12-25 16:56:08 +08:00
|
|
|
../../sanitizer_common/sanitizer_posix.cc
|
2013-06-06 21:00:32 +08:00
|
|
|
../../sanitizer_common/sanitizer_posix_libcdep.cc
|
2013-12-25 16:56:08 +08:00
|
|
|
../../sanitizer_common/sanitizer_procmaps_mac.cc
|
2012-08-14 02:44:44 +08:00
|
|
|
"
|
2012-11-06 21:32:53 +08:00
|
|
|
elif [ "`uname -a | grep MINGW`" != "" ]; then
|
|
|
|
SUFFIX="windows_amd64"
|
2014-06-21 06:53:43 +08:00
|
|
|
OSCFLAGS="-Wno-error=attributes -Wno-attributes -Wno-unused-const-variable -Wno-unknown-warning-option"
|
2012-11-06 21:32:53 +08:00
|
|
|
OSLDFLAGS=""
|
2015-02-03 06:07:39 +08:00
|
|
|
SRCS="
|
|
|
|
$SRCS
|
2012-11-06 21:32:53 +08:00
|
|
|
../rtl/tsan_platform_windows.cc
|
|
|
|
../../sanitizer_common/sanitizer_win.cc
|
|
|
|
"
|
|
|
|
else
|
|
|
|
echo Unknown platform
|
|
|
|
exit 1
|
2012-07-16 21:02:40 +08:00
|
|
|
fi
|
|
|
|
|
2015-02-03 04:37:28 +08:00
|
|
|
CC=${CC:-gcc}
|
|
|
|
IN_TMPDIR=${IN_TMPDIR:-0}
|
|
|
|
SILENT=${SILENT:-0}
|
|
|
|
|
|
|
|
if [ $IN_TMPDIR != "0" ]; then
|
|
|
|
DIR=$(mktemp -qd /tmp/gotsan.XXXXXXXXXX)
|
|
|
|
cleanup() {
|
|
|
|
rm -rf $DIR
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
else
|
|
|
|
DIR=.
|
|
|
|
fi
|
|
|
|
|
2015-02-03 06:07:39 +08:00
|
|
|
SRCS="$SRCS $ADD_SRCS"
|
2012-07-06 00:18:28 +08:00
|
|
|
|
2015-02-03 04:37:28 +08:00
|
|
|
rm -f $DIR/gotsan.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
for F in $SRCS; do
|
2015-02-03 04:37:28 +08:00
|
|
|
cat $F >> $DIR/gotsan.cc
|
2012-07-06 00:18:28 +08:00
|
|
|
done
|
|
|
|
|
2015-01-19 23:01:07 +08:00
|
|
|
FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++11 -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS"
|
2015-02-03 07:14:46 +08:00
|
|
|
if [ "$DEBUG" = "" ]; then
|
2015-02-03 06:07:39 +08:00
|
|
|
FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer"
|
2012-07-06 00:18:28 +08:00
|
|
|
else
|
2015-02-03 06:07:39 +08:00
|
|
|
FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g"
|
2012-07-06 00:18:28 +08:00
|
|
|
fi
|
|
|
|
|
2015-02-03 04:37:28 +08:00
|
|
|
if [ "$SILENT" != "1" ]; then
|
|
|
|
echo $CC gotsan.cc -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS
|
|
|
|
fi
|
|
|
|
$CC $DIR/gotsan.cc -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS
|
2012-07-06 00:18:28 +08:00
|
|
|
|
2016-04-27 16:23:02 +08:00
|
|
|
$CC $OSCFLAGS test.c $DIR/race_$SUFFIX.syso -m64 -g -o $DIR/test $OSLDFLAGS
|
2014-06-06 23:49:49 +08:00
|
|
|
|
2015-02-03 04:37:28 +08:00
|
|
|
export GORACE="exitcode=0 atexit_sleep_ms=0"
|
|
|
|
if [ "$SILENT" != "1" ]; then
|
|
|
|
$DIR/test
|
|
|
|
else
|
|
|
|
$DIR/test 2>/dev/null
|
|
|
|
fi
|