xref: /aosp_15_r20/external/perfetto/docs/data-sources/system-log.md (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1## Syscalls
2The enter and exit of all syscalls can be tracked in Perfetto traces.
3
4
5The following ftrace events need to added to the trace config to collect syscalls.
6
7```protobuf
8data_sources: {
9    config {
10        name: "linux.ftrace"
11        ftrace_config {
12            ftrace_events: "raw_syscalls/sys_enter"
13            ftrace_events: "raw_syscalls/sys_exit"
14        }
15    }
16}
17```
18
19## Linux kernel tracing
20Perfetto integrates with [Linux kernel event tracing](https://www.kernel.org/doc/Documentation/trace/ftrace.txt).
21While Perfetto has special support for some events (for example see [CPU Scheduling](#cpu-scheduling)) Perfetto can collect arbitrary events.
22This config collects four Linux kernel events:
23
24```protobuf
25data_sources {
26  config {
27    name: "linux.ftrace"
28    ftrace_config {
29      ftrace_events: "ftrace/print"
30      ftrace_events: "sched/sched_switch"
31      ftrace_events: "task/task_newtask"
32      ftrace_events: "task/task_rename"
33    }
34  }
35}
36```
37
38The full configuration options for ftrace can be seen in [ftrace_config.proto](/protos/perfetto/config/ftrace/ftrace_config.proto).
39
40## Android system logs
41
42### Android logcat
43Include Android Logcat messages in the trace and view them in conjunction with other trace data.
44
45![](/docs/images/android_logs.png)
46
47You can configure which log buffers are included in the trace. If no buffers are specified, all will be included.
48
49```protobuf
50data_sources: {
51    config {
52        name: "android.log"
53        android_log_config {
54            log_ids: LID_DEFAULT
55            log_ids: LID_SYSTEM
56            log_ids: LID_CRASH
57        }
58    }
59}
60```
61
62You may also want to add filtering on a tags using the `filter_tags` parameter or set a min priority to be included in the trace using `min_prio`.
63For details about configuration options, see [android\_log\_config.proto](/protos/perfetto/config/android/android_log_config.proto).
64
65The logs can be investigated along with other information in the trace using the [Perfetto UI](https://ui.perfetto.dev) as shown in the screenshot above.
66
67If using the `trace_processor`, these logs will be in the [android\_logs](/docs/analysis/sql-tables.autogen#android_logs) table. To look at the logs with the tag ‘perfetto’ you would use the following query:
68
69```sql
70select * from android_logs where tag = "perfetto" order by ts
71```
72
73### Android application tracing
74You can enable atrace through Perfetto.
75
76![](/docs/images/userspace.png)
77
78Add required categories to `atrace_categories` and set `atrace_apps` to a specific app to collect userspace annotations from that app.
79
80```protobuf
81data_sources: {
82    config {
83        name: "linux.ftrace"
84        ftrace_config {
85            atrace_categories: "view"
86            atrace_categories: "webview"
87            atrace_categories: "wm"
88            atrace_categories: "am"
89            atrace_categories: "sm"
90            atrace_apps: "com.android.phone"
91        }
92    }
93}
94```