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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 for (i = 0; enums[i] != NULL; i++) { | 522 for (i = 0; enums[i] != NULL; i++) { |
523 if (strcmp(value, enums[i]) == 0) { | 523 if (strcmp(value, enums[i]) == 0) { |
524 return values[i]; | 524 return values[i]; |
525 } | 525 } |
526 } | 526 } |
527 // Default value. | 527 // Default value. |
528 return values[i]; | 528 return values[i]; |
529 } | 529 } |
530 | 530 |
531 | 531 |
532 typedef bool (*ServiceMethodEntry)(Isolate* isolate, JSONStream* js); | 532 typedef bool (*ServiceMethodEntry)(Thread* thread, JSONStream* js); |
533 | 533 |
534 | 534 |
535 struct ServiceMethodDescriptor { | 535 struct ServiceMethodDescriptor { |
536 const char* name; | 536 const char* name; |
537 const ServiceMethodEntry entry; | 537 const ServiceMethodEntry entry; |
538 const MethodParameter* const * parameters; | 538 const MethodParameter* const * parameters; |
539 }; | 539 }; |
540 | 540 |
541 | 541 |
542 // TODO(johnmccutchan): Do we reject unexpected parameters? | 542 // TODO(johnmccutchan): Do we reject unexpected parameters? |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 } | 643 } |
644 } | 644 } |
645 const char* c_method_name = method_name.ToCString(); | 645 const char* c_method_name = method_name.ToCString(); |
646 | 646 |
647 ServiceMethodDescriptor* method = FindMethod(c_method_name); | 647 ServiceMethodDescriptor* method = FindMethod(c_method_name); |
648 if (method != NULL) { | 648 if (method != NULL) { |
649 if (!ValidateParameters(method->parameters, &js)) { | 649 if (!ValidateParameters(method->parameters, &js)) { |
650 js.PostReply(); | 650 js.PostReply(); |
651 return; | 651 return; |
652 } | 652 } |
653 if (method->entry(I, &js)) { | 653 if (method->entry(T, &js)) { |
654 js.PostReply(); | 654 js.PostReply(); |
655 } else { | 655 } else { |
656 // NOTE(turnidge): All message handlers currently return true, | 656 // NOTE(turnidge): All message handlers currently return true, |
657 // so this case shouldn't be reached, at present. | 657 // so this case shouldn't be reached, at present. |
658 UNIMPLEMENTED(); | 658 UNIMPLEMENTED(); |
659 } | 659 } |
660 return; | 660 return; |
661 } | 661 } |
662 | 662 |
663 EmbedderServiceHandler* handler = FindIsolateEmbedderHandler(c_method_name); | 663 EmbedderServiceHandler* handler = FindIsolateEmbedderHandler(c_method_name); |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 id); | 1004 id); |
1005 } | 1005 } |
1006 | 1006 |
1007 | 1007 |
1008 static const MethodParameter* get_isolate_params[] = { | 1008 static const MethodParameter* get_isolate_params[] = { |
1009 ISOLATE_PARAMETER, | 1009 ISOLATE_PARAMETER, |
1010 NULL, | 1010 NULL, |
1011 }; | 1011 }; |
1012 | 1012 |
1013 | 1013 |
1014 static bool GetIsolate(Isolate* isolate, JSONStream* js) { | 1014 static bool GetIsolate(Thread* thread, JSONStream* js) { |
1015 isolate->PrintJSON(js, false); | 1015 thread->isolate()->PrintJSON(js, false); |
1016 return true; | 1016 return true; |
1017 } | 1017 } |
1018 | 1018 |
1019 | 1019 |
1020 static const MethodParameter* get_stack_params[] = { | 1020 static const MethodParameter* get_stack_params[] = { |
1021 ISOLATE_PARAMETER, | 1021 ISOLATE_PARAMETER, |
1022 new BoolParameter("_full", false), | 1022 new BoolParameter("_full", false), |
1023 NULL, | 1023 NULL, |
1024 }; | 1024 }; |
1025 | 1025 |
1026 | 1026 |
1027 static bool GetStack(Isolate* isolate, JSONStream* js) { | 1027 static bool GetStack(Thread* thread, JSONStream* js) { |
| 1028 Isolate* isolate = thread->isolate(); |
1028 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 1029 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
1029 // Do we want the complete script object and complete local variable objects? | 1030 // Do we want the complete script object and complete local variable objects? |
1030 // This is true for dump requests. | 1031 // This is true for dump requests. |
1031 const bool full = BoolParameter::Parse(js->LookupParam("_full"), false); | 1032 const bool full = BoolParameter::Parse(js->LookupParam("_full"), false); |
1032 JSONObject jsobj(js); | 1033 JSONObject jsobj(js); |
1033 jsobj.AddProperty("type", "Stack"); | 1034 jsobj.AddProperty("type", "Stack"); |
1034 { | 1035 { |
1035 JSONArray jsarr(&jsobj, "frames"); | 1036 JSONArray jsarr(&jsobj, "frames"); |
1036 | 1037 |
1037 intptr_t num_frames = stack->Length(); | 1038 intptr_t num_frames = stack->Length(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 event.AddPropertyTimeMillis("timestamp", OS::GetCurrentTimeMillis()); | 1083 event.AddPropertyTimeMillis("timestamp", OS::GetCurrentTimeMillis()); |
1083 } | 1084 } |
1084 } | 1085 } |
1085 } | 1086 } |
1086 const String& message = String::Handle(String::New(js.ToCString())); | 1087 const String& message = String::Handle(String::New(js.ToCString())); |
1087 uint8_t data[] = {0, 128, 255}; | 1088 uint8_t data[] = {0, 128, 255}; |
1088 SendEventWithData(echo_stream.id(), "_Echo", message, data, sizeof(data)); | 1089 SendEventWithData(echo_stream.id(), "_Echo", message, data, sizeof(data)); |
1089 } | 1090 } |
1090 | 1091 |
1091 | 1092 |
1092 static bool TriggerEchoEvent(Isolate* isolate, JSONStream* js) { | 1093 static bool TriggerEchoEvent(Thread* thread, JSONStream* js) { |
1093 if (Service::echo_stream.enabled()) { | 1094 if (Service::echo_stream.enabled()) { |
1094 Service::SendEchoEvent(isolate, js->LookupParam("text")); | 1095 Service::SendEchoEvent(thread->isolate(), js->LookupParam("text")); |
1095 } | 1096 } |
1096 JSONObject jsobj(js); | 1097 JSONObject jsobj(js); |
1097 return HandleCommonEcho(&jsobj, js); | 1098 return HandleCommonEcho(&jsobj, js); |
1098 } | 1099 } |
1099 | 1100 |
1100 | 1101 |
1101 static bool DumpIdZone(Isolate* isolate, JSONStream* js) { | 1102 static bool DumpIdZone(Thread* thread, JSONStream* js) { |
1102 // TODO(johnmccutchan): Respect _idZone parameter passed to RPC. For now, | 1103 // TODO(johnmccutchan): Respect _idZone parameter passed to RPC. For now, |
1103 // always send the ObjectIdRing. | 1104 // always send the ObjectIdRing. |
1104 // | 1105 // |
1105 ObjectIdRing* ring = isolate->object_id_ring(); | 1106 ObjectIdRing* ring = thread->isolate()->object_id_ring(); |
1106 ASSERT(ring != NULL); | 1107 ASSERT(ring != NULL); |
1107 // When printing the ObjectIdRing, force object id reuse policy. | 1108 // When printing the ObjectIdRing, force object id reuse policy. |
1108 RingServiceIdZone reuse_zone; | 1109 RingServiceIdZone reuse_zone; |
1109 reuse_zone.Init(ring, ObjectIdRing::kReuseId); | 1110 reuse_zone.Init(ring, ObjectIdRing::kReuseId); |
1110 js->set_id_zone(&reuse_zone); | 1111 js->set_id_zone(&reuse_zone); |
1111 ring->PrintJSON(js); | 1112 ring->PrintJSON(js); |
1112 return true; | 1113 return true; |
1113 } | 1114 } |
1114 | 1115 |
1115 | 1116 |
1116 static bool Echo(Isolate* isolate, JSONStream* js) { | 1117 static bool Echo(Thread* thread, JSONStream* js) { |
1117 JSONObject jsobj(js); | 1118 JSONObject jsobj(js); |
1118 return HandleCommonEcho(&jsobj, js); | 1119 return HandleCommonEcho(&jsobj, js); |
1119 } | 1120 } |
1120 | 1121 |
1121 | 1122 |
1122 static bool ContainsNonInstance(const Object& obj) { | 1123 static bool ContainsNonInstance(const Object& obj) { |
1123 if (obj.IsArray()) { | 1124 if (obj.IsArray()) { |
1124 const Array& array = Array::Cast(obj); | 1125 const Array& array = Array::Cast(obj); |
1125 Object& element = Object::Handle(); | 1126 Object& element = Object::Handle(); |
1126 for (intptr_t i = 0; i < array.Length(); ++i) { | 1127 for (intptr_t i = 0; i < array.Length(); ++i) { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 Code& code = Code::Handle(Code::FindCode(pc, timestamp)); | 1415 Code& code = Code::Handle(Code::FindCode(pc, timestamp)); |
1415 if (!code.IsNull()) { | 1416 if (!code.IsNull()) { |
1416 return code.raw(); | 1417 return code.raw(); |
1417 } | 1418 } |
1418 | 1419 |
1419 // Not found. | 1420 // Not found. |
1420 return Object::sentinel().raw(); | 1421 return Object::sentinel().raw(); |
1421 } | 1422 } |
1422 | 1423 |
1423 | 1424 |
1424 static RawObject* LookupHeapObjectMessage(Isolate* isolate, | 1425 static RawObject* LookupHeapObjectMessage(Thread* thread, |
1425 char** parts, int num_parts) { | 1426 char** parts, int num_parts) { |
1426 if (num_parts != 2) { | 1427 if (num_parts != 2) { |
1427 return Object::sentinel().raw(); | 1428 return Object::sentinel().raw(); |
1428 } | 1429 } |
1429 uword message_id = 0; | 1430 uword message_id = 0; |
1430 if (!GetUnsignedIntegerId(parts[1], &message_id, 16)) { | 1431 if (!GetUnsignedIntegerId(parts[1], &message_id, 16)) { |
1431 return Object::sentinel().raw(); | 1432 return Object::sentinel().raw(); |
1432 } | 1433 } |
1433 MessageHandler::AcquiredQueues aq; | 1434 MessageHandler::AcquiredQueues aq; |
1434 isolate->message_handler()->AcquireQueues(&aq); | 1435 thread->isolate()->message_handler()->AcquireQueues(&aq); |
1435 Message* message = aq.queue()->FindMessageById(message_id); | 1436 Message* message = aq.queue()->FindMessageById(message_id); |
1436 if (message == NULL) { | 1437 if (message == NULL) { |
1437 // The user may try to load an expired message. | 1438 // The user may try to load an expired message. |
1438 return Object::sentinel().raw(); | 1439 return Object::sentinel().raw(); |
1439 } | 1440 } |
1440 MessageSnapshotReader reader(message->data(), | 1441 MessageSnapshotReader reader(message->data(), |
1441 message->len(), | 1442 message->len(), |
1442 Thread::Current()); | 1443 thread); |
1443 return reader.ReadObject(); | 1444 return reader.ReadObject(); |
1444 } | 1445 } |
1445 | 1446 |
1446 | 1447 |
1447 static RawObject* LookupHeapObject(Isolate* isolate, | 1448 static RawObject* LookupHeapObject(Thread* thread, |
1448 const char* id_original, | 1449 const char* id_original, |
1449 ObjectIdRing::LookupResult* result) { | 1450 ObjectIdRing::LookupResult* result) { |
1450 Thread* thread = Thread::Current(); | |
1451 char* id = thread->zone()->MakeCopyOfString(id_original); | 1451 char* id = thread->zone()->MakeCopyOfString(id_original); |
1452 | 1452 |
1453 // Parse the id by splitting at each '/'. | 1453 // Parse the id by splitting at each '/'. |
1454 const int MAX_PARTS = 8; | 1454 const int MAX_PARTS = 8; |
1455 char* parts[MAX_PARTS]; | 1455 char* parts[MAX_PARTS]; |
1456 int num_parts = 0; | 1456 int num_parts = 0; |
1457 int i = 0; | 1457 int i = 0; |
1458 int start_pos = 0; | 1458 int start_pos = 0; |
1459 while (id[i] != '\0') { | 1459 while (id[i] != '\0') { |
1460 if (id[i] == '/') { | 1460 if (id[i] == '/') { |
1461 id[i++] = '\0'; | 1461 id[i++] = '\0'; |
1462 parts[num_parts++] = &id[start_pos]; | 1462 parts[num_parts++] = &id[start_pos]; |
1463 if (num_parts == MAX_PARTS) { | 1463 if (num_parts == MAX_PARTS) { |
1464 break; | 1464 break; |
1465 } | 1465 } |
1466 start_pos = i; | 1466 start_pos = i; |
1467 } else { | 1467 } else { |
1468 i++; | 1468 i++; |
1469 } | 1469 } |
1470 } | 1470 } |
1471 if (num_parts < MAX_PARTS) { | 1471 if (num_parts < MAX_PARTS) { |
1472 parts[num_parts++] = &id[start_pos]; | 1472 parts[num_parts++] = &id[start_pos]; |
1473 } | 1473 } |
1474 | 1474 |
1475 if (result != NULL) { | 1475 if (result != NULL) { |
1476 *result = ObjectIdRing::kValid; | 1476 *result = ObjectIdRing::kValid; |
1477 } | 1477 } |
1478 | 1478 |
| 1479 Isolate* isolate = thread->isolate(); |
1479 if (strcmp(parts[0], "objects") == 0) { | 1480 if (strcmp(parts[0], "objects") == 0) { |
1480 // Object ids look like "objects/1123" | 1481 // Object ids look like "objects/1123" |
1481 Object& obj = Object::Handle(thread->zone()); | 1482 Object& obj = Object::Handle(thread->zone()); |
1482 ObjectIdRing::LookupResult lookup_result; | 1483 ObjectIdRing::LookupResult lookup_result; |
1483 obj = LookupObjectId(thread, parts[1], &lookup_result); | 1484 obj = LookupObjectId(thread, parts[1], &lookup_result); |
1484 if (lookup_result != ObjectIdRing::kValid) { | 1485 if (lookup_result != ObjectIdRing::kValid) { |
1485 if (result != NULL) { | 1486 if (result != NULL) { |
1486 *result = lookup_result; | 1487 *result = lookup_result; |
1487 } | 1488 } |
1488 return Object::sentinel().raw(); | 1489 return Object::sentinel().raw(); |
1489 } | 1490 } |
1490 return obj.raw(); | 1491 return obj.raw(); |
1491 | 1492 |
1492 } else if (strcmp(parts[0], "libraries") == 0) { | 1493 } else if (strcmp(parts[0], "libraries") == 0) { |
1493 return LookupHeapObjectLibraries(isolate, parts, num_parts); | 1494 return LookupHeapObjectLibraries(isolate, parts, num_parts); |
1494 } else if (strcmp(parts[0], "classes") == 0) { | 1495 } else if (strcmp(parts[0], "classes") == 0) { |
1495 return LookupHeapObjectClasses(thread, parts, num_parts); | 1496 return LookupHeapObjectClasses(thread, parts, num_parts); |
1496 } else if (strcmp(parts[0], "typearguments") == 0) { | 1497 } else if (strcmp(parts[0], "typearguments") == 0) { |
1497 return LookupHeapObjectTypeArguments(thread, parts, num_parts); | 1498 return LookupHeapObjectTypeArguments(thread, parts, num_parts); |
1498 } else if (strcmp(parts[0], "code") == 0) { | 1499 } else if (strcmp(parts[0], "code") == 0) { |
1499 return LookupHeapObjectCode(isolate, parts, num_parts); | 1500 return LookupHeapObjectCode(isolate, parts, num_parts); |
1500 } else if (strcmp(parts[0], "messages") == 0) { | 1501 } else if (strcmp(parts[0], "messages") == 0) { |
1501 return LookupHeapObjectMessage(isolate, parts, num_parts); | 1502 return LookupHeapObjectMessage(thread, parts, num_parts); |
1502 } | 1503 } |
1503 | 1504 |
1504 // Not found. | 1505 // Not found. |
1505 return Object::sentinel().raw(); | 1506 return Object::sentinel().raw(); |
1506 } | 1507 } |
1507 | 1508 |
1508 | 1509 |
1509 enum SentinelType { | 1510 enum SentinelType { |
1510 kCollectedSentinel, | 1511 kCollectedSentinel, |
1511 kExpiredSentinel, | 1512 kExpiredSentinel, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 return true; | 1614 return true; |
1614 } | 1615 } |
1615 | 1616 |
1616 | 1617 |
1617 static const MethodParameter* get_inbound_references_params[] = { | 1618 static const MethodParameter* get_inbound_references_params[] = { |
1618 ISOLATE_PARAMETER, | 1619 ISOLATE_PARAMETER, |
1619 NULL, | 1620 NULL, |
1620 }; | 1621 }; |
1621 | 1622 |
1622 | 1623 |
1623 static bool GetInboundReferences(Isolate* isolate, JSONStream* js) { | 1624 static bool GetInboundReferences(Thread* thread, JSONStream* js) { |
1624 Thread* thread = Thread::Current(); | |
1625 ASSERT(isolate == thread->isolate()); | |
1626 | |
1627 const char* target_id = js->LookupParam("targetId"); | 1625 const char* target_id = js->LookupParam("targetId"); |
1628 if (target_id == NULL) { | 1626 if (target_id == NULL) { |
1629 PrintMissingParamError(js, "targetId"); | 1627 PrintMissingParamError(js, "targetId"); |
1630 return true; | 1628 return true; |
1631 } | 1629 } |
1632 const char* limit_cstr = js->LookupParam("limit"); | 1630 const char* limit_cstr = js->LookupParam("limit"); |
1633 if (limit_cstr == NULL) { | 1631 if (limit_cstr == NULL) { |
1634 PrintMissingParamError(js, "limit"); | 1632 PrintMissingParamError(js, "limit"); |
1635 return true; | 1633 return true; |
1636 } | 1634 } |
1637 intptr_t limit; | 1635 intptr_t limit; |
1638 if (!GetIntegerId(limit_cstr, &limit)) { | 1636 if (!GetIntegerId(limit_cstr, &limit)) { |
1639 PrintInvalidParamError(js, "limit"); | 1637 PrintInvalidParamError(js, "limit"); |
1640 return true; | 1638 return true; |
1641 } | 1639 } |
1642 | 1640 |
1643 Object& obj = Object::Handle(thread->zone()); | 1641 Object& obj = Object::Handle(thread->zone()); |
1644 ObjectIdRing::LookupResult lookup_result; | 1642 ObjectIdRing::LookupResult lookup_result; |
1645 { | 1643 { |
1646 HANDLESCOPE(thread); | 1644 HANDLESCOPE(thread); |
1647 obj = LookupHeapObject(isolate, target_id, &lookup_result); | 1645 obj = LookupHeapObject(thread, target_id, &lookup_result); |
1648 } | 1646 } |
1649 if (obj.raw() == Object::sentinel().raw()) { | 1647 if (obj.raw() == Object::sentinel().raw()) { |
1650 if (lookup_result == ObjectIdRing::kCollected) { | 1648 if (lookup_result == ObjectIdRing::kCollected) { |
1651 PrintSentinel(js, kCollectedSentinel); | 1649 PrintSentinel(js, kCollectedSentinel); |
1652 } else if (lookup_result == ObjectIdRing::kExpired) { | 1650 } else if (lookup_result == ObjectIdRing::kExpired) { |
1653 PrintSentinel(js, kExpiredSentinel); | 1651 PrintSentinel(js, kExpiredSentinel); |
1654 } else { | 1652 } else { |
1655 PrintInvalidParamError(js, "targetId"); | 1653 PrintInvalidParamError(js, "targetId"); |
1656 } | 1654 } |
1657 return true; | 1655 return true; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 return true; | 1713 return true; |
1716 } | 1714 } |
1717 | 1715 |
1718 | 1716 |
1719 static const MethodParameter* get_retaining_path_params[] = { | 1717 static const MethodParameter* get_retaining_path_params[] = { |
1720 ISOLATE_PARAMETER, | 1718 ISOLATE_PARAMETER, |
1721 NULL, | 1719 NULL, |
1722 }; | 1720 }; |
1723 | 1721 |
1724 | 1722 |
1725 static bool GetRetainingPath(Isolate* isolate, JSONStream* js) { | 1723 static bool GetRetainingPath(Thread* thread, JSONStream* js) { |
1726 Thread* thread = Thread::Current(); | |
1727 ASSERT(isolate == thread->isolate()); | |
1728 | |
1729 const char* target_id = js->LookupParam("targetId"); | 1724 const char* target_id = js->LookupParam("targetId"); |
1730 if (target_id == NULL) { | 1725 if (target_id == NULL) { |
1731 PrintMissingParamError(js, "targetId"); | 1726 PrintMissingParamError(js, "targetId"); |
1732 return true; | 1727 return true; |
1733 } | 1728 } |
1734 const char* limit_cstr = js->LookupParam("limit"); | 1729 const char* limit_cstr = js->LookupParam("limit"); |
1735 if (limit_cstr == NULL) { | 1730 if (limit_cstr == NULL) { |
1736 PrintMissingParamError(js, "limit"); | 1731 PrintMissingParamError(js, "limit"); |
1737 return true; | 1732 return true; |
1738 } | 1733 } |
1739 intptr_t limit; | 1734 intptr_t limit; |
1740 if (!GetIntegerId(limit_cstr, &limit)) { | 1735 if (!GetIntegerId(limit_cstr, &limit)) { |
1741 PrintInvalidParamError(js, "limit"); | 1736 PrintInvalidParamError(js, "limit"); |
1742 return true; | 1737 return true; |
1743 } | 1738 } |
1744 | 1739 |
1745 Object& obj = Object::Handle(thread->zone()); | 1740 Object& obj = Object::Handle(thread->zone()); |
1746 ObjectIdRing::LookupResult lookup_result; | 1741 ObjectIdRing::LookupResult lookup_result; |
1747 { | 1742 { |
1748 HANDLESCOPE(thread); | 1743 HANDLESCOPE(thread); |
1749 obj = LookupHeapObject(isolate, target_id, &lookup_result); | 1744 obj = LookupHeapObject(thread, target_id, &lookup_result); |
1750 } | 1745 } |
1751 if (obj.raw() == Object::sentinel().raw()) { | 1746 if (obj.raw() == Object::sentinel().raw()) { |
1752 if (lookup_result == ObjectIdRing::kCollected) { | 1747 if (lookup_result == ObjectIdRing::kCollected) { |
1753 PrintSentinel(js, kCollectedSentinel); | 1748 PrintSentinel(js, kCollectedSentinel); |
1754 } else if (lookup_result == ObjectIdRing::kExpired) { | 1749 } else if (lookup_result == ObjectIdRing::kExpired) { |
1755 PrintSentinel(js, kExpiredSentinel); | 1750 PrintSentinel(js, kExpiredSentinel); |
1756 } else { | 1751 } else { |
1757 PrintInvalidParamError(js, "targetId"); | 1752 PrintInvalidParamError(js, "targetId"); |
1758 } | 1753 } |
1759 return true; | 1754 return true; |
1760 } | 1755 } |
1761 return PrintRetainingPath(thread, &obj, limit, js); | 1756 return PrintRetainingPath(thread, &obj, limit, js); |
1762 } | 1757 } |
1763 | 1758 |
1764 | 1759 |
1765 static const MethodParameter* get_retained_size_params[] = { | 1760 static const MethodParameter* get_retained_size_params[] = { |
1766 ISOLATE_PARAMETER, | 1761 ISOLATE_PARAMETER, |
1767 NULL, | 1762 NULL, |
1768 }; | 1763 }; |
1769 | 1764 |
1770 | 1765 |
1771 static bool GetRetainedSize(Isolate* isolate, JSONStream* js) { | 1766 static bool GetRetainedSize(Thread* thread, JSONStream* js) { |
1772 const char* target_id = js->LookupParam("targetId"); | 1767 const char* target_id = js->LookupParam("targetId"); |
1773 if (target_id == NULL) { | 1768 if (target_id == NULL) { |
1774 PrintMissingParamError(js, "targetId"); | 1769 PrintMissingParamError(js, "targetId"); |
1775 return true; | 1770 return true; |
1776 } | 1771 } |
1777 ObjectIdRing::LookupResult lookup_result; | 1772 ObjectIdRing::LookupResult lookup_result; |
1778 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, | 1773 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, |
1779 &lookup_result)); | 1774 &lookup_result)); |
1780 if (obj.raw() == Object::sentinel().raw()) { | 1775 if (obj.raw() == Object::sentinel().raw()) { |
1781 if (lookup_result == ObjectIdRing::kCollected) { | 1776 if (lookup_result == ObjectIdRing::kCollected) { |
1782 PrintSentinel(js, kCollectedSentinel); | 1777 PrintSentinel(js, kCollectedSentinel); |
1783 } else if (lookup_result == ObjectIdRing::kExpired) { | 1778 } else if (lookup_result == ObjectIdRing::kExpired) { |
1784 PrintSentinel(js, kExpiredSentinel); | 1779 PrintSentinel(js, kExpiredSentinel); |
1785 } else { | 1780 } else { |
1786 PrintInvalidParamError(js, "targetId"); | 1781 PrintInvalidParamError(js, "targetId"); |
1787 } | 1782 } |
1788 return true; | 1783 return true; |
1789 } | 1784 } |
1790 Thread* thread = Thread::Current(); | |
1791 // TODO(rmacnak): There is no way to get the size retained by a class object. | 1785 // TODO(rmacnak): There is no way to get the size retained by a class object. |
1792 // SizeRetainedByClass should be a separate RPC. | 1786 // SizeRetainedByClass should be a separate RPC. |
1793 if (obj.IsClass()) { | 1787 if (obj.IsClass()) { |
1794 const Class& cls = Class::Cast(obj); | 1788 const Class& cls = Class::Cast(obj); |
1795 ObjectGraph graph(thread); | 1789 ObjectGraph graph(thread); |
1796 intptr_t retained_size = graph.SizeRetainedByClass(cls.id()); | 1790 intptr_t retained_size = graph.SizeRetainedByClass(cls.id()); |
1797 const Object& result = Object::Handle(Integer::New(retained_size)); | 1791 const Object& result = Object::Handle(Integer::New(retained_size)); |
1798 result.PrintJSON(js, true); | 1792 result.PrintJSON(js, true); |
1799 return true; | 1793 return true; |
1800 } | 1794 } |
1801 | 1795 |
1802 ObjectGraph graph(thread); | 1796 ObjectGraph graph(thread); |
1803 intptr_t retained_size = graph.SizeRetainedByInstance(obj); | 1797 intptr_t retained_size = graph.SizeRetainedByInstance(obj); |
1804 const Object& result = Object::Handle(Integer::New(retained_size)); | 1798 const Object& result = Object::Handle(Integer::New(retained_size)); |
1805 result.PrintJSON(js, true); | 1799 result.PrintJSON(js, true); |
1806 return true; | 1800 return true; |
1807 } | 1801 } |
1808 | 1802 |
1809 | 1803 |
1810 static const MethodParameter* evaluate_params[] = { | 1804 static const MethodParameter* evaluate_params[] = { |
1811 ISOLATE_PARAMETER, | 1805 ISOLATE_PARAMETER, |
1812 NULL, | 1806 NULL, |
1813 }; | 1807 }; |
1814 | 1808 |
1815 | 1809 |
1816 static bool Evaluate(Isolate* isolate, JSONStream* js) { | 1810 static bool Evaluate(Thread* thread, JSONStream* js) { |
1817 if (!isolate->compilation_allowed()) { | 1811 if (!thread->isolate()->compilation_allowed()) { |
1818 js->PrintError(kFeatureDisabled, | 1812 js->PrintError(kFeatureDisabled, |
1819 "Cannot evaluate when running a precompiled program."); | 1813 "Cannot evaluate when running a precompiled program."); |
1820 return true; | 1814 return true; |
1821 } | 1815 } |
1822 const char* target_id = js->LookupParam("targetId"); | 1816 const char* target_id = js->LookupParam("targetId"); |
1823 if (target_id == NULL) { | 1817 if (target_id == NULL) { |
1824 PrintMissingParamError(js, "targetId"); | 1818 PrintMissingParamError(js, "targetId"); |
1825 return true; | 1819 return true; |
1826 } | 1820 } |
1827 const char* expr = js->LookupParam("expression"); | 1821 const char* expr = js->LookupParam("expression"); |
1828 if (expr == NULL) { | 1822 if (expr == NULL) { |
1829 PrintMissingParamError(js, "expression"); | 1823 PrintMissingParamError(js, "expression"); |
1830 return true; | 1824 return true; |
1831 } | 1825 } |
1832 Zone* zone = Thread::Current()->zone(); | 1826 Zone* zone = thread->zone(); |
1833 const String& expr_str = String::Handle(zone, String::New(expr)); | 1827 const String& expr_str = String::Handle(zone, String::New(expr)); |
1834 ObjectIdRing::LookupResult lookup_result; | 1828 ObjectIdRing::LookupResult lookup_result; |
1835 Object& obj = Object::Handle(zone, LookupHeapObject(isolate, target_id, | 1829 Object& obj = Object::Handle(zone, LookupHeapObject(thread, target_id, |
1836 &lookup_result)); | 1830 &lookup_result)); |
1837 if (obj.raw() == Object::sentinel().raw()) { | 1831 if (obj.raw() == Object::sentinel().raw()) { |
1838 if (lookup_result == ObjectIdRing::kCollected) { | 1832 if (lookup_result == ObjectIdRing::kCollected) { |
1839 PrintSentinel(js, kCollectedSentinel); | 1833 PrintSentinel(js, kCollectedSentinel); |
1840 } else if (lookup_result == ObjectIdRing::kExpired) { | 1834 } else if (lookup_result == ObjectIdRing::kExpired) { |
1841 PrintSentinel(js, kExpiredSentinel); | 1835 PrintSentinel(js, kExpiredSentinel); |
1842 } else { | 1836 } else { |
1843 PrintInvalidParamError(js, "targetId"); | 1837 PrintInvalidParamError(js, "targetId"); |
1844 } | 1838 } |
1845 return true; | 1839 return true; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 | 1873 |
1880 | 1874 |
1881 static const MethodParameter* evaluate_in_frame_params[] = { | 1875 static const MethodParameter* evaluate_in_frame_params[] = { |
1882 ISOLATE_PARAMETER, | 1876 ISOLATE_PARAMETER, |
1883 new UIntParameter("frameIndex", true), | 1877 new UIntParameter("frameIndex", true), |
1884 new MethodParameter("expression", true), | 1878 new MethodParameter("expression", true), |
1885 NULL, | 1879 NULL, |
1886 }; | 1880 }; |
1887 | 1881 |
1888 | 1882 |
1889 static bool EvaluateInFrame(Isolate* isolate, JSONStream* js) { | 1883 static bool EvaluateInFrame(Thread* thread, JSONStream* js) { |
| 1884 Isolate* isolate = thread->isolate(); |
1890 if (!isolate->compilation_allowed()) { | 1885 if (!isolate->compilation_allowed()) { |
1891 js->PrintError(kFeatureDisabled, | 1886 js->PrintError(kFeatureDisabled, |
1892 "Cannot evaluate when running a precompiled program."); | 1887 "Cannot evaluate when running a precompiled program."); |
1893 return true; | 1888 return true; |
1894 } | 1889 } |
1895 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 1890 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); |
1896 intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex")); | 1891 intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex")); |
1897 if (framePos > stack->Length()) { | 1892 if (framePos > stack->Length()) { |
1898 PrintInvalidParamError(js, "frameIndex"); | 1893 PrintInvalidParamError(js, "frameIndex"); |
1899 return true; | 1894 return true; |
1900 } | 1895 } |
1901 ActivationFrame* frame = stack->FrameAt(framePos); | 1896 ActivationFrame* frame = stack->FrameAt(framePos); |
1902 | 1897 |
1903 Zone* zone = Thread::Current()->zone(); | 1898 Zone* zone = thread->zone(); |
1904 const char* expr = js->LookupParam("expression"); | 1899 const char* expr = js->LookupParam("expression"); |
1905 const String& expr_str = String::Handle(zone, String::New(expr)); | 1900 const String& expr_str = String::Handle(zone, String::New(expr)); |
1906 | 1901 |
1907 const Object& result = Object::Handle(zone, frame->Evaluate(expr_str)); | 1902 const Object& result = Object::Handle(zone, frame->Evaluate(expr_str)); |
1908 result.PrintJSON(js, true); | 1903 result.PrintJSON(js, true); |
1909 return true; | 1904 return true; |
1910 } | 1905 } |
1911 | 1906 |
1912 | 1907 |
1913 class GetInstancesVisitor : public ObjectGraph::Visitor { | 1908 class GetInstancesVisitor : public ObjectGraph::Visitor { |
(...skipping 27 matching lines...) Expand all Loading... |
1941 intptr_t count_; | 1936 intptr_t count_; |
1942 }; | 1937 }; |
1943 | 1938 |
1944 | 1939 |
1945 static const MethodParameter* get_instances_params[] = { | 1940 static const MethodParameter* get_instances_params[] = { |
1946 ISOLATE_PARAMETER, | 1941 ISOLATE_PARAMETER, |
1947 NULL, | 1942 NULL, |
1948 }; | 1943 }; |
1949 | 1944 |
1950 | 1945 |
1951 static bool GetInstances(Isolate* isolate, JSONStream* js) { | 1946 static bool GetInstances(Thread* thread, JSONStream* js) { |
1952 const char* target_id = js->LookupParam("classId"); | 1947 const char* target_id = js->LookupParam("classId"); |
1953 if (target_id == NULL) { | 1948 if (target_id == NULL) { |
1954 PrintMissingParamError(js, "classId"); | 1949 PrintMissingParamError(js, "classId"); |
1955 return true; | 1950 return true; |
1956 } | 1951 } |
1957 const char* limit_cstr = js->LookupParam("limit"); | 1952 const char* limit_cstr = js->LookupParam("limit"); |
1958 if (limit_cstr == NULL) { | 1953 if (limit_cstr == NULL) { |
1959 PrintMissingParamError(js, "limit"); | 1954 PrintMissingParamError(js, "limit"); |
1960 return true; | 1955 return true; |
1961 } | 1956 } |
1962 intptr_t limit; | 1957 intptr_t limit; |
1963 if (!GetIntegerId(limit_cstr, &limit)) { | 1958 if (!GetIntegerId(limit_cstr, &limit)) { |
1964 PrintInvalidParamError(js, "limit"); | 1959 PrintInvalidParamError(js, "limit"); |
1965 return true; | 1960 return true; |
1966 } | 1961 } |
1967 const Object& obj = | 1962 const Object& obj = |
1968 Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | 1963 Object::Handle(LookupHeapObject(thread, target_id, NULL)); |
1969 if (obj.raw() == Object::sentinel().raw() || | 1964 if (obj.raw() == Object::sentinel().raw() || |
1970 !obj.IsClass()) { | 1965 !obj.IsClass()) { |
1971 PrintInvalidParamError(js, "classId"); | 1966 PrintInvalidParamError(js, "classId"); |
1972 return true; | 1967 return true; |
1973 } | 1968 } |
1974 const Class& cls = Class::Cast(obj); | 1969 const Class& cls = Class::Cast(obj); |
1975 Array& storage = Array::Handle(Array::New(limit)); | 1970 Array& storage = Array::Handle(Array::New(limit)); |
1976 GetInstancesVisitor visitor(cls, storage); | 1971 GetInstancesVisitor visitor(cls, storage); |
1977 ObjectGraph graph(Thread::Current()); | 1972 ObjectGraph graph(thread); |
1978 graph.IterateObjects(&visitor); | 1973 graph.IterateObjects(&visitor); |
1979 intptr_t count = visitor.count(); | 1974 intptr_t count = visitor.count(); |
1980 if (count < limit) { | 1975 if (count < limit) { |
1981 // Truncate the list using utility method for GrowableObjectArray. | 1976 // Truncate the list using utility method for GrowableObjectArray. |
1982 GrowableObjectArray& wrapper = GrowableObjectArray::Handle( | 1977 GrowableObjectArray& wrapper = GrowableObjectArray::Handle( |
1983 GrowableObjectArray::New(storage)); | 1978 GrowableObjectArray::New(storage)); |
1984 wrapper.SetLength(count); | 1979 wrapper.SetLength(count); |
1985 storage = Array::MakeArray(wrapper); | 1980 storage = Array::MakeArray(wrapper); |
1986 } | 1981 } |
1987 JSONObject jsobj(js); | 1982 JSONObject jsobj(js); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 const Script& script, | 2043 const Script& script, |
2049 const Class& cls, | 2044 const Class& cls, |
2050 const Function& func) const { | 2045 const Function& func) const { |
2051 return func.raw() == func_.raw(); | 2046 return func.raw() == func_.raw(); |
2052 } | 2047 } |
2053 private: | 2048 private: |
2054 const Function& func_; | 2049 const Function& func_; |
2055 }; | 2050 }; |
2056 | 2051 |
2057 | 2052 |
2058 static bool GetHitsOrSites(Isolate* isolate, JSONStream* js, bool as_sites) { | 2053 static bool GetHitsOrSites(Thread* thread, JSONStream* js, bool as_sites) { |
2059 Thread* thread = Thread::Current(); | |
2060 if (!js->HasParam("targetId")) { | 2054 if (!js->HasParam("targetId")) { |
2061 CodeCoverage::PrintJSON(thread, js, NULL, as_sites); | 2055 CodeCoverage::PrintJSON(thread, js, NULL, as_sites); |
2062 return true; | 2056 return true; |
2063 } | 2057 } |
2064 const char* target_id = js->LookupParam("targetId"); | 2058 const char* target_id = js->LookupParam("targetId"); |
2065 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | 2059 Object& obj = Object::Handle(LookupHeapObject(thread, target_id, NULL)); |
2066 if (obj.raw() == Object::sentinel().raw()) { | 2060 if (obj.raw() == Object::sentinel().raw()) { |
2067 PrintInvalidParamError(js, "targetId"); | 2061 PrintInvalidParamError(js, "targetId"); |
2068 return true; | 2062 return true; |
2069 } | 2063 } |
2070 if (obj.IsScript()) { | 2064 if (obj.IsScript()) { |
2071 ScriptCoverageFilter sf(Script::Cast(obj)); | 2065 ScriptCoverageFilter sf(Script::Cast(obj)); |
2072 CodeCoverage::PrintJSON(thread, js, &sf, as_sites); | 2066 CodeCoverage::PrintJSON(thread, js, &sf, as_sites); |
2073 return true; | 2067 return true; |
2074 } | 2068 } |
2075 if (obj.IsLibrary()) { | 2069 if (obj.IsLibrary()) { |
(...skipping 20 matching lines...) Expand all Loading... |
2096 } | 2090 } |
2097 | 2091 |
2098 | 2092 |
2099 static const MethodParameter* get_coverage_params[] = { | 2093 static const MethodParameter* get_coverage_params[] = { |
2100 ISOLATE_PARAMETER, | 2094 ISOLATE_PARAMETER, |
2101 new IdParameter("targetId", false), | 2095 new IdParameter("targetId", false), |
2102 NULL, | 2096 NULL, |
2103 }; | 2097 }; |
2104 | 2098 |
2105 | 2099 |
2106 static bool GetCoverage(Isolate* isolate, JSONStream* js) { | 2100 static bool GetCoverage(Thread* thread, JSONStream* js) { |
2107 // TODO(rmacnak): Remove this response; it is subsumed by GetCallSiteData. | 2101 // TODO(rmacnak): Remove this response; it is subsumed by GetCallSiteData. |
2108 return GetHitsOrSites(isolate, js, false); | 2102 return GetHitsOrSites(thread, js, false); |
2109 } | 2103 } |
2110 | 2104 |
2111 | 2105 |
2112 static const MethodParameter* get_call_site_data_params[] = { | 2106 static const MethodParameter* get_call_site_data_params[] = { |
2113 ISOLATE_PARAMETER, | 2107 ISOLATE_PARAMETER, |
2114 new IdParameter("targetId", false), | 2108 new IdParameter("targetId", false), |
2115 NULL, | 2109 NULL, |
2116 }; | 2110 }; |
2117 | 2111 |
2118 | 2112 |
2119 static bool GetCallSiteData(Isolate* isolate, JSONStream* js) { | 2113 static bool GetCallSiteData(Thread* thread, JSONStream* js) { |
2120 return GetHitsOrSites(isolate, js, true); | 2114 return GetHitsOrSites(thread, js, true); |
2121 } | 2115 } |
2122 | 2116 |
2123 | 2117 |
2124 static bool AddBreakpointCommon(Isolate* isolate, | 2118 static bool AddBreakpointCommon(Thread* thread, |
2125 JSONStream* js, | 2119 JSONStream* js, |
2126 const String& script_uri) { | 2120 const String& script_uri) { |
2127 const char* line_param = js->LookupParam("line"); | 2121 const char* line_param = js->LookupParam("line"); |
2128 intptr_t line = UIntParameter::Parse(line_param); | 2122 intptr_t line = UIntParameter::Parse(line_param); |
2129 const char* col_param = js->LookupParam("column"); | 2123 const char* col_param = js->LookupParam("column"); |
2130 intptr_t col = -1; | 2124 intptr_t col = -1; |
2131 if (col_param != NULL) { | 2125 if (col_param != NULL) { |
2132 col = UIntParameter::Parse(col_param); | 2126 col = UIntParameter::Parse(col_param); |
2133 if (col == 0) { | 2127 if (col == 0) { |
2134 // Column number is 1-based. | 2128 // Column number is 1-based. |
2135 PrintInvalidParamError(js, "column"); | 2129 PrintInvalidParamError(js, "column"); |
2136 return true; | 2130 return true; |
2137 } | 2131 } |
2138 } | 2132 } |
2139 ASSERT(!script_uri.IsNull()); | 2133 ASSERT(!script_uri.IsNull()); |
2140 Breakpoint* bpt = NULL; | 2134 Breakpoint* bpt = NULL; |
2141 bpt = isolate->debugger()->SetBreakpointAtLineCol(script_uri, line, col); | 2135 bpt = thread->isolate()->debugger()-> |
| 2136 SetBreakpointAtLineCol(script_uri, line, col); |
2142 if (bpt == NULL) { | 2137 if (bpt == NULL) { |
2143 js->PrintError(kCannotAddBreakpoint, | 2138 js->PrintError(kCannotAddBreakpoint, |
2144 "%s: Cannot add breakpoint at line '%s'", | 2139 "%s: Cannot add breakpoint at line '%s'", |
2145 js->method(), line_param); | 2140 js->method(), line_param); |
2146 return true; | 2141 return true; |
2147 } | 2142 } |
2148 bpt->PrintJSON(js); | 2143 bpt->PrintJSON(js); |
2149 return true; | 2144 return true; |
2150 } | 2145 } |
2151 | 2146 |
2152 | 2147 |
2153 static const MethodParameter* add_breakpoint_params[] = { | 2148 static const MethodParameter* add_breakpoint_params[] = { |
2154 ISOLATE_PARAMETER, | 2149 ISOLATE_PARAMETER, |
2155 new IdParameter("scriptId", true), | 2150 new IdParameter("scriptId", true), |
2156 new UIntParameter("line", true), | 2151 new UIntParameter("line", true), |
2157 new UIntParameter("column", false), | 2152 new UIntParameter("column", false), |
2158 NULL, | 2153 NULL, |
2159 }; | 2154 }; |
2160 | 2155 |
2161 | 2156 |
2162 static bool AddBreakpoint(Isolate* isolate, JSONStream* js) { | 2157 static bool AddBreakpoint(Thread* thread, JSONStream* js) { |
2163 const char* script_id_param = js->LookupParam("scriptId"); | 2158 const char* script_id_param = js->LookupParam("scriptId"); |
2164 Object& obj = | 2159 Object& obj = Object::Handle(LookupHeapObject(thread, script_id_param, NULL)); |
2165 Object::Handle(LookupHeapObject(isolate, script_id_param, NULL)); | |
2166 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { | 2160 if (obj.raw() == Object::sentinel().raw() || !obj.IsScript()) { |
2167 PrintInvalidParamError(js, "scriptId"); | 2161 PrintInvalidParamError(js, "scriptId"); |
2168 return true; | 2162 return true; |
2169 } | 2163 } |
2170 const Script& script = Script::Cast(obj); | 2164 const Script& script = Script::Cast(obj); |
2171 const String& script_uri = String::Handle(script.url()); | 2165 const String& script_uri = String::Handle(script.url()); |
2172 ASSERT(!script_uri.IsNull()); | 2166 ASSERT(!script_uri.IsNull()); |
2173 return AddBreakpointCommon(isolate, js, script_uri); | 2167 return AddBreakpointCommon(thread, js, script_uri); |
2174 } | 2168 } |
2175 | 2169 |
2176 | 2170 |
2177 static const MethodParameter* add_breakpoint_with_script_uri_params[] = { | 2171 static const MethodParameter* add_breakpoint_with_script_uri_params[] = { |
2178 ISOLATE_PARAMETER, | 2172 ISOLATE_PARAMETER, |
2179 new IdParameter("scriptUri", true), | 2173 new IdParameter("scriptUri", true), |
2180 new UIntParameter("line", true), | 2174 new UIntParameter("line", true), |
2181 new UIntParameter("column", false), | 2175 new UIntParameter("column", false), |
2182 NULL, | 2176 NULL, |
2183 }; | 2177 }; |
2184 | 2178 |
2185 | 2179 |
2186 static bool AddBreakpointWithScriptUri(Isolate* isolate, JSONStream* js) { | 2180 static bool AddBreakpointWithScriptUri(Thread* thread, JSONStream* js) { |
2187 const char* script_uri_param = js->LookupParam("scriptUri"); | 2181 const char* script_uri_param = js->LookupParam("scriptUri"); |
2188 const String& script_uri = String::Handle(String::New(script_uri_param)); | 2182 const String& script_uri = String::Handle(String::New(script_uri_param)); |
2189 return AddBreakpointCommon(isolate, js, script_uri); | 2183 return AddBreakpointCommon(thread, js, script_uri); |
2190 } | 2184 } |
2191 | 2185 |
2192 | 2186 |
2193 static const MethodParameter* add_breakpoint_at_entry_params[] = { | 2187 static const MethodParameter* add_breakpoint_at_entry_params[] = { |
2194 ISOLATE_PARAMETER, | 2188 ISOLATE_PARAMETER, |
2195 new IdParameter("functionId", true), | 2189 new IdParameter("functionId", true), |
2196 NULL, | 2190 NULL, |
2197 }; | 2191 }; |
2198 | 2192 |
2199 | 2193 |
2200 static bool AddBreakpointAtEntry(Isolate* isolate, JSONStream* js) { | 2194 static bool AddBreakpointAtEntry(Thread* thread, JSONStream* js) { |
2201 const char* function_id = js->LookupParam("functionId"); | 2195 const char* function_id = js->LookupParam("functionId"); |
2202 Object& obj = Object::Handle(LookupHeapObject(isolate, function_id, NULL)); | 2196 Object& obj = Object::Handle(LookupHeapObject(thread, function_id, NULL)); |
2203 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { | 2197 if (obj.raw() == Object::sentinel().raw() || !obj.IsFunction()) { |
2204 PrintInvalidParamError(js, "functionId"); | 2198 PrintInvalidParamError(js, "functionId"); |
2205 return true; | 2199 return true; |
2206 } | 2200 } |
2207 const Function& function = Function::Cast(obj); | 2201 const Function& function = Function::Cast(obj); |
2208 Breakpoint* bpt = | 2202 Breakpoint* bpt = |
2209 isolate->debugger()->SetBreakpointAtEntry(function, false); | 2203 thread->isolate()->debugger()->SetBreakpointAtEntry(function, false); |
2210 if (bpt == NULL) { | 2204 if (bpt == NULL) { |
2211 js->PrintError(kCannotAddBreakpoint, | 2205 js->PrintError(kCannotAddBreakpoint, |
2212 "%s: Cannot add breakpoint at function '%s'", | 2206 "%s: Cannot add breakpoint at function '%s'", |
2213 js->method(), function.ToCString()); | 2207 js->method(), function.ToCString()); |
2214 return true; | 2208 return true; |
2215 } | 2209 } |
2216 bpt->PrintJSON(js); | 2210 bpt->PrintJSON(js); |
2217 return true; | 2211 return true; |
2218 } | 2212 } |
2219 | 2213 |
2220 | 2214 |
2221 static const MethodParameter* add_breakpoint_at_activation_params[] = { | 2215 static const MethodParameter* add_breakpoint_at_activation_params[] = { |
2222 ISOLATE_PARAMETER, | 2216 ISOLATE_PARAMETER, |
2223 new IdParameter("objectId", true), | 2217 new IdParameter("objectId", true), |
2224 NULL, | 2218 NULL, |
2225 }; | 2219 }; |
2226 | 2220 |
2227 | 2221 |
2228 static bool AddBreakpointAtActivation(Isolate* isolate, JSONStream* js) { | 2222 static bool AddBreakpointAtActivation(Thread* thread, JSONStream* js) { |
2229 const char* object_id = js->LookupParam("objectId"); | 2223 const char* object_id = js->LookupParam("objectId"); |
2230 Object& obj = Object::Handle(LookupHeapObject(isolate, object_id, NULL)); | 2224 Object& obj = Object::Handle(LookupHeapObject(thread, object_id, NULL)); |
2231 if (obj.raw() == Object::sentinel().raw() || !obj.IsInstance()) { | 2225 if (obj.raw() == Object::sentinel().raw() || !obj.IsInstance()) { |
2232 PrintInvalidParamError(js, "objectId"); | 2226 PrintInvalidParamError(js, "objectId"); |
2233 return true; | 2227 return true; |
2234 } | 2228 } |
2235 const Instance& closure = Instance::Cast(obj); | 2229 const Instance& closure = Instance::Cast(obj); |
2236 Breakpoint* bpt = | 2230 Breakpoint* bpt = |
2237 isolate->debugger()->SetBreakpointAtActivation(closure); | 2231 thread->isolate()->debugger()->SetBreakpointAtActivation(closure); |
2238 if (bpt == NULL) { | 2232 if (bpt == NULL) { |
2239 js->PrintError(kCannotAddBreakpoint, | 2233 js->PrintError(kCannotAddBreakpoint, |
2240 "%s: Cannot add breakpoint at activation", | 2234 "%s: Cannot add breakpoint at activation", |
2241 js->method()); | 2235 js->method()); |
2242 return true; | 2236 return true; |
2243 } | 2237 } |
2244 bpt->PrintJSON(js); | 2238 bpt->PrintJSON(js); |
2245 return true; | 2239 return true; |
2246 } | 2240 } |
2247 | 2241 |
2248 | 2242 |
2249 static const MethodParameter* remove_breakpoint_params[] = { | 2243 static const MethodParameter* remove_breakpoint_params[] = { |
2250 ISOLATE_PARAMETER, | 2244 ISOLATE_PARAMETER, |
2251 NULL, | 2245 NULL, |
2252 }; | 2246 }; |
2253 | 2247 |
2254 | 2248 |
2255 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { | 2249 static bool RemoveBreakpoint(Thread* thread, JSONStream* js) { |
2256 if (!js->HasParam("breakpointId")) { | 2250 if (!js->HasParam("breakpointId")) { |
2257 PrintMissingParamError(js, "breakpointId"); | 2251 PrintMissingParamError(js, "breakpointId"); |
2258 return true; | 2252 return true; |
2259 } | 2253 } |
2260 const char* bpt_id = js->LookupParam("breakpointId"); | 2254 const char* bpt_id = js->LookupParam("breakpointId"); |
2261 ObjectIdRing::LookupResult lookup_result; | 2255 ObjectIdRing::LookupResult lookup_result; |
| 2256 Isolate* isolate = thread->isolate(); |
2262 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id, &lookup_result); | 2257 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id, &lookup_result); |
2263 // TODO(turnidge): Should we return a different error for bpts whic | 2258 // TODO(turnidge): Should we return a different error for bpts whic |
2264 // have been already removed? | 2259 // have been already removed? |
2265 if (bpt == NULL) { | 2260 if (bpt == NULL) { |
2266 PrintInvalidParamError(js, "breakpointId"); | 2261 PrintInvalidParamError(js, "breakpointId"); |
2267 return true; | 2262 return true; |
2268 } | 2263 } |
2269 isolate->debugger()->RemoveBreakpoint(bpt->id()); | 2264 isolate->debugger()->RemoveBreakpoint(bpt->id()); |
2270 PrintSuccess(js); | 2265 PrintSuccess(js); |
2271 return true; | 2266 return true; |
2272 } | 2267 } |
2273 | 2268 |
2274 | 2269 |
2275 static RawClass* GetMetricsClass(Isolate* isolate) { | 2270 static RawClass* GetMetricsClass(Thread* thread) { |
2276 Zone* zone = isolate->current_zone(); | 2271 Zone* zone = thread->zone(); |
2277 const Library& prof_lib = | 2272 const Library& prof_lib = |
2278 Library::Handle(zone, Library::DeveloperLibrary()); | 2273 Library::Handle(zone, Library::DeveloperLibrary()); |
2279 ASSERT(!prof_lib.IsNull()); | 2274 ASSERT(!prof_lib.IsNull()); |
2280 const String& metrics_cls_name = | 2275 const String& metrics_cls_name = |
2281 String::Handle(zone, String::New("Metrics")); | 2276 String::Handle(zone, String::New("Metrics")); |
2282 ASSERT(!metrics_cls_name.IsNull()); | 2277 ASSERT(!metrics_cls_name.IsNull()); |
2283 const Class& metrics_cls = | 2278 const Class& metrics_cls = |
2284 Class::Handle(zone, prof_lib.LookupClass(metrics_cls_name)); | 2279 Class::Handle(zone, prof_lib.LookupClass(metrics_cls_name)); |
2285 ASSERT(!metrics_cls.IsNull()); | 2280 ASSERT(!metrics_cls.IsNull()); |
2286 return metrics_cls.raw(); | 2281 return metrics_cls.raw(); |
2287 } | 2282 } |
2288 | 2283 |
2289 | 2284 |
2290 | 2285 |
2291 static bool HandleNativeMetricsList(Isolate* isolate, JSONStream* js) { | 2286 static bool HandleNativeMetricsList(Thread* thread, JSONStream* js) { |
2292 JSONObject obj(js); | 2287 JSONObject obj(js); |
2293 obj.AddProperty("type", "MetricList"); | 2288 obj.AddProperty("type", "MetricList"); |
2294 { | 2289 { |
2295 JSONArray metrics(&obj, "metrics"); | 2290 JSONArray metrics(&obj, "metrics"); |
2296 Metric* current = isolate->metrics_list_head(); | 2291 Metric* current = thread->isolate()->metrics_list_head(); |
2297 while (current != NULL) { | 2292 while (current != NULL) { |
2298 metrics.AddValue(current); | 2293 metrics.AddValue(current); |
2299 current = current->next(); | 2294 current = current->next(); |
2300 } | 2295 } |
2301 } | 2296 } |
2302 return true; | 2297 return true; |
2303 } | 2298 } |
2304 | 2299 |
2305 | 2300 |
2306 static bool HandleNativeMetric(Isolate* isolate, | 2301 static bool HandleNativeMetric(Thread* thread, JSONStream* js, const char* id) { |
2307 JSONStream* js, | 2302 Metric* current = thread->isolate()->metrics_list_head(); |
2308 const char* id) { | |
2309 Metric* current = isolate->metrics_list_head(); | |
2310 while (current != NULL) { | 2303 while (current != NULL) { |
2311 const char* name = current->name(); | 2304 const char* name = current->name(); |
2312 ASSERT(name != NULL); | 2305 ASSERT(name != NULL); |
2313 if (strcmp(name, id) == 0) { | 2306 if (strcmp(name, id) == 0) { |
2314 current->PrintJSON(js); | 2307 current->PrintJSON(js); |
2315 return true; | 2308 return true; |
2316 } | 2309 } |
2317 current = current->next(); | 2310 current = current->next(); |
2318 } | 2311 } |
2319 PrintInvalidParamError(js, "metricId"); | 2312 PrintInvalidParamError(js, "metricId"); |
2320 return true; | 2313 return true; |
2321 } | 2314 } |
2322 | 2315 |
2323 | 2316 |
2324 static bool HandleDartMetricsList(Isolate* isolate, JSONStream* js) { | 2317 static bool HandleDartMetricsList(Thread* thread, JSONStream* js) { |
2325 Zone* zone = isolate->current_zone(); | 2318 Zone* zone = thread->zone(); |
2326 const Class& metrics_cls = Class::Handle(zone, GetMetricsClass(isolate)); | 2319 const Class& metrics_cls = |
| 2320 Class::Handle(zone, GetMetricsClass(thread)); |
2327 const String& print_metrics_name = | 2321 const String& print_metrics_name = |
2328 String::Handle(String::New("_printMetrics")); | 2322 String::Handle(String::New("_printMetrics")); |
2329 ASSERT(!print_metrics_name.IsNull()); | 2323 ASSERT(!print_metrics_name.IsNull()); |
2330 const Function& print_metrics = Function::Handle( | 2324 const Function& print_metrics = Function::Handle( |
2331 zone, | 2325 zone, |
2332 metrics_cls.LookupStaticFunctionAllowPrivate(print_metrics_name)); | 2326 metrics_cls.LookupStaticFunctionAllowPrivate(print_metrics_name)); |
2333 ASSERT(!print_metrics.IsNull()); | 2327 ASSERT(!print_metrics.IsNull()); |
2334 const Array& args = Object::empty_array(); | 2328 const Array& args = Object::empty_array(); |
2335 const Object& result = | 2329 const Object& result = |
2336 Object::Handle(zone, DartEntry::InvokeFunction(print_metrics, args)); | 2330 Object::Handle(zone, DartEntry::InvokeFunction(print_metrics, args)); |
2337 ASSERT(!result.IsNull()); | 2331 ASSERT(!result.IsNull()); |
2338 ASSERT(result.IsString()); | 2332 ASSERT(result.IsString()); |
2339 TextBuffer* buffer = js->buffer(); | 2333 TextBuffer* buffer = js->buffer(); |
2340 buffer->AddString(String::Cast(result).ToCString()); | 2334 buffer->AddString(String::Cast(result).ToCString()); |
2341 return true; | 2335 return true; |
2342 } | 2336 } |
2343 | 2337 |
2344 | 2338 |
2345 static bool HandleDartMetric(Isolate* isolate, JSONStream* js, const char* id) { | 2339 static bool HandleDartMetric(Thread* thread, JSONStream* js, const char* id) { |
2346 Zone* zone = isolate->current_zone(); | 2340 Zone* zone = thread->zone(); |
2347 const Class& metrics_cls = Class::Handle(zone, GetMetricsClass(isolate)); | 2341 const Class& metrics_cls = |
| 2342 Class::Handle(zone, GetMetricsClass(thread)); |
2348 const String& print_metric_name = | 2343 const String& print_metric_name = |
2349 String::Handle(String::New("_printMetric")); | 2344 String::Handle(String::New("_printMetric")); |
2350 ASSERT(!print_metric_name.IsNull()); | 2345 ASSERT(!print_metric_name.IsNull()); |
2351 const Function& print_metric = Function::Handle( | 2346 const Function& print_metric = Function::Handle( |
2352 zone, | 2347 zone, |
2353 metrics_cls.LookupStaticFunctionAllowPrivate(print_metric_name)); | 2348 metrics_cls.LookupStaticFunctionAllowPrivate(print_metric_name)); |
2354 ASSERT(!print_metric.IsNull()); | 2349 ASSERT(!print_metric.IsNull()); |
2355 const String& arg0 = String::Handle(String::New(id)); | 2350 const String& arg0 = String::Handle(String::New(id)); |
2356 ASSERT(!arg0.IsNull()); | 2351 ASSERT(!arg0.IsNull()); |
2357 const Array& args = Array::Handle(Array::New(1)); | 2352 const Array& args = Array::Handle(Array::New(1)); |
(...skipping 11 matching lines...) Expand all Loading... |
2369 return true; | 2364 return true; |
2370 } | 2365 } |
2371 | 2366 |
2372 | 2367 |
2373 static const MethodParameter* get_isolate_metric_list_params[] = { | 2368 static const MethodParameter* get_isolate_metric_list_params[] = { |
2374 ISOLATE_PARAMETER, | 2369 ISOLATE_PARAMETER, |
2375 NULL, | 2370 NULL, |
2376 }; | 2371 }; |
2377 | 2372 |
2378 | 2373 |
2379 static bool GetIsolateMetricList(Isolate* isolate, JSONStream* js) { | 2374 static bool GetIsolateMetricList(Thread* thread, JSONStream* js) { |
2380 bool native_metrics = false; | 2375 bool native_metrics = false; |
2381 if (js->HasParam("type")) { | 2376 if (js->HasParam("type")) { |
2382 if (js->ParamIs("type", "Native")) { | 2377 if (js->ParamIs("type", "Native")) { |
2383 native_metrics = true; | 2378 native_metrics = true; |
2384 } else if (js->ParamIs("type", "Dart")) { | 2379 } else if (js->ParamIs("type", "Dart")) { |
2385 native_metrics = false; | 2380 native_metrics = false; |
2386 } else { | 2381 } else { |
2387 PrintInvalidParamError(js, "type"); | 2382 PrintInvalidParamError(js, "type"); |
2388 return true; | 2383 return true; |
2389 } | 2384 } |
2390 } else { | 2385 } else { |
2391 PrintMissingParamError(js, "type"); | 2386 PrintMissingParamError(js, "type"); |
2392 return true; | 2387 return true; |
2393 } | 2388 } |
2394 if (native_metrics) { | 2389 if (native_metrics) { |
2395 return HandleNativeMetricsList(isolate, js); | 2390 return HandleNativeMetricsList(thread, js); |
2396 } | 2391 } |
2397 return HandleDartMetricsList(isolate, js); | 2392 return HandleDartMetricsList(thread, js); |
2398 } | 2393 } |
2399 | 2394 |
2400 | 2395 |
2401 static const MethodParameter* get_isolate_metric_params[] = { | 2396 static const MethodParameter* get_isolate_metric_params[] = { |
2402 ISOLATE_PARAMETER, | 2397 ISOLATE_PARAMETER, |
2403 NULL, | 2398 NULL, |
2404 }; | 2399 }; |
2405 | 2400 |
2406 | 2401 |
2407 static bool GetIsolateMetric(Isolate* isolate, JSONStream* js) { | 2402 static bool GetIsolateMetric(Thread* thread, JSONStream* js) { |
2408 const char* metric_id = js->LookupParam("metricId"); | 2403 const char* metric_id = js->LookupParam("metricId"); |
2409 if (metric_id == NULL) { | 2404 if (metric_id == NULL) { |
2410 PrintMissingParamError(js, "metricId"); | 2405 PrintMissingParamError(js, "metricId"); |
2411 return true; | 2406 return true; |
2412 } | 2407 } |
2413 // Verify id begins with "metrics/". | 2408 // Verify id begins with "metrics/". |
2414 static const char* kMetricIdPrefix = "metrics/"; | 2409 static const char* kMetricIdPrefix = "metrics/"; |
2415 static intptr_t kMetricIdPrefixLen = strlen(kMetricIdPrefix); | 2410 static intptr_t kMetricIdPrefixLen = strlen(kMetricIdPrefix); |
2416 if (strncmp(metric_id, kMetricIdPrefix, kMetricIdPrefixLen) != 0) { | 2411 if (strncmp(metric_id, kMetricIdPrefix, kMetricIdPrefixLen) != 0) { |
2417 PrintInvalidParamError(js, "metricId"); | 2412 PrintInvalidParamError(js, "metricId"); |
2418 return true; | 2413 return true; |
2419 } | 2414 } |
2420 // Check if id begins with "metrics/native/". | 2415 // Check if id begins with "metrics/native/". |
2421 static const char* kNativeMetricIdPrefix = "metrics/native/"; | 2416 static const char* kNativeMetricIdPrefix = "metrics/native/"; |
2422 static intptr_t kNativeMetricIdPrefixLen = strlen(kNativeMetricIdPrefix); | 2417 static intptr_t kNativeMetricIdPrefixLen = strlen(kNativeMetricIdPrefix); |
2423 const bool native_metric = | 2418 const bool native_metric = |
2424 strncmp(metric_id, kNativeMetricIdPrefix, kNativeMetricIdPrefixLen) == 0; | 2419 strncmp(metric_id, kNativeMetricIdPrefix, kNativeMetricIdPrefixLen) == 0; |
2425 if (native_metric) { | 2420 if (native_metric) { |
2426 const char* id = metric_id + kNativeMetricIdPrefixLen; | 2421 const char* id = metric_id + kNativeMetricIdPrefixLen; |
2427 return HandleNativeMetric(isolate, js, id); | 2422 return HandleNativeMetric(thread, js, id); |
2428 } | 2423 } |
2429 const char* id = metric_id + kMetricIdPrefixLen; | 2424 const char* id = metric_id + kMetricIdPrefixLen; |
2430 return HandleDartMetric(isolate, js, id); | 2425 return HandleDartMetric(thread, js, id); |
2431 } | 2426 } |
2432 | 2427 |
2433 | 2428 |
2434 static const MethodParameter* get_vm_metric_list_params[] = { | 2429 static const MethodParameter* get_vm_metric_list_params[] = { |
2435 NO_ISOLATE_PARAMETER, | 2430 NO_ISOLATE_PARAMETER, |
2436 NULL, | 2431 NULL, |
2437 }; | 2432 }; |
2438 | 2433 |
2439 | 2434 |
2440 static bool GetVMMetricList(Isolate* isolate, JSONStream* js) { | 2435 static bool GetVMMetricList(Thread* thread, JSONStream* js) { |
2441 return false; | 2436 return false; |
2442 } | 2437 } |
2443 | 2438 |
2444 | 2439 |
2445 static const MethodParameter* get_vm_metric_params[] = { | 2440 static const MethodParameter* get_vm_metric_params[] = { |
2446 NO_ISOLATE_PARAMETER, | 2441 NO_ISOLATE_PARAMETER, |
2447 NULL, | 2442 NULL, |
2448 }; | 2443 }; |
2449 | 2444 |
2450 | 2445 |
2451 static bool GetVMMetric(Isolate* isolate, JSONStream* js) { | 2446 static bool GetVMMetric(Thread* thread, JSONStream* js) { |
2452 const char* metric_id = js->LookupParam("metricId"); | 2447 const char* metric_id = js->LookupParam("metricId"); |
2453 if (metric_id == NULL) { | 2448 if (metric_id == NULL) { |
2454 PrintMissingParamError(js, "metricId"); | 2449 PrintMissingParamError(js, "metricId"); |
2455 } | 2450 } |
2456 return false; | 2451 return false; |
2457 } | 2452 } |
2458 | 2453 |
2459 | 2454 |
2460 static const MethodParameter* resume_params[] = { | 2455 static const MethodParameter* resume_params[] = { |
2461 ISOLATE_PARAMETER, | 2456 ISOLATE_PARAMETER, |
2462 NULL, | 2457 NULL, |
2463 }; | 2458 }; |
2464 | 2459 |
2465 | 2460 |
2466 static bool Resume(Isolate* isolate, JSONStream* js) { | 2461 static bool Resume(Thread* thread, JSONStream* js) { |
2467 const char* step_param = js->LookupParam("step"); | 2462 const char* step_param = js->LookupParam("step"); |
| 2463 Isolate* isolate = thread->isolate(); |
2468 if (isolate->message_handler()->paused_on_start()) { | 2464 if (isolate->message_handler()->paused_on_start()) { |
2469 // If the user is issuing a 'Over' or an 'Out' step, that is the | 2465 // If the user is issuing a 'Over' or an 'Out' step, that is the |
2470 // same as a regular resume request. | 2466 // same as a regular resume request. |
2471 if ((step_param != NULL) && (strcmp(step_param, "Into") == 0)) { | 2467 if ((step_param != NULL) && (strcmp(step_param, "Into") == 0)) { |
2472 isolate->debugger()->EnterSingleStepMode(); | 2468 isolate->debugger()->EnterSingleStepMode(); |
2473 } | 2469 } |
2474 isolate->message_handler()->set_pause_on_start(false); | 2470 isolate->message_handler()->set_pause_on_start(false); |
2475 isolate->set_last_resume_timestamp(); | 2471 isolate->set_last_resume_timestamp(); |
2476 if (Service::debug_stream.enabled()) { | 2472 if (Service::debug_stream.enabled()) { |
2477 ServiceEvent event(isolate, ServiceEvent::kResume); | 2473 ServiceEvent event(isolate, ServiceEvent::kResume); |
(...skipping 30 matching lines...) Expand all Loading... |
2508 return true; | 2504 return true; |
2509 } | 2505 } |
2510 | 2506 |
2511 | 2507 |
2512 static const MethodParameter* pause_params[] = { | 2508 static const MethodParameter* pause_params[] = { |
2513 ISOLATE_PARAMETER, | 2509 ISOLATE_PARAMETER, |
2514 NULL, | 2510 NULL, |
2515 }; | 2511 }; |
2516 | 2512 |
2517 | 2513 |
2518 static bool Pause(Isolate* isolate, JSONStream* js) { | 2514 static bool Pause(Thread* thread, JSONStream* js) { |
2519 // TODO(turnidge): This interrupt message could have been sent from | 2515 // TODO(turnidge): This interrupt message could have been sent from |
2520 // the service isolate directly, but would require some special case | 2516 // the service isolate directly, but would require some special case |
2521 // code. That would prevent this isolate getting double-interrupted | 2517 // code. That would prevent this isolate getting double-interrupted |
2522 // with OOB messages. | 2518 // with OOB messages. |
| 2519 Isolate* isolate = thread->isolate(); |
2523 isolate->SendInternalLibMessage(Isolate::kInterruptMsg, | 2520 isolate->SendInternalLibMessage(Isolate::kInterruptMsg, |
2524 isolate->pause_capability()); | 2521 isolate->pause_capability()); |
2525 PrintSuccess(js); | 2522 PrintSuccess(js); |
2526 return true; | 2523 return true; |
2527 } | 2524 } |
2528 | 2525 |
2529 | 2526 |
2530 static const MethodParameter* get_tag_profile_params[] = { | 2527 static const MethodParameter* get_tag_profile_params[] = { |
2531 ISOLATE_PARAMETER, | 2528 ISOLATE_PARAMETER, |
2532 NULL, | 2529 NULL, |
2533 }; | 2530 }; |
2534 | 2531 |
2535 | 2532 |
2536 static bool GetTagProfile(Isolate* isolate, JSONStream* js) { | 2533 static bool GetTagProfile(Thread* thread, JSONStream* js) { |
2537 JSONObject miniProfile(js); | 2534 JSONObject miniProfile(js); |
2538 miniProfile.AddProperty("type", "TagProfile"); | 2535 miniProfile.AddProperty("type", "TagProfile"); |
2539 isolate->vm_tag_counters()->PrintToJSONObject(&miniProfile); | 2536 thread->isolate()->vm_tag_counters()->PrintToJSONObject(&miniProfile); |
2540 return true; | 2537 return true; |
2541 } | 2538 } |
2542 | 2539 |
2543 | 2540 |
2544 static const char* tags_enum_names[] = { | 2541 static const char* tags_enum_names[] = { |
2545 "None", | 2542 "None", |
2546 "UserVM", | 2543 "UserVM", |
2547 "UserOnly", | 2544 "UserOnly", |
2548 "VMUser", | 2545 "VMUser", |
2549 "VMOnly", | 2546 "VMOnly", |
(...skipping 13 matching lines...) Expand all Loading... |
2563 | 2560 |
2564 static const MethodParameter* get_cpu_profile_params[] = { | 2561 static const MethodParameter* get_cpu_profile_params[] = { |
2565 ISOLATE_PARAMETER, | 2562 ISOLATE_PARAMETER, |
2566 new EnumParameter("tags", true, tags_enum_names), | 2563 new EnumParameter("tags", true, tags_enum_names), |
2567 new BoolParameter("_codeTransitionTags", false), | 2564 new BoolParameter("_codeTransitionTags", false), |
2568 NULL, | 2565 NULL, |
2569 }; | 2566 }; |
2570 | 2567 |
2571 | 2568 |
2572 // TODO(johnmccutchan): Rename this to GetCpuSamples. | 2569 // TODO(johnmccutchan): Rename this to GetCpuSamples. |
2573 static bool GetCpuProfile(Isolate* isolate, JSONStream* js) { | 2570 static bool GetCpuProfile(Thread* thread, JSONStream* js) { |
2574 Profile::TagOrder tag_order = | 2571 Profile::TagOrder tag_order = |
2575 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); | 2572 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); |
2576 intptr_t extra_tags = 0; | 2573 intptr_t extra_tags = 0; |
2577 if (BoolParameter::Parse(js->LookupParam("_codeTransitionTags"))) { | 2574 if (BoolParameter::Parse(js->LookupParam("_codeTransitionTags"))) { |
2578 extra_tags |= ProfilerService::kCodeTransitionTagsBit; | 2575 extra_tags |= ProfilerService::kCodeTransitionTagsBit; |
2579 } | 2576 } |
2580 ProfilerService::PrintJSON(js, tag_order, extra_tags); | 2577 ProfilerService::PrintJSON(js, tag_order, extra_tags); |
2581 return true; | 2578 return true; |
2582 } | 2579 } |
2583 | 2580 |
2584 | 2581 |
2585 static const MethodParameter* get_allocation_samples_params[] = { | 2582 static const MethodParameter* get_allocation_samples_params[] = { |
2586 ISOLATE_PARAMETER, | 2583 ISOLATE_PARAMETER, |
2587 new EnumParameter("tags", true, tags_enum_names), | 2584 new EnumParameter("tags", true, tags_enum_names), |
2588 new IdParameter("classId", false), | 2585 new IdParameter("classId", false), |
2589 NULL, | 2586 NULL, |
2590 }; | 2587 }; |
2591 | 2588 |
2592 | 2589 |
2593 static bool GetAllocationSamples(Isolate* isolate, JSONStream* js) { | 2590 static bool GetAllocationSamples(Thread* thread, JSONStream* js) { |
2594 Profile::TagOrder tag_order = | 2591 Profile::TagOrder tag_order = |
2595 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); | 2592 EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values); |
2596 const char* class_id = js->LookupParam("classId"); | 2593 const char* class_id = js->LookupParam("classId"); |
2597 intptr_t cid = -1; | 2594 intptr_t cid = -1; |
2598 GetPrefixedIntegerId(class_id, "classes/", &cid); | 2595 GetPrefixedIntegerId(class_id, "classes/", &cid); |
| 2596 Isolate* isolate = thread->isolate(); |
2599 if (IsValidClassId(isolate, cid)) { | 2597 if (IsValidClassId(isolate, cid)) { |
2600 const Class& cls = Class::Handle(GetClassForId(isolate, cid)); | 2598 const Class& cls = Class::Handle(GetClassForId(isolate, cid)); |
2601 ProfilerService::PrintAllocationJSON(js, tag_order, cls); | 2599 ProfilerService::PrintAllocationJSON(js, tag_order, cls); |
2602 } else { | 2600 } else { |
2603 PrintInvalidParamError(js, "classId"); | 2601 PrintInvalidParamError(js, "classId"); |
2604 } | 2602 } |
2605 return true; | 2603 return true; |
2606 } | 2604 } |
2607 | 2605 |
2608 | 2606 |
2609 static const MethodParameter* clear_cpu_profile_params[] = { | 2607 static const MethodParameter* clear_cpu_profile_params[] = { |
2610 ISOLATE_PARAMETER, | 2608 ISOLATE_PARAMETER, |
2611 NULL, | 2609 NULL, |
2612 }; | 2610 }; |
2613 | 2611 |
2614 | 2612 |
2615 static bool ClearCpuProfile(Isolate* isolate, JSONStream* js) { | 2613 static bool ClearCpuProfile(Thread* thread, JSONStream* js) { |
2616 ProfilerService::ClearSamples(); | 2614 ProfilerService::ClearSamples(); |
2617 PrintSuccess(js); | 2615 PrintSuccess(js); |
2618 return true; | 2616 return true; |
2619 } | 2617 } |
2620 | 2618 |
2621 | 2619 |
2622 static const MethodParameter* get_allocation_profile_params[] = { | 2620 static const MethodParameter* get_allocation_profile_params[] = { |
2623 ISOLATE_PARAMETER, | 2621 ISOLATE_PARAMETER, |
2624 NULL, | 2622 NULL, |
2625 }; | 2623 }; |
2626 | 2624 |
2627 | 2625 |
2628 static bool GetAllocationProfile(Isolate* isolate, JSONStream* js) { | 2626 static bool GetAllocationProfile(Thread* thread, JSONStream* js) { |
2629 bool should_reset_accumulator = false; | 2627 bool should_reset_accumulator = false; |
2630 bool should_collect = false; | 2628 bool should_collect = false; |
2631 if (js->HasParam("reset")) { | 2629 if (js->HasParam("reset")) { |
2632 if (js->ParamIs("reset", "true")) { | 2630 if (js->ParamIs("reset", "true")) { |
2633 should_reset_accumulator = true; | 2631 should_reset_accumulator = true; |
2634 } else { | 2632 } else { |
2635 PrintInvalidParamError(js, "reset"); | 2633 PrintInvalidParamError(js, "reset"); |
2636 return true; | 2634 return true; |
2637 } | 2635 } |
2638 } | 2636 } |
2639 if (js->HasParam("gc")) { | 2637 if (js->HasParam("gc")) { |
2640 if (js->ParamIs("gc", "full")) { | 2638 if (js->ParamIs("gc", "full")) { |
2641 should_collect = true; | 2639 should_collect = true; |
2642 } else { | 2640 } else { |
2643 PrintInvalidParamError(js, "gc"); | 2641 PrintInvalidParamError(js, "gc"); |
2644 return true; | 2642 return true; |
2645 } | 2643 } |
2646 } | 2644 } |
| 2645 Isolate* isolate = thread->isolate(); |
2647 if (should_reset_accumulator) { | 2646 if (should_reset_accumulator) { |
2648 isolate->UpdateLastAllocationProfileAccumulatorResetTimestamp(); | 2647 isolate->UpdateLastAllocationProfileAccumulatorResetTimestamp(); |
2649 isolate->class_table()->ResetAllocationAccumulators(); | 2648 isolate->class_table()->ResetAllocationAccumulators(); |
2650 } | 2649 } |
2651 if (should_collect) { | 2650 if (should_collect) { |
2652 isolate->UpdateLastAllocationProfileGCTimestamp(); | 2651 isolate->UpdateLastAllocationProfileGCTimestamp(); |
2653 isolate->heap()->CollectAllGarbage(); | 2652 isolate->heap()->CollectAllGarbage(); |
2654 } | 2653 } |
2655 isolate->class_table()->AllocationProfilePrintJSON(js); | 2654 isolate->class_table()->AllocationProfilePrintJSON(js); |
2656 return true; | 2655 return true; |
2657 } | 2656 } |
2658 | 2657 |
2659 | 2658 |
2660 static const MethodParameter* get_heap_map_params[] = { | 2659 static const MethodParameter* get_heap_map_params[] = { |
2661 ISOLATE_PARAMETER, | 2660 ISOLATE_PARAMETER, |
2662 NULL, | 2661 NULL, |
2663 }; | 2662 }; |
2664 | 2663 |
2665 | 2664 |
2666 static bool GetHeapMap(Isolate* isolate, JSONStream* js) { | 2665 static bool GetHeapMap(Thread* thread, JSONStream* js) { |
| 2666 Isolate* isolate = thread->isolate(); |
2667 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); | 2667 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); |
2668 return true; | 2668 return true; |
2669 } | 2669 } |
2670 | 2670 |
2671 | 2671 |
2672 static const MethodParameter* request_heap_snapshot_params[] = { | 2672 static const MethodParameter* request_heap_snapshot_params[] = { |
2673 ISOLATE_PARAMETER, | 2673 ISOLATE_PARAMETER, |
2674 NULL, | 2674 NULL, |
2675 }; | 2675 }; |
2676 | 2676 |
2677 | 2677 |
2678 static bool RequestHeapSnapshot(Isolate* isolate, JSONStream* js) { | 2678 static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) { |
2679 if (Service::graph_stream.enabled()) { | 2679 if (Service::graph_stream.enabled()) { |
2680 Service::SendGraphEvent(isolate); | 2680 Service::SendGraphEvent(thread); |
2681 } | 2681 } |
2682 // TODO(koda): Provide some id that ties this request to async response(s). | 2682 // TODO(koda): Provide some id that ties this request to async response(s). |
2683 JSONObject jsobj(js); | 2683 JSONObject jsobj(js); |
2684 jsobj.AddProperty("type", "OK"); | 2684 jsobj.AddProperty("type", "OK"); |
2685 return true; | 2685 return true; |
2686 } | 2686 } |
2687 | 2687 |
2688 | 2688 |
2689 void Service::SendGraphEvent(Isolate* isolate) { | 2689 void Service::SendGraphEvent(Thread* thread) { |
2690 uint8_t* buffer = NULL; | 2690 uint8_t* buffer = NULL; |
2691 WriteStream stream(&buffer, &allocator, 1 * MB); | 2691 WriteStream stream(&buffer, &allocator, 1 * MB); |
2692 ObjectGraph graph(Thread::Current()); | 2692 ObjectGraph graph(thread); |
2693 intptr_t node_count = graph.Serialize(&stream); | 2693 intptr_t node_count = graph.Serialize(&stream); |
2694 | 2694 |
2695 // Chrome crashes receiving a single tens-of-megabytes blob, so send the | 2695 // Chrome crashes receiving a single tens-of-megabytes blob, so send the |
2696 // snapshot in megabyte-sized chunks instead. | 2696 // snapshot in megabyte-sized chunks instead. |
2697 const intptr_t kChunkSize = 1 * MB; | 2697 const intptr_t kChunkSize = 1 * MB; |
2698 intptr_t num_chunks = | 2698 intptr_t num_chunks = |
2699 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize; | 2699 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize; |
2700 for (intptr_t i = 0; i < num_chunks; i++) { | 2700 for (intptr_t i = 0; i < num_chunks; i++) { |
2701 JSONStream js; | 2701 JSONStream js; |
2702 { | 2702 { |
2703 JSONObject jsobj(&js); | 2703 JSONObject jsobj(&js); |
2704 jsobj.AddProperty("jsonrpc", "2.0"); | 2704 jsobj.AddProperty("jsonrpc", "2.0"); |
2705 jsobj.AddProperty("method", "streamNotify"); | 2705 jsobj.AddProperty("method", "streamNotify"); |
2706 { | 2706 { |
2707 JSONObject params(&jsobj, "params"); | 2707 JSONObject params(&jsobj, "params"); |
2708 params.AddProperty("streamId", graph_stream.id()); | 2708 params.AddProperty("streamId", graph_stream.id()); |
2709 { | 2709 { |
2710 JSONObject event(¶ms, "event"); | 2710 JSONObject event(¶ms, "event"); |
2711 event.AddProperty("type", "Event"); | 2711 event.AddProperty("type", "Event"); |
2712 event.AddProperty("kind", "_Graph"); | 2712 event.AddProperty("kind", "_Graph"); |
2713 event.AddProperty("isolate", isolate); | 2713 event.AddProperty("isolate", thread->isolate()); |
2714 event.AddPropertyTimeMillis("timestamp", OS::GetCurrentTimeMillis()); | 2714 event.AddPropertyTimeMillis("timestamp", OS::GetCurrentTimeMillis()); |
2715 | 2715 |
2716 event.AddProperty("chunkIndex", i); | 2716 event.AddProperty("chunkIndex", i); |
2717 event.AddProperty("chunkCount", num_chunks); | 2717 event.AddProperty("chunkCount", num_chunks); |
2718 event.AddProperty("nodeCount", node_count); | 2718 event.AddProperty("nodeCount", node_count); |
2719 } | 2719 } |
2720 } | 2720 } |
2721 } | 2721 } |
2722 | 2722 |
2723 const String& message = String::Handle(String::New(js.ToCString())); | 2723 const String& message = String::Handle(String::New(js.ToCString())); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2804 uword addr_; | 2804 uword addr_; |
2805 }; | 2805 }; |
2806 | 2806 |
2807 | 2807 |
2808 static const MethodParameter* get_object_by_address_params[] = { | 2808 static const MethodParameter* get_object_by_address_params[] = { |
2809 ISOLATE_PARAMETER, | 2809 ISOLATE_PARAMETER, |
2810 NULL, | 2810 NULL, |
2811 }; | 2811 }; |
2812 | 2812 |
2813 | 2813 |
2814 static RawObject* GetObjectHelper(Isolate* isolate, uword addr) { | 2814 static RawObject* GetObjectHelper(Thread* thread, uword addr) { |
2815 Object& object = Object::Handle(isolate->current_zone()); | 2815 Object& object = Object::Handle(thread->zone()); |
2816 | 2816 |
2817 { | 2817 { |
2818 NoSafepointScope no_safepoint; | 2818 NoSafepointScope no_safepoint; |
| 2819 Isolate* isolate = thread->isolate(); |
2819 ContainsAddressVisitor visitor(isolate, addr); | 2820 ContainsAddressVisitor visitor(isolate, addr); |
2820 object = isolate->heap()->FindObject(&visitor); | 2821 object = isolate->heap()->FindObject(&visitor); |
2821 } | 2822 } |
2822 | 2823 |
2823 if (!object.IsNull()) { | 2824 if (!object.IsNull()) { |
2824 return object.raw(); | 2825 return object.raw(); |
2825 } | 2826 } |
2826 | 2827 |
2827 { | 2828 { |
2828 NoSafepointScope no_safepoint; | 2829 NoSafepointScope no_safepoint; |
2829 ContainsAddressVisitor visitor(Dart::vm_isolate(), addr); | 2830 ContainsAddressVisitor visitor(Dart::vm_isolate(), addr); |
2830 object = Dart::vm_isolate()->heap()->FindObject(&visitor); | 2831 object = Dart::vm_isolate()->heap()->FindObject(&visitor); |
2831 } | 2832 } |
2832 | 2833 |
2833 return object.raw(); | 2834 return object.raw(); |
2834 } | 2835 } |
2835 | 2836 |
2836 | 2837 |
2837 static bool GetObjectByAddress(Isolate* isolate, JSONStream* js) { | 2838 static bool GetObjectByAddress(Thread* thread, JSONStream* js) { |
2838 const char* addr_str = js->LookupParam("address"); | 2839 const char* addr_str = js->LookupParam("address"); |
2839 if (addr_str == NULL) { | 2840 if (addr_str == NULL) { |
2840 PrintMissingParamError(js, "address"); | 2841 PrintMissingParamError(js, "address"); |
2841 return true; | 2842 return true; |
2842 } | 2843 } |
2843 | 2844 |
2844 // Handle heap objects. | 2845 // Handle heap objects. |
2845 uword addr = 0; | 2846 uword addr = 0; |
2846 if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { | 2847 if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { |
2847 PrintInvalidParamError(js, "address"); | 2848 PrintInvalidParamError(js, "address"); |
2848 return true; | 2849 return true; |
2849 } | 2850 } |
2850 bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); | 2851 bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); |
2851 const Object& obj = Object::Handle(isolate->current_zone(), | 2852 const Object& obj = Object::Handle(thread->zone(), |
2852 GetObjectHelper(isolate, addr)); | 2853 GetObjectHelper(thread, addr)); |
2853 if (obj.IsNull()) { | 2854 if (obj.IsNull()) { |
2854 PrintSentinel(js, kFreeSentinel); | 2855 PrintSentinel(js, kFreeSentinel); |
2855 } else { | 2856 } else { |
2856 obj.PrintJSON(js, ref); | 2857 obj.PrintJSON(js, ref); |
2857 } | 2858 } |
2858 return true; | 2859 return true; |
2859 } | 2860 } |
2860 | 2861 |
2861 | 2862 |
2862 static const MethodParameter* get_ports_params[] = { | 2863 static const MethodParameter* get_ports_params[] = { |
2863 ISOLATE_PARAMETER, | 2864 ISOLATE_PARAMETER, |
2864 NULL, | 2865 NULL, |
2865 }; | 2866 }; |
2866 | 2867 |
2867 | 2868 |
2868 static bool GetPorts(Isolate* isolate, JSONStream* js) { | 2869 static bool GetPorts(Thread* thread, JSONStream* js) { |
2869 MessageHandler* message_handler = isolate->message_handler(); | 2870 MessageHandler* message_handler = thread->isolate()->message_handler(); |
2870 PortMap::PrintPortsForMessageHandler(message_handler, js); | 2871 PortMap::PrintPortsForMessageHandler(message_handler, js); |
2871 return true; | 2872 return true; |
2872 } | 2873 } |
2873 | 2874 |
2874 | 2875 |
2875 static bool RespondWithMalformedJson(Isolate* isolate, | 2876 static bool RespondWithMalformedJson(Thread* thread, JSONStream* js) { |
2876 JSONStream* js) { | |
2877 JSONObject jsobj(js); | 2877 JSONObject jsobj(js); |
2878 jsobj.AddProperty("a", "a"); | 2878 jsobj.AddProperty("a", "a"); |
2879 JSONObject jsobj1(js); | 2879 JSONObject jsobj1(js); |
2880 jsobj1.AddProperty("a", "a"); | 2880 jsobj1.AddProperty("a", "a"); |
2881 JSONObject jsobj2(js); | 2881 JSONObject jsobj2(js); |
2882 jsobj2.AddProperty("a", "a"); | 2882 jsobj2.AddProperty("a", "a"); |
2883 JSONObject jsobj3(js); | 2883 JSONObject jsobj3(js); |
2884 jsobj3.AddProperty("a", "a"); | 2884 jsobj3.AddProperty("a", "a"); |
2885 return true; | 2885 return true; |
2886 } | 2886 } |
2887 | 2887 |
2888 | 2888 |
2889 static bool RespondWithMalformedObject(Isolate* isolate, | 2889 static bool RespondWithMalformedObject(Thread* thread, JSONStream* js) { |
2890 JSONStream* js) { | |
2891 JSONObject jsobj(js); | 2890 JSONObject jsobj(js); |
2892 jsobj.AddProperty("bart", "simpson"); | 2891 jsobj.AddProperty("bart", "simpson"); |
2893 return true; | 2892 return true; |
2894 } | 2893 } |
2895 | 2894 |
2896 | 2895 |
2897 static const MethodParameter* get_object_params[] = { | 2896 static const MethodParameter* get_object_params[] = { |
2898 ISOLATE_PARAMETER, | 2897 ISOLATE_PARAMETER, |
2899 new UIntParameter("offset", false), | 2898 new UIntParameter("offset", false), |
2900 new UIntParameter("count", false), | 2899 new UIntParameter("count", false), |
2901 NULL, | 2900 NULL, |
2902 }; | 2901 }; |
2903 | 2902 |
2904 | 2903 |
2905 static bool GetObject(Isolate* isolate, JSONStream* js) { | 2904 static bool GetObject(Thread* thread, JSONStream* js) { |
2906 const char* id = js->LookupParam("objectId"); | 2905 const char* id = js->LookupParam("objectId"); |
2907 if (id == NULL) { | 2906 if (id == NULL) { |
2908 PrintMissingParamError(js, "objectId"); | 2907 PrintMissingParamError(js, "objectId"); |
2909 return true; | 2908 return true; |
2910 } | 2909 } |
2911 if (js->HasParam("offset")) { | 2910 if (js->HasParam("offset")) { |
2912 intptr_t value = UIntParameter::Parse(js->LookupParam("offset")); | 2911 intptr_t value = UIntParameter::Parse(js->LookupParam("offset")); |
2913 if (value < 0) { | 2912 if (value < 0) { |
2914 PrintInvalidParamError(js, "offset"); | 2913 PrintInvalidParamError(js, "offset"); |
2915 return true; | 2914 return true; |
2916 } | 2915 } |
2917 js->set_offset(value); | 2916 js->set_offset(value); |
2918 } | 2917 } |
2919 if (js->HasParam("count")) { | 2918 if (js->HasParam("count")) { |
2920 intptr_t value = UIntParameter::Parse(js->LookupParam("count")); | 2919 intptr_t value = UIntParameter::Parse(js->LookupParam("count")); |
2921 if (value < 0) { | 2920 if (value < 0) { |
2922 PrintInvalidParamError(js, "count"); | 2921 PrintInvalidParamError(js, "count"); |
2923 return true; | 2922 return true; |
2924 } | 2923 } |
2925 js->set_count(value); | 2924 js->set_count(value); |
2926 } | 2925 } |
2927 | 2926 |
2928 // Handle heap objects. | 2927 // Handle heap objects. |
2929 ObjectIdRing::LookupResult lookup_result; | 2928 ObjectIdRing::LookupResult lookup_result; |
2930 const Object& obj = | 2929 const Object& obj = |
2931 Object::Handle(LookupHeapObject(isolate, id, &lookup_result)); | 2930 Object::Handle(LookupHeapObject(thread, id, &lookup_result)); |
2932 if (obj.raw() != Object::sentinel().raw()) { | 2931 if (obj.raw() != Object::sentinel().raw()) { |
2933 // We found a heap object for this id. Return it. | 2932 // We found a heap object for this id. Return it. |
2934 obj.PrintJSON(js, false); | 2933 obj.PrintJSON(js, false); |
2935 return true; | 2934 return true; |
2936 } else if (lookup_result == ObjectIdRing::kCollected) { | 2935 } else if (lookup_result == ObjectIdRing::kCollected) { |
2937 PrintSentinel(js, kCollectedSentinel); | 2936 PrintSentinel(js, kCollectedSentinel); |
2938 return true; | 2937 return true; |
2939 } else if (lookup_result == ObjectIdRing::kExpired) { | 2938 } else if (lookup_result == ObjectIdRing::kExpired) { |
2940 PrintSentinel(js, kExpiredSentinel); | 2939 PrintSentinel(js, kExpiredSentinel); |
2941 return true; | 2940 return true; |
2942 } | 2941 } |
2943 | 2942 |
2944 // Handle non-heap objects. | 2943 // Handle non-heap objects. |
2945 Breakpoint* bpt = LookupBreakpoint(isolate, id, &lookup_result); | 2944 Breakpoint* bpt = LookupBreakpoint(thread->isolate(), id, &lookup_result); |
2946 if (bpt != NULL) { | 2945 if (bpt != NULL) { |
2947 bpt->PrintJSON(js); | 2946 bpt->PrintJSON(js); |
2948 return true; | 2947 return true; |
2949 } else if (lookup_result == ObjectIdRing::kCollected) { | 2948 } else if (lookup_result == ObjectIdRing::kCollected) { |
2950 PrintSentinel(js, kCollectedSentinel); | 2949 PrintSentinel(js, kCollectedSentinel); |
2951 return true; | 2950 return true; |
2952 } | 2951 } |
2953 | 2952 |
2954 PrintInvalidParamError(js, "objectId"); | 2953 PrintInvalidParamError(js, "objectId"); |
2955 return true; | 2954 return true; |
2956 } | 2955 } |
2957 | 2956 |
2958 | 2957 |
2959 static const MethodParameter* get_class_list_params[] = { | 2958 static const MethodParameter* get_class_list_params[] = { |
2960 ISOLATE_PARAMETER, | 2959 ISOLATE_PARAMETER, |
2961 NULL, | 2960 NULL, |
2962 }; | 2961 }; |
2963 | 2962 |
2964 | 2963 |
2965 static bool GetClassList(Isolate* isolate, JSONStream* js) { | 2964 static bool GetClassList(Thread* thread, JSONStream* js) { |
2966 ClassTable* table = isolate->class_table(); | 2965 ClassTable* table = thread->isolate()->class_table(); |
2967 JSONObject jsobj(js); | 2966 JSONObject jsobj(js); |
2968 table->PrintToJSONObject(&jsobj); | 2967 table->PrintToJSONObject(&jsobj); |
2969 return true; | 2968 return true; |
2970 } | 2969 } |
2971 | 2970 |
2972 | 2971 |
2973 static const MethodParameter* get_type_arguments_list_params[] = { | 2972 static const MethodParameter* get_type_arguments_list_params[] = { |
2974 ISOLATE_PARAMETER, | 2973 ISOLATE_PARAMETER, |
2975 NULL, | 2974 NULL, |
2976 }; | 2975 }; |
2977 | 2976 |
2978 | 2977 |
2979 static bool GetTypeArgumentsList(Isolate* isolate, JSONStream* js) { | 2978 static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) { |
2980 bool only_with_instantiations = false; | 2979 bool only_with_instantiations = false; |
2981 if (js->ParamIs("onlyWithInstantiations", "true")) { | 2980 if (js->ParamIs("onlyWithInstantiations", "true")) { |
2982 only_with_instantiations = true; | 2981 only_with_instantiations = true; |
2983 } | 2982 } |
2984 ObjectStore* object_store = isolate->object_store(); | 2983 ObjectStore* object_store = thread->isolate()->object_store(); |
2985 const Array& table = Array::Handle(object_store->canonical_type_arguments()); | 2984 const Array& table = Array::Handle(object_store->canonical_type_arguments()); |
2986 ASSERT(table.Length() > 0); | 2985 ASSERT(table.Length() > 0); |
2987 TypeArguments& type_args = TypeArguments::Handle(); | 2986 TypeArguments& type_args = TypeArguments::Handle(); |
2988 const intptr_t table_size = table.Length() - 1; | 2987 const intptr_t table_size = table.Length() - 1; |
2989 const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size))); | 2988 const intptr_t table_used = Smi::Value(Smi::RawCast(table.At(table_size))); |
2990 JSONObject jsobj(js); | 2989 JSONObject jsobj(js); |
2991 jsobj.AddProperty("type", "TypeArgumentsList"); | 2990 jsobj.AddProperty("type", "TypeArgumentsList"); |
2992 jsobj.AddProperty("canonicalTypeArgumentsTableSize", table_size); | 2991 jsobj.AddProperty("canonicalTypeArgumentsTableSize", table_size); |
2993 jsobj.AddProperty("canonicalTypeArgumentsTableUsed", table_used); | 2992 jsobj.AddProperty("canonicalTypeArgumentsTableUsed", table_used); |
2994 JSONArray members(&jsobj, "typeArguments"); | 2993 JSONArray members(&jsobj, "typeArguments"); |
2995 for (intptr_t i = 0; i < table_size; i++) { | 2994 for (intptr_t i = 0; i < table_size; i++) { |
2996 type_args ^= table.At(i); | 2995 type_args ^= table.At(i); |
2997 if (!type_args.IsNull()) { | 2996 if (!type_args.IsNull()) { |
2998 if (!only_with_instantiations || type_args.HasInstantiations()) { | 2997 if (!only_with_instantiations || type_args.HasInstantiations()) { |
2999 members.AddValue(type_args); | 2998 members.AddValue(type_args); |
3000 } | 2999 } |
3001 } | 3000 } |
3002 } | 3001 } |
3003 return true; | 3002 return true; |
3004 } | 3003 } |
3005 | 3004 |
3006 | 3005 |
3007 static const MethodParameter* get_version_params[] = { | 3006 static const MethodParameter* get_version_params[] = { |
3008 NO_ISOLATE_PARAMETER, | 3007 NO_ISOLATE_PARAMETER, |
3009 NULL, | 3008 NULL, |
3010 }; | 3009 }; |
3011 | 3010 |
3012 | 3011 |
3013 static bool GetVersion(Isolate* isolate, JSONStream* js) { | 3012 static bool GetVersion(Thread* thread, JSONStream* js) { |
3014 JSONObject jsobj(js); | 3013 JSONObject jsobj(js); |
3015 jsobj.AddProperty("type", "Version"); | 3014 jsobj.AddProperty("type", "Version"); |
3016 jsobj.AddProperty("major", static_cast<intptr_t>(3)); | 3015 jsobj.AddProperty("major", static_cast<intptr_t>(3)); |
3017 jsobj.AddProperty("minor", static_cast<intptr_t>(0)); | 3016 jsobj.AddProperty("minor", static_cast<intptr_t>(0)); |
3018 jsobj.AddProperty("_privateMajor", static_cast<intptr_t>(0)); | 3017 jsobj.AddProperty("_privateMajor", static_cast<intptr_t>(0)); |
3019 jsobj.AddProperty("_privateMinor", static_cast<intptr_t>(0)); | 3018 jsobj.AddProperty("_privateMinor", static_cast<intptr_t>(0)); |
3020 return true; | 3019 return true; |
3021 } | 3020 } |
3022 | 3021 |
3023 | 3022 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3065 jsobj.AddPropertyTimeMillis("startTime", start_time_millis); | 3064 jsobj.AddPropertyTimeMillis("startTime", start_time_millis); |
3066 // Construct the isolate list. | 3065 // Construct the isolate list. |
3067 { | 3066 { |
3068 JSONArray jsarr(&jsobj, "isolates"); | 3067 JSONArray jsarr(&jsobj, "isolates"); |
3069 ServiceIsolateVisitor visitor(&jsarr); | 3068 ServiceIsolateVisitor visitor(&jsarr); |
3070 Isolate::VisitIsolates(&visitor); | 3069 Isolate::VisitIsolates(&visitor); |
3071 } | 3070 } |
3072 } | 3071 } |
3073 | 3072 |
3074 | 3073 |
3075 static bool GetVM(Isolate* isolate, JSONStream* js) { | 3074 static bool GetVM(Thread* thread, JSONStream* js) { |
3076 Service::PrintJSONForVM(js, false); | 3075 Service::PrintJSONForVM(js, false); |
3077 return true; | 3076 return true; |
3078 } | 3077 } |
3079 | 3078 |
3080 | 3079 |
3081 static const MethodParameter* restart_vm_params[] = { | 3080 static const MethodParameter* restart_vm_params[] = { |
3082 NO_ISOLATE_PARAMETER, | 3081 NO_ISOLATE_PARAMETER, |
3083 NULL, | 3082 NULL, |
3084 }; | 3083 }; |
3085 | 3084 |
3086 | 3085 |
3087 static bool RestartVM(Isolate* isolate, JSONStream* js) { | 3086 static bool RestartVM(Thread* thread, JSONStream* js) { |
3088 Isolate::KillAllIsolates(Isolate::kVMRestartMsg); | 3087 Isolate::KillAllIsolates(Isolate::kVMRestartMsg); |
3089 PrintSuccess(js); | 3088 PrintSuccess(js); |
3090 return true; | 3089 return true; |
3091 } | 3090 } |
3092 | 3091 |
3093 | 3092 |
3094 static const char* exception_pause_mode_names[] = { | 3093 static const char* exception_pause_mode_names[] = { |
3095 "All", | 3094 "All", |
3096 "None", | 3095 "None", |
3097 "Unhandled", | 3096 "Unhandled", |
3098 NULL, | 3097 NULL, |
3099 }; | 3098 }; |
3100 | 3099 |
3101 | 3100 |
3102 static Dart_ExceptionPauseInfo exception_pause_mode_values[] = { | 3101 static Dart_ExceptionPauseInfo exception_pause_mode_values[] = { |
3103 kPauseOnAllExceptions, | 3102 kPauseOnAllExceptions, |
3104 kNoPauseOnExceptions, | 3103 kNoPauseOnExceptions, |
3105 kPauseOnUnhandledExceptions, | 3104 kPauseOnUnhandledExceptions, |
3106 kInvalidExceptionPauseInfo, | 3105 kInvalidExceptionPauseInfo, |
3107 }; | 3106 }; |
3108 | 3107 |
3109 | 3108 |
3110 static const MethodParameter* set_exception_pause_mode_params[] = { | 3109 static const MethodParameter* set_exception_pause_mode_params[] = { |
3111 ISOLATE_PARAMETER, | 3110 ISOLATE_PARAMETER, |
3112 new EnumParameter("mode", true, exception_pause_mode_names), | 3111 new EnumParameter("mode", true, exception_pause_mode_names), |
3113 NULL, | 3112 NULL, |
3114 }; | 3113 }; |
3115 | 3114 |
3116 | 3115 |
3117 static bool SetExceptionPauseMode(Isolate* isolate, JSONStream* js) { | 3116 static bool SetExceptionPauseMode(Thread* thread, JSONStream* js) { |
3118 const char* mode = js->LookupParam("mode"); | 3117 const char* mode = js->LookupParam("mode"); |
3119 if (mode == NULL) { | 3118 if (mode == NULL) { |
3120 PrintMissingParamError(js, "mode"); | 3119 PrintMissingParamError(js, "mode"); |
3121 return true; | 3120 return true; |
3122 } | 3121 } |
3123 Dart_ExceptionPauseInfo info = | 3122 Dart_ExceptionPauseInfo info = |
3124 EnumMapper(mode, exception_pause_mode_names, exception_pause_mode_values); | 3123 EnumMapper(mode, exception_pause_mode_names, exception_pause_mode_values); |
3125 if (info == kInvalidExceptionPauseInfo) { | 3124 if (info == kInvalidExceptionPauseInfo) { |
3126 PrintInvalidParamError(js, "mode"); | 3125 PrintInvalidParamError(js, "mode"); |
3127 return true; | 3126 return true; |
3128 } | 3127 } |
| 3128 Isolate* isolate = thread->isolate(); |
3129 isolate->debugger()->SetExceptionPauseInfo(info); | 3129 isolate->debugger()->SetExceptionPauseInfo(info); |
3130 if (Service::debug_stream.enabled()) { | 3130 if (Service::debug_stream.enabled()) { |
3131 ServiceEvent event(isolate, ServiceEvent::kDebuggerSettingsUpdate); | 3131 ServiceEvent event(isolate, ServiceEvent::kDebuggerSettingsUpdate); |
3132 Service::HandleEvent(&event); | 3132 Service::HandleEvent(&event); |
3133 } | 3133 } |
3134 PrintSuccess(js); | 3134 PrintSuccess(js); |
3135 return true; | 3135 return true; |
3136 } | 3136 } |
3137 | 3137 |
3138 | 3138 |
3139 static const MethodParameter* get_flag_list_params[] = { | 3139 static const MethodParameter* get_flag_list_params[] = { |
3140 NO_ISOLATE_PARAMETER, | 3140 NO_ISOLATE_PARAMETER, |
3141 NULL, | 3141 NULL, |
3142 }; | 3142 }; |
3143 | 3143 |
3144 | 3144 |
3145 static bool GetFlagList(Isolate* isolate, JSONStream* js) { | 3145 static bool GetFlagList(Thread* thread, JSONStream* js) { |
3146 Flags::PrintJSON(js); | 3146 Flags::PrintJSON(js); |
3147 return true; | 3147 return true; |
3148 } | 3148 } |
3149 | 3149 |
3150 | 3150 |
3151 static const MethodParameter* set_flags_params[] = { | 3151 static const MethodParameter* set_flags_params[] = { |
3152 NO_ISOLATE_PARAMETER, | 3152 NO_ISOLATE_PARAMETER, |
3153 NULL, | 3153 NULL, |
3154 }; | 3154 }; |
3155 | 3155 |
3156 | 3156 |
3157 static bool SetFlag(Isolate* isolate, JSONStream* js) { | 3157 static bool SetFlag(Thread* thread, JSONStream* js) { |
3158 const char* flag_name = js->LookupParam("name"); | 3158 const char* flag_name = js->LookupParam("name"); |
3159 if (flag_name == NULL) { | 3159 if (flag_name == NULL) { |
3160 PrintMissingParamError(js, "name"); | 3160 PrintMissingParamError(js, "name"); |
3161 return true; | 3161 return true; |
3162 } | 3162 } |
3163 const char* flag_value = js->LookupParam("value"); | 3163 const char* flag_value = js->LookupParam("value"); |
3164 if (flag_value == NULL) { | 3164 if (flag_value == NULL) { |
3165 PrintMissingParamError(js, "value"); | 3165 PrintMissingParamError(js, "value"); |
3166 return true; | 3166 return true; |
3167 } | 3167 } |
(...skipping 11 matching lines...) Expand all Loading... |
3179 | 3179 |
3180 | 3180 |
3181 static const MethodParameter* set_library_debuggable_params[] = { | 3181 static const MethodParameter* set_library_debuggable_params[] = { |
3182 ISOLATE_PARAMETER, | 3182 ISOLATE_PARAMETER, |
3183 new IdParameter("libraryId", true), | 3183 new IdParameter("libraryId", true), |
3184 new BoolParameter("isDebuggable", true), | 3184 new BoolParameter("isDebuggable", true), |
3185 NULL, | 3185 NULL, |
3186 }; | 3186 }; |
3187 | 3187 |
3188 | 3188 |
3189 static bool SetLibraryDebuggable(Isolate* isolate, JSONStream* js) { | 3189 static bool SetLibraryDebuggable(Thread* thread, JSONStream* js) { |
3190 const char* lib_id = js->LookupParam("libraryId"); | 3190 const char* lib_id = js->LookupParam("libraryId"); |
3191 ObjectIdRing::LookupResult lookup_result; | 3191 ObjectIdRing::LookupResult lookup_result; |
3192 Object& obj = Object::Handle(LookupHeapObject(isolate, lib_id, | 3192 Object& obj = Object::Handle(LookupHeapObject(thread, lib_id, |
3193 &lookup_result)); | 3193 &lookup_result)); |
3194 const bool is_debuggable = | 3194 const bool is_debuggable = |
3195 BoolParameter::Parse(js->LookupParam("isDebuggable"), false); | 3195 BoolParameter::Parse(js->LookupParam("isDebuggable"), false); |
3196 if (obj.IsLibrary()) { | 3196 if (obj.IsLibrary()) { |
3197 const Library& lib = Library::Cast(obj); | 3197 const Library& lib = Library::Cast(obj); |
3198 lib.set_debuggable(is_debuggable); | 3198 lib.set_debuggable(is_debuggable); |
3199 PrintSuccess(js); | 3199 PrintSuccess(js); |
3200 return true; | 3200 return true; |
3201 } | 3201 } |
3202 PrintInvalidParamError(js, "libraryId"); | 3202 PrintInvalidParamError(js, "libraryId"); |
3203 return true; | 3203 return true; |
3204 } | 3204 } |
3205 | 3205 |
3206 | 3206 |
3207 static const MethodParameter* set_name_params[] = { | 3207 static const MethodParameter* set_name_params[] = { |
3208 ISOLATE_PARAMETER, | 3208 ISOLATE_PARAMETER, |
3209 new MethodParameter("name", true), | 3209 new MethodParameter("name", true), |
3210 NULL, | 3210 NULL, |
3211 }; | 3211 }; |
3212 | 3212 |
3213 | 3213 |
3214 static bool SetName(Isolate* isolate, JSONStream* js) { | 3214 static bool SetName(Thread* thread, JSONStream* js) { |
| 3215 Isolate* isolate = thread->isolate(); |
3215 isolate->set_debugger_name(js->LookupParam("name")); | 3216 isolate->set_debugger_name(js->LookupParam("name")); |
3216 if (Service::isolate_stream.enabled()) { | 3217 if (Service::isolate_stream.enabled()) { |
3217 ServiceEvent event(isolate, ServiceEvent::kIsolateUpdate); | 3218 ServiceEvent event(isolate, ServiceEvent::kIsolateUpdate); |
3218 Service::HandleEvent(&event); | 3219 Service::HandleEvent(&event); |
3219 } | 3220 } |
3220 PrintSuccess(js); | 3221 PrintSuccess(js); |
3221 return true; | 3222 return true; |
3222 } | 3223 } |
3223 | 3224 |
3224 | 3225 |
3225 static const MethodParameter* set_vm_name_params[] = { | 3226 static const MethodParameter* set_vm_name_params[] = { |
3226 new MethodParameter("name", true), | 3227 new MethodParameter("name", true), |
3227 NULL, | 3228 NULL, |
3228 }; | 3229 }; |
3229 | 3230 |
3230 | 3231 |
3231 static bool SetVMName(Isolate* isolate, JSONStream* js) { | 3232 static bool SetVMName(Thread* thread, JSONStream* js) { |
3232 const char* name_param = js->LookupParam("name"); | 3233 const char* name_param = js->LookupParam("name"); |
3233 free(vm_name); | 3234 free(vm_name); |
3234 vm_name = strdup(name_param); | 3235 vm_name = strdup(name_param); |
3235 if (Service::vm_stream.enabled()) { | 3236 if (Service::vm_stream.enabled()) { |
3236 ServiceEvent event(NULL, ServiceEvent::kVMUpdate); | 3237 ServiceEvent event(NULL, ServiceEvent::kVMUpdate); |
3237 Service::HandleEvent(&event); | 3238 Service::HandleEvent(&event); |
3238 } | 3239 } |
3239 PrintSuccess(js); | 3240 PrintSuccess(js); |
3240 return true; | 3241 return true; |
3241 } | 3242 } |
3242 | 3243 |
3243 | 3244 |
3244 static const MethodParameter* set_trace_class_allocation_params[] = { | 3245 static const MethodParameter* set_trace_class_allocation_params[] = { |
3245 ISOLATE_PARAMETER, | 3246 ISOLATE_PARAMETER, |
3246 new IdParameter("classId", true), | 3247 new IdParameter("classId", true), |
3247 new BoolParameter("enable", true), | 3248 new BoolParameter("enable", true), |
3248 NULL, | 3249 NULL, |
3249 }; | 3250 }; |
3250 | 3251 |
3251 | 3252 |
3252 static bool SetTraceClassAllocation(Isolate* isolate, JSONStream* js) { | 3253 static bool SetTraceClassAllocation(Thread* thread, JSONStream* js) { |
3253 const char* class_id = js->LookupParam("classId"); | 3254 const char* class_id = js->LookupParam("classId"); |
3254 const bool enable = BoolParameter::Parse(js->LookupParam("enable")); | 3255 const bool enable = BoolParameter::Parse(js->LookupParam("enable")); |
3255 intptr_t cid = -1; | 3256 intptr_t cid = -1; |
3256 GetPrefixedIntegerId(class_id, "classes/", &cid); | 3257 GetPrefixedIntegerId(class_id, "classes/", &cid); |
| 3258 Isolate* isolate = thread->isolate(); |
3257 if (!IsValidClassId(isolate, cid)) { | 3259 if (!IsValidClassId(isolate, cid)) { |
3258 PrintInvalidParamError(js, "classId"); | 3260 PrintInvalidParamError(js, "classId"); |
3259 return true; | 3261 return true; |
3260 } | 3262 } |
3261 const Class& cls = Class::Handle(GetClassForId(isolate, cid)); | 3263 const Class& cls = Class::Handle(GetClassForId(isolate, cid)); |
3262 ASSERT(!cls.IsNull()); | 3264 ASSERT(!cls.IsNull()); |
3263 cls.SetTraceAllocation(enable); | 3265 cls.SetTraceAllocation(enable); |
3264 PrintSuccess(js); | 3266 PrintSuccess(js); |
3265 return true; | 3267 return true; |
3266 } | 3268 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3372 ServiceMethodDescriptor& method = service_methods_[i]; | 3374 ServiceMethodDescriptor& method = service_methods_[i]; |
3373 if (strcmp(method_name, method.name) == 0) { | 3375 if (strcmp(method_name, method.name) == 0) { |
3374 return &method; | 3376 return &method; |
3375 } | 3377 } |
3376 } | 3378 } |
3377 return NULL; | 3379 return NULL; |
3378 } | 3380 } |
3379 | 3381 |
3380 | 3382 |
3381 } // namespace dart | 3383 } // namespace dart |
OLD | NEW |