[compiler-rt] r192782 - [TSan] Extend test for reporting globals with races on them
Alexey Samsonov
samsonov at google.com
Wed Oct 16 02:56:17 PDT 2013
Author: samsonov
Date: Wed Oct 16 04:56:17 2013
New Revision: 192782
URL: http://llvm.org/viewvc/llvm-project?rev=192782&view=rev
Log:
[TSan] Extend test for reporting globals with races on them
Modified:
compiler-rt/trunk/lib/tsan/lit_tests/global_race.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
Modified: compiler-rt/trunk/lib/tsan/lit_tests/global_race.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/global_race.cc?rev=192782&r1=192781&r2=192782&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/global_race.cc (original)
+++ compiler-rt/trunk/lib/tsan/lit_tests/global_race.cc Wed Oct 16 04:56:17 2013
@@ -4,22 +4,39 @@
#include <stddef.h>
int GlobalData[10];
+int y;
+namespace XXX {
+ struct YYY {
+ static int ZZZ[10];
+ };
+ int YYY::ZZZ[10];
+}
void *Thread(void *a) {
GlobalData[2] = 42;
+ y = 1;
+ XXX::YYY::ZZZ[0] = 1;
return 0;
}
int main() {
fprintf(stderr, "addr=%p\n", GlobalData);
+ fprintf(stderr, "addr2=%p\n", &y);
+ fprintf(stderr, "addr3=%p\n", XXX::YYY::ZZZ);
pthread_t t;
pthread_create(&t, 0, Thread, 0);
GlobalData[2] = 43;
+ y = 0;
+ XXX::YYY::ZZZ[0] = 0;
pthread_join(t, 0);
}
// CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
+// CHECK: addr2=[[ADDR2:0x[0-9,a-f]+]]
+// CHECK: addr3=[[ADDR3:0x[0-9,a-f]+]]
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'GlobalData' of size 40 at [[ADDR]] ({{.*}}+0x{{[0-9,a-f]+}})
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'y' of size 4 at [[ADDR2]] ({{.*}}+0x{{[0-9,a-f]+}})
// CHECK: WARNING: ThreadSanitizer: data race
-// Requires llvm-symbolizer, so disabled for now.
-// CHECK0: Location is global 'GlobalData' of size 40 at [[ADDR]]
-// CHECK0: (global_race.cc.exe+0x[0-9,a-f]+)
+// CHECK: Location is global 'XXX::YYY::ZZZ' of size 40 at [[ADDR3]] ({{.*}}+0x{{[0-9,a-f]+}})
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc?rev=192782&r1=192781&r2=192782&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc Wed Oct 16 04:56:17 2013
@@ -134,7 +134,7 @@ static void PrintLocation(const ReportLo
bool print_stack = false;
Printf("%s", d.Location());
if (loc->type == ReportLocationGlobal) {
- Printf(" Location is global '%s' of size %zu at %zx (%s+%p)\n\n",
+ Printf(" Location is global '%s' of size %zu at %p (%s+%p)\n\n",
loc->name, loc->size, loc->addr, loc->module, loc->offset);
} else if (loc->type == ReportLocationHeap) {
char thrbuf[kThreadBufSize];
More information about the llvm-commits
mailing list