Skip to content

Commit d4071b0

Browse files
committed
debug
1 parent 5a0a33e commit d4071b0

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

src/afl-fuzz-queue.c

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ inline u32 select_next_queue_entry(afl_state_t *afl) {
6060

6161
}
6262

63+
#define DEBUG_QUEUE 1
6364
double compute_weight(afl_state_t *afl, struct queue_entry *q,
6465
double avg_exec_us, double avg_bitmap_size,
6566
double avg_top_size, double avg_score) {
@@ -73,15 +74,46 @@ double compute_weight(afl_state_t *afl, struct queue_entry *q,
7374

7475
}
7576

77+
#ifdef DEBUG_QUEUE
78+
fprintf(stderr, "WEIGHT id=%u fname=%s start_weight=1.0\n", q->id, q->fname);
79+
fprintf(stderr, " after step 1: %.2f (log10(hits))\n", weight);
80+
#endif
7681
if (likely(afl->schedule < RARE)) { weight *= (avg_exec_us / q->exec_us); }
82+
#ifdef DEBUG_QUEUE
83+
fprintf(stderr, " after step 2: %.2f (exec_us)\n", weight);
84+
#endif
7785
weight *= (log(q->bitmap_size) / avg_bitmap_size);
86+
#ifdef DEBUG_QUEUE
87+
fprintf(stderr, " after step 3: %.2f (log(bitmap_size))\n", weight);
88+
#endif
7889
weight *= (1 + (q->tc_ref / avg_top_size));
79-
if (unlikely(avg_score != 0.0)) { weight *= (log(q->score) / avg_score); }
90+
#ifdef DEBUG_QUEUE
91+
fprintf(stderr, " after step 4: %.2f (top_size)\n", weight);
92+
#endif
93+
if (unlikely(avg_score != 0.0)) { weight *= (q->score / avg_score); }
94+
#ifdef DEBUG_QUEUE
95+
fprintf(stderr, " after step 5: %.2f (score)\n", weight);
96+
#endif
8097

8198
if (unlikely(weight < 0.1)) { weight = 0.1; }
82-
if (unlikely(q->favored)) { weight *= 5; }
83-
if (unlikely(!q->was_fuzzed)) { weight *= 2; }
84-
if (unlikely(q->fs_redundant)) { weight *= 0.8; }
99+
if (unlikely(q->favored)) {
100+
101+
weight += 1;
102+
weight *= 5;
103+
104+
}
105+
106+
#ifdef DEBUG_QUEUE
107+
fprintf(stderr, " after step 6: %.2f (favored)\n", weight);
108+
#endif
109+
if (unlikely(!q->was_fuzzed)) { weight *= 2.5; }
110+
#ifdef DEBUG_QUEUE
111+
fprintf(stderr, " after step 7: %.2f (was_fuzzed)\n", weight);
112+
#endif
113+
if (unlikely(q->fs_redundant)) { weight *= 0.75; }
114+
#ifdef DEBUG_QUEUE
115+
fprintf(stderr, " after final step: %.2f (fs_redundant)\n", weight);
116+
#endif
85117

86118
return weight;
87119

@@ -133,7 +165,7 @@ void create_alias_table(afl_state_t *afl) {
133165
avg_exec_us += q->exec_us;
134166
avg_bitmap_size += log(q->bitmap_size);
135167
avg_top_size += q->tc_ref;
136-
if (exploit) { avg_score += q->score; }
168+
if (exploit) { avg_score += /*log(*/ q->score /*)*/; }
137169
++active;
138170

139171
}

src/afl-fuzz.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,13 +3080,13 @@ int main(int argc, char **argv_orig, char **envp) {
30803080
struct queue_entry *q = afl->queue_buf[k];
30813081
fprintf(stderr,
30823082
"item=%u fname=%s len=%u exec_us=%llu has_new_cov=%u "
3083-
"var_behavior=%u "
3084-
"favored=%u fs_redundant=%u disabled=%u bitmap_size=%u "
3085-
"fuzz_level=%u "
3086-
"mother=%d perf_score=%.2f weight=%.2f score=%u\n",
3083+
"var_behavior=%u favored=%u fs_redundant=%u disabled=%u "
3084+
"bitmap_size=%u "
3085+
"fuzz_level=%u was_fuzzed=%u mother=%d perf_score=%.2f "
3086+
"weight=%.2f score=%u\n",
30873087
k, q->fname, q->len, q->exec_us, q->has_new_cov,
30883088
q->var_behavior, q->favored, q->fs_redundant, q->disabled,
3089-
q->bitmap_size, q->fuzz_level,
3089+
q->bitmap_size, q->fuzz_level, q->was_fuzzed,
30903090
q->mother == NULL ? -1 : (int)q->mother->id, q->perf_score,
30913091
q->weight, q->score);
30923092

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy