Chromium Code Reviews| Index: runtime/vm/service.cc |
| =================================================================== |
| --- runtime/vm/service.cc (revision 34144) |
| +++ runtime/vm/service.cc (working copy) |
| @@ -5,6 +5,7 @@ |
| #include "vm/service.h" |
| #include "include/dart_api.h" |
| +#include "platform/globals.h" |
| #include "vm/compiler.h" |
| #include "vm/coverage.h" |
| @@ -1450,9 +1451,47 @@ |
| } |
| +class ContainsAddressVisitor : public FindObjectVisitor { |
| + public: |
| + ContainsAddressVisitor(Isolate* isolate, uword addr) |
| + : FindObjectVisitor(isolate), addr_(addr) { } |
| + virtual ~ContainsAddressVisitor() { } |
| + |
| + virtual uword filter_addr() const { return addr_; } |
|
turnidge
2014/03/20 17:01:19
Is this accessor used?
koda
2014/03/20 20:25:37
Yes, it's called by the super class (FindObjectVis
|
| + |
| + virtual bool FindObject(RawObject* obj) const { |
| + uword obj_begin = RawObject::ToAddr(obj); |
| + uword obj_end = obj_begin + obj->Size(); |
| + return obj_begin <= addr_ && addr_ < obj_end; |
| + } |
| + private: |
| + uword addr_; |
| +}; |
| + |
| + |
| +static bool HandleAddress(Isolate* isolate, JSONStream* js) { |
| + uword addr = 0; |
| + if (js->num_arguments() != 2 || |
| + !GetUnsignedIntegerId(js->GetArgument(1), &addr, 16)) { |
| + static const uword kExampleAddr = static_cast<uword>(kIntptrMax / 7); |
| + PrintError(js, "Must specify address: address/" Px ".", kExampleAddr); |
| + return true; |
| + } |
| + Object& object = Object::Handle(isolate); |
| + { |
| + NoGCScope no_gc; |
| + ContainsAddressVisitor visitor(isolate, addr); |
| + object = isolate->heap()->FindObject(&visitor); |
| + } |
| + object.PrintToJSONStream(js, true); |
|
turnidge
2014/03/20 17:01:19
Printing the null object isn't the same as printin
turnidge
2014/03/20 17:08:25
Actually returning the null instance here would be
koda
2014/03/20 18:36:26
Note that we might find *any* heap object, not jus
turnidge
2014/03/20 20:34:54
I guess it depends on what the UI expects. We hav
koda
2014/03/20 20:44:19
For most objects, obj.PrintToJSONStream does tag t
|
| + return true; |
| +} |
| + |
| + |
| static IsolateMessageHandlerEntry isolate_handlers[] = { |
| { "_echo", HandleIsolateEcho }, |
| { "", HandleIsolate }, |
| + { "address", HandleAddress }, |
| { "allocationprofile", HandleAllocationProfile }, |
| { "classes", HandleClasses }, |
| { "code", HandleCode }, |