@@ -86,26 +86,18 @@ static int afl_track_unstable_log_fd(void) {
86
86
}
87
87
88
88
void HELPER (afl_maybe_log )(target_ulong cur_loc ) {
89
+ register uintptr_t afl_idx = cur_loc ^ afl_prev_loc ;
89
90
90
- /* If we are tracking fuzzing instability in QEMU, then we simply use the
91
- block id when updating the coverage map (rather than combining it with the
92
- id of the previous block. Therefore when afl-fuzz writes the var_bytes
93
- entries in fuzzer_stats, they actually just contain block ids rather than
94
- edge ids. */
95
- if (unlikely (afl_track_unstable_log_fd () > 0 )) {
91
+ INC_AFL_AREA (afl_idx );
96
92
97
- register uintptr_t afl_idx = cur_loc ;
98
- INC_AFL_AREA (afl_idx );
99
-
100
- } else {
101
- register uintptr_t afl_idx = cur_loc ^ afl_prev_loc ;
102
-
103
- INC_AFL_AREA (afl_idx );
93
+ // afl_prev_loc = ((cur_loc & (MAP_SIZE - 1) >> 1)) |
94
+ // ((cur_loc & 1) << ((int)ceil(log2(MAP_SIZE)) -1));
95
+ afl_prev_loc = cur_loc >> 1 ;
96
+ }
104
97
105
- // afl_prev_loc = ((cur_loc & (MAP_SIZE - 1) >> 1)) |
106
- // ((cur_loc & 1) << ((int)ceil(log2(MAP_SIZE)) -1));
107
- afl_prev_loc = cur_loc >> 1 ;
108
- }
98
+ void HELPER (afl_maybe_log_trace )(target_ulong cur_loc ) {
99
+ register uintptr_t afl_idx = cur_loc ;
100
+ INC_AFL_AREA (afl_idx );
109
101
}
110
102
111
103
static target_ulong pc_hash (target_ulong x ) {
@@ -141,7 +133,11 @@ static void afl_gen_trace(target_ulong cur_loc) {
141
133
if (cur_loc >= afl_inst_rms ) return ;
142
134
143
135
TCGv cur_loc_v = tcg_const_tl (cur_loc );
144
- gen_helper_afl_maybe_log (cur_loc_v );
136
+ if (unlikely (afl_track_unstable_log_fd () >= 0 )) {
137
+ gen_helper_afl_maybe_log_trace (cur_loc_v );
138
+ } else {
139
+ gen_helper_afl_maybe_log (cur_loc_v );
140
+ }
145
141
tcg_temp_free (cur_loc_v );
146
142
147
143
}
@@ -2105,10 +2101,11 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
2105
2101
instruction pointer so that the user can associate these back with the
2106
2102
actual binary */
2107
2103
int track_fd = afl_track_unstable_log_fd ();
2108
- if (unlikely (track_fd > 0 )) {
2109
- uintptr_t block_id = (uintptr_t )(afl_hash_ip ((uint64_t )pc ));
2110
- block_id &= (MAP_SIZE - 1 );
2111
- dprintf (track_fd , "BLOCK ID: 0x%016" PRIx64 ", PC: 0x%016zx-0x%016zx\n" , block_id , pc , pc + tb -> size );
2104
+ if (unlikely (track_fd >= 0 )) {
2105
+ uintptr_t block_id = (uintptr_t )(afl_hash_ip ((uint64_t )pc ));
2106
+ block_id &= (MAP_SIZE - 1 );
2107
+ dprintf (track_fd , "BLOCK ID: 0x%016" PRIx64 ", PC: 0x%016zx-0x%016zx\n" ,
2108
+ block_id , pc , pc + tb -> size );
2112
2109
}
2113
2110
2114
2111
/* generate machine code */
0 commit comments