• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  // Monotonic clock time in nanoseconds. On kernel < 4.1, it's perf clock instead.
21  optional uint64 time = 1;
22  optional int32 thread_id = 2;
23
24  message CallChainEntry {
25    // virtual address of the instruction in elf file
26    optional uint64 vaddr_in_file = 1;
27
28    // index of the elf file containing the instruction
29    optional uint32 file_id = 2;
30
31    // symbol_id refers to the name of the function containing the instruction.
32    // If the function name is found, it is a valid index in the symbol table
33    // of File with 'id' field being file_id, otherwise it is -1.
34    optional int32 symbol_id = 3;
35
36    enum ExecutionType {
37      // methods belong to native libraries, AOT compiled JVM code and ART methods not used near
38      // JVM methods
39      NATIVE_METHOD = 0;
40      INTERPRETED_JVM_METHOD = 1;
41      JIT_JVM_METHOD = 2;
42      // ART methods used near JVM methods. It's shown only when --show-art-frames is used.
43      ART_METHOD = 3;
44    }
45    optional ExecutionType execution_type = 4 [default = NATIVE_METHOD];
46  }
47
48  repeated CallChainEntry callchain = 3;
49
50  // Simpleperf generates one sample whenever a specified amount of events happen
51  // while running a monitored thread. So each sample belongs to one event type.
52  // Event type can be cpu-cycles, cpu-clock, sched:sched_switch or other types.
53  // By using '-e' option, we can ask simpleperf to record samples for one or more
54  // event types.
55  // Each event type generates samples independently. But recording more event types
56  // will cost more cpu time generating samples, which may affect the monitored threads
57  // and sample lost rate.
58  // event_count field shows the count of the events (belong to the sample's event type)
59  // that have happened since last sample (belong to the sample's event type) for the
60  // same thread. However, if there are lost samples between current sample and previous
61  // sample, the event_count is the count of events from the last lost sample.
62  optional uint64 event_count = 4;
63
64  // An index in meta_info.event_type, shows which event type current sample belongs to.
65  optional uint32 event_type_id = 5;
66
67  message UnwindingResult {
68    // error code provided by libunwindstack, in
69    // https://cs.android.com/android/platform/superproject/+/master:system/unwinding/libunwindstack/include/unwindstack/Error.h
70    optional uint32 raw_error_code = 1;
71    // error addr provided by libunwindstack
72    optional uint64 error_addr = 2;
73
74    // error code interpreted by simpleperf
75    enum ErrorCode {
76      ERROR_NONE = 0;                  // No error
77      ERROR_UNKNOWN = 1;               // Error not interpreted by simpleperf, see raw_error_code
78      ERROR_NOT_ENOUGH_STACK = 2;      // Simpleperf doesn't record enough stack data
79      ERROR_MEMORY_INVALID = 3;        // Memory read failed
80      ERROR_UNWIND_INFO = 4;           // No debug info in binary to support unwinding
81      ERROR_INVALID_MAP = 5;           // Unwind in an invalid map
82      ERROR_MAX_FRAME_EXCEEDED = 6;    // Stopped at MAX_UNWINDING_FRAMES, which is 512.
83      ERROR_REPEATED_FRAME = 7;        // The last frame has the same pc/sp as the next.
84      ERROR_INVALID_ELF = 8;           // Unwind in an invalid elf file
85    }
86    optional ErrorCode error_code = 3;
87  }
88
89  // Unwinding result is provided for samples without a complete callchain, when recorded with
90  // --keep-failed-unwinding-result or --keep-failed-unwinding-debug-info.
91  optional UnwindingResult unwinding_result = 6;
92}
93
94message LostSituation {
95  optional uint64 sample_count = 1;
96  optional uint64 lost_count = 2;
97}
98
99message File {
100  // unique id for each file, starting from 0, and add 1 each time.
101  optional uint32 id = 1;
102
103  // file path, like /system/lib/libc.so.
104  optional string path = 2;
105
106  // symbol table of the file.
107  repeated string symbol = 3;
108
109  // mangled symbol table of the file.
110  repeated string mangled_symbol = 4;
111}
112
113message Thread {
114  optional uint32 thread_id = 1;
115  optional uint32 process_id = 2;
116  optional string thread_name = 3;
117}
118
119message MetaInfo {
120  repeated string event_type = 1;
121  optional string app_package_name = 2;
122  optional string app_type = 3;  // debuggable, profileable or non_profileable
123  optional string android_sdk_version = 4;
124  optional string android_build_type = 5;  // user, userdebug or eng
125
126  // True if the profile is recorded with --trace-offcpu option.
127  optional bool trace_offcpu = 6;
128}
129
130// Thread context switch info. It is available when MetaInfo.trace_offcpu = true.
131message ContextSwitch {
132  // If true, the thread is scheduled on cpu, otherwise it is scheduled off cpu.
133  optional bool switch_on = 1;
134
135  // Monotonic clock time in nanoseconds. On kernel < 4.1, it's perf clock instead.
136  optional uint64 time = 2;
137  optional uint32 thread_id = 3;
138}
139
140message Record {
141  oneof record_data {
142    Sample sample = 1;
143    LostSituation lost = 2;
144    File file = 3;
145    Thread thread = 4;
146    MetaInfo meta_info = 5;
147    ContextSwitch context_switch = 6;
148  }
149}