mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-09 08:41:32 +00:00
code format and debug
This commit is contained in:
parent
b3fee6cab2
commit
e8da5f9e28
@ -18,7 +18,7 @@ libAFLDriver.a: aflpp_driver.o
|
|||||||
ar ru libAFLDriver.a aflpp_driver.o
|
ar ru libAFLDriver.a aflpp_driver.o
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
$(LLVM_BINDIR)clang++ -D_DEBUG=\"1\" $(FLAGS) -stdlib=libc++ -funroll-loops -std=c++11 -c aflpp_driver.cpp
|
$(LLVM_BINDIR)clang++ -I../../include -D_DEBUG=\"1\" $(FLAGS) -stdlib=libc++ -funroll-loops -std=c++11 -c aflpp_driver.cpp
|
||||||
ar ru libAFLDriver.a aflpp_driver.o
|
ar ru libAFLDriver.a aflpp_driver.o
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +54,10 @@ If 1, close stdout at startup. If 2 close stderr; if 3 close both.
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#include "hash.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Platform detection. Copied from FuzzerInternal.h
|
// Platform detection. Copied from FuzzerInternal.h
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#define LIBFUZZER_LINUX 1
|
#define LIBFUZZER_LINUX 1
|
||||||
@ -273,7 +277,7 @@ int main(int argc, char **argv) {
|
|||||||
int num_runs = 0;
|
int num_runs = 0;
|
||||||
while (__afl_persistent_loop(N)) {
|
while (__afl_persistent_loop(N)) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
fprintf(stderr, "len: %u\n", *__afl_fuzz_len);
|
fprintf(stderr, "CLIENT crc: %08x len: %u\n", hash32(__afl_fuzz_ptr, *__afl_fuzz_len, 0xa5b35705), *__afl_fuzz_len);
|
||||||
#endif
|
#endif
|
||||||
if (*__afl_fuzz_len) {
|
if (*__afl_fuzz_len) {
|
||||||
num_runs++;
|
num_runs++;
|
||||||
|
@ -837,8 +837,8 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) {
|
|||||||
|
|
||||||
*fsrv->shmem_fuzz_len = len;
|
*fsrv->shmem_fuzz_len = len;
|
||||||
memcpy(fsrv->shmem_fuzz, buf, len);
|
memcpy(fsrv->shmem_fuzz, buf, len);
|
||||||
// printf("test case len: %u [0]:0x%02x\n", *fsrv->shmem_fuzz_len, buf[0]);
|
// fprintf(stderr, "FS crc: %08x len: %u\n", hash32(fsrv->shmem_fuzz,
|
||||||
// fflush(stdout);
|
// *fsrv->shmem_fuzz_len, 0xa5b35705), *fsrv->shmem_fuzz_len);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
|||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
cpuset_t * c;
|
cpuset_t * c;
|
||||||
#elif defined(__sun)
|
#elif defined(__sun)
|
||||||
psetid_t c;
|
psetid_t c;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u8 cpu_used[4096] = {0};
|
u8 cpu_used[4096] = {0};
|
||||||
@ -185,10 +185,10 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
|||||||
ck_free(procs);
|
ck_free(procs);
|
||||||
#elif defined(__sun)
|
#elif defined(__sun)
|
||||||
kstat_named_t *n;
|
kstat_named_t *n;
|
||||||
kstat_ctl_t *m;
|
kstat_ctl_t * m;
|
||||||
kstat_t *k;
|
kstat_t * k;
|
||||||
cpu_stat_t cs;
|
cpu_stat_t cs;
|
||||||
u32 ncpus;
|
u32 ncpus;
|
||||||
|
|
||||||
m = kstat_open();
|
m = kstat_open();
|
||||||
|
|
||||||
@ -213,10 +213,9 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
|||||||
n = kstat_data_lookup(k, "ncpus");
|
n = kstat_data_lookup(k, "ncpus");
|
||||||
ncpus = n->value.i32;
|
ncpus = n->value.i32;
|
||||||
|
|
||||||
if (ncpus > sizeof(cpu_used))
|
if (ncpus > sizeof(cpu_used)) ncpus = sizeof(cpu_used);
|
||||||
ncpus = sizeof(cpu_used);
|
|
||||||
|
|
||||||
for (i = 0; i < ncpus; i ++) {
|
for (i = 0; i < ncpus; i++) {
|
||||||
|
|
||||||
k = kstat_lookup(m, "cpu_stat", i, NULL);
|
k = kstat_lookup(m, "cpu_stat", i, NULL);
|
||||||
if (kstat_read(m, k, &cs)) {
|
if (kstat_read(m, k, &cs)) {
|
||||||
@ -226,8 +225,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cs.cpu_sysinfo.cpu[CPU_IDLE] > 0)
|
if (cs.cpu_sysinfo.cpu[CPU_IDLE] > 0) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (cs.cpu_sysinfo.cpu[CPU_USER] > 0 || cs.cpu_sysinfo.cpu[CPU_KERNEL] > 0)
|
if (cs.cpu_sysinfo.cpu[CPU_USER] > 0 || cs.cpu_sysinfo.cpu[CPU_KERNEL] > 0)
|
||||||
cpu_used[i] = 1;
|
cpu_used[i] = 1;
|
||||||
@ -283,8 +281,8 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
|||||||
if (c == NULL) PFATAL("cpuset_create failed");
|
if (c == NULL) PFATAL("cpuset_create failed");
|
||||||
cpuset_set(i, c);
|
cpuset_set(i, c);
|
||||||
#elif defined(__sun)
|
#elif defined(__sun)
|
||||||
pset_create(&c);
|
pset_create(&c);
|
||||||
if (pset_assign(c, i, NULL)) PFATAL("pset_assign failed");
|
if (pset_assign(c, i, NULL)) PFATAL("pset_assign failed");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@ -316,31 +314,31 @@ void bind_to_free_cpu(afl_state_t *afl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
if (pthread_setaffinity_np(pthread_self(), cpuset_size(c), c)) {
|
if (pthread_setaffinity_np(pthread_self(), cpuset_size(c), c)) {
|
||||||
|
|
||||||
if (cpu_start == afl->cpu_core_count)
|
if (cpu_start == afl->cpu_core_count)
|
||||||
PFATAL("pthread_setaffinity failed for cpu %d, exit", i);
|
PFATAL("pthread_setaffinity failed for cpu %d, exit", i);
|
||||||
WARNF("pthread_setaffinity failed to CPU %d, trying next CPU", i);
|
WARNF("pthread_setaffinity failed to CPU %d, trying next CPU", i);
|
||||||
cpu_start++;
|
cpu_start++;
|
||||||
goto try
|
goto try
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cpuset_destroy(c);
|
cpuset_destroy(c);
|
||||||
#elif defined(__sun)
|
#elif defined(__sun)
|
||||||
if (pset_bind(c, P_PID, getpid(), NULL)) {
|
if (pset_bind(c, P_PID, getpid(), NULL)) {
|
||||||
|
|
||||||
if (cpu_start == afl->cpu_core_count)
|
if (cpu_start == afl->cpu_core_count)
|
||||||
PFATAL("pset_bind failed for cpu %d, exit", i);
|
PFATAL("pset_bind failed for cpu %d, exit", i);
|
||||||
WARNF("pthread_setaffinity failed to CPU %d, trying next CPU", i);
|
WARNF("pthread_setaffinity failed to CPU %d, trying next CPU", i);
|
||||||
cpu_start++;
|
cpu_start++;
|
||||||
goto try
|
goto try
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pset_destroy(c);
|
pset_destroy(c);
|
||||||
#else
|
#else
|
||||||
// this will need something for other platforms
|
// this will need something for other platforms
|
||||||
// TODO: Solaris/Illumos has processor_bind ... might worth a try
|
// TODO: Solaris/Illumos has processor_bind ... might worth a try
|
||||||
|
@ -204,8 +204,7 @@ int main(int argc, char **argv) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__sun)
|
#if defined(__sun)
|
||||||
if (pset_bind(c, P_PID, getpid(), NULL))
|
if (pset_bind(c, P_PID, getpid(), NULL)) PFATAL("pset_bind failed");
|
||||||
PFATAL("pset_bind failed");
|
|
||||||
|
|
||||||
pset_destroy(c);
|
pset_destroy(c);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user