Commit Graph

584 Commits

Author SHA1 Message Date
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
Arnaldo Carvalho de Melo 950fbc7110 [PGLOBAL]: Convert to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:33:17 -03:00
Arnaldo Carvalho de Melo 0004a8ea7a [DTAGNAMES]: Fix cus__print_error_msg prog name
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:33:00 -03:00
Arnaldo Carvalho de Melo 4b733527ed [PREFCNT]: No need to use getopt
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:25:25 -03:00
Arnaldo Carvalho de Melo b7cd0b6fdf [CTRACER]: Convert to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 11:16:50 -03:00
Arnaldo Carvalho de Melo 0f8e3423b5 [CODIFF]: Fix bug in diff_struct
We weren't initializing new_structure when a struct was removed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:59:04 -03:00
Arnaldo Carvalho de Melo 6bcf3751df [CODIFF]: Convert codiff to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:37:37 -03:00
Arnaldo Carvalho de Melo 78beb03ca1 [PFUNCT]: Convert to argp
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:24:13 -03:00
Arnaldo Carvalho de Melo 5f1ba48d5e [PAHOLE]: Convert to argp
Paving the way to move from libdw to libdwfl.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-30 10:07:01 -03:00
Arnaldo Carvalho de Melo 0dcc856a7f [LIB]: Emit a warning when the compiler gets the byte_offset (seemingly) wrong
[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>
2007-03-29 11:25:02 -03:00
Arnaldo Carvalho de Melo 27ac8cec6c [LIB]: Only check if it is a cacheline boundary when the offset changes
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>
2007-03-28 13:21:27 -03:00
Arnaldo Carvalho de Melo c87d8d831a [ALL]: Emit better diagnostic messages
[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>
2007-03-28 12:54:46 -03:00