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

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
Index: runtime/bin/main.cc
===================================================================
--- runtime/bin/main.cc (revision 7293)
+++ 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,13 @@
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 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 +92,26 @@
}
+static void ProcessDebugOption(const char* port) {
+ 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");
siva 2012/05/03 22:52:08 see comment regarding having this option be --debu
hausner 2012/05/03 23:52:00 Done.
+ return;
+ }
+ breakpoint_at = "main";
siva 2012/05/03 22:52:08 Maybe later on this should also be a command line
hausner 2012/05/03 23:52:00 I agree. For now, I need this because I can't inte
+ start_debugger = true;
+}
+
+
static void ProcessPprofOption(const char* filename) {
ASSERT(filename != NULL);
generate_pprof_symbols_filename = filename;
@@ -102,6 +130,7 @@
} main_options[] = {
{ "--break_at=", ProcessBreakpointOption },
{ "--compile_all", ProcessCompileAllOption },
+ { "--debug", ProcessDebugOption },
{ "--generate_pprof_symbols=", ProcessPprofOption },
{ "--import_map=", ProcessImportMapOption },
{ "--package-root=", ProcessPackageRootOption },
@@ -613,6 +642,13 @@
Dart_GetError(result));
}
}
+
+ // Start the debugger wire protocol handler if necessary.
+ if (start_debugger) {
+ ASSERT(debug_port != 0);
+ DebuggerConnectionHandler::StartHandler(debug_port);
+ }
+
// Lookup and invoke the top level main function.
result = Dart_Invoke(library, Dart_NewString("main"), 0, NULL);
if (Dart_IsError(result)) {

Powered by Google App Engine
This is Rietveld 408576698