Chromium Code Reviews| 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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 jsobj.AddProperty("kind", "Free"); | 1436 jsobj.AddProperty("kind", "Free"); |
| 1437 jsobj.AddProperty("valueAsString", "<free>"); | 1437 jsobj.AddProperty("valueAsString", "<free>"); |
| 1438 break; | 1438 break; |
| 1439 default: | 1439 default: |
| 1440 UNIMPLEMENTED(); | 1440 UNIMPLEMENTED(); |
| 1441 break; | 1441 break; |
| 1442 } | 1442 } |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 | 1445 |
| 1446 static Breakpoint* LookupBreakpoint(Isolate* isolate, const char* id) { | 1446 static Breakpoint* LookupBreakpoint(Isolate* isolate, |
| 1447 const char* id, | |
| 1448 ObjectIdRing::LookupResult* result) { | |
| 1449 *result = ObjectIdRing::kInvalid; | |
| 1447 size_t end_pos = strcspn(id, "/"); | 1450 size_t end_pos = strcspn(id, "/"); |
| 1448 if (end_pos == strlen(id)) { | 1451 if (end_pos == strlen(id)) { |
| 1449 return NULL; | 1452 return NULL; |
| 1450 } | 1453 } |
| 1451 const char* rest = id + end_pos + 1; // +1 for '/'. | 1454 const char* rest = id + end_pos + 1; // +1 for '/'. |
| 1452 if (strncmp("breakpoints", id, end_pos) == 0) { | 1455 if (strncmp("breakpoints", id, end_pos) == 0) { |
| 1453 intptr_t bpt_id = 0; | 1456 intptr_t bpt_id = 0; |
| 1454 Breakpoint* bpt = NULL; | 1457 Breakpoint* bpt = NULL; |
| 1455 if (GetIntegerId(rest, &bpt_id)) { | 1458 if (GetIntegerId(rest, &bpt_id)) { |
| 1456 bpt = isolate->debugger()->GetBreakpointById(bpt_id); | 1459 if (bpt_id >= isolate->debugger()->limitBreakpointId()) { |
| 1460 *result = ObjectIdRing::kCollected; | |
|
Cutch
2015/09/11 19:22:19
We've been asked for a breakpoint id larger than a
| |
| 1461 } else { | |
| 1462 bpt = isolate->debugger()->GetBreakpointById(bpt_id); | |
| 1463 if (bpt) { | |
| 1464 *result = ObjectIdRing::kValid; | |
| 1465 return bpt; | |
| 1466 } | |
| 1467 } | |
| 1457 } | 1468 } |
| 1458 return bpt; | |
| 1459 } | 1469 } |
| 1460 return NULL; | 1470 return NULL; |
| 1461 } | 1471 } |
| 1462 | 1472 |
| 1463 | 1473 |
| 1464 // Scans |isolate|'s message queue looking for a message with |id|. | 1474 // Scans |isolate|'s message queue looking for a message with |id|. |
| 1465 // If found, the message is printed to |js| and true is returned. | 1475 // If found, the message is printed to |js| and true is returned. |
| 1466 // If not found, false is returned. | 1476 // If not found, false is returned. |
| 1467 static bool PrintMessage(JSONStream* js, Isolate* isolate, const char* id) { | 1477 static bool PrintMessage(JSONStream* js, Isolate* isolate, const char* id) { |
| 1468 size_t end_pos = strcspn(id, "/"); | 1478 size_t end_pos = strcspn(id, "/"); |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2159 NULL, | 2169 NULL, |
| 2160 }; | 2170 }; |
| 2161 | 2171 |
| 2162 | 2172 |
| 2163 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { | 2173 static bool RemoveBreakpoint(Isolate* isolate, JSONStream* js) { |
| 2164 if (!js->HasParam("breakpointId")) { | 2174 if (!js->HasParam("breakpointId")) { |
| 2165 PrintMissingParamError(js, "breakpointId"); | 2175 PrintMissingParamError(js, "breakpointId"); |
| 2166 return true; | 2176 return true; |
| 2167 } | 2177 } |
| 2168 const char* bpt_id = js->LookupParam("breakpointId"); | 2178 const char* bpt_id = js->LookupParam("breakpointId"); |
| 2169 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id); | 2179 ObjectIdRing::LookupResult lookup_result; |
| 2180 Breakpoint* bpt = LookupBreakpoint(isolate, bpt_id, &lookup_result); | |
| 2181 // TODO(turnidge): Should we return a different error for bpts whic | |
| 2182 // have been already removed? | |
| 2170 if (bpt == NULL) { | 2183 if (bpt == NULL) { |
| 2171 PrintInvalidParamError(js, "breakpointId"); | 2184 PrintInvalidParamError(js, "breakpointId"); |
| 2172 return true; | 2185 return true; |
| 2173 } | 2186 } |
| 2174 isolate->debugger()->RemoveBreakpoint(bpt->id()); | 2187 isolate->debugger()->RemoveBreakpoint(bpt->id()); |
| 2175 PrintSuccess(js); | 2188 PrintSuccess(js); |
| 2176 return true; | 2189 return true; |
| 2177 } | 2190 } |
| 2178 | 2191 |
| 2179 | 2192 |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2814 return true; | 2827 return true; |
| 2815 } else if (lookup_result == ObjectIdRing::kCollected) { | 2828 } else if (lookup_result == ObjectIdRing::kCollected) { |
| 2816 PrintSentinel(js, kCollectedSentinel); | 2829 PrintSentinel(js, kCollectedSentinel); |
| 2817 return true; | 2830 return true; |
| 2818 } else if (lookup_result == ObjectIdRing::kExpired) { | 2831 } else if (lookup_result == ObjectIdRing::kExpired) { |
| 2819 PrintSentinel(js, kExpiredSentinel); | 2832 PrintSentinel(js, kExpiredSentinel); |
| 2820 return true; | 2833 return true; |
| 2821 } | 2834 } |
| 2822 | 2835 |
| 2823 // Handle non-heap objects. | 2836 // Handle non-heap objects. |
| 2824 Breakpoint* bpt = LookupBreakpoint(isolate, id); | 2837 Breakpoint* bpt = LookupBreakpoint(isolate, id, &lookup_result); |
| 2825 if (bpt != NULL) { | 2838 if (bpt != NULL) { |
| 2826 bpt->PrintJSON(js); | 2839 bpt->PrintJSON(js); |
| 2827 return true; | 2840 return true; |
| 2841 } else if (lookup_result == ObjectIdRing::kCollected) { | |
| 2842 PrintSentinel(js, kCollectedSentinel); | |
| 2843 return true; | |
| 2828 } | 2844 } |
| 2829 | 2845 |
| 2830 if (PrintMessage(js, isolate, id)) { | 2846 if (PrintMessage(js, isolate, id)) { |
| 2831 return true; | 2847 return true; |
| 2832 } | 2848 } |
| 2833 | 2849 |
| 2834 PrintInvalidParamError(js, "objectId"); | 2850 PrintInvalidParamError(js, "objectId"); |
| 2835 return true; | 2851 return true; |
| 2836 } | 2852 } |
| 2837 | 2853 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3201 ServiceMethodDescriptor& method = service_methods_[i]; | 3217 ServiceMethodDescriptor& method = service_methods_[i]; |
| 3202 if (strcmp(method_name, method.name) == 0) { | 3218 if (strcmp(method_name, method.name) == 0) { |
| 3203 return &method; | 3219 return &method; |
| 3204 } | 3220 } |
| 3205 } | 3221 } |
| 3206 return NULL; | 3222 return NULL; |
| 3207 } | 3223 } |
| 3208 | 3224 |
| 3209 | 3225 |
| 3210 } // namespace dart | 3226 } // namespace dart |
| OLD | NEW |