From 2268b0aee25ddd9d3a0df6159220bb8c5510e844 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 2 Jan 2024 20:29:56 +0800 Subject: [PATCH] main - Add a hacky option to pause to allow attaching a debugger (e.g. WinDbg time-travel debug) --- src/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 41e0f17a..1923446f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,6 +83,9 @@ struct ProgramParams ::std::set< ::std::string> features; struct { + /// Testing hack: Pause just after startup (to allow a debugger to attach) + bool pause = false; + bool disable_mir_optimisations = false; bool full_validate = false; bool full_validate_early = false; @@ -239,6 +242,12 @@ int main(int argc, char *argv[]) init_debug_list(); ProgramParams params(argc, argv); + if(params.debug.pause) { + char c; + ::std::cerr << "Pausing to attach a debugger\nType any text to continue" << std::endl; + ::std::cin >> c; + } + // Set up cfg values CompilePhaseV("Setup", [&]() { Cfg_SetValue("rust_compiler", "mrustc"); @@ -1133,6 +1142,9 @@ ProgramParams::ProgramParams(int argc, char *argv[]) exit(1); } } + else if( optname == "pause-after-start" ) { + this->debug.pause = true; + } else if( optname == "print-cfgs") { no_optval(); this->print_cfgs = true;