| Index: runtime/bin/main.cc
|
| ===================================================================
|
| --- runtime/bin/main.cc (revision 7329)
|
| +++ runtime/bin/main.cc (working copy)
|
| @@ -11,6 +11,7 @@
|
|
|
| #include "bin/builtin.h"
|
| #include "bin/dartutils.h"
|
| +#include "bin/dbg_connection.h"
|
| #include "bin/directory.h"
|
| #include "bin/eventhandler.h"
|
| #include "bin/extensions.h"
|
| @@ -46,6 +47,15 @@
|
| static const char* breakpoint_at = NULL;
|
|
|
|
|
| +// Global state that indicates whether we should open a connection
|
| +// and listen for a debugger to connect.
|
| +static bool start_debugger = false;
|
| +static const int DEFAULT_DEBUG_PORT = 5858;
|
| +static const char* DEFAULT_DEBUG_IP = "127.0.0.1";
|
| +static const char* debug_ip = DEFAULT_DEBUG_IP;
|
| +static int debug_port = 0;
|
| +
|
| +
|
| // Value of the --package-root flag.
|
| // (This pointer points into an argv buffer and does not need to be
|
| // free'd.)
|
| @@ -84,6 +94,28 @@
|
| }
|
|
|
|
|
| +static void ProcessDebugOption(const char* port) {
|
| + // TODO(hausner): Add support for specifying an IP address on which
|
| + // the debugger should listen.
|
| + ASSERT(port != NULL);
|
| + debug_port = 0;
|
| + if (*port == '\0') {
|
| + debug_port = DEFAULT_DEBUG_PORT;
|
| + } else {
|
| + if ((*port == '=') || (*port == ':')) {
|
| + debug_port = atoi(port + 1);
|
| + }
|
| + }
|
| + if (debug_port == 0) {
|
| + fprintf(stderr, "unrecognized --debug option syntax. "
|
| + "Use --debug[:<port number>]\n");
|
| + return;
|
| + }
|
| + breakpoint_at = "main";
|
| + start_debugger = true;
|
| +}
|
| +
|
| +
|
| static void ProcessPprofOption(const char* filename) {
|
| ASSERT(filename != NULL);
|
| generate_pprof_symbols_filename = filename;
|
| @@ -102,6 +134,7 @@
|
| } main_options[] = {
|
| { "--break_at=", ProcessBreakpointOption },
|
| { "--compile_all", ProcessCompileAllOption },
|
| + { "--debug", ProcessDebugOption },
|
| { "--generate_pprof_symbols=", ProcessPprofOption },
|
| { "--import_map=", ProcessImportMapOption },
|
| { "--package-root=", ProcessPackageRootOption },
|
| @@ -613,6 +646,13 @@
|
| Dart_GetError(result));
|
| }
|
| }
|
| +
|
| + // Start the debugger wire protocol handler if necessary.
|
| + if (start_debugger) {
|
| + ASSERT(debug_port != 0);
|
| + DebuggerConnectionHandler::StartHandler(debug_ip, debug_port);
|
| + }
|
| +
|
| // Lookup and invoke the top level main function.
|
| result = Dart_Invoke(library, Dart_NewString("main"), 0, NULL);
|
| if (Dart_IsError(result)) {
|
|
|