| 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 2989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3000 }; | 3000 }; |
| 3001 | 3001 |
| 3002 | 3002 |
| 3003 static bool RestartVM(Isolate* isolate, JSONStream* js) { | 3003 static bool RestartVM(Isolate* isolate, JSONStream* js) { |
| 3004 Isolate::KillAllIsolates(Isolate::kVMRestartMsg); | 3004 Isolate::KillAllIsolates(Isolate::kVMRestartMsg); |
| 3005 PrintSuccess(js); | 3005 PrintSuccess(js); |
| 3006 return true; | 3006 return true; |
| 3007 } | 3007 } |
| 3008 | 3008 |
| 3009 | 3009 |
| 3010 static const MethodParameter* set_exception_pause_info_params[] = { | 3010 static const char* exception_pause_mode_names[] = { |
| 3011 ISOLATE_PARAMETER, | 3011 "All", |
| 3012 "None", |
| 3013 "Unhandled", |
| 3012 NULL, | 3014 NULL, |
| 3013 }; | 3015 }; |
| 3014 | 3016 |
| 3015 | 3017 |
| 3016 static bool SetExceptionPauseInfo(Isolate* isolate, JSONStream* js) { | 3018 static Dart_ExceptionPauseInfo exception_pause_mode_values[] = { |
| 3017 const char* exceptions = js->LookupParam("exceptions"); | 3019 kPauseOnAllExceptions, |
| 3018 if (exceptions == NULL) { | 3020 kNoPauseOnExceptions, |
| 3019 PrintMissingParamError(js, "exceptions"); | 3021 kPauseOnUnhandledExceptions, |
| 3022 static_cast<Dart_ExceptionPauseInfo>(-1), // Fall through. |
| 3023 }; |
| 3024 |
| 3025 |
| 3026 static const MethodParameter* set_exception_pause_mode_params[] = { |
| 3027 ISOLATE_PARAMETER, |
| 3028 new EnumParameter("mode", true, exception_pause_mode_names), |
| 3029 NULL, |
| 3030 }; |
| 3031 |
| 3032 |
| 3033 static bool SetExceptionPauseMode(Isolate* isolate, JSONStream* js) { |
| 3034 const char* mode = js->LookupParam("mode"); |
| 3035 if (mode == NULL) { |
| 3036 PrintMissingParamError(js, "mode"); |
| 3020 return true; | 3037 return true; |
| 3021 } | 3038 } |
| 3022 | 3039 Dart_ExceptionPauseInfo info = |
| 3023 Dart_ExceptionPauseInfo info = kNoPauseOnExceptions; | 3040 EnumMapper(mode, exception_pause_mode_names, exception_pause_mode_values); |
| 3024 if (strcmp(exceptions, "none") == 0) { | 3041 if (info == -1) { |
| 3025 info = kNoPauseOnExceptions; | 3042 PrintInvalidParamError(js, "mode"); |
| 3026 } else if (strcmp(exceptions, "all") == 0) { | |
| 3027 info = kPauseOnAllExceptions; | |
| 3028 } else if (strcmp(exceptions, "unhandled") == 0) { | |
| 3029 info = kPauseOnUnhandledExceptions; | |
| 3030 } else { | |
| 3031 JSONObject jsobj(js); | |
| 3032 jsobj.AddProperty("type", "Error"); | |
| 3033 jsobj.AddProperty("message", "illegal value for parameter 'exceptions'"); | |
| 3034 return true; | 3043 return true; |
| 3035 } | 3044 } |
| 3036 | |
| 3037 isolate->debugger()->SetExceptionPauseInfo(info); | 3045 isolate->debugger()->SetExceptionPauseInfo(info); |
| 3038 if (Service::debug_stream.enabled()) { | 3046 if (Service::debug_stream.enabled()) { |
| 3039 ServiceEvent event(isolate, ServiceEvent::kDebuggerSettingsUpdate); | 3047 ServiceEvent event(isolate, ServiceEvent::kDebuggerSettingsUpdate); |
| 3040 Service::HandleEvent(&event); | 3048 Service::HandleEvent(&event); |
| 3041 } | 3049 } |
| 3042 PrintSuccess(js); | 3050 PrintSuccess(js); |
| 3043 return true; | 3051 return true; |
| 3044 } | 3052 } |
| 3045 | 3053 |
| 3046 | 3054 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3251 { "pause", Pause, | 3259 { "pause", Pause, |
| 3252 pause_params }, | 3260 pause_params }, |
| 3253 { "removeBreakpoint", RemoveBreakpoint, | 3261 { "removeBreakpoint", RemoveBreakpoint, |
| 3254 remove_breakpoint_params }, | 3262 remove_breakpoint_params }, |
| 3255 { "_restartVM", RestartVM, | 3263 { "_restartVM", RestartVM, |
| 3256 restart_vm_params }, | 3264 restart_vm_params }, |
| 3257 { "resume", Resume, | 3265 { "resume", Resume, |
| 3258 resume_params }, | 3266 resume_params }, |
| 3259 { "_requestHeapSnapshot", RequestHeapSnapshot, | 3267 { "_requestHeapSnapshot", RequestHeapSnapshot, |
| 3260 request_heap_snapshot_params }, | 3268 request_heap_snapshot_params }, |
| 3261 { "_setExceptionPauseInfo", SetExceptionPauseInfo, | 3269 { "setExceptionPauseMode", SetExceptionPauseMode, |
| 3262 set_exception_pause_info_params }, | 3270 set_exception_pause_mode_params }, |
| 3263 { "_setFlag", SetFlag, | 3271 { "_setFlag", SetFlag, |
| 3264 set_flags_params }, | 3272 set_flags_params }, |
| 3265 { "setLibraryDebuggable", SetLibraryDebuggable, | 3273 { "setLibraryDebuggable", SetLibraryDebuggable, |
| 3266 set_library_debuggable_params }, | 3274 set_library_debuggable_params }, |
| 3267 { "setName", SetName, | 3275 { "setName", SetName, |
| 3268 set_name_params }, | 3276 set_name_params }, |
| 3269 { "_setTraceClassAllocation", SetTraceClassAllocation, | 3277 { "_setTraceClassAllocation", SetTraceClassAllocation, |
| 3270 set_trace_class_allocation_params }, | 3278 set_trace_class_allocation_params }, |
| 3271 { "setVMName", SetVMName, | 3279 { "setVMName", SetVMName, |
| 3272 set_vm_name_params }, | 3280 set_vm_name_params }, |
| 3273 }; | 3281 }; |
| 3274 | 3282 |
| 3275 | 3283 |
| 3276 ServiceMethodDescriptor* FindMethod(const char* method_name) { | 3284 ServiceMethodDescriptor* FindMethod(const char* method_name) { |
| 3277 intptr_t num_methods = sizeof(service_methods_) / | 3285 intptr_t num_methods = sizeof(service_methods_) / |
| 3278 sizeof(service_methods_[0]); | 3286 sizeof(service_methods_[0]); |
| 3279 for (intptr_t i = 0; i < num_methods; i++) { | 3287 for (intptr_t i = 0; i < num_methods; i++) { |
| 3280 ServiceMethodDescriptor& method = service_methods_[i]; | 3288 ServiceMethodDescriptor& method = service_methods_[i]; |
| 3281 if (strcmp(method_name, method.name) == 0) { | 3289 if (strcmp(method_name, method.name) == 0) { |
| 3282 return &method; | 3290 return &method; |
| 3283 } | 3291 } |
| 3284 } | 3292 } |
| 3285 return NULL; | 3293 return NULL; |
| 3286 } | 3294 } |
| 3287 | 3295 |
| 3288 | 3296 |
| 3289 } // namespace dart | 3297 } // namespace dart |
| OLD | NEW |