| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 1 | // The file format generated by report_sample.proto is as below: |
| Yabin Cui | 1746121 | 2018-04-09 12:13:39 -0700 | [diff] [blame] | 2 | // char magic[10] = "SIMPLEPERF"; |
| 3 | // LittleEndian16(version) = 1; |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 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 | |
| 13 | syntax = "proto2"; |
| 14 | option optimize_for = LITE_RUNTIME; |
| 15 | package simpleperf_report_proto; |
| Yabin Cui | 35df863 | 2016-07-19 17:15:12 -0700 | [diff] [blame] | 16 | option java_package = "com.android.tools.profiler.proto"; |
| 17 | option java_outer_classname = "SimpleperfReport"; |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 18 | |
| 19 | message Sample { |
| Yabin Cui | 07ee941 | 2017-05-02 13:25:21 -0700 | [diff] [blame] | 20 | // Wall clock time for current sample. |
| 21 | // By default, it is perf clock used in kernel. |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 22 | optional uint64 time = 1; |
| Yabin Cui | 16501ff | 2016-10-19 15:06:29 -0700 | [diff] [blame] | 23 | optional int32 thread_id = 2; |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 24 | |
| 25 | message CallChainEntry { |
| Yabin Cui | 16501ff | 2016-10-19 15:06:29 -0700 | [diff] [blame] | 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; |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| Yabin Cui | 16501ff | 2016-10-19 15:06:29 -0700 | [diff] [blame] | 38 | repeated CallChainEntry callchain = 3; |
| Yabin Cui | 07ee941 | 2017-05-02 13:25:21 -0700 | [diff] [blame] | 39 | |
| Yabin Cui | 20663f5 | 2017-07-31 15:08:27 -0700 | [diff] [blame] | 40 | // Simpleperf generates one sample whenever a specified amount of events happen |
| 41 | // while running a monitored thread. So each sample belongs to one event type. |
| 42 | // Event type can be cpu-cycles, cpu-clock, sched:sched_switch or other types. |
| 43 | // By using '-e' option, we can ask simpleperf to record samples for one or more |
| 44 | // event types. |
| 45 | // Each event type generates samples independently. But recording more event types |
| 46 | // will cost more cpu time generating samples, which may affect the monitored threads |
| 47 | // and sample lost rate. |
| 48 | // event_count field shows the count of the events (belong to the sample's event type) |
| 49 | // that have happened since last sample (belong to the sample's event type) for the |
| 50 | // same thread. However, if there are lost samples between current sample and previous |
| 51 | // sample, the event_count is the count of events from the last lost sample. |
| Yabin Cui | 07ee941 | 2017-05-02 13:25:21 -0700 | [diff] [blame] | 52 | optional uint64 event_count = 4; |
| 53 | |
| Yabin Cui | 20663f5 | 2017-07-31 15:08:27 -0700 | [diff] [blame] | 54 | // An index in meta_info.event_type, shows which event type current sample belongs to. |
| 55 | optional uint32 event_type_id = 5; |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| Yabin Cui | 587fb9b | 2016-07-26 19:49:15 -0700 | [diff] [blame] | 58 | message LostSituation { |
| 59 | optional uint64 sample_count = 1; |
| 60 | optional uint64 lost_count = 2; |
| 61 | } |
| 62 | |
| Yabin Cui | 16501ff | 2016-10-19 15:06:29 -0700 | [diff] [blame] | 63 | message File { |
| 64 | // unique id for each file, starting from 0, and add 1 each time. |
| 65 | optional uint32 id = 1; |
| 66 | |
| 67 | // file path, like /system/lib/libc.so. |
| 68 | optional string path = 2; |
| 69 | |
| 70 | // symbol table of the file. |
| 71 | repeated string symbol = 3; |
| Yabin Cui | 66bade8 | 2018-04-18 15:10:59 -0700 | [diff] [blame] | 72 | |
| 73 | // mangled symbol table of the file. |
| 74 | repeated string mangled_symbol = 4; |
| Yabin Cui | 16501ff | 2016-10-19 15:06:29 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| Yabin Cui | 52190a3 | 2017-06-02 14:47:33 -0700 | [diff] [blame] | 77 | message Thread { |
| 78 | optional uint32 thread_id = 1; |
| 79 | optional uint32 process_id = 2; |
| 80 | optional string thread_name = 3; |
| 81 | } |
| 82 | |
| Yabin Cui | 20663f5 | 2017-07-31 15:08:27 -0700 | [diff] [blame] | 83 | message MetaInfo { |
| Amaury Medeiros | 2277368 | 2017-09-27 13:28:53 +0100 | [diff] [blame] | 84 | repeated string event_type = 1; |
| Yabin Cui | 0a59929 | 2018-04-10 17:05:30 -0700 | [diff] [blame] | 85 | optional string app_package_name = 2; |
| Yabin Cui | 20663f5 | 2017-07-31 15:08:27 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 88 | message Record { |
| Yabin Cui | 16501ff | 2016-10-19 15:06:29 -0700 | [diff] [blame] | 89 | oneof record_data { |
| 90 | Sample sample = 1; |
| 91 | LostSituation lost = 2; |
| 92 | File file = 3; |
| Yabin Cui | 52190a3 | 2017-06-02 14:47:33 -0700 | [diff] [blame] | 93 | Thread thread = 4; |
| Yabin Cui | 20663f5 | 2017-07-31 15:08:27 -0700 | [diff] [blame] | 94 | MetaInfo meta_info = 5; |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 95 | } |
| Yabin Cui | 42c8dc6 | 2016-06-03 15:06:53 -0700 | [diff] [blame] | 96 | } |