From 78d9fa280c1fb8a746527ed4fe93f507b13df213 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Tue, 8 Oct 2019 09:43:38 +0200 Subject: qemu maps debug print --- qemu_mode/patches/afl-qemu-cpu-inl.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'qemu_mode/patches/afl-qemu-cpu-inl.h') diff --git a/qemu_mode/patches/afl-qemu-cpu-inl.h b/qemu_mode/patches/afl-qemu-cpu-inl.h index 8660ba23..cda980e0 100644 --- a/qemu_mode/patches/afl-qemu-cpu-inl.h +++ b/qemu_mode/patches/afl-qemu-cpu-inl.h @@ -231,6 +231,21 @@ static void afl_setup(void) { } + +static void print_mappings(void) { + + u8 buf[MAX_LINE]; + FILE* f = fopen("/proc/self/maps", "r"); + + if (!f) return; + + while (fgets(buf, MAX_LINE, f)) + printf("%s", buf); + + fclose(f); + +} + /* Fork server logic, invoked once we hit _start. */ static void afl_forkserver(CPUState *cpu) { @@ -239,6 +254,9 @@ static void afl_forkserver(CPUState *cpu) { if (forkserver_installed == 1) return; forkserver_installed = 1; + + if (getenv("AFL_QEMU_DEBUG_MAPS")) + print_mappings(); // if (!afl_area_ptr) return; // not necessary because of fixed dummy buffer -- cgit 1.4.1