xref: /aosp_15_r20/system/extras/simpleperf/branch_list.proto (revision 288bf5226967eb3dac5cce6c939ccc2a7f2b4fe5)
1/*
2 * Copyright (C) 2020 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
17// The branch list file format is generated by the inject command. The new format is:
18// struct BranchListFile {
19//   char magic[24] = "simpleperf:EtmBranchList";
20//   uint32 version = 1;
21//   uint8 compressed;  // 1 if compressed, otherwise 0
22//   struct {
23//      uint32 msg_size;
24//      message BranchList msg;
25//   } msgs[];
26// };
27// The old format is a single BranchList message.
28//
29
30syntax = "proto3";
31
32package simpleperf.proto;
33
34message BranchList {
35  // Used to identify format in generated proto files.
36  // Should always be "simpleperf:EtmBranchList".
37  string magic = 1;
38  repeated ETMBinary etm_data = 2;
39  LBRData lbr_data = 3;
40}
41
42message ETMBinary {
43  string path = 1;
44  string build_id = 2;
45
46  message Address {
47    // vaddr in binary, instr addr before the first branch
48    uint64 addr = 1;
49
50    message Branch {
51      // Each bit represents a branch: 0 for not branch, 1 for branch.
52      // Bit 0 comes first, bit 7 comes last.
53      bytes branch = 1;
54      uint32 branch_size = 2;
55      uint64 count = 3;
56    }
57
58    repeated Branch branches = 2;
59  }
60
61  repeated Address addrs = 3;
62
63  enum BinaryType {
64    ELF_FILE = 0;
65    KERNEL = 1;
66    KERNEL_MODULE = 2;
67  }
68  BinaryType type = 4;
69
70  message KernelBinaryInfo {
71    // kernel_start_addr is used to convert kernel ip address to vaddr in vmlinux.
72    // If it is zero, the Address in KERNEL binary has been converted to vaddr. Otherwise,
73    // the Address in KERNEL binary is still ip address, and need to be converted later.
74    uint64 kernel_start_addr = 1;
75  }
76
77  KernelBinaryInfo kernel_info = 5;
78}
79
80message LBRData {
81  repeated Sample samples = 1;
82  repeated Binary binaries = 2;
83
84  message Sample {
85    // If binary_id >= 1, it refers to LBRData.binaries[binary_id - 1]. Otherwise, it's invalid.
86    uint32 binary_id = 1;
87    uint64 vaddr_in_file = 2;
88    repeated Branch branches = 3;
89
90    message Branch {
91      // If from_binary_id >= 1, it refers to LBRData.binaries[from_binary_id - 1]. Otherwise, it's
92      // invalid.
93      uint32 from_binary_id = 1;
94      // If to_binary_id >= 1, it refers to LBRData.binaries[to_binary_id - 1]. Otherwise, it's
95      // invalid.
96      uint32 to_binary_id = 2;
97      uint64 from_vaddr_in_file = 3;
98      uint64 to_vaddr_in_file = 4;
99    }
100  }
101
102  message Binary {
103    string path = 1;
104    string build_id = 2;
105  }
106}
107