Eric Jeong | 59a5650 | 2022-01-31 19:00:37 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright (C) 2019 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | DIR="$( cd "$(dirname "$0")" ; pwd -P )" |
| 17 | |
| 18 | if [[ $# -lt 1 ]]; then |
| 19 | echo "Usage: $0 <db-file>" |
| 20 | fi |
| 21 | |
| 22 | DB_TARGET=$1 |
| 23 | |
| 24 | if ! [[ -f $DB_TARGET ]]; then |
| 25 | echo "ERROR: File '$DB_TARGET' does not exist." >&2 |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | exec_sql_file() { |
| 30 | local filename="$1" |
| 31 | if ! [[ -f $filename ]]; then |
| 32 | echo "ERROR: Can't exec SQL file, '$filename' does not exist." >&2 |
| 33 | return 1 |
| 34 | fi |
| 35 | |
| 36 | sqlite3 "$DB_TARGET" < "$DIR"/"$filename" |
| 37 | } |
| 38 | |
| 39 | exec_sql_file_quiet() { |
| 40 | exec_sql_file "$@" > /dev/null |
| 41 | } |
| 42 | |
| 43 | # Some views/tables need other views already created, so order does matter. |
| 44 | # x -> y , means x depends on y. |
| 45 | |
| 46 | # View: tracing_mark_writes |
| 47 | # Table: tracing_mark_write_split_array -> tracing_mark_writes |
| 48 | exec_sql_file_quiet "queries_all.sql" |
| 49 | |
| 50 | # Table: tracing_mark_write_split -> tracing_mark_write_split_array |
| 51 | exec_sql_file_quiet "queries_mark_write_join.sql" |
| 52 | |
| 53 | # View: start_procs -> tracing_mark_write_split |
| 54 | exec_sql_file_quiet "queries_get_procs.sql" |
| 55 | |
| 56 | # View: sched_switch_next_comm_pids |
| 57 | exec_sql_file_quiet "queries_get_comm_and_pids.sql" |
| 58 | |
| 59 | # View: start_process_ui_threads -> start_procs, sched_switch_next_comm_pids |
| 60 | exec_sql_file_quiet "queries_get_ui_threads.sql" |
| 61 | |
| 62 | # View: launch_durations_named -> tracing_mark_write_split |
| 63 | exec_sql_file_quiet "queries_app_launch_spans_with_name.sql" |
| 64 | |
| 65 | # View: sched_switch_iowaits_pre |
| 66 | # View: sched_switch_iowaits -> sched_switch_iowaits_pre |
| 67 | # Table: blocking_durations -> sched_switch_iowaits |
| 68 | exec_sql_file_quiet "queries_find_sched_switch_unblocked.sql" |
| 69 | |
| 70 | # View: blocked_iowait_for_app_launches -> launch_durations_named, blocking_durations |
| 71 | exec_sql_file_quiet "queries_block_launch.sql" |
| 72 | |
| 73 | ##### |
| 74 | ##### |
| 75 | ##### |
| 76 | |
| 77 | # Final queries |
| 78 | |
| 79 | exec_sql_file "queries_pretty_print_block_launch.sql" |