Commit Graph

77 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo dc5592b844 codiff: Detect changes in padding and the number of holes/bit_holes
$ codiff -V /tmp/pahole.old build/pahole
/home/acme/git/pahole/pahole.c:
  struct tag |   +0
   padding: +2
    refcnt
     removed: uint16_t              /*    56( 0)     2( 0) */
    recursivity_level
     from:    uint16_t              /*    58( 0)     2( 0) */
     to:      uint16_t              /*    56( 0)     2(15) */
    visited
     added:   uint16_t              /*    56(15)     2( 1) */
 1 struct changed

Size is the same, but now we have padding (2 bytes).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-03 10:55:25 -03:00
Arnaldo Carvalho de Melo 5850757671 codiff: improve detection removal and addition of members in structs
Consider this case:

$ codiff -V /tmp/pahole.old build/pahole
/home/acme/git/pahole/pahole.c:
  struct tag |   +0
    refcnt
     removed: uint16_t              /*    56( 0)     2( 0) */
    recursivity_level
     from:    uint16_t              /*    58( 0)     2( 0) */
     to:      uint16_t              /*    56( 0)     2(15) */
    used
     added:   uint16_t              /*    56(15)     2( 1) */
 1 struct changed

The number of members is the same and so is the size of the struct, but
'refcnt' was removed (in fact renamed to used) and 'used' was added.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-03 10:31:14 -03:00
Arnaldo Carvalho de Melo 56be29c649 all: Add the --version
Using the argp tricks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-13 10:57:23 -02:00
Arnaldo Carvalho de Melo 138cc4739c dwarves: Don't pass argp to dwarf_loadfl
Now we just pass a NULL terminated array of filenames, since we got rid
of that ugly -e insertion hack.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-09 21:43:56 -02:00
Arnaldo Carvalho de Melo 3bbd1342b2 dwarf_loader: remove old ugly with_executable_option hack
Now we use dwfl_report_offline directly, having more control about the
whole process, not using anymore dwfl_standard_argp.

This also, semi magicly, makes it work with the built-in.o files
in the Linux kernel, that aggregates multiple object files and that
previously were failing with relocation problems.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-09 16:30:06 -02:00
Arnaldo Carvalho de Melo 212b994ab5 strings: Introduce the strings class
And make the dwarves use it, so that we can remove duplicate strings in
a multi-CU file (vmlinux anyone?) and have it ready for insertion in a
compressed DWARF format with just the types, or better, CTF or some new
compressed debugging info format.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-02 14:34:42 -03:00
Arnaldo Carvalho de Melo efa997ed40 dwarves: Remove type_emissions fields from cus
Now only when one wants to emit this struct is needed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 12:47:42 -03:00
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