diff options
| author | Alexey Samsonov <samsonov@google.com> | 2013-10-16 09:56:17 +0000 |
|---|---|---|
| committer | Alexey Samsonov <samsonov@google.com> | 2013-10-16 09:56:17 +0000 |
| commit | 1fe87e031ce8f4b75efb933c4a389ec578d1ff85 (patch) | |
| tree | b0ec5b2337d8e0e4a0d475b187ce2fb3dd2e63c6 | |
| parent | 6f943e5fb82d3afe15ac8b6d1ef471aab1cb5c08 (diff) | |
| download | bcm5719-llvm-1fe87e031ce8f4b75efb933c4a389ec578d1ff85.tar.gz bcm5719-llvm-1fe87e031ce8f4b75efb933c4a389ec578d1ff85.zip | |
[TSan] Extend test for reporting globals with races on them
llvm-svn: 192782
| -rw-r--r-- | compiler-rt/lib/tsan/lit_tests/global_race.cc | 23 | ||||
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_report.cc | 2 |
2 files changed, 21 insertions, 4 deletions
diff --git a/compiler-rt/lib/tsan/lit_tests/global_race.cc b/compiler-rt/lib/tsan/lit_tests/global_race.cc index 997f0503dee..3e26792d8d6 100644 --- a/compiler-rt/lib/tsan/lit_tests/global_race.cc +++ b/compiler-rt/lib/tsan/lit_tests/global_race.cc @@ -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]+}}) diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cc b/compiler-rt/lib/tsan/rtl/tsan_report.cc index bae7040831e..66307ae09dc 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_report.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_report.cc @@ -134,7 +134,7 @@ static void PrintLocation(const ReportLocation *loc) { 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]; |

