1# Copyright (C) 2022 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Contains tables for tracks.""" 15 16from python.generators.trace_processor_table.public import Column as C 17from python.generators.trace_processor_table.public import ColumnDoc 18from python.generators.trace_processor_table.public import CppInt64 19from python.generators.trace_processor_table.public import CppOptional 20from python.generators.trace_processor_table.public import CppSelfTableId 21from python.generators.trace_processor_table.public import CppString 22from python.generators.trace_processor_table.public import CppTableId 23from python.generators.trace_processor_table.public import CppUint32 24from python.generators.trace_processor_table.public import Table 25from python.generators.trace_processor_table.public import TableDoc 26 27from src.trace_processor.tables.metadata_tables import MACHINE_TABLE 28 29TRACK_TABLE = Table( 30 python_module=__file__, 31 class_name="TrackTable", 32 sql_name="__intrinsic_track", 33 columns=[ 34 C("name", CppString()), 35 C("parent_id", CppOptional(CppSelfTableId())), 36 C("source_arg_set_id", CppOptional(CppUint32())), 37 C('machine_id', CppOptional(CppTableId(MACHINE_TABLE))), 38 C("classification", CppString()), 39 C("dimension_arg_set_id", CppOptional(CppUint32())), 40 C("event_type", CppString()), 41 C("counter_unit", CppOptional(CppString())), 42 ]) 43 44PROCESS_TRACK_TABLE = Table( 45 python_module=__file__, 46 class_name="ProcessTrackTable", 47 sql_name="process_track", 48 columns=[ 49 C("upid", CppUint32()), 50 ], 51 parent=TRACK_TABLE, 52 tabledoc=TableDoc( 53 doc=''' 54 Tracks which are associated to the process given by the |upid| column 55 ''', 56 group='Tracks', 57 columns={ 58 'upid': 59 ColumnDoc( 60 doc='The process associated with this track.', 61 joinable='process.upid'), 62 })) 63 64THREAD_TRACK_TABLE = Table( 65 python_module=__file__, 66 class_name='ThreadTrackTable', 67 sql_name='thread_track', 68 columns=[ 69 C('utid', CppUint32()), 70 ], 71 parent=TRACK_TABLE, 72 tabledoc=TableDoc( 73 doc=''' 74 Tracks which are associated to the thread given by the |utid| column 75 ''', 76 group='Tracks', 77 columns={ 78 'utid': 79 ColumnDoc( 80 doc='The thread associated with this track', 81 joinable='thread.utid', 82 ) 83 })) 84 85CPU_TRACK_TABLE = Table( 86 python_module=__file__, 87 class_name='CpuTrackTable', 88 sql_name='__intrinsic_cpu_track', 89 columns=[ 90 C('cpu', CppUint32()), 91 ], 92 parent=TRACK_TABLE) 93 94GPU_TRACK_TABLE = Table( 95 python_module=__file__, 96 class_name='GpuTrackTable', 97 sql_name='gpu_track', 98 columns=[ 99 C('scope', CppString()), 100 C('description', CppString()), 101 C('context_id', CppOptional(CppInt64())), 102 ], 103 parent=TRACK_TABLE, 104 tabledoc=TableDoc( 105 doc='Tracks associated to a GPU.', 106 group='Tracks', 107 columns={ 108 'scope': 109 'The scope for the track. For debugging purposes only.', 110 'description': 111 'The description of the track. For debugging purposes only.', 112 'context_id': 113 'The context id for the GPU this track is associated to.' 114 })) 115 116# Keep this list sorted. 117ALL_TABLES = [ 118 CPU_TRACK_TABLE, 119 GPU_TRACK_TABLE, 120 PROCESS_TRACK_TABLE, 121 THREAD_TRACK_TABLE, 122 TRACK_TABLE, 123] 124