1/* 2 * Copyright (C) 2018 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 * http://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 */ 16 17syntax = "proto2"; 18package perfetto.protos; 19 20// Metadata about the processes and threads in the trace. 21// Note: this proto was designed to be filled in by traced_probes and should 22// only be populated with accurate information coming from the system. Other 23// trace writers should prefer to fill ThreadDescriptor and ProcessDescriptor 24// in TrackDescriptor. 25message ProcessTree { 26 // Representation of a thread. 27 message Thread { 28 // The thread ID (as per gettid()) in the root PID namespace. 29 optional int32 tid = 1; 30 31 // Thread group id (i.e. the PID of the process, == TID of the main thread) 32 optional int32 tgid = 3; 33 34 // The name of the thread. 35 optional string name = 2; 36 37 // The non-root-level thread IDs if the thread runs in a PID namespace. Read 38 // from the NSpid entry of /proc/<tid>/status, with the first element (root- 39 // level thread ID) omitted. 40 repeated int32 nstid = 4; 41 } 42 43 // Representation of a process. 44 message Process { 45 // The UNIX process ID, aka thread group ID (as per getpid()) in the root 46 // PID namespace. 47 optional int32 pid = 1; 48 49 // The parent process ID, as per getppid(). 50 optional int32 ppid = 2; 51 52 // The command line for the process, as per /proc/pid/cmdline, broken up on 53 // NUL bytes. 54 // If it is a kernel thread or a zombie, there will only be one cmdline 55 // field and it will contain /proc/pid/comm. 56 repeated string cmdline = 3; 57 58 // If true, the |cmdline| field was filled with the main thread's "comm" 59 // field instead. 60 // Introduced in: perfetto v50. 61 optional bool cmdline_is_comm = 9; 62 63 // The uid for the process, as per /proc/pid/status. 64 optional int32 uid = 5; 65 66 // The non-root-level process IDs if the process runs in a PID namespace. 67 // Read from the NSpid entry of /proc/<pid>/status, with the first element 68 // (root-level process ID) omitted. 69 repeated int32 nspid = 6; 70 71 // Timestamp of when the process was created, in nanoseconds 72 // from boot. Parsed from starttime in /proc/pid/stat. 73 // Recorded if record_process_age config option is set. 74 // Resolution of "clock ticks", usually 10ms. 75 optional uint64 process_start_from_boot = 7; 76 77 // If true, the process is a kernel thread. 78 // Set only on linux v6.4+. For traces from older devices, it is possible to 79 // infer most kthreads by checking that they're a descendant of kthreadd 80 // (pid=2), or are the idle process (pid=0). 81 // Introduced in: perfetto v50. 82 optional bool is_kthread = 8; 83 84 // threads_deprecated 85 reserved 4; 86 } 87 88 // List of processes and threads in the client. These lists are incremental 89 // and not exhaustive. A process and its threads might show up separately in 90 // different ProcessTree messages. A thread might event not show up at all, if 91 // no sched_switch activity was detected, for instance: 92 // #0 { processes: [{pid: 10, ...}], threads: [{pid: 11, tgid: 10}] } 93 // #1 { threads: [{pid: 12, tgid: 10}] } 94 // #2 { processes: [{pid: 20, ...}], threads: [{pid: 13, tgid: 10}] } 95 repeated Process processes = 1; 96 repeated Thread threads = 2; 97 98 // The time at which we finish collecting this process tree; 99 // the top-level packet timestamp is the time at which 100 // we begin collection. 101 optional uint64 collection_end_timestamp = 3; 102} 103