Commit Graph

26 Commits

Author SHA1 Message Date
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 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 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 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 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 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 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 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 ff9c2b79cd [CTRACER]: Emit kretprobes too
Now we get this using 'ctracer vmlinux sk_buff', for just one ping packet:

[14402.349410] -> ne2k_pci_block_input: skb=cea97c00
[14402.351310] <- ne2k_pci_block_input
[14402.352712] -> eth_type_trans: skb=cea97c00
[14402.353909] <- eth_type_trans
[14402.354721] -> netif_rx: skb=cea97c00
[14402.355682] <- netif_rx
[14402.356691] -> netif_receive_skb: skb=cea97c00
[14402.358007] -> arp_rcv: skb=cea97c00
[14402.359023] -> arp_process: skb=cea97c00
[14402.360152] -> ip_route_input: skb=cea97c00
[14402.361980] <- ip_route_input
[14402.369199] -> eth_header: skb=cea97b40
[14402.370336] <- eth_header
[14402.371159] -> arp_xmit: skb=cea97b40
[14402.372580] -> dev_queue_xmit: skb=cea97b40
[14402.373742] -> pfifo_fast_enqueue: skb=cea97b40
[14402.374849] <- pfifo_fast_enqueue
[14402.375827] -> dev_hard_start_xmit: skb=cea97b40
[14402.377021] -> ei_start_xmit: skb=cea97b40
[14402.378759] -> kfree_skb: skb=cea97b40
[14402.379783] -> __kfree_skb: skb=cea97b40
[14402.380854] -> kfree_skbmem: skb=cea97b40
[14402.382675] -> ne2k_pci_block_input: skb=cea97a80
[14402.383816] <- ne2k_pci_block_input
[14402.384656] -> eth_type_trans: skb=cea97a80
[14402.385632] <- eth_type_trans
[14402.386366] -> netif_rx: skb=cea97a80
[14402.387220] <- netif_rx
[14402.387949] -> skb_release_data: skb=cea97b40
[14402.389069] <- skb_release_data
[14402.389856] <- kfree_skbmem
[14402.390715] <- __kfree_skb
[14402.391761] <- kfree_skb
[14402.392875] <- ei_start_xmit
[14402.393594] <- dev_hard_start_xmit
[14402.394459] <- dev_queue_xmit
[14402.395169] <- arp_xmit
[14402.395852] -> kfree_skb: skb=cea97c00
[14402.396764] -> __kfree_skb: skb=cea97c00
[14402.397717] -> kfree_skbmem: skb=cea97c00
[14402.398677] -> skb_release_data: skb=cea97c00
[14402.399909] <- skb_release_data
[14402.400637] <- kfree_skbmem
[14402.401267] <- __kfree_skb
[14402.401875] <- kfree_skb
[14402.402489] <- arp_process
[14402.403156] <- arp_rcv
[14402.403757] <- netif_receive_skb
[14402.404674] -> netif_receive_skb: skb=cea97a80
[14402.405789] -> ip_rcv: skb=cea97a80
[14402.406837] -> ip_route_input: skb=cea97a80
[14402.407845] <- ip_route_input
[14402.408654] -> ip_local_deliver: skb=cea97a80
[14402.410031] -> icmp_rcv: skb=cea97a80
[14402.411105] -> __skb_checksum_complete: skb=cea97a80
[14402.412397] <- __skb_checksum_complete
[14402.413512] -> icmp_echo: skb=cea97a80
[14402.414584] -> icmp_reply: skb=cea97a80
[14402.415665] -> ip_options_echo: skb=cea97a80
[14402.416827] <- ip_options_echo
[14402.418188] -> dummy_xfrm_decode_session: skb=cea97a80
[14402.419426] <- dummy_xfrm_decode_session
[14402.422520] -> icmp_glue_bits: skb=cea97c00
[14402.424001] <- icmp_glue_bits
[14402.426607] -> ip_output: skb=cea97c00
[14402.428314] -> neigh_resolve_output: skb=cea97c00
[14402.429559] -> __neigh_event_send: skb=cea97c00
[14402.430747] <- __neigh_event_send
[14402.432143] -> eth_header: skb=cea97c00
[14402.433059] <- eth_header
[14402.433754] -> dev_queue_xmit: skb=cea97c00
[14402.434763] -> pfifo_fast_enqueue: skb=cea97c00
[14402.435782] <- pfifo_fast_enqueue
[14402.437177] -> dev_hard_start_xmit: skb=cea97c00
[14402.438281] -> ei_start_xmit: skb=cea97c00
[14402.439634] -> kfree_skb: skb=cea97c00
[14402.440543] -> __kfree_skb: skb=cea97c00
[14402.441530] -> sock_wfree: skb=cea97c00
[14402.442730] <- sock_wfree
[14402.443433] -> kfree_skbmem: skb=cea97c00
[14402.444383] -> skb_release_data: skb=cea97c00
[14402.445628] <- skb_release_data
[14402.446370] <- kfree_skbmem
[14402.447004] <- __kfree_skb
[14402.447613] <- kfree_skb
[14402.448207] <- ei_start_xmit
[14402.448862] <- dev_hard_start_xmit
[14402.449627] <- dev_queue_xmit
[14402.450328] <- neigh_resolve_output
[14402.451159] <- ip_output
[14402.451987] <- icmp_reply
[14402.452639] <- icmp_echo
[14402.453326] -> kfree_skb: skb=cea97a80
[14402.454220] -> __kfree_skb: skb=cea97a80
[14402.601772] -> kfree_skbmem: skb=cea97a80
[14402.602809] -> skb_release_data: skb=cea97a80
[14402.603762] <- skb_release_data
[14402.604479] <- kfree_skbmem
[14402.605072] <- __kfree_skb
[14402.605646] <- kfree_skb
[14402.606392] <- icmp_rcv
[14402.606996] <- ip_local_deliver
[14402.607694] <- ip_rcv
[14402.608236] <- netif_receive_skb
[14408.809296] -> arp_solicit: skb=00000000
[14408.811051] -> eth_header: skb=cea97a80
[14408.811977] <- eth_header
[14408.812845] -> arp_xmit: skb=cea97a80
[14408.813765] -> dev_queue_xmit: skb=cea97a80
[14408.814760] -> pfifo_fast_enqueue: skb=cea97a80
[14408.815763] <- pfifo_fast_enqueue
[14408.816657] -> dev_hard_start_xmit: skb=cea97a80
[14408.817730] -> ei_start_xmit: skb=cea97a80
[14408.818989] -> kfree_skb: skb=cea97a80
[14408.819892] -> __kfree_skb: skb=cea97a80
[14408.821529] -> ne2k_pci_block_input: skb=cea97c00
[14408.822605] <- ne2k_pci_block_input
[14408.823442] -> eth_type_trans: skb=cea97c00
[14408.824454] <- eth_type_trans
[14408.825198] -> netif_rx: skb=cea97c00
[14408.826049] <- netif_rx
[14408.826732] -> kfree_skbmem: skb=cea97a80
[14408.827681] -> skb_release_data: skb=cea97a80
[14408.828755] <- skb_release_data
[14408.829482] <- kfree_skbmem
[14408.830111] <- __kfree_skb
[14408.830720] <- kfree_skb
[14408.831312] <- ei_start_xmit
[14408.835039] <- dev_hard_start_xmit
[14408.835864] <- dev_queue_xmit
[14408.836495] <- arp_xmit
[14408.837114] <- arp_solicit
[14408.837889] -> netif_receive_skb: skb=cea97c00
[14408.838897] -> arp_rcv: skb=cea97c00
[14408.839933] -> arp_process: skb=cea97c00
[14408.841326] -> kfree_skb: skb=cea97c00
[14408.842194] -> __kfree_skb: skb=cea97c00
[14408.843070] -> kfree_skbmem: skb=cea97c00
[14408.844025] -> skb_release_data: skb=cea97c00
[14408.844932] <- skb_release_data
[14408.845595] <- kfree_skbmem
[14408.846181] <- __kfree_skb
[14408.846749] <- kfree_skb
[14408.847299] <- arp_process
[14408.847944] <- arp_rcv
[14408.848473] <- netif_receive_skb

Now we're getting to the point where a better, non printk based relaying module
is in demand, will look at blktrace relayfs stuff.

Getting access to the traced parameter at kretprobes time is badly needed, so
that we can correlate the exit calls with the entry ones.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

	[14385.224958] ctracer: registered 331 entry probes
[14385.248000] ctracer: registered 331 exit probes
2006-12-23 23:42:39 -02:00
Arnaldo Carvalho de Melo 6276810a8a [CTRACER]: Group open coded function definition in a helper function
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 20:37:23 -02:00
Arnaldo Carvalho de Melo d1a6c173b9 [CTRACER]: Print the number of registered probes at module load time
vmlinux sk_buff example:

[ 1933.122713] ctracer: registered 331 probes

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 20:22:40 -02:00
Arnaldo Carvalho de Melo 4c08435f55 [CTRACER]: Introduce emit_module_license
Its needed after all, if we want to use EXPORT_SYMBOL_GPL'ed symbols such as
register_jprobe, etc :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 20:09:02 -02:00
Arnaldo Carvalho de Melo a9d9241e48 [CLASSES]: Emit module_{exit,init} directly
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 19:58:00 -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 86e083e47b [CTRACER]: No need to use MODULE_{AUTHOR,LICENSE}
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:28:03 -02:00
Arnaldo Carvalho de Melo 64bf0272da [CTRACER]: Use expanded forms of __init and __exit
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:24:25 -02:00
Arnaldo Carvalho de Melo 2e2cd691da [CTRACER]: Don't emit 'NULL', just (void *)0
Again for not having to emit any "#include" in the ctracer generated module
source file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:14:37 -02:00
Arnaldo Carvalho de Melo c883f688cc [CTRACER]: Use expanded form of JPROBE_ENTRY() macro
So that we don't need to include any header in the ctracer generated
module source file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-23 18:12:41 -02:00
Arnaldo Carvalho de Melo 3288e28168 [CTRACER]: Use parameter__names and add a little hack for enums
Now ctracer manages vmlinux at least for struct sk_buff, more to come as tests
are made with other classes (structs).

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 20:41:46 -02:00
Arnaldo Carvalho de Melo f793f83a6d [CTRACER]: struct function has a list of struct parameter
Not struct class_member, that was not much of a problem, as the
initial layout is the same (struct tag).

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 20:09:49 -02:00
Arnaldo Carvalho de Melo b3dab6396c [CTRACER]: Emit forward declarations for the return and parameter types
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 14:27:28 -02:00
Arnaldo Carvalho de Melo 4d98e6f80b [CTRACER]: Fix handling of multi-object files
In cu_emit_kprobes_table_iterator we were defining the jprobes[] table for each
object file, do it surrounding the cu__for_each_cu call.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 13:24:32 -02:00
Arnaldo Carvalho de Melo 5d1d846e62 [CTRACER]: Return 0 on the cu iterators
This way we process not just the first object file in a multi-object
file such as vmlinux.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 13:18:29 -02:00
Arnaldo Carvalho de Melo a5147a7785 [CTRACER]: function->name couldn't possibly be NULL
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 13:10:31 -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 a4f099385b [CTRACER]: New tool
A class tracer, it looks for non-inline functions that receive as one of its
parameters a pointer to the specified "class" (a struct) and will generate a
kprobes kernel module, see the whole sequence in the README.ctracer file.

Next steps involve supporting kretprobes, inserting kprobes at each inline
"method" expansion, using relayfs, and eventually uprobes to make this useful
for userspace as well.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-12-20 12:16:16 -02:00