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