/*
 * Copyright (C) 2017 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 xprof.traceviewer.protos;

message Trace {
  repeated TracePacket packet = 1;
}

message TracePacket {
  optional uint64 timestamp = 8;
  optional bool incremental_state_cleared = 41;
  optional TrackEvent track_event = 11;
  optional TrackDescriptor track_descriptor = 60;
  optional InternedData interned_data = 12;
  optional uint32 trusted_packet_sequence_id = 10;
}

message InternedData {
  repeated EventName event_names = 2;
  repeated EventCategory event_categories = 3;
}

message EventName {
  optional uint64 iid = 1;
  optional string name = 2;
}

message EventCategory {
  optional uint64 iid = 1;
  optional string name = 2;
}

message TrackEvent {
  enum Type {
    TYPE_UNSPECIFIED = 0;
    TYPE_SLICE_BEGIN = 1;
    TYPE_SLICE_END = 2;
    TYPE_INSTANT = 3;
  }
  optional Type type = 9;
  optional uint64 track_uuid = 11;
  optional uint64 name_iid = 10;
  optional string name = 23;
  optional int64 timestamp_delta_us = 1;
  optional int64 timestamp_absolute_us = 16;
}

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

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

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