1// Copyright 2015 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5syntax = "proto2"; 6 7option optimize_for = LITE_RUNTIME; 8option java_package = "org.chromium.components.metrics"; 9 10option java_outer_classname = "CallStackProfileProtos"; 11 12package metrics; 13 14import "execution_context.proto"; 15 16// Call stack sample data for a given profiling session. 17// Next tag: 11 18message CallStackProfile { 19 // Uniquely identifies a module. 20 message ModuleIdentifier { 21 // A hash that uniquely identifies a particular program version with high 22 // probability. This is parsed from headers of the loaded module. 23 // For binaries generated by GNU tools: 24 // Contents of the .note.gnu.build-id field. 25 // On Windows: 26 // GUID + AGE in the debug image headers of a module. 27 optional string build_id = 1; 28 29 // MD5Sum Prefix of the module name. This is the same hashing scheme as used 30 // to hash UMA histogram names. 31 optional fixed64 name_md5_prefix = 2; 32 } 33 34 // Describes a location within executable code. 35 message Location { 36 // Instruction pointer subtracted by module base. 37 optional uint64 address = 1; 38 39 // Index to the module identifier in |module_ids| of CallStackProfile. 40 optional int32 module_id_index = 2; 41 } 42 43 // The sampled call stack. 44 message Stack { 45 // The frames in the callstack. The frame[0] entry represents the call on 46 // the top of the stack. 47 repeated Location frame = 1; 48 } 49 50 // An item of metadata associated with either the entire profile or a single 51 // sample. 52 message MetadataItem { 53 // Index of the hash of the metadata name. 54 optional int32 name_hash_index = 1; 55 56 // Optional user-specified key value. Absent if unspecified. 57 optional sint64 key = 3; 58 59 // Value for the item. An absent value indicates the metadata has become 60 // unset since the previous StackSample. 61 optional sint64 value = 2; 62 } 63 64 // Backtrace of locations of async execution requests (e.g. task postings, IPC 65 // message sending, requests over mojo) that led to the current task 66 // execution. Note that these are saved in a fixed length buffer on the client 67 // which as of 2018/08/14 includes only the most recent four entries. 68 message AsyncBacktrace { 69 // The locations saved in the backtrace, with the most recent in 70 // location[0]. Empty if the work was not tied to an async execution request 71 // -- for example, handling a mouse event. 72 repeated Location location = 1; 73 } 74 75 // Deprecated version of a sample consisting of one or more callstacks with 76 // the same stack frames and instruction pointers. Deprecated as of 77 // 2018/08/14. 78 message Sample { 79 // The callstack. Sample.frame[0] represents the call on the top of the 80 // stack. 81 repeated Location frame = 1; 82 83 // Number of times this stack signature occurs. 84 optional int64 count = 2; 85 86 // This repeating field indicates the current phase of the system such as 87 // whether it is in startup, general operation, or shutdown. The first 88 // Sample of a CallStackProfile will list all phases that have been reached; 89 // later samples will list only the new phases that occurred since the 90 // previous one. 91 repeated ProcessPhase process_phase = 3; 92 } 93 94 // A sampled stack, along with associated metadata. 95 message StackSample { 96 // Index into the profile's repeated |stack| field for the stack 97 // corresponding to this sample. 98 optional int32 stack_index = 1; 99 100 // Sample time relative to the first sample. 101 optional int32 sample_time_offset_ms = 2; 102 103 // True if this sample is executing the same item of work (task, event) as 104 // the last sample. 105 optional bool continued_work = 3; 106 107 // Index of the backtrace in the profile of posted task locations that led 108 // to this task execution. 109 optional int32 async_backtrace_index = 4; 110 111 // Metadata items associated with the sample. To minimize memory usage, 112 // metadata items are specified only when their values change from the 113 // previous sample. Items are not guaranteed to be in a particular order. 114 repeated MetadataItem metadata = 5; 115 116 // Weight of the sample. When omitted the sample is presumed to have 117 // a weight of 1. 118 // Not currently used for CPU profiles. 119 // For heap profiles it represents the total number of bytes associated with 120 // the StackSample record. 121 optional int64 weight = 6; 122 123 // Number of events associated with the sample. When omitted the default 124 // value of 1 should be used. 125 // Not currently used for CPU profiles. 126 // For heap profiles it represents the number of allocations associated with 127 // the StackSample record. The following relation holds: 128 // allocation_size * count == weight. 129 optional int64 count = 7 [default = 1]; 130 } 131 132 // The previous sample encoding. Deprecated 2018/08/04 in favor of 133 // stack_sample. 134 repeated Sample DEPRECATED_sample = 1 [deprecated = true]; 135 136 // List of module ids found in this sample. 137 repeated ModuleIdentifier module_id = 2; 138 139 // Metadata name hashes used in this profile. Recorded global to the profile 140 // to minimize per-sample memory usage. 141 repeated fixed64 metadata_name_hash = 5; 142 143 // Metadata global to the profile. 144 repeated MetadataItem profile_metadata = 6; 145 146 // The distinct async backtraces for the samples. 147 repeated AsyncBacktrace async_backtrace = 7; 148 149 // The distinct stacks for the samples. 150 repeated Stack stack = 8; 151 152 // The stack samples collected for this profile. 153 repeated StackSample stack_sample = 9; 154 155 // Time of the profile relative to the start of the process being profiled. 156 // For CPU profiles, this is the time of the first sample. For Heap profiles 157 // whose samples don't have defined times, it is the time the profile is 158 // collected. 159 optional int64 profile_time_offset_ms = 10; 160 161 // Duration of this profile. 162 optional int32 profile_duration_ms = 3; 163 164 // Time between samples. 165 optional int32 sampling_period_ms = 4; 166} 167