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

Side by Side Diff: runtime/vm/service.cc

Issue 1649843002: Add --warn-on-pause-with-no-debugger flag. Add this to --observe behavior. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code review, etc. Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/service_event.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 29 matching lines...) Expand all
40 40
41 #define Z (T->zone()) 41 #define Z (T->zone())
42 42
43 43
44 DECLARE_FLAG(bool, trace_service); 44 DECLARE_FLAG(bool, trace_service);
45 DECLARE_FLAG(bool, trace_service_pause_events); 45 DECLARE_FLAG(bool, trace_service_pause_events);
46 DEFINE_FLAG(charp, vm_name, "vm", 46 DEFINE_FLAG(charp, vm_name, "vm",
47 "The default name of this vm as reported by the VM service " 47 "The default name of this vm as reported by the VM service "
48 "protocol"); 48 "protocol");
49 49
50 DEFINE_FLAG(bool, warn_on_pause_with_no_debugger, false,
51 "Print a message when an isolate is paused but there is no "
52 "debugger attached.");
53
50 // The name of this of this vm as reported by the VM service protocol. 54 // The name of this of this vm as reported by the VM service protocol.
51 static char* vm_name = NULL; 55 static char* vm_name = NULL;
52 56
53 57
54 static const char* GetVMName() { 58 static const char* GetVMName() {
55 if (vm_name == NULL) { 59 if (vm_name == NULL) {
56 return FLAG_vm_name; 60 return FLAG_vm_name;
57 } 61 }
58 return vm_name; 62 return vm_name;
59 } 63 }
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 { 944 {
941 NoSafepointScope no_safepoint; 945 NoSafepointScope no_safepoint;
942 memmove(message.DataAddr(offset), data, size); 946 memmove(message.DataAddr(offset), data, size);
943 offset += size; 947 offset += size;
944 } 948 }
945 ASSERT(offset == total_bytes); 949 ASSERT(offset == total_bytes);
946 SendEvent(stream_id, event_type, message); 950 SendEvent(stream_id, event_type, message);
947 } 951 }
948 952
949 953
954 static void ReportPauseOnConsole(ServiceEvent* event) {
955 const char* name = event->isolate()->debugger_name();
956 switch (event->kind()) {
957 case ServiceEvent::kPauseStart:
958 OS::PrintErr(
959 "vm-service: isolate '%s' has no debugger attached and is paused at "
960 "start.", name);
961 break;
962 case ServiceEvent::kPauseExit:
963 OS::PrintErr(
964 "vm-service: isolate '%s' has no debugger attached and is paused at "
965 "exit.", name);
966 break;
967 case ServiceEvent::kPauseException:
968 OS::PrintErr(
969 "vm-service: isolate '%s' has no debugger attached and is paused due "
970 "to exception.", name);
971 break;
972 case ServiceEvent::kPauseInterrupted:
973 OS::PrintErr(
974 "vm-service: isolate '%s' has no debugger attached and is paused due "
975 "to interrupt.", name);
976 break;
977 case ServiceEvent::kPauseBreakpoint:
978 OS::PrintErr(
979 "vm-service: isolate '%s' has no debugger attached and is paused.",
980 name);
981 break;
982 default:
983 UNREACHABLE();
984 break;
985 }
986 if (!ServiceIsolate::IsRunning()) {
987 OS::PrintErr(" Start the vm-service to debug.\n");
988 } else if (ServiceIsolate::server_address() == NULL) {
989 OS::PrintErr(" Connect to Observatory to debug.\n");
990 } else {
991 OS::PrintErr(" Connect to Observatory at %s to debug.\n",
992 ServiceIsolate::server_address());
993 }
994 }
995
996
950 void Service::HandleEvent(ServiceEvent* event) { 997 void Service::HandleEvent(ServiceEvent* event) {
951 if (event->isolate() != NULL && 998 if (event->isolate() != NULL &&
952 ServiceIsolate::IsServiceIsolateDescendant(event->isolate())) { 999 ServiceIsolate::IsServiceIsolateDescendant(event->isolate())) {
953 return; 1000 return;
954 } 1001 }
1002 if (FLAG_warn_on_pause_with_no_debugger &&
1003 event->IsPause() && !Service::debug_stream.enabled()) {
1004 // If we are about to pause a running program which has no
1005 // debugger connected, tell the user about it.
1006 ReportPauseOnConsole(event);
1007 }
955 if (!ServiceIsolate::IsRunning()) { 1008 if (!ServiceIsolate::IsRunning()) {
956 return; 1009 return;
957 } 1010 }
958 JSONStream js; 1011 JSONStream js;
959 const char* stream_id = event->stream_id(); 1012 const char* stream_id = event->stream_id();
960 ASSERT(stream_id != NULL); 1013 ASSERT(stream_id != NULL);
961 { 1014 {
962 JSONObject jsobj(&js); 1015 JSONObject jsobj(&js);
963 jsobj.AddProperty("jsonrpc", "2.0"); 1016 jsobj.AddProperty("jsonrpc", "2.0");
964 jsobj.AddProperty("method", "streamNotify"); 1017 jsobj.AddProperty("method", "streamNotify");
(...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after
3891 const ServiceMethodDescriptor& method = service_methods_[i]; 3944 const ServiceMethodDescriptor& method = service_methods_[i];
3892 if (strcmp(method_name, method.name) == 0) { 3945 if (strcmp(method_name, method.name) == 0) {
3893 return &method; 3946 return &method;
3894 } 3947 }
3895 } 3948 }
3896 return NULL; 3949 return NULL;
3897 } 3950 }
3898 3951
3899 3952
3900 } // namespace dart 3953 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/service_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698