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 38A wildcard can be used to collect all events in a category: 39 40```protobuf 41data_sources { 42 config { 43 name: "linux.ftrace" 44 ftrace_config { 45 ftrace_events: "ftrace/print" 46 ftrace_events: "sched/*" 47 } 48 } 49} 50``` 51 52The full configuration options for ftrace can be seen in [ftrace_config.proto](/protos/perfetto/config/ftrace/ftrace_config.proto). 53 54## Android system logs 55 56### Android logcat 57Include Android Logcat messages in the trace and view them in conjunction with other trace data. 58 59 60 61You can configure which log buffers are included in the trace. If no buffers are specified, all will be included. 62 63```protobuf 64data_sources: { 65 config { 66 name: "android.log" 67 android_log_config { 68 log_ids: LID_DEFAULT 69 log_ids: LID_SYSTEM 70 log_ids: LID_CRASH 71 } 72 } 73} 74``` 75 76You 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`. 77For details about configuration options, see [android\_log\_config.proto](/protos/perfetto/config/android/android_log_config.proto). 78 79The 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. 80 81If 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: 82 83```sql 84select * from android_logs where tag = "perfetto" order by ts 85``` 86 87### Android application tracing 88You can enable atrace through Perfetto. 89 90 91 92Add required categories to `atrace_categories` and set `atrace_apps` to a specific app to collect userspace annotations from that app. 93 94```protobuf 95data_sources: { 96 config { 97 name: "linux.ftrace" 98 ftrace_config { 99 atrace_categories: "view" 100 atrace_categories: "webview" 101 atrace_categories: "wm" 102 atrace_categories: "am" 103 atrace_categories: "sm" 104 atrace_apps: "com.android.phone" 105 } 106 } 107} 108```