From 51edc6909ce99b1fc5922df1d491ec65305943f3 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 21 Mar 2016 10:46:43 -0700 Subject: [PATCH] Log more in the fuzzer --- fuzzer/command_file.cpp | 2 +- fuzzer/fuzzer.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fuzzer/command_file.cpp b/fuzzer/command_file.cpp index 28123abe..e3f836ae 100644 --- a/fuzzer/command_file.cpp +++ b/fuzzer/command_file.cpp @@ -52,7 +52,7 @@ static void run_modify(RealmState& state, size_t index, int64_t value) static void run_delete(RealmState& state, size_t index) { if (index < state.table.size()) { - log("delete %zu\n", index); + log("delete %zu (%lld)\n", index, state.table.get_int(1, index)); state.table.move_last_over(index); } } diff --git a/fuzzer/fuzzer.cpp b/fuzzer/fuzzer.cpp index 3a6d5648..b1c9aebb 100644 --- a/fuzzer/fuzzer.cpp +++ b/fuzzer/fuzzer.cpp @@ -22,6 +22,7 @@ using namespace realm; #define FUZZ_SORTED 0 #define FUZZ_LINKVIEW 1 +#define FUZZ_LOG 0 // Read from a fd until eof into a string // Needs to use unbuffered i/o to work properly with afl @@ -63,6 +64,11 @@ static TableView tableview(fuzzer::RealmState& state) static bool apply_changes(fuzzer::CommandFile& commands, fuzzer::RealmState& state) { auto tv = tableview(state); +#if FUZZ_LOG + for (size_t i = 0; i < tv.size(); ++i) + fprintf(stderr, "pre: %lld\n", tv.get_int(0, i)); +#endif + commands.run(state); auto tv2 = tableview(state); @@ -70,6 +76,9 @@ static bool apply_changes(fuzzer::CommandFile& commands, fuzzer::RealmState& sta return true; for (size_t i = 0; i < tv.size(); ++i) { +#if FUZZ_LOG + fprintf(stderr, "%lld %lld\n", tv.get_int(0, i), tv2.get_int(0, i)); +#endif if (!tv.is_row_attached(i)) return true; if (tv.get_int(0, i) != tv2.get_int(0, i)) @@ -114,6 +123,9 @@ static void verify(CollectionChangeIndices const& changes, std::vector for (size_t i = 0; i < values.size(); ++i) { if (values[i] != tv.get_int(1, i)) { +#if FUZZ_LOG + fprintf(stderr, "%lld %lld\n", values[i], tv.get_int(1, i)); +#endif abort(); } }