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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 | 963 |
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 const bool is_paused = isolate->IsPaused(); |
973 InvokeMethod(isolate, msg); | 974 InvokeMethod(isolate, msg); |
| 975 // Don't pause twice. |
| 976 if (!is_paused) { |
| 977 if (isolate->should_pause_post_reload_request()) { |
| 978 isolate->set_should_pause_post_reload_request(false); |
| 979 isolate->PausePostReload(); |
| 980 } |
| 981 } |
974 } | 982 } |
975 | 983 |
976 | 984 |
977 static void Finalizer(void* isolate_callback_data, | 985 static void Finalizer(void* isolate_callback_data, |
978 Dart_WeakPersistentHandle handle, | 986 Dart_WeakPersistentHandle handle, |
979 void* buffer) { | 987 void* buffer) { |
980 free(buffer); | 988 free(buffer); |
981 } | 989 } |
982 | 990 |
983 | 991 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 case ServiceEvent::kPauseInterrupted: | 1086 case ServiceEvent::kPauseInterrupted: |
1079 OS::PrintErr( | 1087 OS::PrintErr( |
1080 "vm-service: isolate '%s' has no debugger attached and is paused due " | 1088 "vm-service: isolate '%s' has no debugger attached and is paused due " |
1081 "to interrupt.", name); | 1089 "to interrupt.", name); |
1082 break; | 1090 break; |
1083 case ServiceEvent::kPauseBreakpoint: | 1091 case ServiceEvent::kPauseBreakpoint: |
1084 OS::PrintErr( | 1092 OS::PrintErr( |
1085 "vm-service: isolate '%s' has no debugger attached and is paused.", | 1093 "vm-service: isolate '%s' has no debugger attached and is paused.", |
1086 name); | 1094 name); |
1087 break; | 1095 break; |
| 1096 case ServiceEvent::kPausePostReload: |
| 1097 OS::PrintErr( |
| 1098 "vm-service: isolate '%s' has no debugger attached and is paused " |
| 1099 "post reload.", name); |
| 1100 break; |
1088 default: | 1101 default: |
1089 UNREACHABLE(); | 1102 UNREACHABLE(); |
1090 break; | 1103 break; |
1091 } | 1104 } |
1092 if (!ServiceIsolate::IsRunning()) { | 1105 if (!ServiceIsolate::IsRunning()) { |
1093 OS::PrintErr(" Start the vm-service to debug.\n"); | 1106 OS::PrintErr(" Start the vm-service to debug.\n"); |
1094 } else if (ServiceIsolate::server_address() == NULL) { | 1107 } else if (ServiceIsolate::server_address() == NULL) { |
1095 OS::PrintErr(" Connect to Observatory to debug.\n"); | 1108 OS::PrintErr(" Connect to Observatory to debug.\n"); |
1096 } else { | 1109 } else { |
1097 OS::PrintErr(" Connect to Observatory at %s to debug.\n", | 1110 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, | 2516 script, |
2504 TokenPosition(start_pos), | 2517 TokenPosition(start_pos), |
2505 TokenPosition(end_pos)); | 2518 TokenPosition(end_pos)); |
2506 return true; | 2519 return true; |
2507 } | 2520 } |
2508 | 2521 |
2509 | 2522 |
2510 static const MethodParameter* reload_sources_params[] = { | 2523 static const MethodParameter* reload_sources_params[] = { |
2511 RUNNABLE_ISOLATE_PARAMETER, | 2524 RUNNABLE_ISOLATE_PARAMETER, |
2512 new BoolParameter("force", false), | 2525 new BoolParameter("force", false), |
| 2526 new BoolParameter("pause", false), |
2513 NULL, | 2527 NULL, |
2514 }; | 2528 }; |
2515 | 2529 |
2516 | 2530 |
2517 static bool ReloadSources(Thread* thread, JSONStream* js) { | 2531 static bool ReloadSources(Thread* thread, JSONStream* js) { |
2518 Isolate* isolate = thread->isolate(); | 2532 Isolate* isolate = thread->isolate(); |
2519 if (!isolate->compilation_allowed()) { | 2533 if (!isolate->compilation_allowed()) { |
2520 js->PrintError(kFeatureDisabled, | 2534 js->PrintError(kFeatureDisabled, |
2521 "Cannot reload source when running a precompiled program."); | 2535 "Cannot reload source when running a precompiled program."); |
2522 return true; | 2536 return true; |
(...skipping 24 matching lines...) Expand all Loading... |
2547 if (!isolate->CanReload()) { | 2561 if (!isolate->CanReload()) { |
2548 js->PrintError(kFeatureDisabled, | 2562 js->PrintError(kFeatureDisabled, |
2549 "This isolate cannot reload sources right now."); | 2563 "This isolate cannot reload sources right now."); |
2550 return true; | 2564 return true; |
2551 } | 2565 } |
2552 const bool force_reload = | 2566 const bool force_reload = |
2553 BoolParameter::Parse(js->LookupParam("force"), false); | 2567 BoolParameter::Parse(js->LookupParam("force"), false); |
2554 | 2568 |
2555 isolate->ReloadSources(js, force_reload); | 2569 isolate->ReloadSources(js, force_reload); |
2556 | 2570 |
| 2571 // Should we pause? |
| 2572 isolate->set_should_pause_post_reload_request( |
| 2573 BoolParameter::Parse(js->LookupParam("pause"), false)); |
| 2574 |
2557 return true; | 2575 return true; |
2558 } | 2576 } |
2559 | 2577 |
2560 | 2578 |
2561 static bool AddBreakpointCommon(Thread* thread, | 2579 static bool AddBreakpointCommon(Thread* thread, |
2562 JSONStream* js, | 2580 JSONStream* js, |
2563 const String& script_uri) { | 2581 const String& script_uri) { |
2564 if (!thread->isolate()->compilation_allowed()) { | 2582 if (!thread->isolate()->compilation_allowed()) { |
2565 js->PrintError(kFeatureDisabled, | 2583 js->PrintError(kFeatureDisabled, |
2566 "Cannot use breakpoints when running a precompiled program."); | 2584 "Cannot use breakpoints when running a precompiled program."); |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4156 { "_getVMTimeline", GetVMTimeline, | 4174 { "_getVMTimeline", GetVMTimeline, |
4157 get_vm_timeline_params }, | 4175 get_vm_timeline_params }, |
4158 { "_getVMTimelineFlags", GetVMTimelineFlags, | 4176 { "_getVMTimelineFlags", GetVMTimelineFlags, |
4159 get_vm_timeline_flags_params }, | 4177 get_vm_timeline_flags_params }, |
4160 { "pause", Pause, | 4178 { "pause", Pause, |
4161 pause_params }, | 4179 pause_params }, |
4162 { "removeBreakpoint", RemoveBreakpoint, | 4180 { "removeBreakpoint", RemoveBreakpoint, |
4163 remove_breakpoint_params }, | 4181 remove_breakpoint_params }, |
4164 { "_restartVM", RestartVM, | 4182 { "_restartVM", RestartVM, |
4165 restart_vm_params }, | 4183 restart_vm_params }, |
| 4184 { "reloadSources", ReloadSources, |
| 4185 reload_sources_params }, |
4166 { "_reloadSources", ReloadSources, | 4186 { "_reloadSources", ReloadSources, |
4167 reload_sources_params }, | 4187 reload_sources_params }, |
4168 { "resume", Resume, | 4188 { "resume", Resume, |
4169 resume_params }, | 4189 resume_params }, |
4170 { "_requestHeapSnapshot", RequestHeapSnapshot, | 4190 { "_requestHeapSnapshot", RequestHeapSnapshot, |
4171 request_heap_snapshot_params }, | 4191 request_heap_snapshot_params }, |
4172 { "setExceptionPauseMode", SetExceptionPauseMode, | 4192 { "setExceptionPauseMode", SetExceptionPauseMode, |
4173 set_exception_pause_mode_params }, | 4193 set_exception_pause_mode_params }, |
4174 { "_setFlag", SetFlag, | 4194 { "_setFlag", SetFlag, |
4175 set_flags_params }, | 4195 set_flags_params }, |
(...skipping 18 matching lines...) Expand all Loading... |
4194 if (strcmp(method_name, method.name) == 0) { | 4214 if (strcmp(method_name, method.name) == 0) { |
4195 return &method; | 4215 return &method; |
4196 } | 4216 } |
4197 } | 4217 } |
4198 return NULL; | 4218 return NULL; |
4199 } | 4219 } |
4200 | 4220 |
4201 #endif // !PRODUCT | 4221 #endif // !PRODUCT |
4202 | 4222 |
4203 } // namespace dart | 4223 } // namespace dart |
OLD | NEW |