Commit Graph

365 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 1750958111 [LIB]: Separate emission of definitions in a type from the emission of the type itself
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-16 12:11:35 -02:00
Arnaldo Carvalho de Melo 14863f943e [LIB]: Remove the prefix tag for enum functions
Now the functions that call cus__emit_enumeration_definitions should call
tag__print_decl_info, so that if it is a typedef we can just print "typedef ",
then call the enum printing routines.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-15 12:15:59 -02:00
Arnaldo Carvalho de Melo 36c4c5a386 [LIB]: Handle union typedefs
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-15 11:21:39 -02:00
Arnaldo Carvalho de Melo 8f8a691a6a [LIB]: Handle enum typedefs
Using 'ctracer vmlinux pci_dev' without and with this cset:

  --- ctracer.c.old 2007-01-15 10:45:45.000000000 -0200
  +++ ctracer.c	  2007-01-15 10:45:57.000000000 -0200
  @@ -2175,7 +2175,28 @@
   struct hwgroup_s;
   struct proc_dir_entry;
   typedef int (ide_ack_intr_t)(struct hwif_s *);
  -typedef enum  hwif_chipset_t;
  +/* <a710> /pub/scm/linux/kernel/git/acme/linux-2.6/include/linux/ide.h:199 */
  +typedef enum {
  +	ide_unknown = 0,
  +	ide_generic = 1,
  +	ide_pci = 2,
  +	ide_cmd640 = 3,
  +	ide_dtc2278 = 4,
  +	ide_ali14xx = 5,
  +	ide_qd65xx = 6,
  +	ide_umc8672 = 7,
  +	ide_ht6560b = 8,
  +	ide_rz1000 = 9,
  +	ide_trm290 = 10,
  +	ide_cmd646 = 11,
  +	ide_cy82c693 = 12,
  +	ide_4drives = 13,
  +	ide_pmac = 14,
  +	ide_etrax100 = 15,
  +	ide_acorn = 16,
  +	ide_au1xxx = 17,
  +	ide_forced = 18,
  +} hwif_chipset_t;
   struct device;

 /* <a796> /pub/scm/linux/kernel/git/acme/linux-2.6/include/linux/ide.h:211 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-15 10:51:07 -02:00
Arnaldo Carvalho de Melo 37d19a9320 [LIB]: Emit definitions for structs in typedefs
I.e. things like

typedef struct foo bar;

will emit the definition for struct foo before emitting the above line.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-15 10:39:23 -02:00
Arnaldo Carvalho de Melo 348fdc8d1a [LIB]: Avoid emitting top level unnamed unions and structs
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-15 10:34:13 -02:00
Arnaldo Carvalho de Melo 9a413e60a3 [LIB]: Fix stupid if + switch case
Where the 'if' should be just one of of the cases in the 'switch', and guess
what:

This:

  diff --git a/dwarves.c b/dwarves.c
  index c0ae7c8..34f29a1 100644
  --- a/dwarves.c
  +++ b/dwarves.c
  @@ -2580,10 +2580,10 @@ static int cus__emit_typedef_definitions
   	}
   	type = cu__find_tag_by_id(cu, tdef->type);

  -	if (type->tag == DW_TAG_typedef)
  -		cus__emit_typedef_definitions(self, cu, type);
  -
   	switch (type->tag) {
  +	case DW_TAG_typedef:
  +		cus__emit_typedef_definitions(self, cu, type);
  +		break;
   	case DW_TAG_pointer_type:
   		ptr_type = cu__find_tag_by_id(cu, type->type);
   		if (ptr_type->tag != DW_TAG_subroutine_type)

Results in this:

[acme@newtoy pahole]$ codiff -V build/libdwarves.so.orig build/libdwarves.so
/home/acme/pahole/dwarves.c:
  cus__emit_typedef_definitions |  -18 # 466 -> 448
 1 function changed, 18 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 16:22:53 -02:00
Arnaldo Carvalho de Melo 9b0f2584fe [LIB]: Minor class_member__snprintf cleanup
Size of generated code doesn't changes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 16:14:45 -02:00
Arnaldo Carvalho de Melo 45f5c5f8e3 [LIB]: switches are cheaper, step 2
[acme@newtoy pahole]$ codiff -V build/libdwarves.so.orig build/libdwarves.so
/home/acme/pahole/dwarves.c:
  class_member__snprintf |  -45 # 1126 -> 1081
 1 function changed, 45 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 16:12:41 -02:00
Arnaldo Carvalho de Melo 59bddf5928 [LIB]: switches are cheaper
[acme@newtoy pahole]$ codiff -V build/libdwarves.so.orig build/libdwarves.so
/home/acme/pahole/dwarves.c:
  tag__name |  -63 # 982 -> 919
 1 function changed, 63 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 16:04:21 -02:00
Arnaldo Carvalho de Melo 003a38d2b0 [LIB]: Emit a ';' after unions in cus__emit_type_definitions
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 15:56:27 -02:00
Arnaldo Carvalho de Melo dc22745064 [CTRACER]: yield the processor while registering the probes
To avoid soft lockups.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 15:53:51 -02:00
Arnaldo Carvalho de Melo b7fcbac565 [CTRACER]: Dont emit duplicate probes for functions with the same name
This is more like a bandaid, namespace clashes should be handled properly in
the future, but for now, well behaved projects will get the profits ;)

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 14:56:16 -02:00
Arnaldo Carvalho de Melo 0bf740a74c [LIB]: Make cus__emit_fwd_decl handle unions
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 14:27:08 -02:00
Arnaldo Carvalho de Melo 3a9ceb41ee [LIB]: Rename cus__emit_struct_definitions to cus__emit_type_definitions
To make it handle unions too.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 14:19:34 -02:00
Arnaldo Carvalho de Melo 03530985c1 [PAHOLE]: Introduce --nr_methods
To show how many non inline functions receive as a parameter each of the structs
in a project, example:

[acme@newtoy ctracer_example]$ pahole --nr_methods vmlinux | sort -k2 -nr | head -5
file: 526
inode: 479
sk_buff: 386
sock: 383
dentry: 295
[acme@newtoy ctracer_example]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 13:59:32 -02:00
Arnaldo Carvalho de Melo 7e57db18d7 [LIB]: Add support for DW_AT_specification in DW_TAG_subprogram
C++ feature, we have to look for the id, then abstract_origin and then
specification.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 11:37:41 -02:00
Arnaldo Carvalho de Melo 5dcd02daa3 [LIB]: Print the cu offset in tag__print_decl_info
To locate the entry in the readelf output when looking for problems.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 10:58:58 -02:00
Arnaldo Carvalho de Melo f6718f5721 [LIB]: Export lexblock__print
tag__print on a DW_TAG_subprogram tag prints just the function prototype,
without the ending ";\", so if a user wants to print the whole function its
just a matter of calling tag__print + lexblock__(tag__function(tag), cu,
indent).

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 10:57:19 -02:00
Arnaldo Carvalho de Melo 777a21fad0 [LIB]: Replace ntabs with indent, for consistency
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-13 10:40:33 -02:00
Arnaldo Carvalho de Melo aa961db9b9 [LIB]: Reintroduce union__print, this time being called by tag__print
And will be used by a new dwarf, that is about to be merged.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 18:00:32 -02:00
Arnaldo Carvalho de Melo de345d7d29 [LIB]: Leave to the callers of enumeration__print to add or not the ; and newline
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 17:40:12 -02:00
Arnaldo Carvalho de Melo ef329ecd49 [LIB]: Leave to callers of typedef__print to add or not the ; and newline
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 17:23:14 -02:00
Arnaldo Carvalho de Melo 49ca9c8a0b [LIB]: Make ftype__snprintf check for types not found
Again, due to some tags not being collected in the C++ case.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:34:53 -02:00
Arnaldo Carvalho de Melo ed2d124a0e [LIB]: Make typedef__print check if the type was not found
This should not happen, but right now happens as we don't support all the C++
tags, so some types are not being collected when inside DW_TAG_namespace dies.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:29:53 -02:00
Arnaldo Carvalho de Melo 16c0586602 [LIB]: Make all callers of function__print use tag__print instead
And since there are no external users now, just unexport it, ditto
for tag__print_decl_info.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:25:20 -02:00
Arnaldo Carvalho de Melo 907831071f [LIB]: Make tag__print support DW_TAG_subprogram
Calling function__print.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:19:13 -02:00
Arnaldo Carvalho de Melo 26747d0053 [LIB]: Don't print the decl info in function__print
Its up to its callers, that will be moot soon as tag__print will call
function__print and as it already prints the decl info it'll be just a matter
of making all the function__print callers call tag__print instead and then
function__print will be unexported.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:17:53 -02:00
Arnaldo Carvalho de Melo df1832ac4f [LIB]: Introduce tag__print_decl_info
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:11:37 -02:00
Arnaldo Carvalho de Melo c1f96237b3 [LIB]: Remove unused variables in function__print
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:03:38 -02:00
Arnaldo Carvalho de Melo 3fe4f09a27 [LIB]: Move the stats printing bits out of function__print
Moving them to a new function, function__print_stats.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 16:00:07 -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 458e7d6867 [LIB]: Call enumeration__print in tag__print
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 15:24:41 -02:00
Arnaldo Carvalho de Melo 18703f8d3c [LIB]: Call typedef__print in tag__print
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 15:13:38 -02:00
Arnaldo Carvalho de Melo bc58353565 [LIB]: Pass prefix and suffix to class__snprintf in class__print
Fixing a regression introduced when doing the class__snprintf introduction out
of class__print, namely this one:

--- ctracer_sock.c.old  2007-01-12 14:57:56.000000000 -0200
+++ ctracer.c   2007-01-12 15:00:21.000000000 -0200
@@ -1668,7 +1668,7 @@
 };

   /* /pub/scm/linux/kernel/git/acme/linux-2.6/include/linux/fs.h:1050 */
  -struct {
  +typedef struct {
          size_t              written;     /*     0     4 */
          size_t              count;       /*     4     4 */
          union {
  @@ -1676,7 +1676,7 @@
                  void *      data;        /*           4 */
          } arg;                           /*     8     4 */
          int                 error;       /*    12     4 */
  -}; /* size: 16, cachelines: 1 */
  +} read_descriptor_t; /* size: 16, cachelines: 1 */
      /* last cacheline: 16 bytes */

   typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, unsigned int, size_t);

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 15:03:59 -02:00
Arnaldo Carvalho de Melo 0661f26f9f [LIB]: Call cus__emit_ftype_definitions for DW_TAG_subroutine_type in cus__emit_tag_definitions
Thus emitting definitions/forward declarations for the types of function
pointers, not just for the return type of the function pointer.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 14:39:26 -02:00
Arnaldo Carvalho de Melo 0905197862 [LIB]: Create typedef__print out of cus__emit_typedef_definitions
This way cus__emit_typedef_definitions first looks for definitions in the
typedef that will be emitted, emits those definitions, then prints the typedef.

With this it'll be possible to make tag__print to print typedefs, when we know
that the definitions it needs were already previously emitted/printed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 13:04:05 -02:00
Arnaldo Carvalho de Melo 0281ee673c [RPM]: New relase with the DW_TAG_reference work
Available at:

http://oops.ghostprotocols.net:81/acme/dwarves/rpm/

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 11:42:57 -02:00
Arnaldo Carvalho de Melo a1f5422656 [LIB]: Add support for DW_TAG_reference_type
One more C++ feature supported:

[acme@newtoy examples]$ pahole qsettings.o QConfFileSettingsPrivate
/* io/qsettings_p.h:233 */
struct QConfFileSettingsPrivate {
        struct QSettingsPrivate (null);               /*     0    76 */
        /* --- cacheline 2 boundary (64 bytes) was 12 bytes ago --- */
        class QConfFile *       confFiles[4];         /*    76    16 */
        enum Format             format;               /*    92     4 */
        /* --- cacheline 3 boundary (96 bytes) --- */
        bool                    (*readFunc)(class QIODevice &, class QMap<QString,QVariant> &); /*    96     4 */
        bool                    (*writeFunc)(class QIODevice &, const class QMap<QString,QVariant>  &); /*   100     4 */
        struct QString          extension;            /*   104     4 */
        >>>ERROR: type for caseSensitivity not found!
}; /* size: 112, cachelines: 4 */
   /* padding: 5 */
   /* last cacheline: 16 bytes */

/* BRAIN FART ALERT! 112 != 108 + 0(holes), diff = 4 */

[acme@newtoy examples]$

Now to see the problem with caseSensitivity type, probably was defined inside
some DW_TAG_namespace, that is not yet supported.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 11:06:59 -02:00
Arnaldo Carvalho de Melo 81f16372eb [RPM]: Add description tag contents
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-12 11:04:54 -02:00
Arnaldo Carvalho de Melo 0ad467a321 [LIB]: Replace type not found asserts by an error message
So that we can continue and see what was the problem, investigate using readelf
-wi and proceed to fix it, normally its just references to not yet supported
tags, so far the ones I know are not supported are DW_TAG_reference_type &
DW_TAG_namespace, i.e. tags not present in the C language, only on C++ and
other object oriented routines with such concepts.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 23:09:06 -02:00
Arnaldo Carvalho de Melo 04d65d98ff [PAHOLE]: Add a verbose command line option
For now it just affects showing differences in definitions of structs with the
same name found in different object files, that could be a real problem but
could as well be just a namespace colision not affecting the project's build
process as they were be local to specific objects.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 22:11:31 -02:00
Arnaldo Carvalho de Melo 0e99883168 [RPM]: Add a spec file to build a rpm file
Quick instructions:

[acme@newtoy pahole]$ pwd
/home/acme/pahole
[acme@newtoy pahole]$ mkdir -p rpm/{BUILD,RPMS/i586,SOURCES,SRPMS}
[acme@newtoy pahole]$ tar cfj rpm/SOURCES/pahole-0.tar.bz2 $(cat MANIFEST)
[acme@newtoy pahole]$ rpmbuild --define "_topdir /home/acme/pahole/rpm" -v -ba rpm/SPECS/dwarves.spec
<SNIP>
Wrote: /home/acme/pahole/rpm/SRPMS/dwarves-0-1.src.rpm
Wrote: /home/acme/pahole/rpm/RPMS/i586/dwarves-0-1.i586.rpm
Wrote: /home/acme/pahole/rpm/RPMS/i586/libdwarves1-0-1.i586.rpm
Wrote: /home/acme/pahole/rpm/RPMS/i586/libdwarves-devel-0-1.i586.rpm
Wrote: /home/acme/pahole/rpm/RPMS/i586/dwarves-debug-0-1.i586.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.37631
+ umask 022
+ cd /home/acme/pahole/rpm/BUILD
+ cd dwarves-0
+ rm -rf /var/tmp/dwarves-0-root
+ exit 0
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 16:50:26 -02:00
Arnaldo Carvalho de Melo e988381a48 [MANIFEST]: Add a MANIFEST file to use when building the tarball
[acme@newtoy pahole]$ tar cvfj rpm/SOURCES/pahole-0.tar.bz2 $(cat MANIFEST)

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 16:43:18 -02:00
Arnaldo Carvalho de Melo c916ae4a99 [CMAKE]: Add the INSTALL rules
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 16:41:54 -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 7339f61868 [CMAKE]: Set a SONAME for libdwarves
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 16:04:22 -02:00
Arnaldo Carvalho de Melo 24842ef908 [CMAKE]: Rerename the library, this time to libdwarves
To avoid a problem in CMakeLists.txt where the lib and the pahole binary
targets had the same name, leading to the binary not being built, and its a
much cooler name anyway.

Thanks to Leonardo Chiquitto for the suggestion he gave on the #dwarves
channel!

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 15:28:08 -02:00
Arnaldo Carvalho de Melo 56f8ddb318 [CMAKE]: Rename libsoname.so to libpahole.so
Next cset will specify a soname, then a rpm specfile will be added.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-11 13:41:28 -02:00
Arnaldo Carvalho de Melo 5410d62210 [CLASSES]: Ditch union__print, not used at all
[acme@newtoy pahole]$ codiff -V build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  union__print | -198 (removed)
 1 function changed, 198 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-10 19:48:46 -02:00