pahole: Describe expected use of 'default' in the man page
[dwarves.git] / changes-v1.18
blob9b52efa181d020abda9a4a5a2d5f2061c1b74452
1 v1.18:
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
22     {
23             .magic = 3622385352885552464,
24             .size = 104,
25             .attr_size = 136,
26             .attrs = {
27                     .offset = 296,
28                     .size = 136,
29             },
30             .data = {
31                     .offset = 432,
32                     .size = 14688,
33             },
34                     .event_types = {
35                     .offset = 0,
36                     .size = 0,
37             },
38             .adds_features = { 376537084, 0, 0, 0 },
39     },
40     $
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 {
62         PERF_RECORD_MMAP = 1,
63         PERF_RECORD_LOST = 2,
64         PERF_RECORD_COMM = 3,
65         PERF_RECORD_EXIT = 4,
66         PERF_RECORD_THROTTLE = 5,
67         PERF_RECORD_UNTHROTTLE = 6,
68         PERF_RECORD_FORK = 7,
69         PERF_RECORD_READ = 8,
70         PERF_RECORD_SAMPLE = 9,
71         PERF_RECORD_MMAP2 = 10,
72         PERF_RECORD_AUX = 11,
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,
82         PERF_RECORD_MAX = 21,
83   };
84   $
86   That is the same as in ~/bin/perf, and, if we get one of these and ask for
87   that struct:
89   $ pahole -C perf_record_mmap ~/bin/perf
90   struct perf_record_mmap {
91         struct perf_event_header   header;               /*     0     8 */
92         __u32                      pid;                  /*     8     4 */
93         __u32                      tid;                  /*    12     4 */
94         __u64                      start;                /*    16     8 */
95         __u64                      len;                  /*    24     8 */
96         __u64                      pgoff;                /*    32     8 */
97         char                       filename[4096];       /*    40  4096 */
98   
99         /* size: 4136, cachelines: 65, members: 7 */
100         /* last cacheline: 40 bytes */
101   };
102   $
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>