OLD | NEW |
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 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 | 964 |
965 void Service::HandleObjectRootMessage(const Array& msg_instance) { | 965 void Service::HandleObjectRootMessage(const Array& msg_instance) { |
966 Isolate* isolate = Isolate::Current(); | 966 Isolate* isolate = Isolate::Current(); |
967 InvokeMethod(isolate, msg_instance, true); | 967 InvokeMethod(isolate, msg_instance, true); |
968 } | 968 } |
969 | 969 |
970 | 970 |
971 void Service::HandleIsolateMessage(Isolate* isolate, const Array& msg) { | 971 void Service::HandleIsolateMessage(Isolate* isolate, const Array& msg) { |
972 ASSERT(isolate != NULL); | 972 ASSERT(isolate != NULL); |
973 InvokeMethod(isolate, msg); | 973 InvokeMethod(isolate, msg); |
| 974 MaybePause(isolate); |
974 } | 975 } |
975 | 976 |
976 | 977 |
977 static void Finalizer(void* isolate_callback_data, | 978 static void Finalizer(void* isolate_callback_data, |
978 Dart_WeakPersistentHandle handle, | 979 Dart_WeakPersistentHandle handle, |
979 void* buffer) { | 980 void* buffer) { |
980 free(buffer); | 981 free(buffer); |
981 } | 982 } |
982 | 983 |
983 | 984 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 case ServiceEvent::kPauseInterrupted: | 1079 case ServiceEvent::kPauseInterrupted: |
1079 OS::PrintErr( | 1080 OS::PrintErr( |
1080 "vm-service: isolate '%s' has no debugger attached and is paused due " | 1081 "vm-service: isolate '%s' has no debugger attached and is paused due " |
1081 "to interrupt.", name); | 1082 "to interrupt.", name); |
1082 break; | 1083 break; |
1083 case ServiceEvent::kPauseBreakpoint: | 1084 case ServiceEvent::kPauseBreakpoint: |
1084 OS::PrintErr( | 1085 OS::PrintErr( |
1085 "vm-service: isolate '%s' has no debugger attached and is paused.", | 1086 "vm-service: isolate '%s' has no debugger attached and is paused.", |
1086 name); | 1087 name); |
1087 break; | 1088 break; |
| 1089 case ServiceEvent::kPausePostRequest: |
| 1090 OS::PrintErr( |
| 1091 "vm-service: isolate '%s' has no debugger attached and is paused " |
| 1092 "post reload.", name); |
| 1093 break; |
1088 default: | 1094 default: |
1089 UNREACHABLE(); | 1095 UNREACHABLE(); |
1090 break; | 1096 break; |
1091 } | 1097 } |
1092 if (!ServiceIsolate::IsRunning()) { | 1098 if (!ServiceIsolate::IsRunning()) { |
1093 OS::PrintErr(" Start the vm-service to debug.\n"); | 1099 OS::PrintErr(" Start the vm-service to debug.\n"); |
1094 } else if (ServiceIsolate::server_address() == NULL) { | 1100 } else if (ServiceIsolate::server_address() == NULL) { |
1095 OS::PrintErr(" Connect to Observatory to debug.\n"); | 1101 OS::PrintErr(" Connect to Observatory to debug.\n"); |
1096 } else { | 1102 } else { |
1097 OS::PrintErr(" Connect to Observatory at %s to debug.\n", | 1103 OS::PrintErr(" Connect to Observatory at %s to debug.\n", |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 script, | 2509 script, |
2504 TokenPosition(start_pos), | 2510 TokenPosition(start_pos), |
2505 TokenPosition(end_pos)); | 2511 TokenPosition(end_pos)); |
2506 return true; | 2512 return true; |
2507 } | 2513 } |
2508 | 2514 |
2509 | 2515 |
2510 static const MethodParameter* reload_sources_params[] = { | 2516 static const MethodParameter* reload_sources_params[] = { |
2511 RUNNABLE_ISOLATE_PARAMETER, | 2517 RUNNABLE_ISOLATE_PARAMETER, |
2512 new BoolParameter("force", false), | 2518 new BoolParameter("force", false), |
| 2519 new BoolParameter("pause", false), |
2513 NULL, | 2520 NULL, |
2514 }; | 2521 }; |
2515 | 2522 |
2516 | 2523 |
2517 static bool ReloadSources(Thread* thread, JSONStream* js) { | 2524 static bool ReloadSources(Thread* thread, JSONStream* js) { |
2518 Isolate* isolate = thread->isolate(); | 2525 Isolate* isolate = thread->isolate(); |
2519 if (!isolate->compilation_allowed()) { | 2526 if (!isolate->compilation_allowed()) { |
2520 js->PrintError(kFeatureDisabled, | 2527 js->PrintError(kFeatureDisabled, |
2521 "Cannot reload source when running a precompiled program."); | 2528 "Cannot reload source when running a precompiled program."); |
2522 return true; | 2529 return true; |
(...skipping 24 matching lines...) Expand all Loading... |
2547 if (!isolate->CanReload()) { | 2554 if (!isolate->CanReload()) { |
2548 js->PrintError(kFeatureDisabled, | 2555 js->PrintError(kFeatureDisabled, |
2549 "This isolate cannot reload sources right now."); | 2556 "This isolate cannot reload sources right now."); |
2550 return true; | 2557 return true; |
2551 } | 2558 } |
2552 const bool force_reload = | 2559 const bool force_reload = |
2553 BoolParameter::Parse(js->LookupParam("force"), false); | 2560 BoolParameter::Parse(js->LookupParam("force"), false); |
2554 | 2561 |
2555 isolate->ReloadSources(js, force_reload); | 2562 isolate->ReloadSources(js, force_reload); |
2556 | 2563 |
| 2564 Service::CheckForPause(isolate, js); |
| 2565 |
2557 return true; | 2566 return true; |
2558 } | 2567 } |
2559 | 2568 |
2560 | 2569 |
| 2570 void Service::CheckForPause(Isolate* isolate, JSONStream* stream) { |
| 2571 // Should we pause? |
| 2572 isolate->set_should_pause_post_service_request( |
| 2573 BoolParameter::Parse(stream->LookupParam("pause"), false)); |
| 2574 } |
| 2575 |
| 2576 |
| 2577 void Service::MaybePause(Isolate* isolate) { |
| 2578 // Don't pause twice. |
| 2579 if (!isolate->IsPaused()) { |
| 2580 if (isolate->should_pause_post_service_request()) { |
| 2581 isolate->set_should_pause_post_service_request(false); |
| 2582 isolate->PausePostRequest(); |
| 2583 } |
| 2584 } |
| 2585 } |
| 2586 |
| 2587 |
2561 static bool AddBreakpointCommon(Thread* thread, | 2588 static bool AddBreakpointCommon(Thread* thread, |
2562 JSONStream* js, | 2589 JSONStream* js, |
2563 const String& script_uri) { | 2590 const String& script_uri) { |
2564 if (!thread->isolate()->compilation_allowed()) { | 2591 if (!thread->isolate()->compilation_allowed()) { |
2565 js->PrintError(kFeatureDisabled, | 2592 js->PrintError(kFeatureDisabled, |
2566 "Cannot use breakpoints when running a precompiled program."); | 2593 "Cannot use breakpoints when running a precompiled program."); |
2567 return true; | 2594 return true; |
2568 } | 2595 } |
2569 const char* line_param = js->LookupParam("line"); | 2596 const char* line_param = js->LookupParam("line"); |
2570 intptr_t line = UIntParameter::Parse(line_param); | 2597 intptr_t line = UIntParameter::Parse(line_param); |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4156 { "_getVMTimeline", GetVMTimeline, | 4183 { "_getVMTimeline", GetVMTimeline, |
4157 get_vm_timeline_params }, | 4184 get_vm_timeline_params }, |
4158 { "_getVMTimelineFlags", GetVMTimelineFlags, | 4185 { "_getVMTimelineFlags", GetVMTimelineFlags, |
4159 get_vm_timeline_flags_params }, | 4186 get_vm_timeline_flags_params }, |
4160 { "pause", Pause, | 4187 { "pause", Pause, |
4161 pause_params }, | 4188 pause_params }, |
4162 { "removeBreakpoint", RemoveBreakpoint, | 4189 { "removeBreakpoint", RemoveBreakpoint, |
4163 remove_breakpoint_params }, | 4190 remove_breakpoint_params }, |
4164 { "_restartVM", RestartVM, | 4191 { "_restartVM", RestartVM, |
4165 restart_vm_params }, | 4192 restart_vm_params }, |
| 4193 { "reloadSources", ReloadSources, |
| 4194 reload_sources_params }, |
4166 { "_reloadSources", ReloadSources, | 4195 { "_reloadSources", ReloadSources, |
4167 reload_sources_params }, | 4196 reload_sources_params }, |
4168 { "resume", Resume, | 4197 { "resume", Resume, |
4169 resume_params }, | 4198 resume_params }, |
4170 { "_requestHeapSnapshot", RequestHeapSnapshot, | 4199 { "_requestHeapSnapshot", RequestHeapSnapshot, |
4171 request_heap_snapshot_params }, | 4200 request_heap_snapshot_params }, |
4172 { "setExceptionPauseMode", SetExceptionPauseMode, | 4201 { "setExceptionPauseMode", SetExceptionPauseMode, |
4173 set_exception_pause_mode_params }, | 4202 set_exception_pause_mode_params }, |
4174 { "_setFlag", SetFlag, | 4203 { "_setFlag", SetFlag, |
4175 set_flags_params }, | 4204 set_flags_params }, |
(...skipping 18 matching lines...) Expand all Loading... |
4194 if (strcmp(method_name, method.name) == 0) { | 4223 if (strcmp(method_name, method.name) == 0) { |
4195 return &method; | 4224 return &method; |
4196 } | 4225 } |
4197 } | 4226 } |
4198 return NULL; | 4227 return NULL; |
4199 } | 4228 } |
4200 | 4229 |
4201 #endif // !PRODUCT | 4230 #endif // !PRODUCT |
4202 | 4231 |
4203 } // namespace dart | 4232 } // namespace dart |
OLD | NEW |