From cba9d08cddf694028ad32119efa4942f7b9b4b79 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Thu, 28 Nov 2024 10:46:11 +0000 Subject: [PATCH] Add LFIDEBUG check --- lfi-leg/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lfi-leg/main.c b/lfi-leg/main.c index 04726a8..64e4047 100644 --- a/lfi-leg/main.c +++ b/lfi-leg/main.c @@ -257,6 +257,18 @@ main(int argc, char** argv) input = argopen(args.input, "r", stdin); output = argopen(args.output, "w", stdout); + char* lfidebug = getenv("LFIDEBUG"); + if (lfidebug) { + // write input to a debug location + FILE* debug = argopen("debug-in.s", "w", NULL); + char buf[BUFSIZ]; + size_t n; + while ((n = fread(buf, 1, BUFSIZ, input)) != 0) + fwrite(buf, 1, n, debug); + fseek(input, 0, SEEK_SET); + fclose(debug); + } + if (args.arch == NULL) { args.arch = getarch(); }