Index: ../../../pnet/engine/ilrun.c =================================================================== --- ../../../pnet/engine/ilrun.c (revision 13) +++ ../../../pnet/engine/ilrun.c (working copy) @@ -25,6 +25,7 @@ #include "il_thread.h" #include "il_coder.h" #include "engine.h" +#include "debugger.h" #if defined(HAVE_UNISTD_H) && !defined(_MSC_VER) #include @@ -110,6 +111,12 @@ "--enable-profile or -E", "Enable simple method profiling at program start."}, #endif +#ifdef IL_CONFIG_DEBUG_LINES + {"-G", 'G', 0, 0, 0}, + {"--debug", 'T', 0, + "--debug or -G", + "Connect to debugger client."}, +#endif {"-T", 'T', 0, 0, 0}, {"--trace", 'T', 0, "--trace or -T", @@ -199,6 +206,10 @@ #ifdef ENHANCED_PROFILER int profilingEnabled = 0; #endif +#ifdef IL_CONFIG_DEBUG_LINES + char *debuggerConnectionString = 0; + ILDebugger *debugger; +#endif /* Initialize the locale routines */ ILInitLocale(); @@ -324,6 +335,15 @@ break; #endif + #ifdef IL_CONFIG_DEBUG_LINES + case 'G': + { + /* TODO: read connection string argument */ + debuggerConnectionString = "tcp://localhost:4571"; + } + break; + #endif + case 'v': { version(); @@ -401,6 +421,37 @@ return 1; } +#ifdef IL_CONFIG_DEBUG_LINES + /* Extract debugger connection string from environment + * if not specified on command line */ + if(debuggerConnectionString == 0) + { + debuggerConnectionString = getenv("IL_DEBUGGER_CONNECTION_STRING"); + } + /* Connect to debugger client, if we have connection string */ + if(debuggerConnectionString) + { + /* Create debugger */ + debugger = ILDebuggerCreate(process); + if(debugger == 0) + { + fprintf(stderr, "%s: could not create debugger\n", progname); + } + else + { + /* Try to connect to debugger client */ + if(!ILDebuggerConnect(debugger, debuggerConnectionString)) + { + /* Connect failed - destroy debugger and print error */ + ILDebuggerDestroy(debugger); + fprintf(stderr, "%s: debugger connection failed on %s\n", + progname, + debuggerConnectionString); + } + } + } +#endif + ILExecProcessSetCoderFlags(process,flags); ILExecProcessSetLoadFlags(process, loadFlags, loadFlags);