| Index: runtime/vm/service.cc
|
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
|
| index 5e34b4a9a4b17984245b32efc0db562261a07ba0..259b2c03a67b63174c9b5b54e97992165a26546b 100644
|
| --- a/runtime/vm/service.cc
|
| +++ b/runtime/vm/service.cc
|
| @@ -3244,17 +3244,33 @@ static bool GetHeapMap(Thread* thread, JSONStream* js) {
|
| }
|
|
|
|
|
| +static const char* snapshot_roots_names[] = {
|
| + "User", "VM", NULL,
|
| +};
|
| +
|
| +
|
| +static ObjectGraph::SnapshotRoots snapshot_roots_values[] = {
|
| + ObjectGraph::kUser, ObjectGraph::kVM,
|
| +};
|
| +
|
| +
|
| 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);
|
| @@ -3263,11 +3279,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.
|
|
|