1/* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17syntax = "proto2"; 18 19import "protos/perfetto/trace/profiling/profile_common.proto"; 20 21// These messages encode a graph of objects that retain one another. Currently 22// this is used for Android Runtime (i.e. Java and Kotlin) heap graphs. 23 24package perfetto.protos; 25 26message ObfuscatedMember { 27 // This is the obfuscated field name relative to the class containing the 28 // ObfuscatedMember. 29 optional string obfuscated_name = 1; 30 // If this is fully qualified (i.e. contains a '.') this is the deobfuscated 31 // field name including its class. Otherwise, this is this the unqualified 32 // deobfuscated field name relative to the class containing this 33 // ObfuscatedMember. 34 optional string deobfuscated_name = 2; 35} 36 37message ObfuscatedClass { 38 optional string obfuscated_name = 1; 39 optional string deobfuscated_name = 2; 40 repeated ObfuscatedMember obfuscated_members = 3; 41} 42 43message DeobfuscationMapping { 44 optional string package_name = 1; 45 optional int64 version_code = 2; 46 repeated ObfuscatedClass obfuscated_classes = 3; 47} 48 49message HeapGraphRoot { 50 enum Type { 51 ROOT_UNKNOWN = 0; 52 ROOT_JNI_GLOBAL = 1; 53 ROOT_JNI_LOCAL = 2; 54 ROOT_JAVA_FRAME = 3; 55 ROOT_NATIVE_STACK = 4; 56 ROOT_STICKY_CLASS = 5; 57 ROOT_THREAD_BLOCK = 6; 58 ROOT_MONITOR_USED = 7; 59 ROOT_THREAD_OBJECT = 8; 60 ROOT_INTERNED_STRING = 9; 61 ROOT_FINALIZING = 10; 62 ROOT_DEBUGGER = 11; 63 ROOT_REFERENCE_CLEANUP = 12; 64 ROOT_VM_INTERNAL = 13; 65 ROOT_JNI_MONITOR = 14; 66 }; 67 // Objects retained by this root. 68 repeated uint64 object_ids = 1 [packed = true]; 69 70 optional Type root_type = 2; 71} 72 73message HeapGraphType { 74 // TODO(fmayer): Consider removing this and using the index in the repeaed 75 // field to save space. 76 optional uint64 id = 1; 77 optional uint64 location_id = 2; 78 optional string class_name = 3; 79} 80 81message HeapGraphObject { 82 optional uint64 id = 1; 83 84 // Index for InternedData.type_names for the name of the type of this object. 85 optional uint64 type_id = 2; 86 87 // Bytes occupied by this objects. 88 optional uint64 self_size = 3; 89 90 // Indices for InternedData.field_names for the name of the field referring 91 // to the object. 92 repeated uint64 reference_field_id = 4 [packed = true]; 93 94 // Ids of the Object that is referred to. 95 repeated uint64 reference_object_id = 5 [packed = true]; 96} 97 98message HeapGraph { 99 optional int32 pid = 1; 100 101 // This contains all objects at the time this dump was taken. Some of these 102 // will be live, some of those unreachable (garbage). To find the live 103 // objects, the client needs to build the transitive closure of objects 104 // reachable from |roots|. 105 // All objects not contained within that transitive closure are garbage that 106 // has not yet been collected. 107 repeated HeapGraphObject objects = 2; 108 109 // Roots at the time this dump was taken. 110 // All live objects are reachable from the roots. All other objects are 111 // garbage. 112 repeated HeapGraphRoot roots = 7; 113 114 // Types used in HeapGraphObjects. 115 repeated HeapGraphType types = 9; 116 117 // Legacy way to encode types. Names here are emitted by old perfetto_hprof, 118 // which do not include the class_name. Handle like a HeapGraphType with 119 // no location_id. 120 // TODO(b/153552977): Remove this. This was was not used in any publicly 121 // available release. 122 repeated InternedString type_names = 3; 123 124 // Field names for references in managed heap graph. 125 repeated InternedString field_names = 4; 126 127 // Paths of files used in managed heap graph. 128 repeated InternedString location_names = 8; 129 130 optional bool continued = 5; 131 optional uint64 index = 6; 132} 133