Commit Graph

321 Commits

Author SHA1 Message Date
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
Arnaldo Carvalho de Melo 465c4978b7 [CLASSES]: Fully support nested classes
Example:

[acme@newtoy pahole]$ pahole net/ipv4/tcp.o flowi
/* include/net/flow.h:13 */
struct flowi {
	int                        oif;                  /*     0     4 */
	int                        iif;                  /*     4     4 */
	__u32                      mark;                 /*     8     4 */
	union {
		struct {
			__be32     daddr;                /*     0     4 */
			__be32     saddr;                /*     4     4 */
			__u8       tos;                  /*     8     1 */
			__u8       scope;                /*     9     1 */
		} ip4_u;                                 /*          12 */
		struct {
			struct in6_addr daddr;           /*     0    16 */
			struct in6_addr saddr;           /*    16    16 */
			/* --- cacheline 1 boundary (32 bytes) --- */
			__be32     flowlabel;            /*    32     4 */
		} ip6_u;                                 /*          36 */
		struct {
			__le16     daddr;                /*     0     2 */
			__le16     saddr;                /*     2     2 */
			__u8       scope;                /*     4     1 */
		} dn_u;                                  /*           6 */
	} nl_u;                                          /*    12    36 */
	/* --- cacheline 1 boundary (32 bytes) was 16 bytes ago --- */
	__u8                       proto;                /*    48     1 */
	__u8                       flags;                /*    49     1 */

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

	union {
		struct {
			__be16     sport;                /*     0     2 */
			__be16     dport;                /*     2     2 */
		} ports;                                 /*           4 */
		struct {
			__u8       type;                 /*     0     1 */
			__u8       code;                 /*     1     1 */
		} icmpt;                                 /*           2 */
		struct {
			__le16     sport;                /*     0     2 */
			__le16     dport;                /*     2     2 */
		} dnports;                               /*           4 */
		__be32             spi;                  /*           4 */
	} uli_u;                                         /*    52     4 */
	__u32                      secid;                /*    56     4 */
}; /* size: 60, cachelines: 2 */
   /* sum members: 58, holes: 1, sum holes: 2 */
   /* last cacheline: 28 bytes */

Supporting anonymous structs and unions just fine, even combinations of both,
like in struct page, in the Linux kernel:

[acme@newtoy pahole]$ pahole mm/mmap.o page
/* include/linux/mmzone.h:391 */
struct page {
	long unsigned int          flags;                /*     0     4 */
	atomic_t                   _count;               /*     4     4 */
	atomic_t                   _mapcount;            /*     8     4 */
	union {
		struct {
			long unsigned int private;       /*     0     4 */
			struct address_space * mapping;  /*     4     4 */
		};                                       /*           8 */
	};                                               /*    12     8 */
	long unsigned int          index;                /*    20     4 */
	struct list_head           lru;                  /*    24     8 */
	/* --- cacheline 1 boundary (32 bytes) --- */
}; /* size: 32, cachelines: 1 */

Or struct freebsd_sys_getdents_args in the OpenBSD kernel:

/* /usr/home/leonardo/openbsd/src/sys/compat/freebsd/freebsd_syscallargs.h:231 */
struct freebsd_sys_getdents_args {
	union {
		register_t         pad;                  /*           4 */
		struct {
			int        datum;                /*     0     4 */
		} le;                                    /*           4 */
		struct {
			int8_t     pad[0];               /*     0     0 */
			int        datum;                /*     0     4 */
		} be;                                    /*           4 */
	} fd;                                            /*     0     4 */
	union {
		register_t         pad;                  /*           4 */
		struct {
			void *     datum;                /*     0     4 */
		} le;                                    /*           4 */
		struct {
			int8_t     pad[0];               /*     0     0 */
			void *     datum;                /*     0     4 */
		} be;                                    /*           4 */
	} dirent;                                        /*     4     4 */
	union {
		register_t         pad;                  /*           4 */
		struct {
			unsigned int datum;              /*     0     4 */
		} le;                                    /*           4 */
		struct {
			int8_t     pad[0];               /*     0     0 */
			unsigned int datum;              /*     0     4 */
		} be;                                    /*           4 */
	} count;                                         /*     8     4 */
}; /* size: 12, cachelines: 1 */
   /* last cacheline: 12 bytes */
   /* definitions: 7 */

One more from the OpenBSD kernel:

/* /usr/home/leonardo/openbsd/src/sys/nfs/nfs.h:344 */
struct nfssvc_sock {
	struct {
		struct nfssvc_sock * tqe_next;           /*     0     4 */
		struct nfssvc_sock * * tqe_prev;         /*     4     4 */
	} ns_chain;                                      /*     0     8 */
	struct {
		struct nfsuid *    tqh_first;            /*     0     4 */
		struct nfsuid * *  tqh_last;             /*     4     4 */
	} ns_uidlruhead;                                 /*     8     8 */
	struct file *              ns_fp;                /*    16     4 */
	struct socket *            ns_so;                /*    20     4 */
	struct mbuf *              ns_nam;               /*    24     4 */
	struct mbuf *              ns_raw;               /*    28     4 */
	/* --- cacheline 1 boundary (32 bytes) --- */
	struct mbuf *              ns_rawend;            /*    32     4 */
	struct mbuf *              ns_rec;               /*    36     4 */
	struct mbuf *              ns_recend;            /*    40     4 */
	struct mbuf *              ns_frag;              /*    44     4 */
	int                        ns_flag;              /*    48     4 */
	int                        ns_solock;            /*    52     4 */
	int                        ns_cc;                /*    56     4 */
	int                        ns_reclen;            /*    60     4 */
	/* --- cacheline 2 boundary (64 bytes) --- */
	int                        ns_numuids;           /*    64     4 */
	u_int32_t                  ns_sref;              /*    68     4 */
	struct {
		struct nfsrv_descript * lh_first;        /*     0     4 */
	} ns_tq;                                         /*    72     4 */
	struct                     ns_uidhashtbl[29];    /*    76   116 */
	/* --- cacheline 6 boundary (192 bytes) --- */
	struct nfsrvw_delayhash    ns_wdelayhashtbl[16]; /*   192    64 */
	/* --- cacheline 8 boundary (256 bytes) --- */
}; /* size: 256, cachelines: 8 */
   /* definitions: 12 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-10 19:46:47 -02:00
Arnaldo Carvalho de Melo 63edfc24e0 [CLASSES]: Introduce class__snprintf, out of class__print
That now just calls class__snprintf with a huge buffer (struct
security_operations in the linux kernel uses about 18KB in its definition).

Now to make union__snprintf use it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-10 16:39:20 -02:00
Arnaldo Carvalho de Melo feeaad9d37 [CLASSES]: Rename class__print_struct to class__print
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-10 14:27:03 -02:00
Arnaldo Carvalho de Melo c6e1a5eebd [CLASSES]: Ditch class_member__names
Was a awful function, to replace it added some new __snprintf methods for more
classes (array_type, class_member, etc), the end result is a much nicer
rendering, for instance:

@@ -6549,11 +6549,11 @@
         /* XXX 2 bytes hole, try to pack */

         union {
-                struct ff_constant_effect constant;             /*          10 */
-                struct ff_ramp_effect ramp;                 /*          12 */
-                struct ff_periodic_effect periodic;             /*          28 */
-                struct ff_condition_effect condition[2];         /*          24 */
-                struct ff_rumble_effect rumble;               /*           4 */
+                struct ff_constant_effect constant;      /*          10 */
+                struct ff_ramp_effect ramp;              /*          12 */
+                struct ff_periodic_effect periodic;      /*          28 */
+                struct ff_condition_effect condition[2];  /*          24 */
+                struct ff_rumble_effect rumble;          /*           4 */
         } u;                                             /*    16    28 */
         /* --- cacheline 1 boundary (32 bytes) was 12 bytes ago --- */
 }; /* size: 44, cachelines: 2 */

Previously when such big class members appeared the comments with the size and
offset were unaligned, now its only in extreme cases, such as the array above
that things get unaligned.

End result is a smaller library:

[acme@newtoy pahole]$ codiff -V build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct array_type   |   -4
   nr_members: -1
    -const char  *name   /*    36     4 */
 1 struct changed
  enumeration__print  |  +10 # 175 -> 185
  union__snprintf     |  +32 # 576 -> 608
  union__print        |  +16 # 182 -> 198
  class_member__names | -851 (removed)
  class_member__print | -721 # 1218 -> 497
  class__print_struct |  +54 # 1403 -> 1457
 6 functions changed, 112 bytes added, 1572 bytes removed, diff: -1460

/home/acme/pahole/classes.c:
  array_type__snprintf   | +249 (added)
  class_member__snprintf | +892 (added)
 2 functions changed, 1141 bytes added

build/libclasses.so:
 8 functions changed, 1253 bytes added, 1572 bytes removed, diff: -319

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-10 14:19:55 -02:00
Arnaldo Carvalho de Melo 8594be9256 [CLASSES]: Unexport class_member__names
Now to kill its last users.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 15:13:33 -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 52b5bb606b [CLASSES]: Export tag__size()
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 15:10:31 -02:00
Arnaldo Carvalho de Melo b916bb459e [CTRACER]: Avoid comparing DW_TAG_subprogram with DW_AT_abstract_origin
See d0e47a6f2c commit.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 14:26:07 -02:00
Arnaldo Carvalho de Melo bd62cad409 [CODIFF]: Use ftype__snprintf
And with this the only user of parameter__names is gone, so ditch it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 13:34:15 -02:00
Arnaldo Carvalho de Melo 8b797ddc38 [CLASSES]: Remove redundant setting in cus__emit_struct_definitions
cus__add_definition already dos this for us.

[acme@newtoy pahole]$ codiff -V build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  cus__emit_struct_definitions |  -13 # 336 -> 323
 1 function changed, 13 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 13:03:09 -02:00
Arnaldo Carvalho de Melo 406e9db7c1 [CLASSES]: Introduce die__process_tag
That does the common processing previously found in cu__process_unit,
cu__process_function and cu__process_class, reducing complexity and hopefully
supporting C++ a tad better by looking for more tags that can appear inside
class definitions, function within functions, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 12:55:45 -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 c453da1b35 [CLASSES]: Rename the cu__{create_new,process} functions to die__
To better reflect that the main data structure being handled is Dwarf_Die.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 12:17:48 -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 049c8fccfc [CLASSES]: Add the tag after the switch
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 12:04:12 -02:00
Arnaldo Carvalho de Melo 5cbea44c42 [CLASSES]: Use just struct type to represent DW_TAG_union_type
Reducing the memory required to represent such tags.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-09 10:17:39 -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 99610d5857 [CLASSES]: Handle DW_TAG_enumeration_type in cu__process_class
In C++ we can have enums defined inside classes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-08 22:06:11 -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 e8e38bd27e [PFUNCT]: Only check duplicates in verbose mode
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-08 11:42:52 -02:00
Arnaldo Carvalho de Melo e5251f65a8 [CLASSES]: Introduce cu__tag_not_handled
Makign the tag not handled warnings homogeneous.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 23:57:32 -02:00
Luis Cludio R. Gonalves 346e3a7e17 [CMAKE]: Fix build on ubuntu
Signed-off-by: Luis Cludio R. Gonalves <lclaudio@unix.sh>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 23:56:43 -02:00
Arnaldo Carvalho de Melo 0872d8e312 [CLASSES]: Support abstract origin in formal parameters
Sortof, mostly works, but still has a problem where the abstract origin is not
being found, but for now its ok to keep the bandaid, everything works as
before, there are more important things to do right now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 17:57:00 -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 fddb3f4e15 [CLASSES]: Remove dead code
[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  cu__create_new_function |  -90
 1 function changed, 90 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 15:54:41 -02:00
Arnaldo Carvalho de Melo 0ca8dccffb [CLASSES]: Stop using bitfields in struct type
sizeof(struct type) stays the same and we reduce the code size a bit:

[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct type                       |   +0
 1 struct changed
  type__init                        |  -12
  cus__add_definition               |   -6
  cus__add_fwd_decl                 |   -6
  cus__emit_typedef_definitions     |   -9
  cus__emit_enumeration_definitions |   -9
  cus__emit_fwd_decl                |   -9
  cus__emit_struct_definitions      |  -15
 7 functions changed, 66 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 15:15:32 -02:00
Arnaldo Carvalho de Melo d607b0e2fa [CLASSES]: Stop using bitfields in struct function
sizeof(struct function) stay the same and we shrink the code a bit:

[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct function           |   +0
 1 struct changed
  function__new             |  -41
  function__declared_inline |   -6
 2 functions changed, 47 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 15:13:50 -02:00
Arnaldo Carvalho de Melo c4fa14e2ad [CLASSES]: Promote bitfield to uint8_t
As there are no other bitfield, we end up using one byte and by
not using it as a bitfield we shrink the code size:

[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct class |   +0
 1 struct changed
  class__new   |  -15
 1 function changed, 15 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 15:11:03 -02:00
Arnaldo Carvalho de Melo 085df7d247 [CLASSES]: Remove class_member ->class backpointer
Not used anymore.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 15:07:39 -02:00
Arnaldo Carvalho de Melo 6c90357d6e [CLASSES]: Introduce struct enumeration
To represent DW_TAG_enumeration_type, using less space than struct class.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 13:27:12 -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 3368862360 [CLASSES]: Call cus__add_definition in cus__emit_enumeration_definitions
To avoid emitting the same enumeration when it appears in more than one object
file (CU).

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-07 11:40:10 -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 276ba078f2 [CLASSES]: Remove the last bits of recursion in dealing with dies
And don't create a struct case as default, instead emit a warning that the tag
is not being handled.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-06 14:07:28 -02:00
Arnaldo Carvalho de Melo 0b930b1ce8 [CLASSES]: Move cu__create_new_enumeration to before cu__process_function
Will be used by cu__process_function, no code changed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-06 14:01:09 -02:00
Arnaldo Carvalho de Melo 136f3786de [CTRACER]: Fix the case where kprobes_filename is not set in the cmdline
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-05 16:58:58 -02:00
Arnaldo Carvalho de Melo 9f9f2896b2 [CLASSES]: attr_string doesn't need a Dwarf_Attributte passed to it
Just use one in the stack.

[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  base_type__new        |   -7
  enumerator__new       |   -7
  variable__new         |   -7
  class_member__new     |  -11
  parameter__new        |   -7
  inline_expansion__new |   -7
  label__new            |   -7
  class__new            |   -7
  function__new         |   -7
  cus__load             |   -7
 10 functions changed, 74 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-04 17:27:24 -02:00
Arnaldo Carvalho de Melo 47b4f029fb [CLASSES]: Handle DW_TAG_unspecified_parameters in function pointers
My favourite guinea pig (linux's vmlinux) has not one pointer to a function
that has unspecified parameters (...), but a new guinea pig, also a kernel,
has, openbsd's kernel, example:

/* /usr/home/leonardo/openbsd/src/sys/sys/protosw.h:63 */
struct protosw {
        short int pr_type;              /*     0     2 */
<SNIP>
        void      (*pr_input)(struct mbuf *, ...); /*    12     4 */
        int       (*pr_output)(struct mbuf *, ...); /*    16     4 */
<SNIP>

So fix it!

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-04 13:28:45 -02:00
Arnaldo Carvalho de Melo 9f3a65c7fa [CLASSES]: Introduce lexblock__find_tag_by_id
Right now used only by cu__find_variable_by_id, so that we can ditch the
cu_node node in struct variable and keep variables only in the lexblock tags
list.

[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct cu               |   -8
  struct variable         |   -8
 2 structs changed
  cu__new                 |  -18
  cu__add_variable        |  -32
  cu__find_variable_by_id |  +66
  variable__name          |  -31
  cu__create_new_variable |  -18
 5 functions changed, 66 bytes added, 99 bytes removed

/home/acme/pahole/classes.c:
  lexblock__find_tag_by_id | +174
 1 function changed, 174 bytes added

build/libclasses.so:
 6 functions changed, 240 bytes added, 99 bytes removed

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-04 13:13:21 -02:00
Arnaldo Carvalho de Melo 78ae95c02d [CLASSES]: Handle DW_TAG_subroutine_type in tag__name
This has to be reworked as it doesn't do the right thing, it has to be a mask
as function pointers needs, but variables are not something so heavily used in
the more interesting tools, so leave this for later.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-04 13:06:29 -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