@@ -508,10 +508,6 @@ int main(int argc, char** argv)
508
508
cover_open (&extra_cov, true );
509
509
cover_mmap (&extra_cov);
510
510
cover_protect (&extra_cov);
511
- if (flag_extra_coverage) {
512
- // Don't enable comps because we don't use them in the fuzzer yet.
513
- cover_enable (&extra_cov, false , true );
514
- }
515
511
char sep = ' /' ;
516
512
#if GOOS_windows
517
513
sep = ' \\ ' ;
@@ -753,7 +749,7 @@ void execute_one()
753
749
if (!flag_threaded)
754
750
cover_enable (&threads[0 ].cov , flag_comparisons, false );
755
751
if (flag_extra_coverage)
756
- cover_reset (&extra_cov);
752
+ cover_enable (&extra_cov, flag_comparisons, true );
757
753
}
758
754
759
755
int call_index = 0 ;
@@ -1110,20 +1106,11 @@ void copyout_call_results(thread_t* th)
1110
1106
}
1111
1107
}
1112
1108
1113
- void write_call_output ( thread_t * th, bool finished )
1109
+ void write_call_shmem_output ( int call_index, int call_num, uint32 reserrno, uint32 call_flags, cover_t * cov )
1114
1110
{
1115
- uint32 reserrno = ENOSYS;
1116
- const bool blocked = finished && th != last_scheduled;
1117
- uint32 call_flags = call_flag_executed | (blocked ? call_flag_blocked : 0 );
1118
- if (finished) {
1119
- reserrno = th->res != -1 ? 0 : th->reserrno ;
1120
- call_flags |= call_flag_finished |
1121
- (th->fault_injected ? call_flag_fault_injected : 0 );
1122
- }
1123
- #if SYZ_EXECUTOR_USES_SHMEM
1124
1111
write_output (kOutMagic );
1125
- write_output (th-> call_index );
1126
- write_output (th-> call_num );
1112
+ write_output (call_index);
1113
+ write_output (call_num);
1127
1114
write_output (reserrno);
1128
1115
write_output (call_flags);
1129
1116
uint32* signal_count_pos = write_output (0 ); // filled in later
@@ -1132,15 +1119,15 @@ void write_call_output(thread_t* th, bool finished)
1132
1119
1133
1120
if (flag_comparisons) {
1134
1121
// Collect only the comparisons
1135
- uint32 ncomps = th-> cov . size ;
1136
- kcov_comparison_t * start = (kcov_comparison_t *)(th-> cov . data + sizeof (uint64));
1122
+ uint32 ncomps = cov-> size ;
1123
+ kcov_comparison_t * start = (kcov_comparison_t *)(cov-> data + sizeof (uint64));
1137
1124
kcov_comparison_t * end = start + ncomps;
1138
- if ((char *)end > th-> cov . data_end )
1125
+ if ((char *)end > cov-> data_end )
1139
1126
failmsg (" too many comparisons" , " ncomps=%u" , ncomps);
1140
- cover_unprotect (&th-> cov );
1127
+ cover_unprotect (cov);
1141
1128
std::sort (start, end);
1142
1129
ncomps = std::unique (start, end) - start;
1143
- cover_protect (&th-> cov );
1130
+ cover_protect (cov);
1144
1131
uint32 comps_size = 0 ;
1145
1132
for (uint32 i = 0 ; i < ncomps; ++i) {
1146
1133
if (start[i].ignore ())
@@ -1152,15 +1139,29 @@ void write_call_output(thread_t* th, bool finished)
1152
1139
*comps_count_pos = comps_size;
1153
1140
} else if (flag_collect_signal || flag_collect_cover) {
1154
1141
if (is_kernel_64_bit)
1155
- write_coverage_signal<uint64>(&th-> cov , signal_count_pos, cover_count_pos);
1142
+ write_coverage_signal<uint64>(cov, signal_count_pos, cover_count_pos);
1156
1143
else
1157
- write_coverage_signal<uint32>(&th-> cov , signal_count_pos, cover_count_pos);
1144
+ write_coverage_signal<uint32>(cov, signal_count_pos, cover_count_pos);
1158
1145
}
1159
1146
debug_verbose (" out #%u: index=%u num=%u errno=%d finished=%d blocked=%d sig=%u cover=%u comps=%u\n " ,
1160
- completed, th-> call_index , th-> call_num , reserrno, finished, blocked,
1147
+ completed, call_index, call_num, reserrno, finished, blocked,
1161
1148
*signal_count_pos, *cover_count_pos, *comps_count_pos);
1162
1149
completed++;
1163
1150
write_completed (completed);
1151
+ }
1152
+
1153
+ void write_call_output (thread_t * th, bool finished)
1154
+ {
1155
+ uint32 reserrno = ENOSYS;
1156
+ const bool blocked = finished && th != last_scheduled;
1157
+ uint32 call_flags = call_flag_executed | (blocked ? call_flag_blocked : 0 );
1158
+ if (finished) {
1159
+ reserrno = th->res != -1 ? 0 : th->reserrno ;
1160
+ call_flags |= call_flag_finished |
1161
+ (th->fault_injected ? call_flag_fault_injected : 0 );
1162
+ }
1163
+ #if SYZ_EXECUTOR_USES_SHMEM
1164
+ write_call_shmem_output (th->call_index , th->call_num , reserrno, call_flags, &th->cov );
1164
1165
#else
1165
1166
call_reply reply;
1166
1167
reply.header .magic = kOutMagic ;
@@ -1184,27 +1185,13 @@ void write_call_output(thread_t* th, bool finished)
1184
1185
void write_extra_output ()
1185
1186
{
1186
1187
#if SYZ_EXECUTOR_USES_SHMEM
1187
- if (!cover_collection_required () || !flag_extra_coverage || flag_comparisons )
1188
+ if (!cover_collection_required () || !flag_extra_coverage)
1188
1189
return ;
1189
1190
cover_collect (&extra_cov);
1190
1191
if (!extra_cov.size )
1191
1192
return ;
1192
- write_output (kOutMagic );
1193
- write_output (-1 ); // call index
1194
- write_output (-1 ); // call num
1195
- write_output (999 ); // errno
1196
- write_output (0 ); // call flags
1197
- uint32* signal_count_pos = write_output (0 ); // filled in later
1198
- uint32* cover_count_pos = write_output (0 ); // filled in later
1199
- write_output (0 ); // comps_count_pos
1200
- if (is_kernel_64_bit)
1201
- write_coverage_signal<uint64>(&extra_cov, signal_count_pos, cover_count_pos);
1202
- else
1203
- write_coverage_signal<uint32>(&extra_cov, signal_count_pos, cover_count_pos);
1193
+ write_call_shmem_output (-1 , -1 , 999 , 0 , &extra_cov);
1204
1194
cover_reset (&extra_cov);
1205
- debug_verbose (" extra: sig=%u cover=%u\n " , *signal_count_pos, *cover_count_pos);
1206
- completed++;
1207
- write_completed (completed);
1208
1195
#endif // if SYZ_EXECUTOR_USES_SHMEM
1209
1196
}
1210
1197
0 commit comments