public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "id":
                    Id = (int)longVal;
                    break;

                case "source_arg_set_id":
                    SourceArgSetId = (uint)longVal;
                    break;

                case "gpu_id":
                    GpuId = (uint)longVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "name":
                    Name = strVal;
                    break;

                case "unit":
                    Unit = strVal;
                    break;

                case "description":
                    Description = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 2
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "utid":
                    Utid = (uint)longVal;
                    break;

                case "ts":
                    Timestamp = longVal;
                    break;

                case "cpu":
                    Cpu = (uint)longVal;
                    break;

                case "arg_set_id":
                    ArgSetId = (uint)longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "name":
                    Name = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "id":
                    Id = (int)longVal;
                    break;

                case "depth":
                    Depth = (uint)longVal;
                    break;

                case "parent_id":
                    ParentId = (int)longVal;
                    break;

                case "frame_id":
                    FrameId = (int)longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "type":
                    Type = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "ts":
                    Timestamp = longVal;
                    break;

                case "clock_id":
                    ClockId = longVal;
                    break;

                case "clock_value":
                    ClockValue = longVal;
                    break;

                case "snapshot_id":
                    SnapshotId = longVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = stringCells[counters.StringCounter++];
                switch (col)
                {
                case "clock_name":
                    ClockName = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 5
0
        public override void ProcessCell(string colName,
            QueryResult.Types.CellsBatch.Types.CellType cellType,
            QueryResult.Types.CellsBatch batch,
            string[] stringCells,
            CellCounters counters)
        {
            var col = colName.ToLower();
            switch (cellType)
            {
                case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
                case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                    break;
                case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                    var longVal = batch.VarintCells[counters.IntCounter++];
                    switch (col)
                    {
                        case "id":
                            Id = (int)longVal;
                            break;
                        case "uid":
                            Uid = (uint) longVal;
                            break;
                        case "debuggable":
                            Debuggable = Convert.ToBoolean(longVal);
                            break;
                        case "profileable_from_shell":
                            ProfileableFromShell = Convert.ToBoolean(longVal);
                            break;
                        case "version_code":
                            VersionCode = longVal;
                            break;
                    }

                    break;
                case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                    break;
                case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                    var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                    switch (col)
                    {
                        case "type":
                            Type = strVal;
                            break;
                        case "package_name":
                            PackageName = strVal;
                            break;
                    }
                    break;
                case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                    break;
                default:
                    throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 6
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "int_value":
                    IntValue = longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = stringCells[counters.StringCounter++];
                switch (col)
                {
                case "name":
                    Name = strVal;
                    break;

                case "key_type":
                    KeyType = strVal;
                    break;

                case "str_value":
                    StrValue = strVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception($"Unexpected CellType {col} {cellType}");
            }
        }
Esempio n. 7
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "start_ts":
                    StartTimestamp = longVal;
                    break;

                case "end_ts":
                    EndTimestamp = longVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 8
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "id":
                    Id = (int)longVal;
                    break;

                case "start":
                    Start = longVal;
                    break;

                case "end":
                    End = longVal;
                    break;

                case "exact_offset":
                    ExactOffset = longVal;
                    break;

                case "start_offset":
                    StartOffset = longVal;
                    break;

                case "load_bias":
                    LoadBias = longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "name":
                    Name = strVal;
                    break;

                case "type":
                    Type = strVal;
                    break;

                case "build_id":
                    BuildId = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "upid":
                    Upid = (uint)longVal;
                    break;

                case "id":
                    Id = longVal;
                    break;

                case "pid":
                    Pid = (uint)longVal;
                    break;

                case "uid":
                    Uid = (uint)longVal;
                    break;

                case "parent_upid":
                    ParentUpid = (uint)longVal;
                    break;

                case "android_appid":
                    AndroidAppId = (uint)longVal;
                    break;

                case "arg_set_id":
                    ArgSetId = (uint)longVal;
                    break;

                case "start_ts":
                    StartTimestamp = longVal;
                    break;

                case "end_ts":
                    EndTimestamp = longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = stringCells[counters.StringCounter++];
                switch (col)
                {
                case "type":
                    Type = strVal;
                    break;

                case "cmdline":
                    CmdLine = strVal;
                    break;

                case "name":
                    Name = strVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 10
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "id":
                    Id = (int)longVal;
                    break;

                case "mapping":
                    Mapping = (int)longVal;
                    break;

                case "rel_pc":
                    RelPc = longVal;
                    break;

                case "symbol_set_id":
                    SymbolSetId = (uint)longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "name":
                    Name = strVal;
                    break;

                case "type":
                    Type = strVal;
                    break;

                case "deobfuscated_name":
                    DeobfuscatedName = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 11
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "id":
                    Id = (int)longVal;
                    break;

                case "ts":
                    Timestamp = longVal;
                    break;

                case "dur":
                    Duration = longVal;
                    break;

                case "arg_set_id":
                    ArgSetId = (uint)longVal;
                    break;

                case "track_id":
                    TrackId = (int)longVal;
                    break;

                case "parent_id":
                    ParentId = (int)longVal;
                    break;

                case "display_frame_token":
                    DisplayFrameToken = longVal;
                    break;

                case "surface_frame_token":
                    SurfaceFrameToken = longVal;
                    break;

                case "upid":
                    Upid = (uint)longVal;
                    break;

                case "on_time_finish":
                    OnTimeFinish = (int)longVal;
                    break;

                case "gpu_composition":
                    GpuComposition = (int)longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "name":
                    Name = strVal;
                    break;

                case "type":
                    Type = strVal;
                    break;

                case "category":
                    Category = strVal;
                    break;

                case "layer_name":
                    LayerName = strVal;
                    break;

                case "jank_type":
                    JankType = Common.StringIntern(strVal);
                    break;

                case "jank_tag":
                    JankTag = Common.StringIntern(strVal);
                    break;

                case "prediction_type":
                    PredictionType = Common.StringIntern(strVal);
                    break;

                case "present_type":
                    PresentType = Common.StringIntern(strVal);
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 12
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "arg_set_id":
                    ArgSetId = (uint)longVal;
                    break;

                case "int_value":
                    IntValue = longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                var floatVal = batch.Float64Cells[counters.FloatCounter++];
                if (col == "real_value")
                {
                    RealValue = floatVal;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "flat_key":
                    Flatkey = strVal;
                    break;

                case "key":
                    ArgKey = strVal;
                    break;

                case "string_value":
                    StringValue = strVal;
                    break;

                case "value_type":
                    ValueType = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "utid":
                    Utid = (uint)longVal;
                    break;

                case "ts":
                    Timestamp = longVal;
                    break;

                case "prio":
                    Priority = (int)longVal;
                    if (Priority >= 0 && Priority < PriorityToString.Length)
                    {
                        PriorityString = PriorityToString[longVal];
                    }
                    else
                    {
                        PriorityString = Common.StringIntern(longVal.ToString());
                    }
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "tag":
                    Tag = strVal;
                    break;

                case "msg":
                    Message = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 14
0
 /// <summary>
 /// This method is responsible for processing an individual cell in a SQL query, which is stored in the QueryResult
 /// protobuf object (QueryResult.Batch.Cells)
 ///
 /// CellType defines what type this cell is (int, string, float, ...) and the batch object contains
 /// separate data arrays for each of those types (varintcells[], varfloatcells[]). The counters object
 /// maintains the indices into each of these data arrays.
 ///
 /// String cells need to be preprocessed by us because they come as a single string delimited by null characater.
 ///
 /// For more information, see comments for QueryResult and CellsBatch inside TraceProcessor.cs
 ///
 /// </summary>
 /// <param name="colName">String name of the column</param>
 /// <param name="cellType">Type of cell</param>
 /// <param name="batch">Batch object that contains the data arrays</param>
 /// <param name="stringCells">All the string cells already split into an array</param>
 /// <param name="counters">Indexes into the data arrays</param>
 public abstract void ProcessCell(string colName,
                                  QueryResult.Types.CellsBatch.Types.CellType cellType,
                                  QueryResult.Types.CellsBatch batch,
                                  string[] stringCells,
                                  CellCounters counters);
Esempio n. 15
0
        public override void ProcessCell(string colName,
                                         QueryResult.Types.CellsBatch.Types.CellType cellType,
                                         QueryResult.Types.CellsBatch batch,
                                         string[] stringCells,
                                         CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "id":
                    Id = (int)longVal;
                    break;

                case "ts":
                    Timestamp = longVal;
                    break;

                case "utid":
                    Utid = (uint)longVal;
                    break;

                case "cpu":
                    Cpu = (uint)longVal;
                    break;

                case "callsite_id":
                    CallsiteId = (int)longVal;
                    break;

                case "perf_session_id":
                    PerfSessionId = (uint)longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = Common.StringIntern(stringCells[counters.StringCounter++]);
                switch (col)
                {
                case "type":
                    Type = strVal;
                    break;

                case "cpu_mode":
                    CpuMode = strVal;
                    break;

                case "unwind_error":
                    UnwindError = strVal;
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Perform a SQL query against trace_processor_shell to gather Perfetto trace data. Processes the QueryResult
        /// and returns PerfettoSqlObjects through a callback
        /// </summary>
        /// <param name="sqlQuery">The query to perform against the loaded trace in trace_processor_shell</param>
        /// <param name="eventKey">The event key that corresponds to the type of PerfettoSqlEvent to process for this query</param>
        /// <param name="eventCallback">Completed PerfettoSqlEvents will be sent here</param>
        /// <returns>Count of rows from query result</returns>
        public long QueryTraceForEvents(string sqlQuery, string eventKey, Action <PerfettoSqlEvent> eventCallback)
        {
            long eventCount = 0;
            var  rpcs       = QueryTrace(sqlQuery);

            if (rpcs.Count == 0)
            {
                return(eventCount);
            }

            // Column information is only available in first result
            var numColumns = rpcs[0].QueryResult.ColumnNames.Count;
            var cols       = rpcs[0].QueryResult.ColumnNames;

            foreach (var rpc in rpcs)
            {
                var qr = rpc.QueryResult;

                foreach (var batch in qr.Batch)
                {
                    CellCounters cellCounters = new CellCounters();

                    // String cells get stored as a single string delimited by null character. Split that up ourselves
                    var stringCells = batch.StringCells.Split('\0');

                    int cellCount       = 0;
                    PerfettoSqlEvent ev = null;
                    foreach (var cell in batch.Cells)
                    {
                        if (ev == null)
                        {
                            ev = eventKey switch
                            {
                                PerfettoSliceEvent.Key => new PerfettoSliceEvent(),
                                PerfettoArgEvent.Key => new PerfettoArgEvent(),
                                PerfettoThreadTrackEvent.Key => new PerfettoThreadTrackEvent(),
                                PerfettoThreadEvent.Key => new PerfettoThreadEvent(),
                                PerfettoProcessRawEvent.Key => new PerfettoProcessRawEvent(),
                                PerfettoSchedSliceEvent.Key => new PerfettoSchedSliceEvent(),
                                PerfettoAndroidLogEvent.Key => new PerfettoAndroidLogEvent(),
                                PerfettoRawEvent.Key => new PerfettoRawEvent(),
                                PerfettoCounterEvent.Key => new PerfettoCounterEvent(),
                                PerfettoCpuCounterTrackEvent.Key => new PerfettoCpuCounterTrackEvent(),
                                PerfettoGpuCounterTrackEvent.Key => new PerfettoGpuCounterTrackEvent(),
                                PerfettoClockSnapshotEvent.Key => new PerfettoClockSnapshotEvent(),
                                PerfettoTraceBoundsEvent.Key => new PerfettoTraceBoundsEvent(),
                                PerfettoMetadataEvent.Key => new PerfettoMetadataEvent(),
                                PerfettoProcessCounterTrackEvent.Key => new PerfettoProcessCounterTrackEvent(),
                                PerfettoCounterTrackEvent.Key => new PerfettoCounterTrackEvent(),
                                PerfettoProcessTrackEvent.Key => new PerfettoProcessTrackEvent(),
                                PerfettoPerfSampleEvent.Key => new PerfettoPerfSampleEvent(),
                                PerfettoStackProfileCallSiteEvent.Key => new PerfettoStackProfileCallSiteEvent(),
                                PerfettoStackProfileFrameEvent.Key => new PerfettoStackProfileFrameEvent(),
                                PerfettoStackProfileMappingEvent.Key => new PerfettoStackProfileMappingEvent(),
                                PerfettoStackProfileSymbolEvent.Key => new PerfettoStackProfileSymbolEvent(),
                                PerfettoActualFrameEvent.Key => new PerfettoActualFrameEvent(),
                                PerfettoExpectedFrameEvent.Key => new PerfettoExpectedFrameEvent(),
                                PerfettoPackageListEvent.Key => new PerfettoPackageListEvent(),
                                _ => throw new Exception("Invalid event type"),
                            };
                        }

                        var colIndex = cellCount % numColumns;
                        var colName  = cols[colIndex].ToLower();

                        // The event itself is responsible for figuring out how to process and store cell contents
                        ev.ProcessCell(colName, cell, batch, stringCells, cellCounters);

                        // If we've reached the end of a row, we've finished an event.
                        if (++cellCount % numColumns == 0)
                        {
                            // Report the event back
                            eventCallback(ev);

                            ev = null;
                            eventCount++;
                        }
                    }
                }
            }
            return(eventCount);
        }
        public override void ProcessCell(string colName, QueryResult.Types.CellsBatch.Types.CellType cellType, QueryResult.Types.CellsBatch batch, string[] stringCells, CellCounters counters)
        {
            var col = colName.ToLower();

            switch (cellType)
            {
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellInvalid:
            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellNull:
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellVarint:
                var longVal = batch.VarintCells[counters.IntCounter++];
                switch (col)
                {
                case "utid":
                    Utid = (uint)longVal;
                    break;

                case "ts":
                    Timestamp = longVal;
                    break;

                case "dur":
                    Duration = longVal;
                    break;

                case "cpu":
                    Cpu = (uint)longVal;
                    break;

                case "priority":
                    Priority = (int)longVal;
                    break;
                }

                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellFloat64:
                var floatVal = batch.Float64Cells[counters.FloatCounter++];
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellString:
                var strVal = stringCells[counters.StringCounter++];
                switch (col)
                {
                case "end_state":
                    SetEndState(strVal);
                    break;
                }
                break;

            case Perfetto.Protos.QueryResult.Types.CellsBatch.Types.CellType.CellBlob:
                break;

            default:
                throw new Exception("Unexpected CellType");
            }
        }