1// Copyright (C) 2024 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 15import {SqlTableDescription} from '../../components/widgets/sql/table/table_description'; 16import { 17 ArgSetIdColumn, 18 DurationColumn, 19 ProcessIdColumn, 20 SchedIdColumn, 21 SliceIdColumn, 22 StandardColumn, 23 ThreadIdColumn, 24 ThreadStateIdColumn, 25 TimestampColumn, 26} from '../../components/widgets/sql/table/columns'; 27 28export function getThreadTable(): SqlTableDescription { 29 return { 30 name: 'thread', 31 columns: [ 32 new ThreadIdColumn('utid', {type: 'id'}), 33 new StandardColumn('tid'), 34 new StandardColumn('name'), 35 new TimestampColumn('start_ts'), 36 new TimestampColumn('end_ts'), 37 new ProcessIdColumn('upid', {notNull: true}), 38 new StandardColumn('is_main_thread'), 39 ], 40 }; 41} 42 43export function getProcessTable(): SqlTableDescription { 44 return { 45 name: 'process', 46 columns: [ 47 new ProcessIdColumn('upid', {type: 'id'}), 48 new StandardColumn('pid'), 49 new StandardColumn('name'), 50 new TimestampColumn('start_ts'), 51 new TimestampColumn('end_ts'), 52 new ProcessIdColumn('parent_upid'), 53 new StandardColumn('uid'), 54 new StandardColumn('android_appid'), 55 new StandardColumn('cmdline', {startsHidden: true}), 56 new StandardColumn('machine_id'), 57 new ArgSetIdColumn('arg_set_id'), 58 ], 59 }; 60} 61 62export function getSliceTable(): SqlTableDescription { 63 return { 64 imports: ['slices.with_context'], 65 name: 'thread_or_process_slice', 66 displayName: 'thread_or_process_slice', 67 columns: [ 68 new SliceIdColumn('id', {notNull: true, type: 'id'}), 69 new TimestampColumn('ts'), 70 new DurationColumn('dur'), 71 new StandardColumn('category'), 72 new StandardColumn('name'), 73 new StandardColumn('track_id', {startsHidden: true}), 74 new ThreadIdColumn('utid'), 75 new ProcessIdColumn('upid'), 76 new StandardColumn('depth', {startsHidden: true}), 77 new SliceIdColumn('parent_id'), 78 new ArgSetIdColumn('arg_set_id'), 79 ], 80 }; 81} 82 83export function getAndroidLogsTable(): SqlTableDescription { 84 return { 85 name: 'android_logs', 86 columns: [ 87 new StandardColumn('id'), 88 new TimestampColumn('ts'), 89 new StandardColumn('tag'), 90 new StandardColumn('prio'), 91 new ThreadIdColumn('utid'), 92 new ProcessIdColumn({ 93 column: 'upid', 94 source: { 95 table: 'thread', 96 joinOn: {utid: 'utid'}, 97 }, 98 }), 99 new StandardColumn('msg'), 100 ], 101 }; 102} 103 104export function getSchedTable(): SqlTableDescription { 105 return { 106 name: 'sched', 107 columns: [ 108 new SchedIdColumn('id'), 109 new TimestampColumn('ts'), 110 new DurationColumn('dur'), 111 new StandardColumn('cpu'), 112 new StandardColumn('priority'), 113 new ThreadIdColumn('utid'), 114 new ProcessIdColumn({ 115 column: 'upid', 116 source: { 117 table: 'thread', 118 joinOn: {utid: 'utid'}, 119 }, 120 }), 121 new StandardColumn('end_state'), 122 new StandardColumn('ucpu', {startsHidden: true}), 123 ], 124 }; 125} 126 127export function getThreadStateTable(): SqlTableDescription { 128 return { 129 name: 'thread_state', 130 columns: [ 131 new ThreadStateIdColumn('id'), 132 new TimestampColumn('ts'), 133 new DurationColumn('dur'), 134 new StandardColumn('state'), 135 new StandardColumn('cpu'), 136 new ThreadIdColumn('utid'), 137 new ProcessIdColumn({ 138 column: 'upid', 139 source: { 140 table: 'thread', 141 joinOn: {utid: 'utid'}, 142 }, 143 }), 144 new StandardColumn('io_wait'), 145 new StandardColumn('blocked_function'), 146 new ThreadIdColumn('waker_utid'), 147 new ThreadStateIdColumn('waker_id'), 148 new StandardColumn('irq_context'), 149 new StandardColumn('ucpu', {startsHidden: true}), 150 ], 151 }; 152} 153