• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2024 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
16INCLUDE PERFETTO MODULE callstacks.stack_profile;
17
18CREATE PERFETTO TABLE _linux_perf_raw_callstacks AS
19SELECT
20  *
21FROM _callstacks_for_callsites!((
22  SELECT p.callsite_id
23  FROM perf_sample p
24)) AS c
25ORDER BY
26  c.id;
27
28-- Table summarising the callstacks captured during all
29-- perf samples in the trace.
30--
31-- Specifically, this table returns a tree containing all
32-- the callstacks seen during the trace with `self_count`
33-- equal to the number of samples with that frame as the
34-- leaf and `cumulative_count` equal to the number of
35-- samples with the frame anywhere in the tree.
36CREATE PERFETTO TABLE linux_perf_samples_summary_tree (
37  -- The id of the callstack. A callstack in this context
38  -- is a unique set of frames up to the root.
39  id LONG,
40  -- The id of the parent callstack for this callstack.
41  parent_id LONG,
42  -- The function name of the frame for this callstack.
43  name STRING,
44  -- The name of the mapping containing the frame. This
45  -- can be a native binary, library, JAR or APK.
46  mapping_name STRING,
47  -- The name of the file containing the function.
48  source_file STRING,
49  -- The line number in the file the function is located at.
50  line_number LONG,
51  -- The number of samples with this function as the leaf
52  -- frame.
53  self_count LONG,
54  -- The number of samples with this function appearing
55  -- anywhere on the callstack.
56  cumulative_count LONG
57) AS
58SELECT
59  r.*,
60  a.cumulative_count
61FROM _callstacks_self_to_cumulative!((
62  SELECT id, parent_id, self_count
63  FROM _linux_perf_raw_callstacks
64)) AS a
65JOIN _linux_perf_raw_callstacks AS r
66  USING (id)
67ORDER BY
68  r.id;
69