@@ -606,7 +606,9 @@ void _record_gc_just_edge(const char *edge_type, size_t from_idx, size_t to_idx,
606606void final_serialize_heap_snapshot (ios_t *json, ios_t *strings, HeapSnapshot &snapshot, char all_one)
607607{
608608 // mimicking https://github.com/nodejs/node/blob/5fd7a72e1c4fbaf37d3723c4c81dce35c149dc84/deps/v8/src/profiler/heap-snapshot-generator.cc#L2567-L2567
609+ // also https://github.com/microsoft/vscode-v8-heap-tools/blob/c5b34396392397925ecbb4ecb904a27a2754f2c1/v8-heap-parser/src/decoder.rs#L43-L51
609610 ios_printf (json, " {\" snapshot\" :{" );
611+
610612 ios_printf (json, " \" meta\" :{" );
611613 ios_printf (json, " \" node_fields\" :[\" type\" ,\" name\" ,\" id\" ,\" self_size\" ,\" edge_count\" ,\" trace_node_id\" ,\" detachedness\" ]," );
612614 ios_printf (json, " \" node_types\" :[" );
@@ -617,10 +619,25 @@ void final_serialize_heap_snapshot(ios_t *json, ios_t *strings, HeapSnapshot &sn
617619 ios_printf (json, " \" edge_types\" :[" );
618620 snapshot.edge_types .print_json_array (json, false );
619621 ios_printf (json, " ," );
620- ios_printf (json, " \" string_or_number\" ,\" from_node\" ]" );
622+ ios_printf (json, " \" string_or_number\" ,\" from_node\" ]," );
623+ // not used. Required by microsoft/vscode-v8-heap-tools
624+ ios_printf (json, " \" trace_function_info_fields\" :[\" function_id\" ,\" name\" ,\" script_name\" ,\" script_id\" ,\" line\" ,\" column\" ]," );
625+ ios_printf (json, " \" trace_node_fields\" :[\" id\" ,\" function_info_index\" ,\" count\" ,\" size\" ,\" children\" ]," );
626+ ios_printf (json, " \" sample_fields\" :[\" timestamp_us\" ,\" last_assigned_id\" ]," );
627+ ios_printf (json, " \" location_fields\" :[\" object_index\" ,\" script_id\" ,\" line\" ,\" column\" ]" );
628+ // end not used
621629 ios_printf (json, " },\n " ); // end "meta"
630+
622631 ios_printf (json, " \" node_count\" :%zu," , snapshot.num_nodes );
623- ios_printf (json, " \" edge_count\" :%zu" , snapshot.num_edges );
624- ios_printf (json, " }\n " ); // end "snapshot"
632+ ios_printf (json, " \" edge_count\" :%zu," , snapshot.num_edges );
633+ ios_printf (json, " \" trace_function_count\" :0" ); // not used. Required by microsoft/vscode-v8-heap-tools
634+ ios_printf (json, " },\n " ); // end "snapshot"
635+
636+ // not used. Required by microsoft/vscode-v8-heap-tools
637+ ios_printf (json, " \" trace_tree\" :[]," );
638+ ios_printf (json, " \" samples\" :[]," );
639+ ios_printf (json, " \" locations\" :[]" );
640+ // end not used
641+
625642 ios_printf (json, " }" );
626643}
0 commit comments