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

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: 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
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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 { 919 {
916 NoSafepointScope no_safepoint; 920 NoSafepointScope no_safepoint;
917 memmove(message.DataAddr(offset), data, size); 921 memmove(message.DataAddr(offset), data, size);
918 offset += size; 922 offset += size;
919 } 923 }
920 ASSERT(offset == total_bytes); 924 ASSERT(offset == total_bytes);
921 SendEvent(stream_id, event_type, message); 925 SendEvent(stream_id, event_type, message);
922 } 926 }
923 927
924 928
929 static void ReportPauseOnConsole(ServiceEvent* event) {
930 const char* name = event->isolate()->debugger_name();
931 switch (event->kind()) {
932 case ServiceEvent::kPauseStart:
933 OS::PrintErr(
934 "vm-service: isolate '%s' has no debugger attached and is paused at "
935 "start. Connect to Observatory to debug.\n", name);
936 break;
937 case ServiceEvent::kPauseExit:
938 OS::PrintErr(
939 "vm-service: isolate '%s' has no debugger attached and is paused at "
940 "exit. Connect to Observatory to debug.\n", name);
941 break;
942 case ServiceEvent::kPauseException:
943 OS::PrintErr(
944 "vm-service: isolate '%s' has no debugger attached and is paused due "
945 "to exception. Connect to Observatory to debug.\n", name);
946 break;
947 case ServiceEvent::kPauseInterrupted:
948 OS::PrintErr(
949 "vm-service: isolate '%s' has no debugger attached and is paused due "
950 "to interrupt. Connect to Observatory to debug.\n", name);
951 break;
952 case ServiceEvent::kPauseBreakpoint:
953 OS::PrintErr(
954 "vm-service: isolate '%s' has no debugger attached and is paused. "
955 "Connect to Observatory to debug.\n", name);
956 break;
957 default:
958 UNREACHABLE();
959 break;
960 }
961 }
962
963
925 void Service::HandleEvent(ServiceEvent* event) { 964 void Service::HandleEvent(ServiceEvent* event) {
926 if (event->isolate() != NULL && 965 if (event->isolate() != NULL &&
927 ServiceIsolate::IsServiceIsolateDescendant(event->isolate())) { 966 ServiceIsolate::IsServiceIsolateDescendant(event->isolate())) {
928 return; 967 return;
929 } 968 }
969 if (FLAG_warn_on_pause_with_no_debugger &&
970 event->IsPause() && !Service::debug_stream.enabled()) {
971 // If we are about to pause a running program which has no
972 // debugger connected, tell the user about it.
973 ReportPauseOnConsole(event);
974 }
930 if (!ServiceIsolate::IsRunning()) { 975 if (!ServiceIsolate::IsRunning()) {
931 return; 976 return;
932 } 977 }
933 JSONStream js; 978 JSONStream js;
934 const char* stream_id = event->stream_id(); 979 const char* stream_id = event->stream_id();
935 ASSERT(stream_id != NULL); 980 ASSERT(stream_id != NULL);
936 { 981 {
937 JSONObject jsobj(&js); 982 JSONObject jsobj(&js);
938 jsobj.AddProperty("jsonrpc", "2.0"); 983 jsobj.AddProperty("jsonrpc", "2.0");
939 jsobj.AddProperty("method", "streamNotify"); 984 jsobj.AddProperty("method", "streamNotify");
(...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after
3866 const ServiceMethodDescriptor& method = service_methods_[i]; 3911 const ServiceMethodDescriptor& method = service_methods_[i];
3867 if (strcmp(method_name, method.name) == 0) { 3912 if (strcmp(method_name, method.name) == 0) {
3868 return &method; 3913 return &method;
3869 } 3914 }
3870 } 3915 }
3871 return NULL; 3916 return NULL;
3872 } 3917 }
3873 3918
3874 3919
3875 } // namespace dart 3920 } // namespace dart
OLDNEW
« runtime/bin/main.cc ('K') | « 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