• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2020 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--     https://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
17SELECT RUN_METRIC('android/process_metadata.sql');
18
19DROP VIEW IF EXISTS android_task_names_output;
20CREATE PERFETTO VIEW android_task_names_output AS
21WITH
22-- Process to thread name
23threads_by_upid AS (
24  SELECT
25    upid,
26    RepeatedField(name) AS thread_names
27  FROM thread
28  WHERE name IS NOT NULL
29  GROUP BY 1
30),
31upid_packages AS (
32  SELECT
33    upid,
34    RepeatedField(package_name) AS packages
35  FROM process
36  JOIN android_process_metadata USING (upid)
37  WHERE package_name IS NOT NULL
38  GROUP BY 1
39)
40SELECT AndroidTaskNames(
41  'process', RepeatedField(
42    AndroidTaskNames_Process(
43      'pid', p.pid,
44      'process_name', p.name,
45      'thread_name', threads_by_upid.thread_names,
46      'uid', p.uid,
47      'uid_package_name', upid_packages.packages
48    )
49  )
50)
51FROM process p
52LEFT JOIN threads_by_upid USING (upid)
53LEFT JOIN upid_packages USING (upid)
54WHERE upid != 0;
55