Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index 8991390491f3258fde761e22ea96b5170fe7b52e..b27a21fa601d65245464508e0ed762caa56466e2 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -47,6 +47,10 @@ DEFINE_FLAG(charp, vm_name, "vm", |
"The default name of this vm as reported by the VM service " |
"protocol"); |
+DEFINE_FLAG(bool, warn_on_pause_with_no_debugger, false, |
+ "Print a message when an isolate is paused but there is no " |
+ "debugger attached."); |
+ |
// The name of this of this vm as reported by the VM service protocol. |
static char* vm_name = NULL; |
@@ -922,11 +926,52 @@ void Service::SendEventWithData(const char* stream_id, |
} |
+static void ReportPauseOnConsole(ServiceEvent* event) { |
+ const char* name = event->isolate()->debugger_name(); |
+ switch (event->kind()) { |
+ case ServiceEvent::kPauseStart: |
+ OS::PrintErr( |
+ "vm-service: isolate '%s' has no debugger attached and is paused at " |
+ "start. Connect to Observatory to debug.\n", name); |
+ break; |
+ case ServiceEvent::kPauseExit: |
+ OS::PrintErr( |
+ "vm-service: isolate '%s' has no debugger attached and is paused at " |
+ "exit. Connect to Observatory to debug.\n", name); |
+ break; |
+ case ServiceEvent::kPauseException: |
+ OS::PrintErr( |
+ "vm-service: isolate '%s' has no debugger attached and is paused due " |
+ "to exception. Connect to Observatory to debug.\n", name); |
+ break; |
+ case ServiceEvent::kPauseInterrupted: |
+ OS::PrintErr( |
+ "vm-service: isolate '%s' has no debugger attached and is paused due " |
+ "to interrupt. Connect to Observatory to debug.\n", name); |
+ break; |
+ case ServiceEvent::kPauseBreakpoint: |
+ OS::PrintErr( |
+ "vm-service: isolate '%s' has no debugger attached and is paused. " |
+ "Connect to Observatory to debug.\n", name); |
+ break; |
+ default: |
+ UNREACHABLE(); |
+ break; |
+ } |
+} |
+ |
+ |
void Service::HandleEvent(ServiceEvent* event) { |
if (event->isolate() != NULL && |
ServiceIsolate::IsServiceIsolateDescendant(event->isolate())) { |
return; |
} |
+ if (FLAG_warn_on_pause_with_no_debugger && |
+ event->IsPause() && !Service::debug_stream.enabled()) { |
+ // If we are about to pause a running program which has no |
+ // debugger connected, tell the user about it. |
+ ReportPauseOnConsole(event); |
+ } |
if (!ServiceIsolate::IsRunning()) { |
return; |
} |