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
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
f93f16b51a
[CLASSES]: Pass the die to the tag type constructors
...
For now we're just supporting DWARF, so no need to keep the DWARF
knowledge outside of the core type constructors, with this we greatly
simplify the code, shrinking the resulting binaries:
[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
tag__init | +38
tag__new | -74
base_type__new | -26
enumerator__new | -26
variable__new | -43
class_member__new | -164
parameter__new | -44
inline_expansion__new | +295
label__new | -29
array_type__new | -67
class__new | -24
lexblock__init | +46
lexblock__new | -102
ftype__init | -61
ftype__new | -74
function__new | -56
cu__create_new_tag | -62
cu__create_new_class | -203
cu__create_new_base_type | -95
cu__create_new_array | -59
cu__create_new_parameter | -135
cu__create_new_label | -209
cu__create_new_variable | -180
cu__new_subroutine_type | -308
cu__process_class | -258
cu__create_new_lexblock | -180
cu__create_new_inline_expansion | -437
cu__process_function | -8
cu__create_new_function | -251
cu__create_new_enumeration | -309
cu__process_die | -376
31 functions changed, 379 bytes added, 3860 bytes removed
/home/acme/pahole/classes.c:
cu__create_new_subroutine_type | +241
1 function changed, 241 bytes added
build/libclasses.so:
32 functions changed, 620 bytes added, 3860 bytes removed
[acme@newtoy pahole]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 20:22:51 -02:00
Arnaldo Carvalho de Melo
44575d7b08
[CLASSES]: Normalize the rest of the cu__create_new_ functions
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 11:59:31 -02:00
Arnaldo Carvalho de Melo
918d3d16b8
[CLASSES]: Normalize cu__create_new_function
...
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 11:28:28 -02:00
Arnaldo Carvalho de Melo
3ca3d94f1b
[CLASSES]: Simplify cu__create_new_class
...
[acme@newtoy pahole]$ codiff build/libclasses.so.orig build/libclasses.so
/home/acme/pahole/classes.c:
cu__create_new_class | +75
cu__process_class | -49
cu__process_function | -165
cu__process_die | -52
4 functions changed, 75 bytes added, 266 bytes removed
[acme@newtoy pahole]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2007-01-03 11:09:52 -02:00
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