Arnaldo Carvalho de Melo
5afa478d8d
[CLASSES]: Introduce struct tag
...
This should have been done from the start: all DW_TAG_s will be represented by
structs that has as its first member a struct tag, so that we can fully
represent the DWARF information, following csets will take continue the
restructuring.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-18 11:54:02 -02:00
Arnaldo Carvalho de Melo
7ebee113cc
[PAHOLE]: Check if we found the struct before calling class__is_struct
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-14 13:30:15 -02:00
Arnaldo Carvalho de Melo
9490088ae0
[CLASSES]: Use the struct cu backpointer
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 17:33:37 -02:00
Arnaldo Carvalho de Melo
0f5548a55f
[CODIFF]: New tool
...
1. build, save the object
2. change it, build
3. do the diff!
[acme@newtoy net-2.6.20]$ codiff /tmp/ipv6.ko.before /tmp/ipv6.ko.after | head -22
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/af_inet6.c:
inet6_init | +50
inet6_create | -15
inet6_getname | +13
inet6_sk_rebuild_header | +5
4 functions changed, 68 bytes added, 15 bytes removed
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/anycast.c:
ipv6_sock_ac_join | +7
1 function changed, 7 bytes added
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/ip6_output.c:
ip6_output2 | +14
ip6_sk_dst_lookup | -2
ip6_push_pending_frames | +5
ip6_xmit | +4
ip6_forward | +1
ip6_nd_hdr | +13
6 functions changed, 37 bytes added, 2 bytes removed
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/addrconf.c:
ipv6_rcv_saddr_equal | +16
[acme@newtoy net-2.6.20]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-11 16:31:04 -02:00
Arnaldo Carvalho de Melo
e45f877489
[MAKEFILE]: Use -Wall
...
And fix the warnings generated.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-11 14:15:50 -02:00
Arnaldo Carvalho de Melo
51c81fb099
[CLASSES]: namespace cleanups: just rename the classes__ with cu__
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-05 15:46:45 -02:00
Arnaldo Carvalho de Melo
633dd33a05
[PAHOLE]: Print cacheline boundaries
...
Cacheline size defaults to 32, sample output changing the default to 64 bytes:
pahole --cacheline=64 ../../acme/OUTPUT/qemu/net-2.6/net/ipv4/tcp.o inode
/* /pub/scm/linux/kernel/git/acme/net-2.6/include/linux/dcache.h:86 */
struct inode {
struct hlist_node i_hash; /* 0 8 */
struct list_head i_list; /* 8 8 */
struct list_head i_sb_list; /* 16 8 */
struct list_head i_dentry; /* 24 8 */
long unsigned int i_ino; /* 32 4 */
atomic_t i_count; /* 36 4 */
umode_t i_mode; /* 40 2 */
/* XXX 2 bytes hole, try to pack */
unsigned int i_nlink; /* 44 4 */
uid_t i_uid; /* 48 4 */
gid_t i_gid; /* 52 4 */
dev_t i_rdev; /* 56 4 */
loff_t i_size; /* 60 8 */
struct timespec i_atime; /* 68 8 */
struct timespec i_mtime; /* 76 8 */
struct timespec i_ctime; /* 84 8 */
unsigned int i_blkbits; /* 92 4 */
long unsigned int i_version; /* 96 4 */
blkcnt_t i_blocks; /* 100 4 */
short unsigned int i_bytes; /* 104 2 */
spinlock_t i_lock; /* 106 0 */
/* XXX 2 bytes hole, try to pack */
struct mutex i_mutex; /* 108 24 */
/* ---------- cacheline 2 boundary ---------- */
struct rw_semaphore i_alloc_sem; /* 132 12 */
struct inode_operations * i_op; /* 144 4 */
const struct file_operations * i_fop; /* 148 4 */
struct super_block * i_sb; /* 152 4 */
struct file_lock * i_flock; /* 156 4 */
struct address_space * i_mapping; /* 160 4 */
struct address_space i_data; /* 164 72 */
struct list_head i_devices; /* 236 8 */
union ; /* 244 4 */
int i_cindex; /* 248 4 */
__u32 i_generation; /* 252 4 */
long unsigned int i_dnotify_mask; /* 256 4 */
/* ---------- cacheline 4 boundary ---------- */
struct dnotify_struct * i_dnotify; /* 260 4 */
struct list_head inotify_watches; /* 264 8 */
struct mutex inotify_mutex; /* 272 24 */
long unsigned int i_state; /* 296 4 */
long unsigned int dirtied_when; /* 300 4 */
unsigned int i_flags; /* 304 4 */
atomic_t i_writecount; /* 308 4 */
void * i_private; /* 312 4 */
}; /* size: 316, sum members: 312, holes: 2, sum holes: 4 */
Has to be improved to show the other cacheline boundaries, that may be buried
into a included struct or union.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-05 15:34:54 -02:00
Arnaldo Carvalho de Melo
34b5f29576
[PAHOLE]: Add basic support for typedefs
...
[acme@newtoy guinea_pig-2.6]$ pahole mm/slab.o kmem_cache_t | head -6
/* include/linux/slab.h:12 */
struct kmem_cache {
struct array_cache *array[8]; /* 0 32 */
unsigned int batchcount; /* 32 4 */
unsigned int limit; /* 36 4 */
unsigned int shared; /* 40 4 */
[acme@newtoy guinea_pig-2.6]$ pahole --sizes fs/ext3/built-in.o | grep typedef | head -5
typedef pgd_t:struct(): 4 0
typedef pgprot_t:struct(): 4 0
typedef cpumask_t:struct(): 4 0
typedef mm_segment_t:struct(): 4 0
typedef raw_spinlock_t:struct(): 4 0
[acme@newtoy guinea_pig-2.6]$ pahole fs/ext3/built-in.o pgd_t
/* include/asm/page.h:57 */
struct {
long unsigned int pgd; /* 0 4 */
}; /* size: 4 */
[acme@newtoy guinea_pig-2.6]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-05 02:17:19 -02:00
Arnaldo Carvalho de Melo
1ec7e4aa18
[PAHOLE]: Dwarf trivia: show number of files that include a struct
...
[acme@newtoy guinea_pig-2.6]$ pahole -t ../../acme/OUTPUT/qemu/net-2.6/vmlinux | sort -k2 -nr | head -5
list_head 468
__wait_queue_head 466
timespec 466
rw_semaphore 466
plist_head 466
[acme@newtoy guinea_pig-2.6]$
Which leads to another, more non-trivia question, what if a struct
definition is included but there are no references to this function?
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-03 20:24:37 -03:00
Arnaldo Carvalho de Melo
6b82eae556
[PAHOLE]: getopt support
...
With some of the options in pfunct, such as:
[acme@newtoy guinea_pig-2.6]$ pahole --sizes kernel/sched.o | sort -k2 -nr | head -5
pglist_data: 3456
task_struct: 2704
rq: 2480
mmu_gather: 2040
zone: 1664
[acme@newtoy guinea_pig-2.6]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-02 13:47:37 -03:00
Arnaldo Carvalho de Melo
5aaca80de6
[CLASSES]: Rework the find_by routines
...
So that we can find all the cus for some specific class
(cus__find_class_by_name), or traverse all the CUs (cus__for_each_cu),
etc.
Now we don't look at just the first CU in multi-CU files (vmlinux, etc).
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-31 17:23:16 -03:00
Arnaldo Carvalho de Melo
0ca9826e36
Introduce struct cu, i.e. a per compilation unit struct that holds the list of
...
types for each CU, for now when working on multi-CU files (vmlinux, any binary
with more than one object file linked) we look only at the first CU when
looking for a specific class or function name, this will be fixed in the
upcoming csets, but doesn't affect the case when we don't specify a class or
function name, where all the CU's are traversed.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-31 16:12:42 -03:00
Arnaldo Carvalho de Melo
35e87417f9
Move the classes methods out of pahole.c and into classes.c,
...
that will be used by other new dwarves 8)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 18:22:42 -03:00
Arnaldo Carvalho de Melo
f4cc126c11
Separate finding the holes from printing the class, so that we are able to
...
print just the structs with holes, that indeed is what we do now if no class
name is passed.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 18:10:47 -03:00
Arnaldo Carvalho de Melo
01f021b2a7
Prefix the functions that create the classes list with "classes__",
...
in preparation to moving them to a library.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 14:16:29 -03:00
Arnaldo Carvalho de Melo
06672633cb
Move the top level dwarf traversal of the CUs to a new function,
...
classes__load().
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 14:08:46 -03:00
Arnaldo Carvalho de Melo
13ec307479
Move the global 'bf' buffer to the only place still using it.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:51:34 -03:00
Arnaldo Carvalho de Melo
3593eb45a6
Move the class and class_member structs to a new header file,
...
classes.h.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:45:59 -03:00
Arnaldo Carvalho de Melo
5c3d14ac09
Renane class__print to class__print_struct and make class__print
...
call it if the class ->tag is DW_TAG_structure_type, and do a basic
print for the other tags.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:37:20 -03:00
Arnaldo Carvalho de Melo
7f5ce05961
Initialize struct class->name in the constructor if no name was
...
informed.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:16:59 -03:00
Arnaldo Carvalho de Melo
23cc5e41cb
Get the file and line where the classes were declared and use it
...
in the printout.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 09:52:08 -03:00
Arnaldo Carvalho de Melo
98295e3fd2
Improve attr_numeric to handle more form types, convering DW_AT_type,
...
etc, so ditch attr_type().
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-27 17:51:18 -03:00
Arnaldo Carvalho de Melo
7dbb993d8b
Rename attr_unsigned to attr_numeric, simplifying it to not require a
...
Dwarf_Attribute to work on, as we just return a integer and it handles more
than just unsigned ints.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-27 15:04:18 -03:00
Arnaldo Carvalho de Melo
0c707643d7
Print the number of holes
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-26 03:31:58 -03:00
Arnaldo Carvalho de Melo
d36e7147f0
Stop using libdwarf from SGI, use the one in elfutils instead, the code got
...
much cleaner and now uses what seems to be a better maintained DWARF library
that hopefully works well on 64bit platforms, well see.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-26 03:06:32 -03:00
Arnaldo Carvalho de Melo
e5e7c6fc8b
Initialize nr_entries in class__new
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 15:21:34 -03:00
Arnaldo Carvalho de Melo
17025a38f2
Handle multi CU (Compile Unit) files, like vmlinux :-)
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 14:33:59 -03:00
Arnaldo Carvalho de Melo
aac0259cc0
Use return for consistency in main.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 14:03:44 -03:00
Arnaldo Carvalho de Melo
3acc236241
Support void pointers, i.e. DW_TAG_pointer_type with no DW_AT_type.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:47:54 -03:00
Arnaldo Carvalho de Melo
4881c2f0d2
Add a .gitignore file
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:32:07 -03:00
Arnaldo Carvalho de Melo
134120b796
Ditch the program_name variable, use "pahole" directly
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:29:38 -03:00
Arnaldo Carvalho de Melo
e01a32fddc
Remove leftover check_error variable.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:20:18 -03:00
Arnaldo Carvalho de Melo
2338691b42
Show the sum of the members sizeof only if there are holes, and if so print the
...
sum of all holes too.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:18:43 -03:00
Arnaldo Carvalho de Melo
031b291d9a
Add a copyright notice.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:49:47 -03:00
Arnaldo Carvalho de Melo
51a8d81527
bitfields, ugh, if you have, say:
...
struct foo {
char c:1;
int b:1;
short a:1;
};
the first byte_size for the first member (c) will be 1, as the "type"
is char, but the compiler combines all of them into a single 4 byte
bitfield, and the '4' only appear when the bit field has type int, in
the above case on the second member.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:46:26 -03:00
Arnaldo Carvalho de Melo
96ef1165ae
Add support for enum printing.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:42:53 -03:00
Arnaldo Carvalho de Melo
a4e260fc1a
Grr, another fix for bitfields, this time for a sequence of
...
bitfields, i.e. the offset changes from one bitfield to another.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:14:27 -03:00
Arnaldo Carvalho de Melo
e45d94f9de
Fix bitfield accounting, as I was assuming that the first field would be
...
at the 0 offset, but its not, so just look if the last member was in a
bitfield.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:01:18 -03:00
Arnaldo Carvalho de Melo
d4c95e9b49
Remove more dead code, we don't use the srcfile table.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 02:55:36 -03:00
Arnaldo Carvalho de Melo
9b15e948e4
Remove dead code
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 02:42:57 -03:00
Arnaldo Carvalho de Melo
23971435ad
Fix the struct declaration case.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 02:37:21 -03:00
Arnaldo Carvalho de Melo
e748ac69c3
Print the diff when the sum of the member sizeofs + the sum of the
...
holes is not equal to the size of the struct:
struct task_struct {
<SNIP>
}; /* sizeof struct: 1312, sum sizeof members: 1279 */
/* BRAIN FART ALERT! 1312 != 1279 + 25(holes), diff = 8 */
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 01:18:15 -03:00
Arnaldo Carvalho de Melo
99dd25f7f6
More output layout changes, this time for the elusive task_struct
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 01:04:26 -03:00
Arnaldo Carvalho de Melo
f517a01b6e
Support DW_TAG_volatile_type and DW_TAG_const_type.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:54:57 -03:00
Arnaldo Carvalho de Melo
668aec0284
Cosmetic, output layout tidyup to have struct sock output perfect,
...
its our supermodel 8)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:40:06 -03:00
Arnaldo Carvalho de Melo
034dafb614
Handle the case where DW_TAG_subroutine_type has no DW_AT_type, meaning
...
it doesn't have a return value, i.e. it "returns" void.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:27:29 -03:00
Arnaldo Carvalho de Melo
3e4d70ad47
Support bitfields, still not checking if there are bits available at
...
the end of it.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:18:05 -03:00
Arnaldo Carvalho de Melo
d07bbf65fc
Just some output layout changes.
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 23:28:37 -03:00
Arnaldo Carvalho de Melo
cc701e54a3
Check if the sum of the struct member sizeofs plus the sum of all the holes
...
found is equal to the sizeof of the structure and emit a "BRAIN FART ALERT!" if
this assertion fails, good news is that no such brain farts ocurred so far :-)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 23:09:46 -03:00
Arnaldo Carvalho de Melo
00a86e1267
For now don't print the "nameless structs", aka "typedef struct { } foo".
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 22:45:43 -03:00