Commit Graph

266 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 850ad9262d [CLASSES]: Simplify cu__create_new_lexblock
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 10:58:28 -02:00
Arnaldo Carvalho de Melo 56c2d99953 [CLASSES]: Remove most c'n'pasted, useless dwarf parameter
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 10:16:42 -02:00
Arnaldo Carvalho de Melo 03a83c7faf [CLASSES]: Simplify cu__create_new_inline_expansion
All the cu__create_new_foo functions are now being normalised, will provide
opportunies for further consolidation/cleaning up, lets do this now before
moving on to libelf work.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 10:01:37 -02:00
Arnaldo Carvalho de Melo a3871a073e [CLASSES]: Create cu__create_new_label out of cu__process__function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 09:54:06 -02:00
Arnaldo Carvalho de Melo 8d850effe1 [CLASSES]: Create cu__create_new_variable out of cu__process_function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 09:49:20 -02:00
Arnaldo Carvalho de Melo 3c36b7488f [CLASSES]: Emit definitions for DW_TAG_subroutine_type
Now that we have its parameter list we must call cus__emit_ftype_definitions in
cus__emit_typedef_definitions when we find DW_TAG_subroutine tags.

This fixes this problem with ctracer:

[acme@newtoy ctracer_example]$ make
<SNIP>
  CC [M]  /home/acme/pahole/ctracer_example/ctracer.o
/home/acme/pahole/ctracer_example/ctracer.c:21: warning: 'struct pt_regs' declared inside parameter list
/home/acme/pahole/ctracer_example/ctracer.c:21: warning: its scope is only this definition or declaration, which is probably not what you want
/home/acme/pahole/ctracer_example/ctracer.c:21: warning: 'struct kprobe' declared inside parameter list
<SNIP>

I.e. the struct pt_regs and kprobe forward declarations are done earlier.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 22:49:19 -02:00
Arnaldo Carvalho de Melo 214a115dc6 [CLASSES]: Use just one tags list in struct lexblock
To preserve ordering, even with DW_tag_label tags not being kept in order by
gcc its better to have just one list, uses less space and keeps what is in the
dwarf sections.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 22:26:01 -02:00
Arnaldo Carvalho de Melo 5b17097b2e [CLASSES]: Add missing lexblock__init initialization of {high,low}_pc
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 18:36:03 -02:00
Arnaldo Carvalho de Melo c6d68d705c [CLASSES]: Consolidate DW_TAG_formal_parameter handling
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 18:21:59 -02:00
Arnaldo Carvalho de Melo 6705960010 [CLASSES]: Fix oom message prefix
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 18:02:08 -02:00
Arnaldo Carvalho de Melo 9618245851 [CLASSES]: Create cu__create_new_inline_expansion out of cu__process_function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 16:26:11 -02:00
Arnaldo Carvalho de Melo ce281d1341 [CLASSES]: Improve lexblock handling
Creating nested lexblocks, that improves a bit the function body printing.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 13:25:56 -02:00
Arnaldo Carvalho de Melo 28c09d1f77 [CLASSES]: Introduce cu__create_new_function
And make cu__process_function use a real loop for the siblings, not calling
itself again like in the code pahole was initially based of.

This causes tags below DW_TAG_lexical_block tags to be discarded, will be fixed
in the next csets, with proper lex block support.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 12:20:32 -02:00
Arnaldo Carvalho de Melo e173712c04 [CLASSES]: Use ftype__snprintf in class_member__print
To fix these cases:

--- /tmp/pahole.before  2006-12-29 14:47:59.000000000 -0200
+++ /tmp/pahole.after   2007-01-02 03:16:43.000000000 -0200
@@ -52,8 +52,8 @@

 /* /pub/scm/linux/kernel/git/acme/linux-2.6/net/xfrm/xfrm_user.c:1649 */
 struct xfrm_link {
-        int (*doit)(void /* FIXME: add parm list */); /* 0  4 */
-        int (*dump)(void /* FIXME: add parm list */); /* 4  4 */
+        int (*doit)(struct sk_buff *, struct nlmsghdr *, void * *); /* 0  4 */
+        int (*dump)(struct sk_buff *, struct netlink_callback *); /* 4  4 */
 }; /* size: 8, cachelines: 1 */
    /* last cacheline: 8 bytes */
    /* definitions: 1 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 03:18:33 -02:00
Arnaldo Carvalho de Melo 8a4df0e070 [CLASSES]: Introduce DW_TAG_subroutine_type specific parser
So that we handle DW_TAG_formal_parameters in this tag, fixing
these cases:

--- /tmp/ctracer.c.before   2006-12-29 13:27:24.000000000 -0200
+++ /tmp/ctracer.c       2007-01-02 02:34:18.000000000 -0200
<SNIP>
@@ -62,7 +62,7 @@
 }; /* size: 68, cachelines: 3 */
    /* last cacheline: 4 bytes */

-typedef int (*kretprobe_handler_t)(void /* FIXME: add parm list */);
+typedef int (*kretprobe_handler_t)(struct kretprobe_instance *, struct pt_regs *);
 /* /pub/scm/linux/kernel/git/acme/linux-2.6/include/linux/list.h:607 */
 struct hlist_head {
         struct hlist_node *        first;                /*     0     4 */
[acme@newtoy ctracer_example]$

--- /tmp/pfunct.before  2006-12-30 16:18:25.000000000 -0200
+++ /tmp/pfunct.after   2007-01-02 02:08:50.000000000 -0200
@@ -249,7 +249,7 @@
 /* definitions: 1 */

 /* /pub/scm/linux/kernel/git/acme/linux-2.6/lib/klist.c:57 */
-void klist_init(struct klist * k,  * get,  * put);
+void klist_init(struct klist * k, void (*get)(struct klist_node *), void (*put)(struct klist_node *));
 /* size: 12, inline expansions: 1 (5 bytes) */
 /* definitions: 1 */

The struct/union case still needs fixing, but we're getting there...

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 02:42:33 -02:00
Arnaldo Carvalho de Melo 0f5b2d57ce [CLASSES]: Add missing ftype__has_parm_of_type prototype
And fix its usage in ctracer and pfunct, guess the cmake adoption
is still a little problematic...

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 02:37:24 -02:00
Arnaldo Carvalho de Melo 2d08b4d00f [CLASSES]: Don't pass the function pointer to the childs in cu__process_function
This is very hackish, see the previous cset comment, without this hack
unrelated, deeper DW_TAG_formal_parameter tags were being attributed to the
function being processed, proper fix is described in previous comment, for now
this is enough as a bandaid.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 02:21:59 -02:00
Arnaldo Carvalho de Melo 1e985b42eb [CLASSES]: Process DW_TAG_{union,structure}_type tags in cu__process_function
There are cases where just a declaration is emitted, such as in
blk_rq_map_user_iov's iov parameter:

 <2><dc04>: Abbrev Number: 29 (DW_TAG_structure_type)
     DW_AT_name        : (indirect string, offset: 0x3be8): sg_iovec
     DW_AT_declaration : 1
 <2><dc0a>: Abbrev Number: 88 (DW_TAG_formal_parameter)
     DW_AT_name        : iov
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 2472
     DW_AT_type        : <dc60>
     DW_AT_location    : 0x4288 (location list)

I.e. the DW_TAG_structure_type tag is emitted at the same level as the
DW_TAG_formal_parameter tags, so handled inside the cu__process_function
method.

This and the next cset only shows that a normalization in the parsing routines
is in real demand and will be done, normalization because what needs to be done
is similar to what is already done in places like cu__create_new_array, i.e.
process all the siblings in a level in tag specific cu methods.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 02:17:37 -02:00
Arnaldo Carvalho de Melo f49e492555 [CLASSES]: Make the derived class helpers be static inline
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-02 02:11:38 -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 e78718148d [CLASSES]: Introduce struct base_type
To use less memory to represent DW_TAG_base_type tags.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-29 20:58:03 -02:00
Arnaldo Carvalho de Melo c83a88bd77 [CLASSES]: Use only a struct tag to represent DW_TAG_{pointer,const}_type tags
This reduces by 8MB the dtagnames memory footprint when processing a qemu
vmlinux, that now uses ~79MB.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-29 16:34:11 -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 3e177d577a [CLASSES]: Discard DW_TAG_formal_parameter when processing classes
Only needed, so far, when processing functions, have to reenable this in the
future when we got to handle it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 14:35:44 -02:00
Arnaldo Carvalho de Melo ded72c80bd [DTAGNAMES]: 6th dwarf
Just dump the tag names, simple utility to help rework classes abstractions to
reduce memory footprint:

[acme@newtoy pahole]$ dtagnames /pub/scm/linux/kernel/git/acme/OUTPUT/qemu/linux-2.6/vmlinux | sort | uniq -c | sort -nr
size: 110832408
 207882 formal_parameter
 167305 pointer_type
 106945 structure_type
  82200 subroutine_type
  44130 typedef
  28372 array_type
   9121 const_type
   7940 union_type
   6572 base_type
   1690 enumeration_type
    894 volatile_type
[acme@newtoy pahole]$

Argh, the 'struct class' catchall uses way too many memory for non
'structure_type' classes, work to do to reduce the current 105MB memory
footprint for processing a qemu vmlinux.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 14:03:42 -02:00
Arnaldo Carvalho de Melo 5079fbea92 [CLASSES]: Save 4 bytes in struct function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 12:27:12 -02:00
Arnaldo Carvalho de Melo 594463f756 [CLASSES]: Save 12 bytes on struct class
With some tradeoff for the code size...

[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
  struct class            |  -12
 1 struct changed
  class__array_nr_entries |   +3
  class_member__names     |   +3
  parameter__names        |   +3
  class__find_holes       |   -8
  class__print_struct     |   -1
  cu__create_new_array    |  +48
 6 functions changed, 57 bytes added, 9 bytes removed
[acme@newtoy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 12:00:21 -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 a6d3a1c5e3 [CLASSES]: Be a bit paranoid on class_member__new
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 10:10:07 -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 849eda4a71 [CLASSES]: Fix abstract_origin type, its a Dwarf_Off
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 09:38:40 -02:00
Arnaldo Carvalho de Melo e838c259e0 [CLASSES]: low_pc and high_pc attributes are Dwarf_Addr
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-28 09:36:39 -02:00
Arnaldo Carvalho de Melo f397d61173 [CTRACER]: Load directory trees
And now we have --kprobes to specify where to find the kprobes struct
definitions, needed as we don't include any header files, emitting the needed
struct definitions, forward declarations when just pointers are used and also
for function prototypes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-27 14:59:17 -02:00
Arnaldo Carvalho de Melo 3ac4b868aa [CLASSES]: Introduce cus__load_dir()
To load directory trees, looking for files with a specified glob mask, calling
cus__load() on the ones that match and optionally recursively searching for
more matches in subdirectories.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-27 14:57:19 -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 5f2af297df [CLASSES]: Emit definitions for DW_TAG_subroutine_type in cus__emit_tag_definitions
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-27 10:21:40 -02:00
Arnaldo Carvalho de Melo 6be23f3d82 [CLASSES]: Support unions
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-26 20:44:03 -02:00
Arnaldo Carvalho de Melo bc5728f294 [CLASSES]: Store the high and low pc addresses in inline_expansion
For the ranges cases we store the lowest low_pc (in the first range) and the
highest high_pc (in the last range).

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-26 11:44:05 -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 c6713500c9 [CLASSES]: Tidy up class__print_struct prefix, suffix
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 19:46:52 -02:00
Arnaldo Carvalho de Melo e07a9095c4 [CTRACER]: Add missing newlines after kretprobes
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 14:41:07 -02:00
Arnaldo Carvalho de Melo 6497bcae21 [CLASSES]: Handle typedef opaque types
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 14:29:08 -02:00
Arnaldo Carvalho de Melo baadeeb7c0 [CLASSES]: Add a hack for the parm lists in function pointer struct members
To "fix" this:

/* include/linux/timer.h:10 */
struct timer_list {
<SNIP>
        void (*function)();  /*    12     4 */
<SNIP>
ctracer.c:3077: warning: function declaration isn't a prototype

Doing this for now:

struct timer_list {
<SNIP>
        void (*function)(void /* FIXME: add parm list */); /*    12     4 */
<SNIP>

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 14:06:48 -02:00
Arnaldo Carvalho de Melo 9de459007b [CLASSES]: Handle alternative function typedefs
Now we handle:

typedef void (dio_iodone_t)(void /* FIXME: add parm list */);

In addition to:

typedef int (*kprobe_pre_handler_t)(void /* FIXME: add parm list */);

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 14:00:16 -02:00
Arnaldo Carvalho de Melo 8716a7e2a7 [CLASSES]: Handle arrays in cus__emit_tag_definitions
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 13:52:28 -02:00
Arnaldo Carvalho de Melo 4587fc886a [CLASSES]: Handle 'const' and 'volatile' in cus__emit_tag_definitions
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 13:51:01 -02:00
Arnaldo Carvalho de Melo c9ccd3bb04 [CTRACER]: Add helper functions to emit struct definitions and fwd declarations
[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:36:13 -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 7483c767f4 [CLASSES]: 'type' is also a Dwarf_Off
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 12:18:14 -02:00