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

Unified Diff: runtime/bin/main.cc

Issue 19231005: Initial NOOP VM Service (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/bin.gypi ('k') | runtime/bin/resources.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index af293005be2a52d25f9f95c0a57dcd8c8c4605bb..7d892524c7e7faae6ba75c80721d44e3901c4d6c 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -20,6 +20,7 @@
#include "bin/log.h"
#include "bin/platform.h"
#include "bin/process.h"
+#include "bin/vmservice_impl.h"
#include "platform/globals.h"
namespace dart {
@@ -66,6 +67,12 @@ static bool has_check_function_fingerprints = false;
static bool has_print_script = false;
+// VM Service options.
+static bool start_vm_service = false;
+static int vm_service_server_port = -1;
+static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
+
+
static bool IsValidFlag(const char* name,
const char* prefix,
intptr_t prefix_length) {
@@ -199,6 +206,25 @@ static bool ProcessGenScriptSnapshotOption(const char* filename) {
}
+static bool ProcessEnableVmServiceOption(const char* port) {
+ ASSERT(port != NULL);
+ vm_service_server_port = -1;
+ if (*port == '\0') {
+ vm_service_server_port = DEFAULT_VM_SERVICE_SERVER_PORT;
+ } else {
+ if ((*port == '=') || (*port == ':')) {
+ vm_service_server_port = atoi(port + 1);
+ }
+ }
+ if (vm_service_server_port < 0) {
+ Log::PrintErr("unrecognized --enable-vm-service option syntax. "
+ "Use --enable-vm-service[:<port number>]\n");
+ return false;
+ }
+ start_vm_service = true;
+ return true;
+}
+
static struct {
const char* option_name;
bool (*process)(const char* option);
@@ -217,6 +243,7 @@ static struct {
{ "--snapshot=", ProcessGenScriptSnapshotOption },
{ "--print-script", ProcessPrintScriptOption },
{ "--check-function-fingerprints", ProcessFingerprintedFunctions },
+ { "--enable-vm-service", ProcessEnableVmServiceOption },
{ NULL, NULL }
};
@@ -549,6 +576,10 @@ static void PrintUsage() {
"--print-script\n"
" generates Dart source code back and prints it after parsing a Dart script\n"
"\n"
+"--enable-vm-service[:<port number>]\n"
+" enables the VM service and listens on specified port for connections\n"
+" (default port number is 8181)\n"
+"\n"
"The following options are only used for VM development and may\n"
"be changed in any future version:\n");
const char* print_flags = "--print_flags";
@@ -720,6 +751,16 @@ int main(int argc, char** argv) {
}
}
+ // Start the VM service isolate, if necessary.
+ if (start_vm_service) {
+ ASSERT(vm_service_server_port >= 0);
+ bool r = VmService::Start(vm_service_server_port);
+ if (!r) {
+ Log::PrintErr("Could not start VM Service isolate %s",
+ VmService::GetErrorMessage());
+ }
+ }
+
// Call CreateIsolateAndSetup which creates an isolate and loads up
// the specified application script.
char* error = NULL;
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/bin/resources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698