Commit Graph

136 Commits

Author SHA1 Message Date
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
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
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
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
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
Arnaldo Carvalho de Melo
45c40e4b8d [CLASSES]: Use Dwarf_Off type for the cu_offset derived variables/members
This is part of a cleanup process were I'm revisiting the types used for
the various abstractions, using the correct libdw.h types.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 12:07:41 -02:00
Arnaldo Carvalho de Melo
30128e9d11 [CLASSES]: Use uint32_t for the cu id
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 12:00:07 -02:00
Arnaldo Carvalho de Melo
3ca40af1fd [CLASSES]: Add support for enums
Be it named enums such as:

/* include/linux/pid.h:7 */
enum pid_type {
	PIDTYPE_PID = 0,
	PIDTYPE_PGID = 1,
	PIDTYPE_SID = 2,
	PIDTYPE_MAX = 3,
};

Or nameless enums inside structs:

/* include/linux/journal-head.h:14 */
typedef struct transaction_s {
        journal_t *                t_journal;            /*     0     4 */
        tid_t                      t_tid;                /*     4     4 */
        enum {
		T_RUNNING = 0,
		T_LOCKED = 1,
		T_RUNDOWN = 2,
		T_FLUSH = 3,
		T_COMMIT = 4,
		T_FINISHED = 5,
	} t_state;                                       /*     8     4 */
        long unsigned int          t_log_start;          /*    12     4 */
<SNIP>
} transaction_t; /* size: 84, cachelines: 3 */
                 /* last cacheline: 20 bytes */

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-24 11:56:59 -02:00
Arnaldo Carvalho de Melo
ca50c1a52f [CLASSES]: Make cus__emit_struct_definitions register what it defines
So that we don't get duplicates.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 23:34:42 -02:00
Arnaldo Carvalho de Melo
82692a819d [CLASSES]: Export cus__emit_fwd_decl
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 23:33:37 -02:00
Arnaldo Carvalho de Melo
8cecc52959 [CLASSES]: Look for nameless classes in cus__find_definition
structs typedef'ed...

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 22:35:38 -02:00
Arnaldo Carvalho de Melo
297d7b3f8f [CLASSES]: Handle cases where fwd decls and definitions can happen
If a definition is being emitted and there was already a forward declaration,
remove the class from the fwd_decl list before adding it to the declarations
list, in the reverse case just don't add it to the fwd_decl list.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 22:28:40 -02:00
Arnaldo Carvalho de Melo
2d7ec7cd35 [CLASSES]: Set ->{fwd_decl_emitted,visited} to speed up lookups
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 21:44:55 -02:00
Arnaldo Carvalho de Melo
bbac253ab0 [CLASSES]: Just move class__subroutine_ptr_mask before class_member__names
So that we can use it there.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 20:39:24 -02:00
Arnaldo Carvalho de Melo
149f4f81ed [CLASSES]: Introduce functions to rebuild structs, typedefs, etc
So that we can build a module that doesn't uses #includes to get these
definitions.

More work to be done for enums, etc, but this already is enough for
ctracer to handle tracing the sk_buff methods in vmlinux.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 19:29:27 -02:00
Arnaldo Carvalho de Melo
f7a934cf0a [CLASSES]: Add _add and _find functions for definitions and fwd decls
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:53:25 -02:00
Arnaldo Carvalho de Melo
af9adf0b9a [CLASSES]: Introduce cus__find_function_by_name
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:46:05 -02:00
Arnaldo Carvalho de Melo
7d581ce17c [CLASSES]: Introduce list heads for definitions and forward declarations
In struct cus, that will be used when rebuilding class definitions for
enums, struct pointers, struct definitions, etc, in ctracer for a start.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:30:48 -02:00
Arnaldo Carvalho de Melo
66ef6a39ba [CLASSES]: Add optional prefix and suffix parameters to class__print
That will be used when typedefs are being emitted, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:09:47 -02:00
Arnaldo Carvalho de Melo
27af1f615b [CLASSES]: Introduce parameter__names
Some rework is needed to make class_member__names and parameter__names to share
more code, but there are things like bitfields that are exclusive to
class_member entries, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 20:40:13 -02:00
Arnaldo Carvalho de Melo
973d243189 [CLASSES]: Introduce tag__fwd_decl
To emit forward declarations for types, used in ctracer.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 14:10:07 -02:00
Arnaldo Carvalho de Melo
c372555a6c [CLASSES]: Return NULL in cu__find_class_by_id if tag.type == 0
I.e. if the type is void, avoiding looking the whole list for something
that is not there.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 14:02:05 -02:00
Arnaldo Carvalho de Melo
3e7e387ddb [CLASSES]: Move passing the object file name from cus__new to cus__load
So that we can load many object files, that is what the next csets will
do, to recursively look for files with debug info in a build tree, such
as the kernel one.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 12:35:45 -02:00
Arnaldo Carvalho de Melo
4a015cf738 [CLASSES]: Add list nodes to struct cu and function to be used by tools
Any tool can use it, first one will be ctracer, the class tracer.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 12:07:09 -02:00
Arnaldo Carvalho de Melo
5cb0779231 [CLASSES]: Pass the cookie to the filter in cu__for_each_function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 12:05:29 -02:00
Arnaldo Carvalho de Melo
5484abff49 [CLASSES]: Move function__has_parameter_of_type from pfunct to libclasses
Will be used by a new tool, ctracer.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 12:03:12 -02:00
Arnaldo Carvalho de Melo
a9d464021d [CLASSES]: Make class__name return "void" when passed a NULL class
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-19 09:20:52 -02:00
Arnaldo Carvalho de Melo
0dd2519bff [CLASSES]: Export class__name
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-19 09:11:17 -02:00
Arnaldo Carvalho de Melo
a7f819ccb2 [CLASSES]: Remove some now unused functions
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-18 17:14:31 -02:00
Arnaldo Carvalho de Melo
bd4dfbccb9 [CLASSES]: Add a filter to cu__for_each_function
Same purpose as in the one in cu__for_each_class.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-18 15:35:31 -02:00
Arnaldo Carvalho de Melo
6d02afd548 [CLASSES]: Remove newlines at the end of class__print
Let the callers decide if they want to do it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-18 10:20:57 -02:00
Arnaldo Carvalho de Melo
e70860fe11 [CLASSES]: Constify print routines class parameter
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-18 09:29:41 -02:00