• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2021 Huawei Device Co., Ltd.
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6//     http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// Note: this is must be kept in sync with
15// /system/extra/simpleperf/report_sample.proto
16
17// The file format generated by report_sample.proto is as below:
18// char magic[10] = "SIMPLEPERF";
19// LittleEndian16(version) = 1;
20// LittleEndian32(record_size_0)
21// message Record(record_0) (having record_size_0 bytes)
22// LittleEndian32(record_size_1)
23// message Record(record_1) (having record_size_1 bytes)
24// ...
25// LittleEndian32(record_size_N)
26// message Record(record_N) (having record_size_N bytes)
27// LittleEndian32(0)
28
29syntax = "proto3";
30option java_package = "ohos.devtools.datasources.transport.grpc.service";
31option java_outer_classname = "SimpleperfReport";
32
33message Sample{
34  // Exceptionally allow unsigned since this proto is from simpleperf.
35  // Same applies to other unsigned fields.
36  // Wall clock time for current sample.
37  // By default, it is perf clock used in kernel.
38  uint64 time = 1;
39  int32 thread_id = 2;
40
41  message CallChainEntry {
42    // virtual address of the instruction in elf file
43    uint64 vaddr_in_file = 1;
44
45    // index of the elf file containing the instruction
46    uint32 file_id = 2;
47
48    // symbol_id refers to the name of the function containing the instruction.
49    // If the function name is found, it is a valid index in the symbol table
50    // of File with 'id' field being file_id, otherwise it is -1.
51    int32 symbol_id = 3;
52  }
53
54  // Sampled call chain ordered from the leaf to the root.
55  repeated CallChainEntry callchain = 3;
56
57  // Simpleperf generates one sample whenever a specified amount of events happen
58  // while running a monitored thread. So each sample belongs to one event type.
59  // Event type can be cpu-cycles, cpu-clock, sched:sched_switch or other types.
60  // By using '-e' option, we can ask simpleperf to record samples for one or more
61  // event types.
62  // Each event type generates samples independently. But recording more event types
63  // will cost more cpu time generating samples, which may affect the monitored threads
64  // and sample lost rate.
65  // event_count field shows the count of the events (belong to the sample's event type)
66  // that have happened since last sample (belong to the sample's event type) for the
67  // same thread. However, if there are lost samples between current sample and previous
68  // sample, the event_count is the count of events from the last lost sample.
69  uint64 event_count = 4;
70
71  // An index in meta_info.event_type, shows which event type current sample belongs to.
72  uint32 event_type_id = 5;
73}
74
75message LostSituation {
76  uint64 sample_count = 1;
77  uint64 lost_count = 2;
78}
79
80message File {
81  // unique id for each file, starting from 0, and add 1 each time.
82  uint32 id = 1;
83
84  // file path, like /system/lib/libc.so.
85  string path = 2;
86
87  // symbol table of the file.
88  repeated string symbol = 3;
89}
90
91message MetaInfo {
92  repeated string event_type = 1;
93  string app_package_name = 2;
94}
95
96message Thread {
97  int32 thread_id = 1;
98  int32 process_id = 2;
99  string thread_name = 3;
100}
101
102message Record {
103  oneof record_data {
104    Sample sample = 1;
105    LostSituation lost = 2;
106    File file = 3;
107    Thread thread = 4;
108    MetaInfo meta_info = 5;
109  }
110}