3 - Use type information to pretty print raw data from stdin, all
4 documented in the man pages, further information in the csets.
6 TLDRish: this almost completely deciphers a perf.data file:
8 $ pahole ~/bin/perf --header=perf_file_header \
9 -C 'perf_file_attr(range=attrs),perf_event_header(range=data,sizeof,type,type_enum=perf_event_type+perf_user_event_type)' < perf.data
11 What the above command line does:
13 This will state that a 'struct perf_file_header' is available in BTF or DWARF
14 in the ~/bin/perf file and that at the start of stdin it should be used to decode
15 sizeof(struct perf_file_header) bytes, pretty printing it according to its members.
17 Furthermore, that header can be referenced later in the command line, for instance
18 that 'range=data' means that in the header, it expects a 'range' member in
19 'struct perf_file_header' to be used:
21 $ pahole ~/bin/perf --header=perf_file_header < perf.data
23 .magic = 3622385352885552464,
38 .adds_features = { 376537084, 0, 0, 0 },
42 That 'range' field is expected to have 'offset' and 'size' fields, so that
43 it can go on decoding a number of 'struct perf_event_header' entries.
45 That 'sizeof' in turn expects that in 'struct perf_event_header' there is a
46 'size' field stating how long that particular record is, one can also use
47 'sizeof=some_other_member_name'.
49 This supports variable sized records and then the 'type' field expects there
50 is a 'struct perf_event_type' member named 'type' (again, type=something_else
51 may be used. Finally, the value in the 'type' field is used to lookup an entry
52 in the set formed by the two enumerations specified in the 'type_enum=' argument.
54 If we look at these enums we'll see that its entries have names that can be,
55 when lowercased, point to structs containing the layout for the variable sized
56 record, which allows it to cast and produce the right pretty printed output.
58 I.e. using the kernel BTF info we get:
60 $ pahole perf_event_type
61 enum perf_event_type {
66 PERF_RECORD_THROTTLE = 5,
67 PERF_RECORD_UNTHROTTLE = 6,
70 PERF_RECORD_SAMPLE = 9,
71 PERF_RECORD_MMAP2 = 10,
73 PERF_RECORD_ITRACE_START = 12,
74 PERF_RECORD_LOST_SAMPLES = 13,
75 PERF_RECORD_SWITCH = 14,
76 PERF_RECORD_SWITCH_CPU_WIDE = 15,
77 PERF_RECORD_NAMESPACES = 16,
78 PERF_RECORD_KSYMBOL = 17,
79 PERF_RECORD_BPF_EVENT = 18,
80 PERF_RECORD_CGROUP = 19,
81 PERF_RECORD_TEXT_POKE = 20,
86 That is the same as in ~/bin/perf, and, if we get one of these and ask for
89 $ pahole -C perf_record_mmap ~/bin/perf
90 struct perf_record_mmap {
91 struct perf_event_header header; /* 0 8 */
94 __u64 start; /* 16 8 */
96 __u64 pgoff; /* 32 8 */
97 char filename[4096]; /* 40 4096 */
99 /* size: 4136, cachelines: 65, members: 7 */
100 /* last cacheline: 40 bytes */
104 Many other options were introduced to work with this, including --count,
105 --skip, etc, look at the man page for details.
107 - Store percpu variables in vmlinux BTF. This can be disabled when debugging
108 kernel features being developed to use it.
110 - pahole now should be segfault free when handling gdb test suit DWARF
111 files, including ADA, FORTRAN, rust and dwp compressed files, the
112 later being just flatly refused, that got left for v1.19.
114 - Bail out on partial units for now, avoiding segfaults and providing warning
115 to user, hopefully will be addressed in v1.19.
117 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>