• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
19package perfetto.protos;
20
21// TODO(fmayer): Figure out naming thoroughout this file to get a
22// nomenclature that works between Windows and Linux.
23
24// The interning fields in this file can refer to 2 different intern tables,
25// depending on the message they are used in. If the interned fields are present
26// in ProfilePacket proto, then the intern tables included in the ProfilePacket
27// should be used. If the intered fields are present in the
28// StreamingProfilePacket proto, then the intern tables included in all of the
29// previous InternedData message with same sequence ID should be used.
30// TODO(fmayer): Move to the intern tables to a common location.
31message InternedString {
32  optional uint64 iid = 1;
33  optional bytes str = 2;
34}
35
36// A symbol field that is emitted after the trace is written. These tables would
37// be appended as the last packets in the trace that the profiler will use, so
38// that the actual trace need not be rewritten to symbolize the profiles.
39message ProfiledFrameSymbols {
40  // Use the frame id as the interning key for the symbols.
41  optional uint64 frame_iid = 1;
42
43  // These are repeated because when inlining happens, multiple functions'
44  // frames can be at a single address. Imagine function Foo calling the
45  // std::vector<int> constructor, which gets inlined at 0xf00. We then get
46  // both Foo and the std::vector<int> constructor when we symbolize the
47  // address.
48  repeated uint64 function_name_id = 2;  // key to InternedString
49  repeated uint64 file_name_id = 3;      // key to InternedString
50  repeated uint32 line_number = 4;
51}
52
53message Line {
54  optional string function_name = 1;
55  optional string source_file_name = 2;
56  optional uint32 line_number = 3;
57}
58
59// Symbols for a given address in a module.
60message AddressSymbols {
61  optional uint64 address = 1;
62
63  // Source lines that correspond to this address.
64  //
65  // These are repeated because when inlining happens, multiple functions'
66  // frames can be at a single address. Imagine function Foo calling the
67  // std::vector<int> constructor, which gets inlined at 0xf00. We then get
68  // both Foo and the std::vector<int> constructor when we symbolize the
69  // address.
70  repeated Line lines = 2;
71}
72
73// Symbols for addresses seen in a module.
74message ModuleSymbols {
75  // Fully qualified path to the mapping.
76  // E.g. /system/lib64/libc.so.
77  optional string path = 1;
78
79  // .note.gnu.build-id on Linux (not hex encoded).
80  // uuid on MacOS.
81  // Module GUID on Windows.
82  optional string build_id = 2;
83  repeated AddressSymbols address_symbols = 3;
84}
85
86message Mapping {
87  optional uint64 iid = 1;       // Interning key.
88  optional uint64 build_id = 2;  // Interning key.
89
90  // The linker may create multiple memory mappings for the same shared
91  // library.
92  // This is so that the ELF header is mapped as read only, while the
93  // executable memory is mapped as executable only.
94  // The details of this depend on the linker, a possible mapping of an ELF
95  // file is this:
96  //         +----------------------+
97  // ELF     |xxxxxxxxxyyyyyyyyyyyyy|
98  //         +---------+------------+
99  //         |         |
100  //         | read    | executable
101  //         v mapping v mapping
102  //         +----------------------+
103  // Memory  |xxxxxxxxx|yyyyyyyyyyyy|
104  //         +------------------+---+
105  //         ^         ^        ^
106  //         +         +        +
107  //       start     exact    relpc
108  //       offset   offset    0x1800
109  //       0x0000   0x1000
110  //
111  // exact_offset is the offset into the library file of this mapping.
112  // start_offset is the offset into the library file of the first mapping
113  // for that library. For native libraries (.so files) this should be 0.
114  optional uint64 exact_offset = 8;  // This is not set on Android 10.
115  optional uint64 start_offset = 3;
116  optional uint64 start = 4;
117  optional uint64 end = 5;
118  optional uint64 load_bias = 6;
119  // E.g. ["system", "lib64", "libc.so"]
120  repeated uint64 path_string_ids = 7;  // id of string.
121}
122
123message Frame {
124  optional uint64 iid = 1;  // Interning key
125  // E.g. "fopen"
126  optional uint64 function_name_id = 2;  // id of string.
127  optional uint64 mapping_id = 3;
128  optional uint64 rel_pc = 4;
129}
130
131message Callstack {
132  optional uint64 iid = 1;
133  // Frames of this callstack. Bottom frame first.
134  repeated uint64 frame_ids = 2;
135}
136