By default, pahole will display the offsets of the inner struct members from
the top level struct. If the user wants to focus on some inner structs, just
call the tool with the -r option to use relative offset instead of the base
offset.
Signed-off-by: Eugene Teo <eteo@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
So that we can go on adding more config knobs without requiring adding new
parameters to lots of functions.
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>
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>
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>
[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>
So that we get rid of all the buffer limits, if we need to format into strings
we can use string streams, like we're doing now in just one case, tag__name for
DW_TAG_subroutine_type, that is bogus as it is, as we need to have the name of
the type inside the type declaration (void (*type_name)(parameters)) and not
after (void (*)(parameters) type_name)), but leave this for an upcoming cset.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
And use it in a new tool, pglobal, that shows global variables and functions.
Signed-off-by: Davi Arnaut <davi@haxent.com.br>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
So that in tools like ctracer we can print to a file, most of the tools just
pass stdout, keeping the previous behaviour.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Will be used in ctracer to create a struct subset with just the types for which
we have "collectors", i.e. functions that reduce complex types to base types
that will be put in the mini-struct, that will be as tightly packed as it can
be.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>