diff options
author | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 14:30:48 +0000 |
---|---|---|
committer | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-11 14:30:48 +0000 |
commit | 31bd98bb777821b12e2ebac13839d8b86331b127 (patch) | |
tree | f96ef7cfb376bf8cab3b98fefb96b12e6b1c696d /base | |
parent | a3cc2543cbf44fa3c317ae986f754acfd07f2a83 (diff) | |
download | chromium_src-31bd98bb777821b12e2ebac13839d8b86331b127.zip chromium_src-31bd98bb777821b12e2ebac13839d8b86331b127.tar.gz chromium_src-31bd98bb777821b12e2ebac13839d8b86331b127.tar.bz2 |
Merge the dynamic annotations from ThreadSanitizer r3424.
This introduces two major changes:
- each annotation has a non-trivial implementation which prevents identical code folding
- ANNOTATE_HAPPENS_BEFORE and ANNOTATE_HAPPENS_AFTER are separated from ANNOTATE_CONDVAR_{SIGNAL,WAIT}.
The corresponding annotation functions are supported by ThreadSanitizer as of r3075
TEST=trybots
Review URL: http://codereview.chromium.org/6982022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84975 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/third_party/dynamic_annotations/dynamic_annotations.c | 165 | ||||
-rw-r--r-- | base/third_party/dynamic_annotations/dynamic_annotations.h | 17 |
2 files changed, 137 insertions, 45 deletions
diff --git a/base/third_party/dynamic_annotations/dynamic_annotations.c b/base/third_party/dynamic_annotations/dynamic_annotations.c index 31e9a2b..e7d44f4 100644 --- a/base/third_party/dynamic_annotations/dynamic_annotations.c +++ b/base/third_party/dynamic_annotations/dynamic_annotations.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2009, Google Inc. +/* Copyright (c) 2011, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,9 +22,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * --- - * Author: Kostya Serebryany */ #ifdef _MSC_VER @@ -50,82 +47,172 @@ #if DYNAMIC_ANNOTATIONS_ENABLED == 1 +/* Identical code folding(-Wl,--icf=all) countermeasures. + This makes all Annotate* functions different, which prevents the linker from + folding them. */ +#ifdef __COUNTER__ +#define DYNAMIC_ANNOTATIONS_IMPL \ + volatile short lineno = (__LINE__ << 8) + __COUNTER__; (void)lineno; +#else +#define DYNAMIC_ANNOTATIONS_IMPL \ + volatile short lineno = (__LINE__ << 8); (void)lineno; +#endif + +/* WARNING: always add new annotations to the end of the list. + Otherwise, lineno (see above) numbers for different Annotate* functions may + conflict. */ void DYNAMIC_ANNOTATIONS_NAME(AnnotateRWLockCreate)( - const char *file, int line, const volatile void *lock){} + const char *file, int line, const volatile void *lock) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateRWLockDestroy)( - const char *file, int line, const volatile void *lock){} + const char *file, int line, const volatile void *lock) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateRWLockAcquired)( - const char *file, int line, const volatile void *lock, long is_w){} + const char *file, int line, const volatile void *lock, long is_w) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateRWLockReleased)( - const char *file, int line, const volatile void *lock, long is_w){} + const char *file, int line, const volatile void *lock, long is_w) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateBarrierInit)( const char *file, int line, const volatile void *barrier, long count, - long reinitialization_allowed) {} + long reinitialization_allowed) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateBarrierWaitBefore)( - const char *file, int line, const volatile void *barrier) {} + const char *file, int line, const volatile void *barrier) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateBarrierWaitAfter)( - const char *file, int line, const volatile void *barrier) {} + const char *file, int line, const volatile void *barrier) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateBarrierDestroy)( - const char *file, int line, const volatile void *barrier) {} + const char *file, int line, const volatile void *barrier) +{DYNAMIC_ANNOTATIONS_IMPL} void DYNAMIC_ANNOTATIONS_NAME(AnnotateCondVarWait)( const char *file, int line, const volatile void *cv, - const volatile void *lock){} + const volatile void *lock) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateCondVarSignal)( - const char *file, int line, const volatile void *cv){} + const char *file, int line, const volatile void *cv) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateCondVarSignalAll)( - const char *file, int line, const volatile void *cv){} + const char *file, int line, const volatile void *cv) +{DYNAMIC_ANNOTATIONS_IMPL} + +void DYNAMIC_ANNOTATIONS_NAME(AnnotateHappensBefore)( + const char *file, int line, const volatile void *obj) +{DYNAMIC_ANNOTATIONS_IMPL}; + +void DYNAMIC_ANNOTATIONS_NAME(AnnotateHappensAfter)( + const char *file, int line, const volatile void *obj) +{DYNAMIC_ANNOTATIONS_IMPL}; + void DYNAMIC_ANNOTATIONS_NAME(AnnotatePublishMemoryRange)( - const char *file, int line, const volatile void *address, long size){} + const char *file, int line, const volatile void *address, long size) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateUnpublishMemoryRange)( - const char *file, int line, const volatile void *address, long size){} + const char *file, int line, const volatile void *address, long size) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotatePCQCreate)( - const char *file, int line, const volatile void *pcq){} + const char *file, int line, const volatile void *pcq) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotatePCQDestroy)( - const char *file, int line, const volatile void *pcq){} + const char *file, int line, const volatile void *pcq) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotatePCQPut)( - const char *file, int line, const volatile void *pcq){} + const char *file, int line, const volatile void *pcq) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotatePCQGet)( - const char *file, int line, const volatile void *pcq){} + const char *file, int line, const volatile void *pcq) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateNewMemory)( - const char *file, int line, const volatile void *mem, long size){} + const char *file, int line, const volatile void *mem, long size) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateExpectRace)( const char *file, int line, const volatile void *mem, - const char *description){} + const char *description) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateFlushExpectedRaces)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateBenignRace)( const char *file, int line, const volatile void *mem, - const char *description){} + const char *description) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateBenignRaceSized)( const char *file, int line, const volatile void *mem, long size, - const char *description){} + const char *description) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateMutexIsUsedAsCondVar)( - const char *file, int line, const volatile void *mu){} + const char *file, int line, const volatile void *mu) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateMutexIsNotPHB)( - const char *file, int line, const volatile void *mu){} + const char *file, int line, const volatile void *mu) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateTraceMemory)( - const char *file, int line, const volatile void *arg){} + const char *file, int line, const volatile void *arg) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateThreadName)( - const char *file, int line, const char *name){} + const char *file, int line, const char *name) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateIgnoreReadsBegin)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateIgnoreReadsEnd)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateIgnoreWritesBegin)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateIgnoreWritesEnd)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateIgnoreSyncBegin)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateIgnoreSyncEnd)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateEnableRaceDetection)( - const char *file, int line, int enable){} + const char *file, int line, int enable) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateNoOp)( - const char *file, int line, const volatile void *arg){} + const char *file, int line, const volatile void *arg) +{DYNAMIC_ANNOTATIONS_IMPL} + void DYNAMIC_ANNOTATIONS_NAME(AnnotateFlushState)( - const char *file, int line){} + const char *file, int line) +{DYNAMIC_ANNOTATIONS_IMPL} #endif /* DYNAMIC_ANNOTATIONS_ENABLED == 1 */ diff --git a/base/third_party/dynamic_annotations/dynamic_annotations.h b/base/third_party/dynamic_annotations/dynamic_annotations.h index 263b8ef..f10e27f 100644 --- a/base/third_party/dynamic_annotations/dynamic_annotations.h +++ b/base/third_party/dynamic_annotations/dynamic_annotations.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2009, Google Inc. +/* Copyright (c) 2011, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -22,9 +22,6 @@ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * --- - * Author: Kostya Serebryany */ /* This file defines dynamic annotations for use with dynamic analysis @@ -145,8 +142,10 @@ DYNAMIC_ANNOTATIONS_NAME(AnnotateCondVarSignalAll)(__FILE__, __LINE__, cv) /* Annotations for user-defined synchronization mechanisms. */ - #define ANNOTATE_HAPPENS_BEFORE(obj) ANNOTATE_CONDVAR_SIGNAL(obj) - #define ANNOTATE_HAPPENS_AFTER(obj) ANNOTATE_CONDVAR_WAIT(obj) + #define ANNOTATE_HAPPENS_BEFORE(obj) \ + DYNAMIC_ANNOTATIONS_NAME(AnnotateHappensBefore)(__FILE__, __LINE__, obj) + #define ANNOTATE_HAPPENS_AFTER(obj) \ + DYNAMIC_ANNOTATIONS_NAME(AnnotateHappensAfter)(__FILE__, __LINE__, obj) /* DEPRECATED. Don't use it. */ #define ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \ @@ -463,6 +462,12 @@ void DYNAMIC_ANNOTATIONS_NAME(AnnotateCondVarSignal)( void DYNAMIC_ANNOTATIONS_NAME(AnnotateCondVarSignalAll)( const char *file, int line, const volatile void *cv) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK; +void DYNAMIC_ANNOTATIONS_NAME(AnnotateHappensBefore)( + const char *file, int line, + const volatile void *obj) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK; +void DYNAMIC_ANNOTATIONS_NAME(AnnotateHappensAfter)( + const char *file, int line, + const volatile void *obj) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK; void DYNAMIC_ANNOTATIONS_NAME(AnnotatePublishMemoryRange)( const char *file, int line, const volatile void *address, long size) DYNAMIC_ANNOTATIONS_ATTRIBUTE_WEAK; |