Index: src/main.cc
===================================================================
--- src/main.cc	(revision b3976bffdbe2eaf5064329ae5c0c09b3c7a4bb36)
+++ src/main.cc	(revision dee1f892debc88dfe69449a54ea03dbb87f3f3d0)
@@ -17,8 +17,8 @@
 #include <execinfo.h>                       // for backtrace, backtrace_symbols
 #include <getopt.h>                         // for no_argument, optind, geto...
-#include <signal.h>                         // for signal, SIGABRT, SIGSEGV
 #include <cassert>                          // for assertf
 #include <cstdio>                           // for fopen, FILE, fclose, stdin
 #include <cstdlib>                          // for exit, free, abort, EXIT_F...
+#include <csignal>                         // for signal, SIGABRT, SIGSEGV
 #include <cstring>                          // for index
 #include <fstream>                          // for ofstream
@@ -96,4 +96,6 @@
 DeclarationNode * parseTree = nullptr;					// program parse tree
 
+static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start
+
 static std::string PreludeDirector = "";
 
@@ -167,5 +169,4 @@
 } // sigAbortHandler
 
-
 int main( int argc, char * argv[] ) {
 	FILE * input;										// use FILE rather than istream because yyin is FILE
@@ -185,4 +186,11 @@
 	parse_cmdline( argc, argv, filename );				// process command-line arguments
 	CodeGen::FixMain::setReplaceMain( !nomainp );
+
+	if(waiting_for_gdb) {
+		std::cerr << "Waiting for gdb" << std::endl;
+		std::cerr << "run :" << std::endl;
+		std::cerr << "  gdb attach " << getpid() << std::endl;
+		raise(SIGSTOP);
+	}
 
 	try {
@@ -198,4 +206,5 @@
 		} else {										// no input file name
 			input = stdin;
+			std::cerr << "Input from stdin" << std::endl;
 			// if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
 			// a fake name along
@@ -438,5 +447,5 @@
 
 
-static const char optstring[] = ":hlLmNnpP:S:twW:D:F:";
+static const char optstring[] = ":hlLmNnpP:S:tgwW:D:F:";
 
 enum { PreludeDir = 128 };
@@ -453,4 +462,5 @@
 	{ "statistics", required_argument, nullptr, 'S' },
 	{ "tree", no_argument, nullptr, 't' },
+	{ "gdb", no_argument, nullptr, 'g' },
 	{ "", no_argument, nullptr, 0 },					// -w
 	{ "", no_argument, nullptr, 0 },					// -W
@@ -471,5 +481,6 @@
 	"<directory> prelude directory for debug/nodebug",	// no flag
 	"<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
-	"build in tree",									// -t
+	"building cfa standard lib",									// -t
+	"wait for gdb to attach",									// -g
 	"",													// -w
 	"",													// -W
@@ -582,6 +593,9 @@
 			Stats::parse_params( optarg );
 			break;
-		  case 't':										// build in tree
+		  case 't':										// building cfa stdlib
 			treep = true;
+			break;
+		  case 'g':										// wait for gdb
+			waiting_for_gdb = true;
 			break;
 		  case 'w':										// suppress all warnings, hidden
