Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: runtime/vm/service.cc

Issue 206583003: Add 'address' vm service message that finds heap objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/scavenger.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "platform/globals.h"
8 9
9 #include "vm/compiler.h" 10 #include "vm/compiler.h"
10 #include "vm/coverage.h" 11 #include "vm/coverage.h"
11 #include "vm/cpu.h" 12 #include "vm/cpu.h"
12 #include "vm/dart_api_impl.h" 13 #include "vm/dart_api_impl.h"
13 #include "vm/dart_entry.h" 14 #include "vm/dart_entry.h"
14 #include "vm/debugger.h" 15 #include "vm/debugger.h"
15 #include "vm/isolate.h" 16 #include "vm/isolate.h"
16 #include "vm/message.h" 17 #include "vm/message.h"
17 #include "vm/message_handler.h" 18 #include "vm/message_handler.h"
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 return true; 1444 return true;
1444 } 1445 }
1445 1446
1446 1447
1447 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) { 1448 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) {
1448 isolate->heap()->PrintHeapMapToJSONStream(js); 1449 isolate->heap()->PrintHeapMapToJSONStream(js);
1449 return true; 1450 return true;
1450 } 1451 }
1451 1452
1452 1453
1454 class ContainsAddressVisitor : public FindObjectVisitor {
1455 public:
1456 ContainsAddressVisitor(Isolate* isolate, uword addr)
1457 : FindObjectVisitor(isolate), addr_(addr) { }
1458 virtual ~ContainsAddressVisitor() { }
1459
1460 virtual uword filter_addr() const { return addr_; }
1461
1462 virtual bool FindObject(RawObject* obj) const {
1463 uword obj_begin = RawObject::ToAddr(obj);
1464 uword obj_end = obj_begin + obj->Size();
1465 return obj_begin <= addr_ && addr_ < obj_end;
1466 }
1467 private:
1468 uword addr_;
1469 };
1470
1471
1472 static bool HandleAddress(Isolate* isolate, JSONStream* js) {
1473 uword addr = 0;
1474 if (js->num_arguments() != 2 ||
1475 !GetUnsignedIntegerId(js->GetArgument(1), &addr, 16)) {
1476 static const uword kExampleAddr = static_cast<uword>(kIntptrMax / 7);
1477 PrintError(js, "Must specify address: address/" Px ".", kExampleAddr);
1478 return true;
1479 }
1480 Object& object = Object::Handle(isolate);
1481 {
1482 NoGCScope no_gc;
1483 ContainsAddressVisitor visitor(isolate, addr);
1484 object = isolate->heap()->FindObject(&visitor);
1485 }
1486 object.PrintToJSONStream(js, true);
1487 return true;
1488 }
1489
1490
1453 static IsolateMessageHandlerEntry isolate_handlers[] = { 1491 static IsolateMessageHandlerEntry isolate_handlers[] = {
1454 { "_echo", HandleIsolateEcho }, 1492 { "_echo", HandleIsolateEcho },
1455 { "", HandleIsolate }, 1493 { "", HandleIsolate },
1494 { "address", HandleAddress },
1456 { "allocationprofile", HandleAllocationProfile }, 1495 { "allocationprofile", HandleAllocationProfile },
1457 { "classes", HandleClasses }, 1496 { "classes", HandleClasses },
1458 { "code", HandleCode }, 1497 { "code", HandleCode },
1459 { "coverage", HandleCoverage }, 1498 { "coverage", HandleCoverage },
1460 { "cpu", HandleCpu }, 1499 { "cpu", HandleCpu },
1461 { "debug", HandleDebug }, 1500 { "debug", HandleDebug },
1462 { "heapmap", HandleHeapMap }, 1501 { "heapmap", HandleHeapMap },
1463 { "libraries", HandleLibraries }, 1502 { "libraries", HandleLibraries },
1464 { "objects", HandleObjects }, 1503 { "objects", HandleObjects },
1465 { "profile", HandleProfile }, 1504 { "profile", HandleProfile },
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 while (current != NULL) { 1717 while (current != NULL) {
1679 if (strcmp(name, current->name()) == 0) { 1718 if (strcmp(name, current->name()) == 0) {
1680 return current; 1719 return current;
1681 } 1720 }
1682 current = current->next(); 1721 current = current->next();
1683 } 1722 }
1684 return NULL; 1723 return NULL;
1685 } 1724 }
1686 1725
1687 } // namespace dart 1726 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/scavenger.cc ('k') | runtime/vm/service_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698