Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: runtime/bin/main.cc

Issue 10357003: Beginnings of a debugger wire protocol (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/fdutils_macos.cc ('k') | runtime/lib/mirrors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)) {
« no previous file with comments | « runtime/bin/fdutils_macos.cc ('k') | runtime/lib/mirrors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698