| Index: runtime/vm/service.cc
|
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
|
| index 1c05a5c3df5d165937d23b18fe6e8edbea18b528..e68ba67abdb7ea07fa36567b0193a738e5113058 100644
|
| --- a/runtime/vm/service.cc
|
| +++ b/runtime/vm/service.cc
|
| @@ -3235,17 +3235,33 @@ static bool GetHeapMap(Thread* thread, JSONStream* js) {
|
| }
|
|
|
|
|
| +static const char* snapshot_roots_names[] = {
|
| + "VM", "User", NULL,
|
| +};
|
| +
|
| +
|
| +static ObjectGraph::SnapshotRoots snapshot_roots_values[] = {
|
| + ObjectGraph::kVM, ObjectGraph::kUser,
|
| +};
|
| +
|
| +
|
| static const MethodParameter* request_heap_snapshot_params[] = {
|
| RUNNABLE_ISOLATE_PARAMETER,
|
| + new EnumParameter("roots", false /* not required */, snapshot_roots_names),
|
| new BoolParameter("collectGarbage", false /* not required */), NULL,
|
| };
|
|
|
|
|
| static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) {
|
| + ObjectGraph::SnapshotRoots roots = ObjectGraph::kVM;
|
| + const char* roots_arg = js->LookupParam("roots");
|
| + if (roots_arg != NULL) {
|
| + roots = EnumMapper(roots_arg, snapshot_roots_names, snapshot_roots_values);
|
| + }
|
| const bool collect_garbage =
|
| BoolParameter::Parse(js->LookupParam("collectGarbage"), true);
|
| if (Service::graph_stream.enabled()) {
|
| - Service::SendGraphEvent(thread, collect_garbage);
|
| + Service::SendGraphEvent(thread, roots, collect_garbage);
|
| }
|
| // TODO(koda): Provide some id that ties this request to async response(s).
|
| JSONObject jsobj(js);
|
| @@ -3254,11 +3270,13 @@ static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) {
|
| }
|
|
|
|
|
| -void Service::SendGraphEvent(Thread* thread, bool collect_garbage) {
|
| +void Service::SendGraphEvent(Thread* thread,
|
| + ObjectGraph::SnapshotRoots roots,
|
| + bool collect_garbage) {
|
| uint8_t* buffer = NULL;
|
| WriteStream stream(&buffer, &allocator, 1 * MB);
|
| ObjectGraph graph(thread);
|
| - intptr_t node_count = graph.Serialize(&stream, collect_garbage);
|
| + intptr_t node_count = graph.Serialize(&stream, roots, collect_garbage);
|
|
|
| // Chrome crashes receiving a single tens-of-megabytes blob, so send the
|
| // snapshot in megabyte-sized chunks instead.
|
|
|