Alexey Samsonov
500e99639d
[Sanitizer] Wrapper around llvm::DIContext from LLVM DebugInfo library. If a macro SANITIZER_USES_LLVM_LIBS is defined (by default it is not), then sanitizer runtime includes llvm headers and tries to use LLVM libs for in-process symbolization. To make it functional, we have to link with these LLVM libs - either pass them to linker from Clang driver, or link them into static ASan runtime when we build it.
...
llvm-svn: 161045
2012-07-31 11:51:26 +00:00
Kostya Serebryany
7a32f8dcb8
[tsan] fix lint
...
llvm-svn: 160504
2012-07-19 12:22:04 +00:00
Kostya Serebryany
a415df6539
[tsan] minor fixes in tsan allocator and its testlib. Now runs fine with chrome
...
llvm-svn: 160503
2012-07-19 12:15:33 +00:00
Alexey Samsonov
7acdc1738f
[Sanitizer] When obtaining the data for loaded modules, add address ranges of loadable segments only. Looks like address range of PT_TLS segment may intersect with loadable segments of other modules.
...
llvm-svn: 160498
2012-07-19 07:51:20 +00:00
Kostya Serebryany
ab34919413
[tsan] minor enhancements in the new tsan allocator and a test malloc replacement library that can be linked to any program to replace malloc (tested on spec2006)
...
llvm-svn: 160436
2012-07-18 16:04:55 +00:00
Alexey Samsonov
4dbfad627e
[Sanitizer] add missing unit test for flag parsing (forgot to run svn add before)
...
llvm-svn: 160428
2012-07-18 06:29:18 +00:00
Alexey Samsonov
d77fbba74a
[Sanitizer] implement straightforward nlogn sorting, as qsort() may call malloc, which leads to deadlock in ASan allocator
...
llvm-svn: 160262
2012-07-16 11:27:17 +00:00
Alexey Samsonov
2d4bd13eb6
[Sanitizer] fix CMake build
...
llvm-svn: 159988
2012-07-10 09:17:06 +00:00
Alexey Samsonov
2c94cd6e3d
[Sanitizer] move flag parsing routines (and unit tests) from tsan runtime to common runtime.
...
llvm-svn: 159928
2012-07-09 13:21:39 +00:00
Alexander Potapenko
b4e9fd297c
Suppress a lint warning.
...
llvm-svn: 159915
2012-07-08 15:00:06 +00:00
Kostya Serebryany
739b0de5b1
[tsan] start using AllocatorCache in CombinedAllocator
...
llvm-svn: 159825
2012-07-06 14:32:00 +00:00
Kostya Serebryany
d1e6094f9e
[tsan] implement SizeClassAllocatorLocalCache (part of tsan allocator)
...
llvm-svn: 159823
2012-07-06 13:46:49 +00:00
Kostya Serebryany
78e973fa6b
[tsan] use intrusive list in the new tsan allocator
...
llvm-svn: 159814
2012-07-06 09:26:01 +00:00
Kostya Serebryany
ff13537a94
[tsan] add intrusive list to be used in tsan allocator, etc
...
llvm-svn: 159812
2012-07-06 09:03:45 +00:00
Dmitry Vyukov
03d32ecd4f
tsan: Go language support
...
llvm-svn: 159754
2012-07-05 16:18:28 +00:00
Alexey Samsonov
38b1ec4317
[ASan] Add a default constructor for DWARFSection to initialize it with zeros.
...
llvm-svn: 159748
2012-07-05 14:28:37 +00:00
Dmitry Vyukov
5dc3f01676
tsan/asan: kill STL
...
First, placement new from standard library conflicts with our own.
Second, we are in trouble if user uses the same function (we either get instrumented code in runtime, or non-instrumented code in user program).
llvm-svn: 159738
2012-07-05 09:23:37 +00:00
Alexey Samsonov
716aa7e2f2
[ASan] fixup for r159652
...
llvm-svn: 159655
2012-07-03 09:06:39 +00:00
Alexey Samsonov
961276af26
[Sanitizer] Extend a symbolizer code. Implemented for Linux only. Use dl_iterate_phdr to get virtual addresses of mapped module sections. To symbolize an address from a module, map this module to memory and obtain pointers to debug info sections. Later these pointers can be passed to constructor of DWARF context-in-memory from LLVM DebugInfo lib.
...
llvm-svn: 159652
2012-07-03 08:24:14 +00:00
Dmitry Vyukov
b13099c26e
asan/tsan: improve SpinMutex
...
llvm-svn: 159518
2012-07-02 07:09:21 +00:00
Dmitry Vyukov
b462dfcaeb
tsan/asan: add mutex to 64-bit allocator
...
llvm-svn: 159516
2012-07-02 06:54:24 +00:00
Alexey Samsonov
4618508ea4
[ASan] cmake cleanup: make tab/space padding in CMakeLists consistent, silence/fix some pedantic warnings
...
llvm-svn: 159514
2012-07-02 06:48:10 +00:00
Dmitry Vyukov
3c5c9e7774
tsan/asan: third try on msvc atomics
...
llvm-svn: 159449
2012-06-29 18:37:45 +00:00
Dmitry Vyukov
b379fe51b4
tsan/asan: second attemp on msvc atomics
...
llvm-svn: 159447
2012-06-29 18:28:02 +00:00
Dmitry Vyukov
e8cee12ce2
tsan/asan: first try on msvc atomics
...
llvm-svn: 159443
2012-06-29 18:00:38 +00:00
Dmitry Vyukov
513f0238d8
tsan/asan: add SpinMutex to sanitizer_common
...
llvm-svn: 159439
2012-06-29 17:32:18 +00:00
Dmitry Vyukov
7a9fa7dbc5
tsan/asan: unify ScopedLock
...
llvm-svn: 159438
2012-06-29 17:10:08 +00:00
Dmitry Vyukov
6fa46f7003
tsan/asan: unify atomics (move atomics from tsan to sanitizer_common)
...
llvm-svn: 159437
2012-06-29 16:58:33 +00:00
Kostya Serebryany
92afdb6c31
[tsan] added CombinedAllocator for tsan
...
llvm-svn: 159432
2012-06-29 15:35:18 +00:00
Kostya Serebryany
5766a9e015
[asan] fix lint
...
llvm-svn: 159429
2012-06-29 14:14:32 +00:00
Kostya Serebryany
d32d537d63
[asan] get rid of libc's sscanf as it causes infinite recursion on Fedora.
...
llvm-svn: 159424
2012-06-29 13:05:36 +00:00
Dmitry Vyukov
090f345522
tsan: prevent insertion of unwanted memset/memcpy/memcmp into runtime
...
llvm-svn: 159294
2012-06-27 21:00:23 +00:00
Kostya Serebryany
4196046714
[tsan] added LargeMmapAllocator, a part of the new tsan allocator
...
llvm-svn: 159204
2012-06-26 14:23:32 +00:00
Dmitry Vyukov
c598de93bd
tsan: remove internal allocator, switch to sanitizer_common one.
...
llvm-svn: 159142
2012-06-25 15:09:24 +00:00
Kostya Serebryany
aad697eb8a
[tsan] lint
...
llvm-svn: 159140
2012-06-25 14:58:17 +00:00
Kostya Serebryany
100590f756
[tsan] minor changes in tsan allocator
...
llvm-svn: 159139
2012-06-25 14:53:49 +00:00
Kostya Serebryany
6bbb5140cc
[tsan] fix the build
...
llvm-svn: 159137
2012-06-25 14:31:59 +00:00
Chandler Carruth
9359efa986
Cleanup the handling of CFLAGS even more in the cmake build for ASan.
...
Add the initial support for building ASan tests.
The first change here is to try to get the CFLAGS to more closely match
those used by the old Makefile. There are probably still goofs here,
ASan folks, your review would be appreciated.
The second big change is to add support for building both
instrumentation based an non-instrumentation based unittests for ASan.
They are built a bit differently from how the old makefiles managed
things. Specifically, there are two binaries, one for the
non-instrumented case, and one for the instrumented case.
Also, the instrumented unit tests rely on the host compiler supporting
AddressSanitizer's intrumentation pass. This is kind-of gross, but
I don't know of a better way yet. I've mailed llvmdev to discuss this
issue.
One big caveat is that the detection logic currently doesn't work. I've
commented it out temporarily as I'd like to get feedback from the ASan
developers, etc.
llvm-svn: 159134
2012-06-25 12:57:43 +00:00
Chandler Carruth
c78ad00c07
Another big step toward a viable CMake build system for CompilerRT,
...
ASan, and friends.
This explicitly switches the CompilerRT CMake build to require CMake
version 2.8.8 or newer which provides first-class support for "object"
libraries which consist of a pile of '.o' files -- exactly what is
desired for composing runtime libraries. I've gone ahead and switched to
using this.
I've also added the interception library which I missed initially. And
I've added proper dependencies between the various libraries. With this,
I'm able to build archives for asan that appear to contain all of the
necessary .o files.
The final tweak here is to start setting up the compile flags and macro
defines expected by ASan and its helper libraries. These may not be
entirely correct currently, they're based loosely on my reading of the
old Makefiles. However, they can be tweaked more easily now that they're
wired up properly.
llvm-svn: 159129
2012-06-25 08:40:10 +00:00
Kostya Serebryany
f299f7013a
[tsan] a better CHECK for OOM in the new allocator
...
llvm-svn: 159122
2012-06-25 04:12:49 +00:00
Kostya Serebryany
278ccdacdc
[tsan] add metadata to the new tsan allocator
...
llvm-svn: 159002
2012-06-22 16:13:28 +00:00
Kostya Serebryany
5b01415dc0
[tsan] more code for a specialized tsan allocator
...
llvm-svn: 158991
2012-06-22 13:00:50 +00:00
Kostya Serebryany
6e26fa9dd1
[tsan] first step in implementing a custom allocator for tsan (and msan) which saves precious shadow
...
llvm-svn: 158913
2012-06-21 10:04:36 +00:00
Kostya Serebryany
98390d0b71
[tsan] a bit more lint and Makefile changes to run tests from sanitizer_common
...
llvm-svn: 158821
2012-06-20 15:19:17 +00:00
Chandler Carruth
bf22bd21e9
Resuming work on the compiler-rt CMake build at long long last. In order
...
to get it working again, two changes were needed:
- I had to give up on glob-based file expansion. This just isn't well
supported by CMake, and until we convince upstream there of its value,
it's not worth dealing with the pain.
- Add the common library as otherwise even ASan won't build.
This now builds again, although the "correctness" of it is a touch
debatable. ;] Specifically, there is no merging of the common runtime
library with the asan runtime library into a single archive file. I'm
not really sure what the best technique is for that, and it may be
influenced by the ongoing discussion about how best to link runtime
libraries.
Note of course that this is still very much WIP. It doesn't entirely
work yet, and remains disabled by the LLVM projects/CMakeLists.txt until
it is in a working state.
llvm-svn: 158811
2012-06-20 10:18:43 +00:00
Alexey Samsonov
e1cb524226
[Sanitizer] Renaming: SNPrintf -> internal_snprintf (and move it to sanitizer libc)
...
llvm-svn: 158710
2012-06-19 09:21:57 +00:00
Alexey Samsonov
af70c09b84
[Sanitizer] State that sanitizer_libc.h header can be included in the user code (and therefore it shouldn't include other sanitizer runtime headers).
...
llvm-svn: 158707
2012-06-19 08:52:02 +00:00
Alexey Samsonov
b13ac747d4
[Sanitizer] use fully qualified type for placement new replacement
...
llvm-svn: 158706
2012-06-19 07:40:45 +00:00
Alexey Samsonov
8516014790
[Sanitizer] add internal_strncmp to sanitizer libc
...
llvm-svn: 158658
2012-06-18 14:34:59 +00:00
Alexey Samsonov
cf7d233ac0
[TSan] kill some linux-specific code in favor of code in common runtime: reuse wrappers for mmap routines, ProcessMaps iterator, thread stack calculation
...
llvm-svn: 158657
2012-06-18 09:42:39 +00:00
Alexey Samsonov
58a3c58ec9
[Sanitizer] move different wrappers from TSan to common sanitizer runtime
...
llvm-svn: 158655
2012-06-18 08:44:30 +00:00
Alexey Samsonov
25c40e5a5b
[Sanitizer] Fix type for placement new on 32-bit Mac
...
llvm-svn: 158524
2012-06-15 14:32:39 +00:00
Alexey Samsonov
0d76e8983f
[Sanitizer] Use ProcessMaps in symbolizer to get module name and offset for instruction address
...
llvm-svn: 158522
2012-06-15 14:00:25 +00:00
Alexey Samsonov
156958dd0c
[Sanitizer] move all the rest re-implementations of libc functions from ASan runtime to common sanitizer runtime
...
llvm-svn: 158519
2012-06-15 13:09:52 +00:00
Alexey Samsonov
3efd6fc26c
[Sanitizer] Use DEFINE_REAL macro in TSan runtime to call libc implementations of functions. Move strchr to sanitizer_libc.
...
llvm-svn: 158517
2012-06-15 12:24:07 +00:00
Alexey Samsonov
8c4dcd72e3
[Sanitizer] Use mmaped buffer in DumpProcessMaps to avoid large stack frames
...
llvm-svn: 158502
2012-06-15 07:41:23 +00:00
Alexey Samsonov
40e5128412
[Sanitizer] move ShadowRangeIsAvailable and several defines to common runtime
...
llvm-svn: 158499
2012-06-15 07:29:14 +00:00
Alexey Samsonov
e4a889866d
[Sanitizer] move atomic ops, min/max and sort to commnon runtime
...
llvm-svn: 158496
2012-06-15 07:00:31 +00:00
Alexey Samsonov
70afb91636
[Sanitizer] move more portability wrappers to common runtime: sleep, _exit, abort, atexit, pthread_self
...
llvm-svn: 158493
2012-06-15 06:37:34 +00:00
Alexey Samsonov
ae1e171b72
[Sanitizer] move DumpProcessMap and DisableCoreDumper to common runtime
...
llvm-svn: 158490
2012-06-15 06:08:19 +00:00
Alexey Samsonov
c70d1086f6
[Sanitizer] move rest of mmap routines to common sanitizer runtime
...
llvm-svn: 158452
2012-06-14 14:42:58 +00:00
Alexey Samsonov
0c53a38abb
[Sanitizer] move portable GetEnv to common sanitizer runtime
...
llvm-svn: 158451
2012-06-14 14:07:21 +00:00
Alexey Samsonov
96ef49a71e
[Sanitizer] Move internal_memcmp to common sanitizer libc
...
llvm-svn: 158450
2012-06-14 14:04:54 +00:00
Alexey Samsonov
aac5d0c831
[Sanitizer] Workaround for -Wunused-private-field warning - add an attribute in TSan unit test, and silence this warning as gtest has unused fields.
...
llvm-svn: 158449
2012-06-14 14:02:32 +00:00
Alexey Samsonov
bb62f555f3
[Sanitizer] Use __libc_malloc/__libc_free instead of malloc/free inside internal allocator on Linux (important for TSan)
...
llvm-svn: 158261
2012-06-09 09:21:44 +00:00
Alexey Samsonov
59036d2c06
[Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/
...
llvm-svn: 158202
2012-06-08 14:11:12 +00:00
Alexey Samsonov
91e1a7eb17
[Sanitizer] move internal_strdup and internal_memcpy to common runtime. Make internal allocations from TSan runtime call InternalAlloc from common runtime
...
llvm-svn: 158148
2012-06-07 11:54:08 +00:00
Alexey Samsonov
8b9aea522f
[Sanitizer] use unsigned int as a parameter for placement new on 32 bits
...
llvm-svn: 158147
2012-06-07 10:09:41 +00:00
Alexey Samsonov
8bd9098b32
[Sanitizer] move placement_new definiton from TSan to common runtime
...
llvm-svn: 158145
2012-06-07 09:50:16 +00:00
Alexey Samsonov
94e2b7d040
[Sanitizer] include stdlib.h header to get malloc/free
...
llvm-svn: 158144
2012-06-07 09:26:13 +00:00
Alexey Samsonov
3a6ddb86e8
[Sanitizer] Allocator for internal runtime purposes. Currently it calls libcmalloc, but we might have to make it more low-level in future
...
llvm-svn: 158142
2012-06-07 08:52:56 +00:00
Alexey Samsonov
cf4d3a027d
[Sanitizer] Fix mac build.
...
llvm-svn: 158141
2012-06-07 07:32:00 +00:00
Alexey Samsonov
4b1f1031e6
[Sanitizer] factor out GetThreadStackTopAndBottom from ASan runtime to common.
...
llvm-svn: 158140
2012-06-07 07:13:46 +00:00
Alexey Samsonov
28a9895ee0
[Sanitizer] __asan::AsanProcMaps -> __sanitizer::ProcessMaps.
...
llvm-svn: 158139
2012-06-07 06:15:12 +00:00
Alexey Samsonov
fe44fbd750
[Sanitizer] Move ReadFileToBuffer to sanitizer_common.
...
llvm-svn: 158138
2012-06-07 05:38:26 +00:00
Kostya Serebryany
c0bbfbfba2
[asan] more allocator compaction
...
llvm-svn: 158082
2012-06-06 16:33:46 +00:00
Alexey Samsonov
40d5b772e5
[Sanitizer] Switch to common mmap/munmap routines in ASan run-time.
...
llvm-svn: 158078
2012-06-06 16:15:07 +00:00
Alexey Samsonov
e95e29c2ac
[Sanitizer] Make UNIMPLEMENTED macro common.
...
llvm-svn: 158077
2012-06-06 15:47:40 +00:00
Alexey Samsonov
e428779dbf
[Sanitizer] Use common CHECK machinery. Currently each tool has to define its own CheckFailed function.
...
llvm-svn: 158075
2012-06-06 15:22:20 +00:00
Kostya Serebryany
64166ca86b
[tsan,asan] comment out O_CLOEXEC as it causes build failures on old linux kernels
...
llvm-svn: 158071
2012-06-06 14:11:31 +00:00
Alexey Samsonov
d323f4e78e
[Sanitizer] Remove __attribute__((format))
...
llvm-svn: 158070
2012-06-06 13:58:39 +00:00
Alexey Samsonov
8bafdd020e
[Sanitizer] fix Win build - ignore __attribute__((format)).
...
llvm-svn: 158067
2012-06-06 13:37:02 +00:00
Alexey Samsonov
51ae983718
[Sanitizer]: Introduce a common internal printf function. For now, also use tool-specific wrappers TsanPrintf (its output is controlled by TSan flags) and AsanPrintf (which copies its results to the ASan-private buffer). Supported formats: %[z]{d,u,x}, %s, %p. Re-write all format strings in TSan according to this format (this should have no effect on 64-bit platforms).
...
llvm-svn: 158065
2012-06-06 13:11:29 +00:00
Alexey Samsonov
201aa367fc
[ASan] fix win build - add missing header
...
llvm-svn: 158057
2012-06-06 09:43:32 +00:00
Alexey Samsonov
ee07290628
[Sanitizer] Move more functions/constants to sanitizer_common.
...
llvm-svn: 158056
2012-06-06 09:26:25 +00:00
Alexey Samsonov
ca2b5d7abb
[Sanitizer] move internal_filesize and internal_dup2 from TSan to sanitizer_common.
...
llvm-svn: 158052
2012-06-06 07:30:33 +00:00
Alexey Samsonov
bc3a7e3fe2
[Sanitizer] add sanitizer_common.h for routines shared between TSan and ASan runtimes. Use __sanitizer::Die() in TSan.
...
llvm-svn: 158050
2012-06-06 06:47:26 +00:00
Alexey Samsonov
5bbf8290a7
[Sanitizer] rename sanitizer_defs.h to sanitizer_internal_defs.h
...
llvm-svn: 158001
2012-06-05 14:25:27 +00:00
Alexey Samsonov
3768b58f82
[Sanitizer] fix compilation on Mac OS 10.6 - don't use O_CLOEXEC
...
llvm-svn: 158000
2012-06-05 14:07:11 +00:00
Alexey Samsonov
ef2e2cfd33
[Sanitizer] Use common defines for ASan and TSan runtime. Split defines between interface defines (can be visible in user code that includes interface ASan/TSan headers) and internal defines.
...
llvm-svn: 157998
2012-06-05 13:50:57 +00:00
Alexey Samsonov
7ac77d6b29
[Sanitizer] add sanitizer_posix.cc. Move more various functions into sanitizer_libc: sscanf, munmap, memchr
...
llvm-svn: 157994
2012-06-05 09:49:25 +00:00
Alexey Samsonov
03c8b846c4
[Sanitizer] add internal_{close,read,write} functions to sanitizer_libc
...
llvm-svn: 157990
2012-06-05 08:32:53 +00:00
Alexey Samsonov
298dd7c361
[TSan] use __sanitizer::internal_open in TSan run-time
...
llvm-svn: 157988
2012-06-05 07:46:31 +00:00
Alexey Samsonov
dde1f11fe6
[Sanitizer] Add sanitizer_win.cc for windows-specific implementations of libc functions. Add internal_open.
...
llvm-svn: 157985
2012-06-05 07:05:10 +00:00
Alexey Samsonov
b6e4f3690b
[Sanitizer] Enable lint for sanitizer_common/
...
llvm-svn: 157931
2012-06-04 14:35:09 +00:00
Alexey Samsonov
2c5fc3bb11
Created files sanitizer_linux.cc and sanitizer_mac.cc for platform-specific implementations of common functions. Turned asan_mmap into __sanitizer::internal_mmap.
...
llvm-svn: 157930
2012-06-04 14:27:50 +00:00
Alexey Samsonov
3b2f9f4c98
Remove file-type tags in .cc files in tsan/ and sanitizer_common/
...
llvm-svn: 157928
2012-06-04 13:55:19 +00:00
Alexey Samsonov
90f9630c80
[Sanitizer]: move internal_strcmp to sanitizer_common
...
llvm-svn: 157926
2012-06-04 13:27:49 +00:00
Alexey Samsonov
06f2cd38c1
[Sanitizer] Move internal_strncpy to sanitizer_libc (and make its behavior conforming to manual)
...
llvm-svn: 157922
2012-06-04 10:30:16 +00:00
Alexey Samsonov
c1971ca12f
[Sanitizer_common] fix filenames in comments
...
llvm-svn: 157919
2012-06-04 09:33:06 +00:00