Suggested by: Jeff Muizelaar.
And it was wrong in the sense that the help was like:
--executable|-e FILE <SNIP lots of other options> FILE
So now its a bit redundant, like:
--executable|-e FILE <SNIP lots of other options> -e FILE
But as this is the most common usage pattern, give it more visibility.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
1. if the first member is a bitfield, we have to have set current_bitfield_size to 0
prior to entering the loop.
2. If sizeof(last member) == 0, don't try to move it
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
The offset of a member in a class can be higher than 64KB (even if it doesn't
sound sane), without this change, if the offset overflowed, you would have got
the bitfield warning.
Committer note: I haven't bumped the SONAME because I haven't released yet the
0.0 release, so there is not yet a stable ABI.
Signed-off-by: Diego "Flameeyes" Pettenò <flameeyes@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Confusing huh? Think about ____cacheline_aligned_in_smp, and you'll get the
idea, look at this patch inline comment to understand the issue.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
E.g. in struct net_device when moving sysfs_groups[3] to after reg_state,
sizeof(sisfs_groups[3]) is 24 and the hole found after some reorganizing after
reg_state is 80 bytes, so align it just after reg_state, not 8 bytes after it.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
A more brute force approach: create a clone, reorganize it, if the resulting
size is less than the cloned class, it is packable.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Now we have:
[acme@filo pahole]$ pahole --help
Usage: pahole [OPTION...] [FILE] {[CLASS]}
-a, --anon_include include anonymous classes
-A, --nested_anon_include include nested (inside other structs) anonymous
classes
-B, --bit_holes=NR_HOLES Show only structs at least NR_HOLES bit holes
-c, --cacheline_size=SIZE set cacheline size to SIZE
-D, --decl_exclude=PREFIX exclude classes declared in files with PREFIX
-E, --expand_types expand class members
-H, --holes=NR_HOLES show only structs at least NR_HOLES holes
-m, --nr_methods show number of methods
-n, --nr_members show number of members
-N, --class_name_len show size of classes
-P, --packable show only structs that has holes that can be
packed
-R, --reorganize reorg struct trying to kill holes
-s, --sizes show size of classes
-S, --show_reorg_steps show the struct layout at each reorganization step
-t, --nr_definitions show how many times struct was defined
-V, --verbose be verbose
-x, --exclude=PREFIX exclude PREFIXed classes
-X, --cu_exclude=PREFIX exclude PREFIXed compilation units
Input Selection:
--debuginfo-path=PATH Search path for separate debuginfo files
-e, --executable=FILE Find addresses in FILE
-k, --kernel Find addresses in the running kernel
-K, --offline-kernel[=RELEASE] Kernel with all modules
-M, --linux-process-map=FILE Find addresses in files mapped as read from
FILE in Linux /proc/PID/maps format
-p, --pid=PID Find addresses in files mapped into process PID
-?, --help Give this help list
--usage Give a short usage message
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Now there is a cus__loadfl function that receives the tool argp tables and uses
libdwfl to process the DWARF info, with this RELA objects such as .o and .ko
files in a Linux kernel build are supported, and all the other goodies that
come from using libdwfl, such as separate debuginfo files, etc come as a bonus.
Now to convert the tools, pahole being the first, that already works well using
cus__loadfl().
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
[acme@filo examples]$ pahole -a mpg_audio_frame_t
/* <14f> /home/acme/git/pahole/examples/mpg_audio_frame_t.c:4 */
typedef struct {
uint16_t frame_sync; /* 0 2 */
uint8_t layer; /* 2 1 */
/* WARNING: DWARF offset=0, real offset=3 */
uint32_t mpeg25_bit:1; /* 0 4 */
uint32_t lsf_bit:1; /* 0 4 */
uint32_t bitrate_idx:4; /* 0 4 */
<SNIP>
So gcc combined a uint16_t + a uint8_t + the first entries in the uint32_t
bitfield that could fit in the 8 bits after the first two fields but haven't
updated the size of the bitfield (4) and wrote 0 as the offset, warn about such
inconsistencies.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
So that we print the boundary after the last member in a bitfield.
Spotted by Matthew Wilcox.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
[acme@mica pahole]$ pahole lala
pahole: Permission denied
[acme@mica pahole]$ pahole foo
pahole: No such file or directory
[acme@mica pahole]$ pahole ctracer.c
pahole: couldn't load DWARF info from ctracer.c
[acme@mica pahole]$
Thanks to Matthew Wilcox for noticing how lame it was :-)
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
And let the final binaries get it from that. Fixes building with
-Wl,--as-needed
Signed-off-by: Diego "Flameeyes" Pettenò <flameeyes@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
[acme@filo pahole]$ cat examples/expand_typedefs.c
<SNIP>
typedef struct {
int a, b, c;
} inner;
static struct outer {
int q, b;
inner m;
} foo;
<SNIP>
[acme@filo pahole]$ pahole --expand_types examples/expand_typedefs
/* <158> /home/acme/git/pahole/examples/expand_typedefs.c:7 */
struct outer {
int q; /* 0 4 */
int b; /* 4 4 */
/* typedef inner */ struct {
int a; /* 0 4 */
int b; /* 4 4 */
int c; /* 8 4 */
} m; /* 8 12 */
}; /* size: 20, cachelines: 1 */
/* last cacheline: 20 bytes */
/* definitions: 1 */
[acme@filo pahole]$
For now it does all typedef expansions, which in at least the base types may be
a bit too much, e.g. u32 -> unsigned long int, lets see if somebody complains,
perhaps even myself 8) If that is the case we can add yet another command line
option to specify that such base type expansions should be filtered out, making
the expand_types parameter be flag mask, not just a boolean as it is today.
To see a more complete output look at:
http://oops.ghostprotocols.net:81/acme/dwarves/vmlinux-pahole-expand_types-typedef_unfolding.txt
Suggested by Jeff Muizelaar.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
To tell where to find the elfutils/libdw.h, etc if they are not in the standard
system include dirs, i.e. its no use to find the paths if we don't tell the
cmake system to use the paths found 8)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>