Commit Graph

495 Commits

Author SHA1 Message Date
Eugene Teo 93183ec9ee [PAHOLE]: Added an option -r to use rel_offset when printing inner structs
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>
2007-05-02 16:14:20 -03:00
Arnaldo Carvalho de Melo 224ba634ee [LIB]: Make ftype__fprintf_parms optionally indent parameters
One per line.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-30 16:37:18 -03:00
Arnaldo Carvalho de Melo ccb9ff1b29 [LIB]: Introduce ftype__fprintf_parms
So that we can print just the list of arguments.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-30 16:26:29 -03:00
Arnaldo Carvalho de Melo 5d1513d035 [LIB]: Print the inline expansion sizes when printing a function
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-30 16:10:54 -03:00
Arnaldo Carvalho de Melo 5adafd00c4 [CODIFF]: Use cus__loadfl/libdwfl
This argv munging seems gross, but nah, there are persons wanting to use codiff
on RELA architectures such as x86_64 so lets go with this for now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-30 15:44:11 -03:00
Arnaldo Carvalho de Melo 27e77b8bc4 [PREFCNT]: reference count functions
Cut'n'paste error, was never looking into DW_TAG_subprogram tags.

Also traverse the forest of lexblocks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 17:19:50 -03:00
Arnaldo Carvalho de Melo c3381fbd08 [LIB]: Add missing newline in cus__emit_typedef_definitions
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 16:58:03 -03:00
Arnaldo Carvalho de Melo 210921279a [LIB]: Fix problem introduced by the conf_fprintf work
type__emit needs to use .emit_stats = 1 or emit the ';', do the former.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 16:49:10 -03:00
Arnaldo Carvalho de Melo 0a6607d22c [CTRACER]: Fix conversion to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 16:15:34 -03:00
Arnaldo Carvalho de Melo 262a5d24ea [LIB]: Introduce conf_fprintf
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>
2007-04-28 16:13:35 -03:00
Arnaldo Carvalho de Melo 711d96943a [LIB]: Use a base_offset when printing inner structs
That way we can have the offsets from the top level struct. If the user wants
to focus some inner struct, just call the tool again specifying the inner
struct name.

Perhaps this is not so clear, shoot me, erm, no, an example should help. Look
at the member offsets (first column in the comment after each member), before
and after:

before:

acme@filo pahole]$ pahole -C tcp_sock --expand_types examples/net
/* <12a> examples/expand.c:18 */
struct tcp_sock {
	struct inet_sock {
		struct sock {
			int        protocol;     /*     0     4 */
			struct spinlock {
				int magic;       /*     0     4 */
				int counter;     /*     4     4 */
			} sklock; /*     4     8 */
			int        b;            /*    12     4 */
			int        c;            /*    16     4 */
		} sk; /*     0    20 */
		long int           daddr;        /*    20     4 */
	} inet; /*     0    24 */
	long int                   cwnd;         /*    24     4 */
	struct spinlock {
		int                magic;        /*     0     4 */
		int                counter;      /*     4     4 */
	} lock; /*    28     8 */
}; /* size: 36, cachelines: 1 */
   /* last cacheline: 36 bytes */

After:

acme@filo pahole]$ pahole -C tcp_sock --expand_types examples/net
/* <12a> examples/expand.c:18 */
struct tcp_sock {
	struct inet_sock {
		struct sock {
			int        protocol;     /*     0     4 */
			struct spinlock {
				int magic;       /*     4     4 */
				int counter;     /*     8     4 */
			} sklock; /*     4     8 */
			int        b;            /*    12     4 */
			int        c;            /*    16     4 */
		} sk; /*     0    20 */
		long int           daddr;        /*    20     4 */
	} inet; /*     0    24 */
	long int                   cwnd;         /*    24     4 */
	struct spinlock {
		int                magic;        /*    28     4 */
		int                counter;      /*    32     4 */
	} lock; /*    28     8 */
}; /* size: 36, cachelines: 1 */
   /* last cacheline: 36 bytes */

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 10:01:54 -03:00
Arnaldo Carvalho de Melo 55dd0a7efa [LIB]: Move variable to inside only scope that uses it
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-28 09:07:35 -03:00
Arnaldo Carvalho de Melo ddc45f12be [RPM]: Rename libdwarves-devel to libdwarves1-devel
To comply with fedora packaging policy.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-26 11:53:21 -03:00
Arnaldo Carvalho de Melo 4325358170 [RPM]: First batch of fixes to comply with fedora packaging policy
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-26 11:06:09 -03:00
Arnaldo Carvalho de Melo ee12d416f3 [CMAKE]: Allow specifying CMAKE_BUILD_TYPE
Defaults to "Debug", but the rpm will use "MinSizeRel"

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-26 11:02:20 -03:00
Arnaldo Carvalho de Melo f85781d5b9 [LIB]: Allow of not specifying -e
cus__loadfl will just insert the -e and pass it up to dwfl_standard_argp.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-24 16:09:34 -03:00
Arnaldo Carvalho de Melo 19ca955ec6 [CMAKE]: Make the default install prefix be /usr/local
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-19 18:01:47 -03:00
Arnaldo Carvalho de Melo bd4e74162c [PAHOLE]: Handle typedef'ed anonymous structs in --reorganize
In fact in any place that uses -a.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-04 14:44:56 -03:00
Arnaldo Carvalho de Melo e8926e6bc0 [PAHOLE]: Make -x work with anonymous structs
Just look for a typedef that points to the anonymous struct, if it matches
the -x prefix, exclude it.

[acme@filo pahole]$ pahole -PAae examples/anonymous_struct_typedef
/home/acme/git/pahole/examples/anonymous_struct_typedef.c:12    12     8     4
teste_t                             12     8     4
[acme@filo pahole]$ pahole -x teste -PAae examples/anonymous_struct_typedef
/home/acme/git/pahole/examples/anonymous_struct_typedef.c:12    12     8     4
[acme@filo pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-04 14:21:41 -03:00
Arnaldo Carvalho de Melo 6ddeeb3b90 [PAHOLE]: For real anonymous structs print file:line where was defined
For example, the inner, anonymous struct here:

struct {
        int d;
        int z;
        struct {
                short a;
                int  b;
                char  c;
        };
} biba = { .d = 2, };

[acme@filo pahole]$ pahole --packable --anon_include --nested_anon_include -e examples/anonymous_struct_typedef
/home/acme/git/pahole/examples/anonymous_struct_typedef.c:12    12     8     4
teste_t                             12     8     4
[acme@filo pahole]$

The long options can be shortened to -PAae :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-04 14:11:40 -03:00
Arnaldo Carvalho de Melo a62ebae88b [PAHOLE]: Look for a typedef pointing to anonymous structs in --packable
Problem reported by Diego 'Flameeyes' Pettenò. Thanks!

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-04 13:59:54 -03:00
Arnaldo Carvalho de Melo 786ef46234 [TOOLS]: Give "-e FILE", the basic way of using most tools, more visibility
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>
2007-04-04 08:29:21 -03:00
Jeff Muizelaar 1d473d951e [CMAKE]: Add rules for checking libebl installation
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-04 08:23:41 -03:00
Arnaldo Carvalho de Melo 8615c1c416 [RPM]: 18th release
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-03 09:15:02 -03:00
Arnaldo Carvalho de Melo f3c4f527f7 [PAHOLE]: Rework the output of pahole --packable
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-03 09:11:06 -03:00
Arnaldo Carvalho de Melo 5df74480e4 [LIB]: Detect adjacent bitfields and avoid, for now, moving the first ones
See the comment in the cset for further information.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-03 08:21:26 -03:00
Arnaldo Carvalho de Melo 757765a779 [LIB]: Disable some code in class__find_next_bit_hole_of_size
See the comment in the cset.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-03 08:00:04 -03:00
Arnaldo Carvalho de Melo 983fef74b2 [LIB]: Initialize bitfield_head to NULL in class__demote_bitfields
For the cases where the first member in a struct is part of a bitfield.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-02 19:41:09 -03:00
Arnaldo Carvalho de Melo 9a2f107820 [LIB]: Fix some more reorganize bugs
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>
2007-04-02 10:50:49 -03:00
Arnaldo Carvalho de Melo 06a81a80ef [RPM]: 17th release
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-02 10:18:39 -03:00
Arnaldo Carvalho de Melo 1ec66565a1 [PAHOLE]: Change the output of --packable to show orig size, new size and the diff
[acme@filo pahole]$ pahole --packable -e examples/dccp.ko.x86_64 | sort -k5 -nr | head -5
net_device: 1664 -> 1448: 216
module: 16960 -> 16848: 112
hh_cache: 192 -> 80: 112
zone: 2752 -> 2672: 80
softnet_data: 1792 -> 1728: 64
[acme@filo pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-02 10:12:09 -03:00
Diego "Flameeyes" Pettenò 18d620ee3c [LIB]: Expand the size of offset field for class_member to 32-bit.
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>
2007-04-01 22:08:21 -03:00
Arnaldo Carvalho de Melo a27a17088f [LIB]: Fill holes by moving members from the tail to after the hole
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-01 13:32:02 -03:00
Arnaldo Carvalho de Melo 286d96c520 [LIB]: Avoid moving the next member to after the current member
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>
2007-04-01 12:07:09 -03:00
Arnaldo Carvalho de Melo 46d3c408f0 [LIB]: Members bigger than cu->addr_size should be aligned by cu->addr_size
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>
2007-04-01 11:36:21 -03:00
Arnaldo Carvalho de Melo bf6ee86eae [LIB]: Use class__find_holes more frequently
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-01 10:33:36 -03:00
Arnaldo Carvalho de Melo 2626f863c1 [LIB]: Call class__find_holes in class__reorganize
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-01 10:10:50 -03:00
Arnaldo Carvalho de Melo 57ff4ea736 [PAHOLE] In --packable show just the savings when not in verbose mode
Example:

[acme@filo pahole]$ pahole -P -e examples/dccp.ko.x86_64 | sort -k2 -nr | head -20
hh_cache: 112
softnet_data: 64
task_struct: 56
net_device: 56
module: 32
inet_hashinfo: 32
zone: 24
device: 24
thread_struct: 16
super_block: 16
mm_struct: 16
dccp_sock: 16
block_device: 16
socket: 8
signal_struct: 8
sighand_struct: 8
rt6_info: 8
proto: 8
pglist_data: 8
nf_bridge_info: 8
[acme@filo pahole]$

Some may well be false positives or gcc DWARF emitter artifacts, checking...

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-01 10:03:04 -03:00
Arnaldo Carvalho de Melo ef79438fc2 [LIB]: Find base types of 8 bytes on 32 and 64 bits
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-01 09:44:53 -03:00
Arnaldo Carvalho de Melo 57fce1596b [PAHOLE]: Use class__reorganize in class__packable
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>
2007-04-01 09:31:35 -03:00
Arnaldo Carvalho de Melo 416f00a81b [LIB]: Emit comment about moving to the padding in class__move_member only if in verbose mode
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-04-01 09:30:21 -03:00
Arnaldo Carvalho de Melo 1a9cabdbf8 [RPM]: 16th release
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 14:21:32 -03:00
Arnaldo Carvalho de Melo fd35423175 [PREFCNT]: Use libdwfl
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 14:07:09 -03:00
Arnaldo Carvalho de Melo cbdcd5fed9 [PGLOBAL]: Use libdwfl
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 14:02:33 -03:00
Arnaldo Carvalho de Melo e3be206009 [DTAGNAMES]: Use libdwfl
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 14:00:36 -03:00
Arnaldo Carvalho de Melo 712c9f76d8 [PDWTAGS]: Use libdwfl
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 13:54:59 -03:00
Arnaldo Carvalho de Melo df2a515d4f [LIB]: Allow passing a NULL argp to cus__loadfl
For tools such as pdwtags, that don't have any further options.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 13:54:14 -03:00
Arnaldo Carvalho de Melo cd07fdbaf0 [PFUNCT]: Use cus__loadfl, aka libdwfl
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 13:45:57 -03:00
Arnaldo Carvalho de Melo 61609b4364 [PAHOLE]: Use cus__loadfl, i.e. libdwfl
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>
2007-03-30 13:25:51 -03:00
Arnaldo Carvalho de Melo 26ea852c17 [LIB]: Moving to libdwfl
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>
2007-03-30 13:22:28 -03:00