1/* 2 * Copyright (C) 2017 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 17syntax = "proto2"; 18option optimize_for = LITE_RUNTIME; 19 20import "perfetto/config/trace_config.proto"; 21 22package perfetto.protos; 23 24// IPC interface definition for the consumer port of the tracing service. 25service ConsumerPort { 26 // Creates the ring buffers that will be used for the tracing session. 27 // TODO(primiano): not implemented yet. EnableTracing will implicitly create 28 // the required buffer. This is to allow Enabling/Disabling tracing with 29 // different configs without losing the contents of the buffers for the 30 // previous tracing session. 31 // rpc CreateBuffers(CreateBuffersRequest) returns (CreateBuffersResponse) {} 32 33 // Enables tracing for one or more data sources. At least one buffer must have 34 // been previously created. The EnableTracingResponse is sent when tracing is 35 // disabled (either explicitly or because of the |duration_ms| expired). 36 rpc EnableTracing(EnableTracingRequest) returns (EnableTracingResponse) {} 37 38 // Disables tracing for one or more data sources. 39 rpc DisableTracing(DisableTracingRequest) returns (DisableTracingResponse) {} 40 41 // Streams back the contents of one or more buffers. One call is enough to 42 // drain all the buffers. The response consists in a sequence of 43 // ReadBufferResponse messages (hence the "stream" in the return type), each 44 // carrying one or more TracePacket(s). An EOF flag is attached to the last 45 // ReadBufferResponse through the |has_more| == false field. 46 rpc ReadBuffers(ReadBuffersRequest) returns (stream ReadBuffersResponse) {} 47 48 // Destroys the buffers previously created. Note: all buffers are destroyed 49 // implicitly if the Consumer disconnects. 50 rpc FreeBuffers(FreeBuffersRequest) returns (FreeBuffersResponse) {} 51 52 // Asks the service to request to all data sources involved in the tracing 53 // session to commit their data into the trace buffer. The FlushResponse is 54 // sent only: 55 // - After the data has been committed (in which case FlushResponse succeeds) 56 // or 57 // - After FlushRequest.timeout_ms milliseconds (in which case the 58 // FlushResponse is rejected and fails). 59 rpc Flush(FlushRequest) returns (FlushResponse) {} 60 61 // TODO rpc ListDataSources(), for the UI. 62} 63 64// Arguments for rpc EnableTracing(). 65message EnableTracingRequest { 66 optional protos.TraceConfig trace_config = 1; 67} 68 69message EnableTracingResponse { 70 oneof state { bool disabled = 1; } 71} 72 73// Arguments for rpc DisableTracing(). 74message DisableTracingRequest { 75 // TODO: not supported yet, selectively disable only some data sources. 76 // repeated string data_source_name; 77} 78 79message DisableTracingResponse {} 80 81// Arguments for rpc ReadBuffers(). 82message ReadBuffersRequest { 83 // The |id|s of the buffer, as passed to CreateBuffers(). 84 // TODO: repeated uint32 buffer_ids = 1; 85} 86 87message ReadBuffersResponse { 88 // TODO: uint32 buffer_id = 1; 89 90 // Each streaming reply returns one or more slices for one or more trace 91 // packets, or even just a portion of it (if it's too big to fit within one 92 // IPC). The returned slices are ordered and contiguous: packets' slices are 93 // not interleaved and slices are sent only once all slices for a packet are 94 // available (i.e. the consumer will never see any gap). 95 message Slice { 96 optional bytes data = 1; 97 98 // When true, this is the last slice for the packet. A ReadBufferResponse 99 // might have no slices marked as |last_slice_for_packet|==true, in the case 100 // of a very large packet that gets chunked into several IPCs (in which case 101 // only the last IPC for the packet will have this flag set). 102 optional bool last_slice_for_packet = 2; 103 } 104 repeated Slice slices = 2; 105} 106 107// Arguments for rpc FreeBuffers(). 108message FreeBuffersRequest { 109 // The |id|s of the buffer, as passed to CreateBuffers(). 110 repeated uint32 buffer_ids = 1; 111} 112 113message FreeBuffersResponse {} 114 115// Arguments for rpc Flush(). 116message FlushRequest { 117 optional uint32 timeout_ms = 1; 118} 119 120message FlushResponse {} 121