gcc v4.8.x add options for debugging your program:
-fsanitize=thread
Enable ThreadSanitizer, a fast data race detector. Memory access instructions wil
I did some exploration:
ThreadSanitizer has been added and can be enabled via -fsanitize=thread. Instructions will be instrumented to detect data races. The ThreadSanitizer is available on x86-64 GNU/Linux.
-fsanitize=thread is only supported on 64 bit CPU. My linux uname -a
outputs:
Linux hl.zy 3.9.8-300.fc19.i686 #1 SMP Thu Jun 27 19:40:39 UTC 2013 i686 i686 i386 GNU/Linux
My CPU is 32 bit, It's not supported!
below is output of "gcc -dumpspecs | grep tsan":
%{fsanitize=thread:%{static-libtsan:%{!shared:-Bstatic --whole-archive \
-ltsan --no-whole-archive -Bdynamic}}%{!static-libtsan:-ltsan}}}} %o
But I don't understand the output.
I have install Fedora 19 64 bit, you can install libtsan
:
sudo yum install libtsan.x86_64
Concusion:
-fsanitize=thread is only supported on 64 bit gcc now.