forked from OSchip/llvm-project
[TSan] Extend test for reporting globals with races on them
llvm-svn: 192782
This commit is contained in:
parent
6f943e5fb8
commit
1fe87e031c
|
@ -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
|
||||
// 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 '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
|
||||
// CHECK: Location is global 'XXX::YYY::ZZZ' of size 40 at [[ADDR3]] ({{.*}}+0x{{[0-9,a-f]+}})
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue