1// The file format generated by cmd_report_sample.proto is as below:
2// char magic[10] = "SIMPLEPERF";
3// LittleEndian16(version) = 1;
4// LittleEndian32(record_size_0)
5// message Record(record_0) (having record_size_0 bytes)
6// LittleEndian32(record_size_1)
7// message Record(record_1) (having record_size_1 bytes)
8// ...
9// LittleEndian32(record_size_N)
10// message Record(record_N) (having record_size_N bytes)
11// LittleEndian32(0)
12
13syntax = "proto2";
14option optimize_for = LITE_RUNTIME;
15package simpleperf_report_proto;
16option java_package = "com.android.tools.profiler.proto";
17option java_outer_classname = "SimpleperfReport";
18
19message Sample {
20  // Wall clock time for current sample.
21  // By default, it is perf clock used in kernel.
22  optional uint64 time = 1;
23  optional int32 thread_id = 2;
24
25  message CallChainEntry {
26    // virtual address of the instruction in elf file
27    optional uint64 vaddr_in_file = 1;
28
29    // index of the elf file containing the instruction
30    optional uint32 file_id = 2;
31
32    // symbol_id refers to the name of the function containing the instruction.
33    // If the function name is found, it is a valid index in the symbol table
34    // of File with 'id' field being file_id, otherwise it is -1.
35    optional int32 symbol_id = 3;
36
37    enum ExecutionType {
38      // methods belong to native libraries, AOT compiled JVM code and ART methods not used near
39      // JVM methods
40      NATIVE_METHOD = 0;
41      INTERPRETED_JVM_METHOD = 1;
42      JIT_JVM_METHOD = 2;
43      // ART methods used near JVM methods. It's shown only when --show-art-frames is used.
44      ART_METHOD = 3;
45    }
46    optional ExecutionType execution_type = 4 [default = NATIVE_METHOD];
47  }
48
49  repeated CallChainEntry callchain = 3;
50
51  // Simpleperf generates one sample whenever a specified amount of events happen
52  // while running a monitored thread. So each sample belongs to one event type.
53  // Event type can be cpu-cycles, cpu-clock, sched:sched_switch or other types.
54  // By using '-e' option, we can ask simpleperf to record samples for one or more
55  // event types.
56  // Each event type generates samples independently. But recording more event types
57  // will cost more cpu time generating samples, which may affect the monitored threads
58  // and sample lost rate.
59  // event_count field shows the count of the events (belong to the sample's event type)
60  // that have happened since last sample (belong to the sample's event type) for the
61  // same thread. However, if there are lost samples between current sample and previous
62  // sample, the event_count is the count of events from the last lost sample.
63  optional uint64 event_count = 4;
64
65  // An index in meta_info.event_type, shows which event type current sample belongs to.
66  optional uint32 event_type_id = 5;
67
68  message UnwindingResult {
69    // error code provided by libunwindstack, in
70    // https://cs.android.com/android/platform/superproject/+/master:system/unwinding/libunwindstack/include/unwindstack/Error.h
71    optional uint32 raw_error_code = 1;
72    // error addr provided by libunwindstack
73    optional uint64 error_addr = 2;
74
75    // error code interpreted by simpleperf
76    enum ErrorCode {
77      ERROR_NONE = 0;                  // No error
78      ERROR_UNKNOWN = 1;               // Error not interpreted by simpleperf, see raw_error_code
79      ERROR_NOT_ENOUGH_STACK = 2;      // Simpleperf doesn't record enough stack data
80      ERROR_MEMORY_INVALID = 3;        // Memory read failed
81      ERROR_UNWIND_INFO = 4;           // No debug info in binary to support unwinding
82      ERROR_INVALID_MAP = 5;           // Unwind in an invalid map
83      ERROR_MAX_FRAME_EXCEEDED = 6;    // Stopped at MAX_UNWINDING_FRAMES, which is 512.
84      ERROR_REPEATED_FRAME = 7;        // The last frame has the same pc/sp as the next.
85      ERROR_INVALID_ELF = 8;           // Unwind in an invalid elf file
86    }
87    optional ErrorCode error_code = 3;
88  }
89
90  // Unwinding result is provided for samples without a complete callchain, when recorded with
91  // --keep-failed-unwinding-result or --keep-failed-unwinding-debug-info.
92  optional UnwindingResult unwinding_result = 6;
93}
94
95message LostSituation {
96  optional uint64 sample_count = 1;
97  optional uint64 lost_count = 2;
98}
99
100message File {
101  // unique id for each file, starting from 0, and add 1 each time.
102  optional uint32 id = 1;
103
104  // file path, like /system/lib/libc.so.
105  optional string path = 2;
106
107  // symbol table of the file.
108  repeated string symbol = 3;
109
110  // mangled symbol table of the file.
111  repeated string mangled_symbol = 4;
112}
113
114message Thread {
115  optional uint32 thread_id = 1;
116  optional uint32 process_id = 2;
117  optional string thread_name = 3;
118}
119
120message MetaInfo {
121  repeated string event_type = 1;
122  optional string app_package_name = 2;
123}
124
125message Record {
126  oneof record_data {
127    Sample sample = 1;
128    LostSituation lost = 2;
129    File file = 3;
130    Thread thread = 4;
131    MetaInfo meta_info = 5;
132  }
133}