xref: /aosp_15_r20/external/perfetto/docs/analysis/debug-tracks.md (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1*6dbdd20aSAndroid Build Coastguard Worker# Debug Tracks
2*6dbdd20aSAndroid Build Coastguard Worker
3*6dbdd20aSAndroid Build Coastguard WorkerDebug Tracks are a way to display tabular results from running a PerfettoSQL
4*6dbdd20aSAndroid Build Coastguard Workerquery as a so-called "debug" track. Specifically, if the resultant table can
5*6dbdd20aSAndroid Build Coastguard Workerbe visualised in a slice format (ex: the
6*6dbdd20aSAndroid Build Coastguard Worker[`slice`](sql-tables.autogen#slice) table) or counter format
7*6dbdd20aSAndroid Build Coastguard Worker(ex: the [`counter`](sql-tables.autogen#counter) table),
8*6dbdd20aSAndroid Build Coastguard Workera debug track can be created from it.
9*6dbdd20aSAndroid Build Coastguard Worker
10*6dbdd20aSAndroid Build Coastguard WorkerFor a result table to be visualised, it should
11*6dbdd20aSAndroid Build Coastguard Workerinclude:
12*6dbdd20aSAndroid Build Coastguard Worker
13*6dbdd20aSAndroid Build Coastguard Worker1. A name (the name of the slice) column.
14*6dbdd20aSAndroid Build Coastguard Worker1. A non-null timestamp (the timestamp, in nanoseconds, at the start of the
15*6dbdd20aSAndroid Build Coastguard Worker  slice) column.
16*6dbdd20aSAndroid Build Coastguard Worker1. (For `slice` tracks) a duration (the duration, in nanoseconds, of the slice)
17*6dbdd20aSAndroid Build Coastguard Worker   column.
18*6dbdd20aSAndroid Build Coastguard Worker1. (Optionally) the name of a column to pivot
19*6dbdd20aSAndroid Build Coastguard Worker
20*6dbdd20aSAndroid Build Coastguard Worker    Note: Pivoting means allows you to create a single debug track per distinct
21*6dbdd20aSAndroid Build Coastguard Worker    value in the selected "pivot" column.
22*6dbdd20aSAndroid Build Coastguard Worker
23*6dbdd20aSAndroid Build Coastguard Worker## Creating Debug `slice` Tracks
24*6dbdd20aSAndroid Build Coastguard Worker
25*6dbdd20aSAndroid Build Coastguard WorkerTo create `slice` tracks:
26*6dbdd20aSAndroid Build Coastguard Worker
27*6dbdd20aSAndroid Build Coastguard Worker1. Run a SQL query, and ensure its results are `slice`-like (as described
28*6dbdd20aSAndroid Build Coastguard Worker  above).
29*6dbdd20aSAndroid Build Coastguard Worker  ![Query for debug slice track](/docs/images/debug-tracks/slice-track-query.png)
30*6dbdd20aSAndroid Build Coastguard Worker1. Navigate to the "Show Timeline" view, and click on "Show debug track" to set
31*6dbdd20aSAndroid Build Coastguard Worker   up a new debug track. Select "slice" from the Track type dropdown.
32*6dbdd20aSAndroid Build Coastguard Worker
33*6dbdd20aSAndroid Build Coastguard Worker   Note that the names of the columns in the result table do
34*6dbdd20aSAndroid Build Coastguard Worker   not necessarily have to be `name`, `ts`, or `dur`. Columns which
35*6dbdd20aSAndroid Build Coastguard Worker   _semantically_ match but have a different name can be selected from the
36*6dbdd20aSAndroid Build Coastguard Worker   drop-down selectors.
37*6dbdd20aSAndroid Build Coastguard Worker
38*6dbdd20aSAndroid Build Coastguard Worker   ![Create a new debug slice track](/docs/images/debug-tracks/slice-track-create.png)
39*6dbdd20aSAndroid Build Coastguard Worker
40*6dbdd20aSAndroid Build Coastguard Worker1. The debug slice track is visible as a pinned track near the top of the
41*6dbdd20aSAndroid Build Coastguard Worker   Timeline view with slices from the table from which the track was created
42*6dbdd20aSAndroid Build Coastguard Worker   (note that slices with no/zero duration will be displayed as instant events).
43*6dbdd20aSAndroid Build Coastguard Worker   Debug tracks may be manually unpinned and will appear on the top of other
44*6dbdd20aSAndroid Build Coastguard Worker   unpinned tracks.
45*6dbdd20aSAndroid Build Coastguard Worker   ![Resultant debug track](/docs/images/debug-tracks/slice-track-result.png)
46*6dbdd20aSAndroid Build Coastguard Worker
47*6dbdd20aSAndroid Build Coastguard Worker1. (Optional) Pivoted `slice` tracks are created by selecting a value from the
48*6dbdd20aSAndroid Build Coastguard Worker   "pivot" column.
49*6dbdd20aSAndroid Build Coastguard Worker
50*6dbdd20aSAndroid Build Coastguard Worker   Note: You can enter queries into the search box directly by typing `:` to
51*6dbdd20aSAndroid Build Coastguard Worker   enter SQL mode.
52*6dbdd20aSAndroid Build Coastguard Worker
53*6dbdd20aSAndroid Build Coastguard Worker   ![Creating pivoted debug slice tracks](/docs/images/debug-tracks/pivot-slice-tracks-create.png)
54*6dbdd20aSAndroid Build Coastguard Worker
55*6dbdd20aSAndroid Build Coastguard Worker   This will result in a debug slice track created for each distinct pivot
56*6dbdd20aSAndroid Build Coastguard Worker   value.
57*6dbdd20aSAndroid Build Coastguard Worker
58*6dbdd20aSAndroid Build Coastguard Worker   ![Resultant pivoted debug slice tracks](/docs/images/debug-tracks/pivot-slice-tracks-results.png)
59*6dbdd20aSAndroid Build Coastguard Worker
60*6dbdd20aSAndroid Build Coastguard Worker## Creating Debug `counter` Tracks
61*6dbdd20aSAndroid Build Coastguard Worker
62*6dbdd20aSAndroid Build Coastguard WorkerYou can create new debug `counter` tracks by following similar steps to the ones
63*6dbdd20aSAndroid Build Coastguard Workermentioned above:
64*6dbdd20aSAndroid Build Coastguard Worker
65*6dbdd20aSAndroid Build Coastguard Worker1. Run a SQL query, and ensure its results are `counter`-like (as described
66*6dbdd20aSAndroid Build Coastguard Worker   above).
67*6dbdd20aSAndroid Build Coastguard Worker
68*6dbdd20aSAndroid Build Coastguard Worker   ![Query for debug counter track](/docs/images/debug-tracks/counter-tracks-query.png)
69*6dbdd20aSAndroid Build Coastguard Worker1. Navigate to the Timeline view, and click on "Show debug track" to set up a
70*6dbdd20aSAndroid Build Coastguard Worker   new debug track. Select "counter" from the Track type dropdown and the
71*6dbdd20aSAndroid Build Coastguard Worker   semantically matching column names of interest.
72*6dbdd20aSAndroid Build Coastguard Worker
73*6dbdd20aSAndroid Build Coastguard Worker   ![Create a new debug counter track](/docs/images/debug-tracks/counter-tracks-create.png)
74*6dbdd20aSAndroid Build Coastguard Worker
75*6dbdd20aSAndroid Build Coastguard Worker1. The counter track will appear as a pinned track near the top of the Timeline view.
76*6dbdd20aSAndroid Build Coastguard Worker
77*6dbdd20aSAndroid Build Coastguard Worker   ![Resultant pivoted debug counter track](/docs/images/debug-tracks/counter-tracks-results.png)
78*6dbdd20aSAndroid Build Coastguard Worker
79*6dbdd20aSAndroid Build Coastguard Worker1. (Optional) Pivoted `counter` tracks are created by selecting a value from the
80*6dbdd20aSAndroid Build Coastguard Worker   "pivot" column.
81*6dbdd20aSAndroid Build Coastguard Worker
82*6dbdd20aSAndroid Build Coastguard Worker   ![Create a new debug counter track](/docs/images/debug-tracks/pivot-counter-tracks-create.png)
83*6dbdd20aSAndroid Build Coastguard Worker
84*6dbdd20aSAndroid Build Coastguard Worker   This will result in a debug counter track created for each distinct pivot
85*6dbdd20aSAndroid Build Coastguard Worker   value.
86*6dbdd20aSAndroid Build Coastguard Worker
87*6dbdd20aSAndroid Build Coastguard Worker   ![Resultant pivoted debug counter track](/docs/images/debug-tracks/pivot-counter-tracks-results.png)
88