Commit Graph

120 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo c3f6f8b79f dwarves_emit: Introduce type_emissions
We may want to work on just one object file, not on a multi cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 11:26:51 -03:00
Arnaldo Carvalho de Melo aa22f16f56 codiff: Detect changes in the prototype even when function size doesn't changes
[acme@doppio pahole]$ codiff -V examples/tag-v6 examples/tag
tag.c:
   |   +0 # 42 -> 42, prototype: int (struct tag * self, int bar) -> unsigned int (struct tag * self, int bar)
 1 function changed, diff: +0
[acme@doppio pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-06 13:48:28 -03:00
Arnaldo Carvalho de Melo 5488b1dbde [DWARVES]: Check if any cu was found
Reported-by: Diego 'Flameeyes' Pettenò <flameeyes@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-05-12 15:25:45 -03:00
Arnaldo Carvalho de Melo fb809733cc [DWARVES]: Introduce tag__assert_search_result
For correctly created and completely parsed debugging information the type will
always be found, but as we still need to parse more tags and expecting
debugging information to be always correctly built is not sane... sprinkle some
asserts.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-20 18:56:36 -03:00
Arnaldo Carvalho de Melo ac6a9a6745 [CODIFF]: Allow passing /dev/null as one of the files to compare
If passed as the old file, all functions in the new file will appear as being
new, etc.

Suggested by Ilpo Järvinen.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-31 10:05:02 -02:00
Arnaldo Carvalho de Melo 46d63102eb [DWARVES]: Fixup usage messages
Thanks to Ilpo Järvinen for getting this to my attention.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-31 09:30:55 -02:00
Arnaldo Carvalho de Melo 0a7fabf304 [CODIFF]: Check if the objects are the same when we have build-id
Speeding up the process, no need to check for changes in the same object file,
be it standalone or part of a multi-cu file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-14 15:48:03 -02:00
Arnaldo Carvalho de Melo 8e099cf5d1 [CODIFF]: Ignore DW_TAG_subprogram tags with DW_AT_abstract_origin
We're not interested in aliases, where we don't have the DW_AT_inline
information we need.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-03 23:34:51 -02:00
Ilpo Järvinen f9fd585591 [CODIFF]: Be even more consistent on the summary lines
Forgotten change similar to the previous patch.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-03 21:33:02 -02:00
Arnaldo Carvalho de Melo aebb6313c0 [CODIFF]: Be consistent on the summary lines
I.e. always print "diff: N", e.g.:

 2 functions changed, 78 bytes removed, diff: -78

/home/acme/git/net-2.6.25/net/ipv4/tcp_input.c:
tcp_sack_extend |  +34
 1 function changed, 34 bytes added, diff: +34

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-03 14:55:20 -02:00
Arnaldo Carvalho de Melo 2d5c5b7438 [CODIFF]: Handle (un)inlining of functions
Thanks to Ilpo Järvinen for reporting that codiff was not reporting such changes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-03 13:03:32 -02:00
Arnaldo Carvalho de Melo f7b1128d6f [CODIFF]: Show changes to a struct only on the first object file it appears
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-17 11:27:24 -02:00
Arnaldo Carvalho de Melo 5bc698ab1b [DUTIL]: Move __unused definition to dutil.h
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-16 14:47:59 -02:00
Arnaldo Carvalho de Melo bd4d998ea2 [CODIFF]: Remove unused goto label
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-08 01:50:25 -02:00
Arnaldo Carvalho de Melo 6c7a1721ec [DWARVES]: Tell cu__find_struct_by_name if struct declarations are wanted
When we are looking for members of some type in all CUs it may be that in
some CU we don't have the full type, but just a declaration.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-11-16 18:16:56 -02:00
Arnaldo Carvalho de Melo 60737d18e3 [CODIFF]: Fix the new structs case
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-09-27 10:18:42 -03:00
Arnaldo Carvalho de Melo 4ca65f4e1d [CODIFF]: Don't show a struct diff when the struct is not present in the new object file
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-09-26 14:23:11 -03:00
Arnaldo Carvalho de Melo cf124f1636 [LIB]: Introduce tag__is_struct() for a common idiom
And also to get this less, ho-hum, DWARF specific.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-05-31 01:53:01 -03:00
Arnaldo Carvalho de Melo e59b1ebb05 [LIB]: Support DW_AT_specification in DW_TAG_structure_type tags
C++ uses this, and to cache the result of the lookup at type__name time we need
to pass the cu to class__name and type__name. Big fallout because of that :-\

But now the output is mucho embelished by the humongous strings representing
C++ templates.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-05-24 18:45:34 -03:00
Arnaldo Carvalho de Melo c0cbf4fa94 [LIB]: Introduce type__for_each_member
Will be useful to show that the intent is to traverse just the DW_TAG_member
entries in the type list. Right now there are both DW_TAG_inheritance and
DW_TAG_member entries in the ->members type list. But there will be many more
tags, like enumerations, classes, etc, that are defined inside classes, a C++
feature. This will also help with DW_TAG_namespace support.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-05-23 21:43:01 -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 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 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
Arnaldo Carvalho de Melo 7bd8fb3c43 [LIB]: Fix compiler warnings on 64bits
Mostly related to size_t, Dwarf_Off -> (unsigned long long), etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-03-28 11:38:32 -03:00
Arnaldo Carvalho de Melo a2b4f4fd6f [CODIFF]: Look for diffs in the number and total size of inline expansions:
Example

/home/acme/git/net-2.6/net/ipv4/tcp_input.c:
  tcp_prune_queue |  +24 : 683 -> 707, size inlines: 389 -> 417

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-02-24 23:12:34 -02:00
Arnaldo Carvalho de Melo b5baabcd16 [ALL]: Fixup warnings
Using export CFLAGS="-Wall -Wfatal-errors -Wformat=2 -Wsequence-point -Wextra
-Wno-parentheses -g", suggested by Davi Arnault, amazing how cruft piles up
when one is not looking ;)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-01-29 10:42:03 -02:00
Arnaldo Carvalho de Melo 812406d9fb [LIB]: Use sysconf to get the L1 cacheline size
As suggested by Ulrich Drepper.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
2007-01-18 21:41:25 -02:00
Arnaldo Carvalho de Melo d385563a53 [LIB]: Make the function methods return and receive a struct tag
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 15:47:26 -02:00
Arnaldo Carvalho de Melo 30b6aa2f73 [LIB]: Rename classes.[ch] to dwarves.[ch]
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 16:07:05 -02:00
Arnaldo Carvalho de Melo 5828563c91 [CODIFF]: Stop using class_member__names
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 15:10:57 -02:00
Arnaldo Carvalho de Melo 770f579b71 [CODIFF]: Show a diff when bytes were removed and added
build/libclasses.so:
 36 functions changed, 3334 bytes added, 3348 bytes removed, diff: -14
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 12:22:03 -02:00
Arnaldo Carvalho de Melo 49907df8a9 [CODIFF]: in verbose mode show if a function was removed or added
[acme@newtoy pahole]$ codiff -V build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  cu__create_new_tag              | -136 (removed)
  cu__create_new_class            | -123 (removed)
  cu__create_new_union            | -123 (removed)
  cu__create_new_base_type        | -112 (removed)
  cu__create_new_typedef          | -112 (removed)
  cu__create_new_array            | -474 (removed)
  cu__create_new_parameter        | -102 (removed)
  cu__create_new_label            |  -76 (removed)
  cu__create_new_variable         |  -76 (removed)
  cu__create_new_subroutine_type  | -216 (removed)
  cu__create_new_enumeration      | -261 (removed)
  cu__process_class               | -264 (removed)
  cu__create_new_lexblock         | -109 (removed)
  cu__create_new_inline_expansion |  -76 (removed)
  cu__process_function            | -424 (removed)
  cu__create_new_function         |  -96 (removed)
  cu__process_unit                | -319 (removed)
  cu__process                     | -249 (removed)
 18 functions changed, 3348 bytes removed

/home/acme/pahole/classes.c:
  die__create_new_tag              | +136 (added)
  die__create_new_class            | +123 (added)
  die__create_new_union            | +123 (added)
  die__create_new_base_type        | +112 (added)
  die__create_new_typedef          | +112 (added)
  die__create_new_array            | +474 (added)
  die__create_new_parameter        | +102 (added)
  die__create_new_label            |  +76 (added)
  die__create_new_variable         |  +76 (added)
  die__create_new_subroutine_type  | +216 (added)
  die__create_new_enumeration      | +261 (added)
  die__process_class               | +264 (added)
  die__create_new_lexblock         | +109 (added)
  die__create_new_inline_expansion |  +76 (added)
  die__process_function            | +410 (added)
  die__create_new_function         |  +96 (added)
  die__process_unit                | +319 (added)
  die__process                     | +249 (added)
 18 functions changed, 3334 bytes added

build/libclasses.so:
 36 functions changed, 3334 bytes added, 3348 bytes removed

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 12:16:46 -02:00
Arnaldo Carvalho de Melo 8062d1a874 [CLASSES]: Make struct class and enumeration share more thru struct type
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 10:00:47 -02:00
Arnaldo Carvalho de Melo 746f462b4e [CODIFF]: Show more info in verbose mode for function diffs
Example:

Applying this patch to the linux kernel sources:

     diff --git a/include/net/xfrm.h b/include/net/xfrm.h
     index e476541..178eb50 100644
     - a/include/net/xfrm.h
     + b/include/net/xfrm.h
     @@ -853,7 +853,7 @@ struct xfrm_algo_comp_info {
      struct xfrm_algo_desc {
 	     char *name;
 	     char *compat;
     -	u8 available:1;
     +	u8 available;
 	     union {
 		     struct xfrm_algo_auth_info auth;
 		     struct xfrm_algo_encr_info encr;

We get this result:

[acme@newtoy linux-2.6]$ codiff -V /tmp/vmlinux.before vmlinux
net/xfrm/xfrm_algo.c:
  struct xfrm_algo_desc     |   +0
    available:1;
     from: u8                    /*     8(7)     1(1) */
     to:   u8                    /*     8(0)     1(0) */
 1 struct changed
  xfrm_count_auth_supported |  -15 # 42 -> 27
  xfrm_count_enc_supported  |  -15 # 42 -> 27
  xfrm_get_byname           |  -14 # 250 -> 236
  xfrm_probe_algs           | -102 # 284 -> 182
 4 functions changed, 146 bytes removed

net/xfrm/xfrm_user.c:
  struct xfrm_algo_desc |   +0
    available:1;
     from: u8                    /*     8(7)     1(1) */
     to:   u8                    /*     8(0)     1(0) */
 1 struct changed

vmlinux:
 4 functions changed, 146 bytes removed

See the info after the '#' character? old size -> new size.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-08 12:21:47 -02:00
Arnaldo Carvalho de Melo d0e47a6f2c [CODIFF]: Avoid comparing DW_TAG_subprogram with DW_AT_abstract_origin
We were comparing DW_TAG_subprogram tags without low_pc/high_pc with
aliases to it, that have low_pc/high_pc, not good.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-08 12:07:59 -02:00
Arnaldo Carvalho de Melo 29103e42be [CLASSES]: Handle DW_AT_abstract_origin in DW_TAG_subprogram
We have to check for a possible alias (abstract origin attribute) and handle
that when we want the function name, if it is an alias, do the lookup and cache
the result in ->name, that after all doesn't have a value in the first place.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 17:13:39 -02:00
Arnaldo Carvalho de Melo a200508985 [CLASSES]: Rename the find_class_by_name to find_struct_by_name
As they already look just for DW_TAG_structure_type. Also make it return a
struct tag to avoid having to cast it back and forth too much.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 13:11:20 -02:00
Arnaldo Carvalho de Melo 5deeded578 [CLASSES]: Introduce struct type
Out of struct typedef_tag, that now becomes the superclass of struct class, and
that also will be for struct enumeration, struct union_type and then finally
for struct struct_type, when struct class finally dies.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 12:30:58 -02:00
Arnaldo Carvalho de Melo 6165ac5ba6 [CLASSES]: Reduce the space needed to represent a DW_TAG_typedef
By having its own class, struct typedef_tag.

As it, as structs, unions and enums have a common part, the node and visited
fields, required when emitting its definitions there is an opportunity for
consolidation, that will be explored when adding the specific classes for
DW_TAG_enumeration & DW_TAG_union.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-06 15:17:58 -02:00
Arnaldo Carvalho de Melo b11c508509 [CLASSES]: Remove cu field from struct class
Same reason as for the previous structs were the same change was made.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-04 01:41:11 -02:00
Arnaldo Carvalho de Melo 251e3973ef [CLASSES]: Ditch struct function->cu
Since we have it available where we need:

[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct function                     |   -4
 1 struct changed
  cu__add_function                    |   -9
  cus__find_class_by_name             |  +14
  cus__find_function_by_name          |  +14
  lexblock__account_inline_expansions |   -6
  function__print                     |  -10
 5 functions changed, 28 bytes added, 25 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 21:57:35 -02:00
Arnaldo Carvalho de Melo bed9378b42 [CLASSES]: Use just one list for classes (structs, unions, etc) and functions
Almost mirroring the DWARF on-disk linkage on memory, more to come before
getting over these simplification refactorings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 21:29:24 -02:00
Arnaldo Carvalho de Melo 29fc67353c [CLASSES]: Pave the way to reuse DW_TAG_subprogram prototype code
Will be reused when handling DW_TAG_subprogram_type more comprehensively, in
the upcoming csets.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-30 16:34:20 -02:00
Arnaldo Carvalho de Melo bbf3f8d95e [CLASSES]: Become struct tag centric
So far struct class was being used as the main data structure, switch to struct
tag, that already was the top of the tag hierarchy, being a struct class
ancestor, so reflect that and stop using struct class as the catch all class,
as a started DW_TAG_array_type tags are now represented by a new class, struct
array_type, reducing the size of struct class and reducing DW__TAG_array_type
instance memory usage.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-29 15:28:58 -02:00
Arnaldo Carvalho de Melo 43de2d269f [CLASSES]: Use ISO C99 integer types more comprehensively
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 11:18:43 -02:00
Arnaldo Carvalho de Melo 95578b7694 [CLASSES]: Shrink struct class_member
[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct class_member |  -16
 1 struct changed
  class_member__new   |   +6
  class_member__names |   +5
  class_member__print |   -9
  class__find_holes   |  -37
  class__print_struct |  -22
  cu__process_class   |   +1
 6 functions changed, 12 bytes added, 68 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 10:09:18 -02:00
Arnaldo Carvalho de Melo b0e2c51ec8 [CLASSES]: Allow struct cus instances to share a list of defs and fwd_decls
So that we can extract bits from one and combine it bits from other instances,
like we'll do in ctracer, where we want to have a cus instance just to get the
kprobes definitions and forward declarations but not handle the methods in it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-27 14:39:37 -02:00
Arnaldo Carvalho de Melo 3e60a747e6 [CLASSES]: Use size_t for size variables
uint64_t is a bit excessive.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 22:27:22 -02:00
Arnaldo Carvalho de Melo ef4fe6ebac [CODIFF]: Find structs that were removed
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 13:35:21 -02:00
Arnaldo Carvalho de Melo 349463c0ca [CODIFF]: Handle new functions
[acme@newtoy pahole]$ codiff build/ctracer.before build/ctracer
/home/acme/pahole/ctracer.c:
  emit_module_preamble | -188
 1 function changed, 188 bytes removed

/home/acme/pahole/ctracer.c:
  emit_struct_defs    |  +74
  emit_class_fwd_decl |  +58
 2 functions changed, 132 bytes added

build/ctracer:
 3 functions changed, 132 bytes added, 188 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 13:03:33 -02:00
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