44 {
45 (void) argc;
46 (void) args;
47
48 char myLine[16384];
50 char type1, type2;
51 char fname1[256], fname2[256];
52 char *paren1, *paren2;
53
54 FILE *HELOUT = fopen("helgrind_out.txt", "r");
55 if (HELOUT == NULL) {
56 fprintf(
stderr,
"Could not open helgrind_out.txt.\n");
57 exit(-1);
58 }
59
60 char PDRR[]="Possible data race during read";
61 char PDRW[]="Possible data race during write";
62 char TCWW[]="This conflicts with a previous write";
63 char TCWR[]="This conflicts with a previous read";
64 char atSTR[]=" at ";
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
84 while (fgets(myLine, 16384, HELOUT) != NULL) {
85 if (strlen(myLine) < 20) continue;
87 case 0:
88 if (strstr(myLine, PDRR) != NULL) {
89 type1='R';
91 continue;
92 }
93
94 if (strstr(myLine, PDRW) != NULL) {
95 type1='W';
97 continue;
98 }
99
100 continue;
101 break;
102
103 case 1:
104 if (strncmp(myLine+10, atSTR, 6) != 0) continue;
105 paren1=strchr(myLine, '(');
106 paren2=strchr(myLine, ')');
107 if (paren1 == NULL || paren2 == NULL ||
108 paren1 > paren2) {
110 continue;
111 }
112
113 size = paren2-paren1-1;
114 strncpy(fname1, paren1+1, size);
115 fname1[size]=0;
117 continue;
118 break;
119
120 case 2:
121 if (strstr(myLine, TCWR) != NULL) {
122 type2='R';
124 continue;
125 }
126
127 if (strstr(myLine, TCWW) != NULL) {
128 type2='W';
130 continue;
131 }
132
133 if (strstr(myLine, PDRR) != NULL) {
134 type1='R';
136 continue;
137 }
138
139 if (strstr(myLine, PDRW) != NULL) {
140 type1='W';
142 continue;
143 }
144
145 continue;
146 break;
147
148 case 3:
149 if (strncmp(myLine+10, atSTR, 6) != 0) continue;
150 paren1=strchr(myLine, '(');
151 paren2=strchr(myLine, ')');
152 if (paren1 == NULL || paren2 == NULL ||
153 paren1 > paren2) {
155 continue;
156 }
157
158 size = paren2-paren1-1;
159 strncpy(fname2, paren1+1, size);
160 fname2[size]=0;
161 fprintf(
stdout,
"%c@%-32s %c@%-32s\n", type1, fname1, type2, fname2);
163 continue;
164 break;
165 }
166 }
167
169 exit(0);
170}
int fclose(FILE *__stream)