Commit Graph

19 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 3ca40af1fd [CLASSES]: Add support for enums
Be it named enums such as:

/* include/linux/pid.h:7 */
enum pid_type {
	PIDTYPE_PID = 0,
	PIDTYPE_PGID = 1,
	PIDTYPE_SID = 2,
	PIDTYPE_MAX = 3,
};

Or nameless enums inside structs:

/* include/linux/journal-head.h:14 */
typedef struct transaction_s {
        journal_t *                t_journal;            /*     0     4 */
        tid_t                      t_tid;                /*     4     4 */
        enum {
		T_RUNNING = 0,
		T_LOCKED = 1,
		T_RUNDOWN = 2,
		T_FLUSH = 3,
		T_COMMIT = 4,
		T_FINISHED = 5,
	} t_state;                                       /*     8     4 */
        long unsigned int          t_log_start;          /*    12     4 */
<SNIP>
} transaction_t; /* size: 84, cachelines: 3 */
                 /* last cacheline: 20 bytes */

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 11:56:59 -02:00
Arnaldo Carvalho de Melo 3e7e387ddb [CLASSES]: Move passing the object file name from cus__new to cus__load
So that we can load many object files, that is what the next csets will
do, to recursively look for files with debug info in a build tree, such
as the kernel one.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 12:35:45 -02:00
Arnaldo Carvalho de Melo 67621fcea8 [CLASSES]: Codiff and prefcnt doesn't use the filter in cu__for_each_function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-18 15:42:03 -02:00
Arnaldo Carvalho de Melo 5c777371cd [CLASSES]: Make cu__for_each_class receive a filter
Same semantic as in the cus__for_each_cu filter.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-01 00:00:24 -02:00
Arnaldo Carvalho de Melo e5a400d01f [CLASSES]: Make cus__for_each_cu receive an optional filter
To simplify the callsites and make implementing the same thing on the other
dwarves (prefcnt, pfunct, etc) easy.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-30 23:48:34 -02:00
Arnaldo Carvalho de Melo bff3938037 [CLASSES]: Introduce struct function & struct parameter
And helper routines, so as to separate DW_TAG_subprogram from
the type tags (DW_TAG_structure_type, basic_type, etc).

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-18 14:33:48 -02:00
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 d3b9b9bfcf [CLASSES]: Add backpointer to class in inline_expansion
And several assorted tidy-ups.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-13 00:31:48 -02:00
Arnaldo Carvalho de Melo c49c7c8bee [CLASSES] class_member: add backpointer to the class
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 17:52:03 -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 570a00b29f [CLASSES] classes: Add a backpoint to the CU that owns the class
This fixes a problem with codiff usage of the ->class_to_diff member, as we
were looking at a different CU than the one intended, so we'd have to have a
pointer to the CU associated with ->class_to_diff, heck, its time to have this
backpointer :-)

Now to audit the rest of the code to look for simplifications since we now have
this backpointer and thus don't need to pass CU pointers around.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 16:59:47 -02:00
Arnaldo Carvalho de Melo 5d96b74eef [CODIFF]: Terse mode
Well, needs to be a bit more terse, as prints the types per CU, i.e. for
types defined in multiple CUs we get them repeated, but using grep +
sort -u does the trick.

[acme@newtoy pahole]$ codiff -t /tmp/ipv6.ko.before /tmp/ipv6.ko.after | grep ^struct | sort -u
struct inet_connection_sock: size, offset
struct inet_sock: size, nr_members, offset
struct proto: nr_members, type
struct raw6_sock: size, offset
struct tcp6_sock: size
struct tcp_sock: size, offset
struct udp_sock: size, offset
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 16:46:11 -02:00
Arnaldo Carvalho de Melo d99bee8d7b [CODIFF]: Detect and print all sorts of changes in structs
[acme@newtoy examples]$ cat struct.c

static struct foo {
	char	       a:2;
	unsigned int   b;
	unsigned long  c;
	unsigned long  d;
	unsigned long  e;
} bar;

int main(int argc, char *argv[])
{
    printf("%d", bar.a);
}
[acme@newtoy examples]$

Then change "a:2" to "a:4":

[acme@newtoy examples]$ codiff -V old_struct new_struct
struct.c:
  struct foo |   +0
    a:2;
     from: char                  /*     0(6)     1(2) */
     to:   char                  /*     0(4)     1(4) */
 1 struct changed

Now, on top of that move a after b:

[acme@newtoy examples]$ codiff -V old_struct new_struct
struct.c:
  struct foo |   +0
    a:2;
     from: char                  /*     0(6)     1(2) */
     to:   char                  /*     4(4)     1(4) */
    b;
     from: unsigned int          /*     4(0)     4(0) */
     to:   unsigned int          /*     0(0)     4(0) */
 1 struct changed
[acme@newtoy examples]$

Move it back a to before b and change the type of e without changing its size,
i.e. from unsigned long to long:

[acme@newtoy examples]$ codiff -V old_struct new_struct
struct.c:
  struct foo |   +0
    a:2;
     from: char                  /*     0(6)     1(2) */
     to:   char                  /*     0(4)     1(4) */
    e;
     from: long unsigned int     /*    16(0)     4(0) */
     to:   long int              /*    16(0)     4(0) */
 1 struct changed
[acme@newtoy examples]$

Now on top of this lets delete the c member:

[acme@newtoy examples]$ codiff -V old_struct new_struct
struct.c:
  struct foo |   -4
   nr_members: -1
    -long unsigned int          c;                    /*     8     4 */
    a:2;
     from: char                  /*     0(6)     1(2) */
     to:   char                  /*     0(4)     1(4) */
    d;
     from: long unsigned int     /*    12(0)     4(0) */
     to:   long unsigned int     /*     8(0)     4(0) */
    e;
     from: long unsigned int     /*    16(0)     4(0) */
     to:   long int              /*    12(0)     4(0) */
 1 struct changed
[acme@newtoy examples]$

WOW, many changes, what an ABI breakage, no? :-)

It started as:

[acme@newtoy examples]$ pahole old_struct foo
/* /home/acme/pahole/examples/struct.c:3 */
struct foo {
        char                       a:2;                  /*     0     1 */

        /* XXX 3 bytes hole, try to pack */

        unsigned int               b;                    /*     4     4 */
        long unsigned int          c;                    /*     8     4 */
        long unsigned int          d;                    /*    12     4 */
        long unsigned int          e;                    /*    16     4 */
}; /* size: 20, sum members: 17, holes: 1, sum holes: 3 */

And ended up as:

[acme@newtoy examples]$ pahole new_struct foo
/* /home/acme/pahole/examples/struct.c:3 */
struct foo {
        char                       a:4;                  /*     0     1 */

        /* XXX 3 bytes hole, try to pack */

        unsigned int               b;                    /*     4     4 */
        long unsigned int          d;                    /*     8     4 */
        long int                   e;                    /*    12     4 */
}; /* size: 16, sum members: 13, holes: 1, sum holes: 3 */

[acme@newtoy examples]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 15:07:21 -02:00
Arnaldo Carvalho de Melo c322523dfd [CODIFF]: Add --verbose to show diff details (members removed, etc)
First step:

Show if struct members were removed or added:

[acme@newtoy net-2.6.20]$ codiff -sV /tmp/ipv6.ko.before /tmp/ipv6.ko.after
<SNIP>
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/tcp_ipv6.c:
  struct inet_sock            |   -4
   nr_members: -1
  struct inet_connection_sock |   -4
  struct tcp_sock             |   -4
  struct tcp6_sock            |   -4
 4 structs changed
<SNIP>

Oh, so struct inet_sock must be one of the members of the other structs that
haven't had changes in its number of members? Yes, this is the case :-)

Now lets see _which_ members were removed, added or had its type changed
causing a reduction in the struct size.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 12:56:52 -02:00
Arnaldo Carvalho de Melo 05b84f1c1c [CODIFF]: Allow showing only structs or function diffs
[acme@newtoy net-2.6.20]$ codiff --help
usage: codiff [options] <old_file> <new_file>
 where:
   -h, --help        usage options
   -s, --structs     show struct diffs
   -f, --functions   show function diffs
 without options all diffs are shown
[acme@newtoy net-2.6.20]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 12:41:44 -02:00
Arnaldo Carvalho de Melo e4f5c8395c [CODIFF]: Show structure changes
[acme@newtoy net-2.6.20]$ codiff /tmp/ipv6.ko.before /tmp/ipv6.ko.after | head -12
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/af_inet6.c:
  struct inet_sock        |   -4
 1 struct changed
  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
[acme@newtoy net-2.6.20]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 12:29:33 -02:00
Arnaldo Carvalho de Melo 03122517ec [CODIFF]: Move printing total stats diff to separate function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-12 11:09:15 -02:00
Arnaldo Carvalho de Melo 5e1bd5145e [CODIFF]: Print total stats on multi-cu files
[acme@newtoy net-2.6.20]$ codiff /tmp/ipv6.ko.before ../OUTPUT/qemu/net-2.6.20/net/ipv6/ipv6.ko | tail -7
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/inet6_connection_sock.c:
 inet6_csk_addr2sockaddr |   +2
 inet6_csk_xmit          |   +6
2 functions changed, 8 bytes added

../OUTPUT/qemu/net-2.6.20/net/ipv6/ipv6.ko:
 45 functions changed, 390 bytes added, 298 bytes removed
[acme@newtoy net-2.6.20]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-11 23:14:02 -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