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
49  // key to InternedString
50  repeated uint64 function_name_id = 2;
51
52  // key to InternedString
53  repeated uint64 file_name_id = 3;
54
55  repeated uint32 line_number = 4;
56}
57
58message Line {
59  optional string function_name = 1;
60  optional string source_file_name = 2;
61  optional uint32 line_number = 3;
62}
63
64// Symbols for a given address in a module.
65message AddressSymbols {
66  optional uint64 address = 1;
67
68  // Source lines that correspond to this address.
69  //
70  // These are repeated because when inlining happens, multiple functions'
71  // frames can be at a single address. Imagine function Foo calling the
72  // std::vector<int> constructor, which gets inlined at 0xf00. We then get
73  // both Foo and the std::vector<int> constructor when we symbolize the
74  // address.
75  repeated Line lines = 2;
76}
77
78// Symbols for addresses seen in a module.
79message ModuleSymbols {
80  // Fully qualified path to the mapping.
81  // E.g. /system/lib64/libc.so.
82  optional string path = 1;
83
84  // .note.gnu.build-id on Linux (not hex encoded).
85  // uuid on MacOS.
86  // Module GUID on Windows.
87  optional string build_id = 2;
88  repeated AddressSymbols address_symbols = 3;
89}
90
91message Mapping {
92  // Interning key.
93  optional uint64 iid = 1;
94
95  // Interning key.
96  optional uint64 build_id = 2;
97
98  // The linker may create multiple memory mappings for the same shared
99  // library.
100  // This is so that the ELF header is mapped as read only, while the
101  // executable memory is mapped as executable only.
102  // The details of this depend on the linker, a possible mapping of an ELF
103  // file is this:
104  //         +----------------------+
105  // ELF     |xxxxxxxxxyyyyyyyyyyyyy|
106  //         +---------+------------+
107  //         |         |
108  //         | read    | executable
109  //         v mapping v mapping
110  //         +----------------------+
111  // Memory  |xxxxxxxxx|yyyyyyyyyyyy|
112  //         +------------------+---+
113  //         ^         ^        ^
114  //         +         +        +
115  //       start     exact    relpc
116  //       offset   offset    0x1800
117  //       0x0000   0x1000
118  //
119  // exact_offset is the offset into the library file of this mapping.
120  // start_offset is the offset into the library file of the first mapping
121  // for that library. For native libraries (.so files) this should be 0.
122
123  // This is not set on Android 10.
124  optional uint64 exact_offset = 8;
125
126  optional uint64 start_offset = 3;
127  optional uint64 start = 4;
128  optional uint64 end = 5;
129  optional uint64 load_bias = 6;
130
131  // E.g. ["system", "lib64", "libc.so"]
132  // id of string.
133  repeated uint64 path_string_ids = 7;
134}
135
136message Frame {
137  // Interning key
138  optional uint64 iid = 1;
139
140  // E.g. "fopen"
141  // id of string.
142  optional uint64 function_name_id = 2;
143
144  optional uint64 mapping_id = 3;
145  optional uint64 rel_pc = 4;
146}
147
148message Callstack {
149  optional uint64 iid = 1;
150  // Frames of this callstack. Bottom frame first.
151  repeated uint64 frame_ids = 2;
152}
153