/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package perfetto.protos;

message Trace {
  repeated TracePacket packet = 1;
}

message TracePacket {
  optional uint64 timestamp = 8;
  oneof data {
    TrackEvent track_event = 11;
    TrackDescriptor track_descriptor = 60;
  }
  oneof optional_trusted_packet_sequence_id {
    uint32 trusted_packet_sequence_id = 10;
  }
}

message TrackDescriptor {
  optional uint64 uuid = 1;
  optional uint64 parent_uuid = 5;
  optional string name = 2;
  optional ProcessDescriptor process = 3;
  optional ThreadDescriptor thread = 4;
}

message TrackEvent {
  enum Type {
    TYPE_UNSPECIFIED = 0;
    TYPE_SLICE_BEGIN = 1;
    TYPE_SLICE_END = 2;
    TYPE_INSTANT = 3;
    TYPE_COUNTER = 4;
  }
  required string name = 23;
  optional Type type = 9;
  optional uint64 track_uuid = 11;
  repeated DebugAnnotation debug_annotations = 4;
}

message ProcessDescriptor {
  optional int32 pid = 1;
  optional string process_name = 6;
  repeated string process_labels = 8;
}

message ThreadDescriptor {
  optional int32 pid = 1;
  optional int32 tid = 2;
  optional string thread_name = 5;
}

message DebugAnnotation {
  oneof name_field {
    string name = 10;
  }
  oneof value {
    bool bool_value = 2;
    uint64 uint_value = 3;
    int64 int_value = 4;
    double double_value = 5;
    string string_value = 6;
  }
  repeated DebugAnnotation dict_entries = 11;
  repeated DebugAnnotation array_values = 12;
}
