about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2021-06-07 13:47:27 +0200
committerhexcoder- <heiko@hexco.de>2021-06-07 13:47:27 +0200
commit2449866f21fd66f04d0da51394b6604b406095c3 (patch)
tree0d85e26eb47e2d278b2b4bd186397990e723d7af
parentc69edc2b3cc6c9d58c1d10385555817d6d1c43b0 (diff)
downloadafl++-2449866f21fd66f04d0da51394b6604b406095c3.tar.gz
more info for error logging
-rw-r--r--instrumentation/afl-compiler-rt.o.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c
index a4760153..50117012 100644
--- a/instrumentation/afl-compiler-rt.o.c
+++ b/instrumentation/afl-compiler-rt.o.c
@@ -630,7 +630,9 @@ static void __afl_unmap_shm(void) {
 
 }
 
-void write_error(char *text) {
+#define write_error(text) write_error_with_location(text, __FILE__, __LINE__)
+
+void write_error_with_location(char *text, char* filename, int linenumber) {
 
   u8 *  o = getenv("__AFL_OUT_DIR");
   char *e = strerror(errno);
@@ -643,14 +645,14 @@ void write_error(char *text) {
 
     if (f) {
 
-      fprintf(f, "Error(%s): %s\n", text, e);
+      fprintf(f, "File %s, line %d: Error(%s): %s\n", filename, linenumber, text, e);
       fclose(f);
 
     }
 
   }
 
-  fprintf(stderr, "Error(%s): %s\n", text, e);
+  fprintf(stderr, "File %s, line %d: Error(%s): %s\n", filename, linenumber, text, e);
 
 }
 
@@ -2079,3 +2081,4 @@ void __afl_coverage_interesting(u8 val, u32 id) {
 
 }
 
+#undef write_error