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 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1444 if ((id < 0) || (id >= libs.Length())) { | 1444 if ((id < 0) || (id >= libs.Length())) { |
1445 return Object::sentinel().raw(); | 1445 return Object::sentinel().raw(); |
1446 } | 1446 } |
1447 Library& lib = Library::Handle(); | 1447 Library& lib = Library::Handle(); |
1448 lib ^= libs.At(id); | 1448 lib ^= libs.At(id); |
1449 ASSERT(!lib.IsNull()); | 1449 ASSERT(!lib.IsNull()); |
1450 if (num_parts == 2) { | 1450 if (num_parts == 2) { |
1451 return lib.raw(); | 1451 return lib.raw(); |
1452 } | 1452 } |
1453 if (strcmp(parts[2], "scripts") == 0) { | 1453 if (strcmp(parts[2], "scripts") == 0) { |
1454 // Script ids look like "libraries/35/scripts/library%2Furl.dart" | 1454 // Script ids look like "libraries/35/scripts/library%2Furl.dart/12345" |
1455 if (num_parts != 4) { | 1455 if (num_parts != 5) { |
1456 return Object::sentinel().raw(); | 1456 return Object::sentinel().raw(); |
1457 } | 1457 } |
1458 const String& id = String::Handle(String::New(parts[3])); | 1458 const String& id = String::Handle(String::New(parts[3])); |
1459 ASSERT(!id.IsNull()); | 1459 ASSERT(!id.IsNull()); |
1460 // The id is the url of the script % encoded, decode it. | 1460 // The id is the url of the script % encoded, decode it. |
1461 const String& requested_url = String::Handle(String::DecodeIRI(id)); | 1461 const String& requested_url = String::Handle(String::DecodeIRI(id)); |
1462 | |
1463 // Each script id is tagged with a load time. | |
1464 int64_t timestamp; | |
1465 if (!GetInteger64Id(parts[4], ×tamp, 16) || (timestamp < 0)) { | |
1466 return Object::sentinel().raw(); | |
1467 } | |
1468 | |
1462 Script& script = Script::Handle(); | 1469 Script& script = Script::Handle(); |
1463 String& script_url = String::Handle(); | 1470 String& script_url = String::Handle(); |
1464 const Array& loaded_scripts = Array::Handle(lib.LoadedScripts()); | 1471 const Array& loaded_scripts = Array::Handle(lib.LoadedScripts()); |
1465 ASSERT(!loaded_scripts.IsNull()); | 1472 ASSERT(!loaded_scripts.IsNull()); |
1466 intptr_t i; | 1473 intptr_t i; |
1467 for (i = 0; i < loaded_scripts.Length(); i++) { | 1474 for (i = 0; i < loaded_scripts.Length(); i++) { |
1468 script ^= loaded_scripts.At(i); | 1475 script ^= loaded_scripts.At(i); |
1469 ASSERT(!script.IsNull()); | 1476 ASSERT(!script.IsNull()); |
1470 script_url ^= script.url(); | 1477 script_url ^= script.url(); |
1471 if (script_url.Equals(requested_url)) { | 1478 if (script_url.Equals(requested_url) && |
1479 (timestamp == script.load_timestamp())) { | |
1472 return script.raw(); | 1480 return script.raw(); |
1473 } | 1481 } |
1474 } | 1482 } |
1475 } | 1483 } |
1476 | 1484 |
1477 // Not found. | 1485 // Not found. |
1478 return Object::sentinel().raw(); | 1486 return Object::sentinel().raw(); |
1479 } | 1487 } |
1480 | 1488 |
1481 static RawObject* LookupHeapObjectClasses(Thread* thread, | 1489 static RawObject* LookupHeapObjectClasses(Thread* thread, |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2367 } | 2375 } |
2368 SourceReport report(report_set, compile_mode); | 2376 SourceReport report(report_set, compile_mode); |
2369 report.PrintJSON(js, | 2377 report.PrintJSON(js, |
2370 script, | 2378 script, |
2371 TokenPosition(start_pos), | 2379 TokenPosition(start_pos), |
2372 TokenPosition(end_pos)); | 2380 TokenPosition(end_pos)); |
2373 return true; | 2381 return true; |
2374 } | 2382 } |
2375 | 2383 |
2376 | 2384 |
2385 static const MethodParameter* reload_sources_params[] = { | |
2386 RUNNABLE_ISOLATE_PARAMETER, | |
2387 NULL, | |
2388 }; | |
2389 | |
2390 | |
2391 static bool ReloadSources(Thread* thread, JSONStream* js) { | |
2392 Isolate* isolate = thread->isolate(); | |
2393 if (!isolate->compilation_allowed()) { | |
2394 js->PrintError(kFeatureDisabled, | |
2395 "Cannot reload source when running a precompiled program."); | |
2396 return true; | |
2397 } | |
rmacnak
2016/05/11 19:56:18
if (Dart::snapshot_kind() == kAppWithJIT) {
"Can
| |
2398 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); | |
2399 if (handler == NULL) { | |
2400 js->PrintError(kFeatureDisabled, | |
2401 "A library tag handler must be installed."); | |
2402 return true; | |
2403 } | |
2404 if (isolate->IsReloading()) { | |
2405 js->PrintError(kIsolateIsReloading, | |
2406 "This isolate is being reloaded."); | |
2407 return true; | |
2408 } | |
2409 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | |
2410 ASSERT(isolate->CanReload()); | |
2411 | |
2412 if (stack->Length() > 0) { | |
2413 // TODO(turnidge): We need to support this case. | |
2414 js->PrintError(kFeatureDisabled, | |
2415 "Source can only be reloaded when stack is empty."); | |
2416 return true; | |
2417 } else { | |
2418 isolate->ReloadSources(); | |
2419 } | |
2420 | |
2421 PrintSuccess(js); | |
2422 return true; | |
2423 } | |
2424 | |
2425 | |
2377 static bool AddBreakpointCommon(Thread* thread, | 2426 static bool AddBreakpointCommon(Thread* thread, |
2378 JSONStream* js, | 2427 JSONStream* js, |
2379 const String& script_uri) { | 2428 const String& script_uri) { |
2380 if (!thread->isolate()->compilation_allowed()) { | 2429 if (!thread->isolate()->compilation_allowed()) { |
2381 js->PrintError(kFeatureDisabled, | 2430 js->PrintError(kFeatureDisabled, |
2382 "Cannot use breakpoints when running a precompiled program."); | 2431 "Cannot use breakpoints when running a precompiled program."); |
2383 return true; | 2432 return true; |
2384 } | 2433 } |
2385 const char* line_param = js->LookupParam("line"); | 2434 const char* line_param = js->LookupParam("line"); |
2386 intptr_t line = UIntParameter::Parse(line_param); | 2435 intptr_t line = UIntParameter::Parse(line_param); |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3940 { "_getVMTimeline", GetVMTimeline, | 3989 { "_getVMTimeline", GetVMTimeline, |
3941 get_vm_timeline_params }, | 3990 get_vm_timeline_params }, |
3942 { "_getVMTimelineFlags", GetVMTimelineFlags, | 3991 { "_getVMTimelineFlags", GetVMTimelineFlags, |
3943 get_vm_timeline_flags_params }, | 3992 get_vm_timeline_flags_params }, |
3944 { "pause", Pause, | 3993 { "pause", Pause, |
3945 pause_params }, | 3994 pause_params }, |
3946 { "removeBreakpoint", RemoveBreakpoint, | 3995 { "removeBreakpoint", RemoveBreakpoint, |
3947 remove_breakpoint_params }, | 3996 remove_breakpoint_params }, |
3948 { "_restartVM", RestartVM, | 3997 { "_restartVM", RestartVM, |
3949 restart_vm_params }, | 3998 restart_vm_params }, |
3999 { "_reloadSources", ReloadSources, | |
4000 reload_sources_params }, | |
3950 { "resume", Resume, | 4001 { "resume", Resume, |
3951 resume_params }, | 4002 resume_params }, |
3952 { "_requestHeapSnapshot", RequestHeapSnapshot, | 4003 { "_requestHeapSnapshot", RequestHeapSnapshot, |
3953 request_heap_snapshot_params }, | 4004 request_heap_snapshot_params }, |
3954 { "setExceptionPauseMode", SetExceptionPauseMode, | 4005 { "setExceptionPauseMode", SetExceptionPauseMode, |
3955 set_exception_pause_mode_params }, | 4006 set_exception_pause_mode_params }, |
3956 { "_setFlag", SetFlag, | 4007 { "_setFlag", SetFlag, |
3957 set_flags_params }, | 4008 set_flags_params }, |
3958 { "setLibraryDebuggable", SetLibraryDebuggable, | 4009 { "setLibraryDebuggable", SetLibraryDebuggable, |
3959 set_library_debuggable_params }, | 4010 set_library_debuggable_params }, |
(...skipping 16 matching lines...) Expand all Loading... | |
3976 if (strcmp(method_name, method.name) == 0) { | 4027 if (strcmp(method_name, method.name) == 0) { |
3977 return &method; | 4028 return &method; |
3978 } | 4029 } |
3979 } | 4030 } |
3980 return NULL; | 4031 return NULL; |
3981 } | 4032 } |
3982 | 4033 |
3983 #endif // !PRODUCT | 4034 #endif // !PRODUCT |
3984 | 4035 |
3985 } // namespace dart | 4036 } // namespace dart |
OLD | NEW |