• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 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--     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
17INCLUDE PERFETTO MODULE android.process_metadata;
18
19-- Alias the process_metadata_table since unfortunately there are places
20-- depending on it (which we will clean up)
21DROP VIEW IF EXISTS process_metadata_table;
22CREATE PERFETTO VIEW process_metadata_table AS
23SELECT * FROM android_process_metadata;
24
25CREATE OR REPLACE PERFETTO FUNCTION process_metadata_proto(upid INT)
26RETURNS PROTO
27AS
28SELECT NULL_IF_EMPTY(AndroidProcessMetadata(
29    'name', process_name,
30    'uid', uid,
31    'android_user_id', user_id,
32    'pid', pid,
33    'is_kernel_task', is_kernel_task,
34    'package', NULL_IF_EMPTY(AndroidProcessMetadata_Package(
35      'package_name', package_name,
36      'apk_version_code', version_code,
37      'debuggable', debuggable
38    ))
39  ))
40FROM android_process_metadata
41WHERE upid = $upid;
42
43DROP VIEW IF EXISTS process_metadata;
44CREATE PERFETTO VIEW process_metadata AS
45SELECT
46  upid,
47  process_metadata_proto(upid) AS metadata
48FROM android_process_metadata;
49
50-- Given a process name, return if it is debuggable.
51CREATE OR REPLACE PERFETTO FUNCTION is_process_debuggable(process_name STRING)
52RETURNS BOOL AS
53SELECT p.debuggable
54FROM android_process_metadata p
55WHERE p.process_name = $process_name
56LIMIT 1;
57