about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/afl-common.c1
-rw-r--r--src/afl-showmap.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/src/afl-common.c b/src/afl-common.c
index 2802cda3..79d419cd 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -54,6 +54,7 @@ char *afl_environment_variables[] = {
     "AFL_CMIN_CRASHES_ONLY", "AFL_CODE_END", "AFL_CODE_START",
     "AFL_COMPCOV_BINNAME", "AFL_COMPCOV_LEVEL", "AFL_CUSTOM_MUTATOR_LIBRARY",
     "AFL_CUSTOM_MUTATOR_ONLY", "AFL_CXX", "AFL_DEBUG", "AFL_DEBUG_CHILD_OUTPUT",
+    "AFL_DEBUG_GDB",
     //"AFL_DEFER_FORKSRV", // not implemented anymore, so warn additionally
     "AFL_DISABLE_TRIM", "AFL_DONT_OPTIMIZE", "AFL_DUMB_FORKSRV",
     "AFL_ENTRYPOINT", "AFL_EXIT_WHEN_DONE", "AFL_FAST_CAL", "AFL_FORCE_UI",
diff --git a/src/afl-showmap.c b/src/afl-showmap.c
index 24e83721..994d80eb 100644
--- a/src/afl-showmap.c
+++ b/src/afl-showmap.c
@@ -890,10 +890,13 @@ int main(int argc, char **argv_orig, char **envp) {
     struct dirent *dir_ent;
     int            done = 0;
     u8             infile[PATH_MAX], outfile[PATH_MAX];
+    u8             wait_for_gdb = 0;
 #if !defined(DT_REG)
     struct stat statbuf;
 #endif
 
+    if (getenv("AFL_DEBUG_GDB")) wait_for_gdb = 1;
+
     fsrv->dev_null_fd = open("/dev/null", O_RDWR);
     if (fsrv->dev_null_fd < 0) { PFATAL("Unable to open /dev/null"); }
 
@@ -982,6 +985,12 @@ int main(int argc, char **argv_orig, char **envp) {
 
       if (read_file(infile)) {
 
+        if (wait_for_gdb) { 
+          fprintf(stderr, "exec: gdb -p %d\n", fsrv->child_pid);
+          fprintf(stderr, "exec: kill -CONT %d\n", getpid());
+          kill(0, SIGSTOP);
+        }
+
         showmap_run_target_forkserver(fsrv, use_argv, in_data, in_len);
         ck_free(in_data);
         tcnt = write_results_to_file(fsrv, outfile);