diff options
author | hunt <hunt> | 2005-04-07 15:12:19 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-04-07 15:12:19 +0000 |
commit | 979f20e0ecb8d287af1aedf33ac0c3b50ac9003d (patch) | |
tree | 19a2fecdafeea759885360d0df8022bddce7e7a3 /runtime | |
parent | e32551b18f4560056d2d482f5e1505b1b98fa82a (diff) | |
download | systemtap-steved-979f20e0ecb8d287af1aedf33ac0c3b50ac9003d.tar.gz systemtap-steved-979f20e0ecb8d287af1aedf33ac0c3b50ac9003d.tar.xz systemtap-steved-979f20e0ecb8d287af1aedf33ac0c3b50ac9003d.zip |
Update to use relayfs, new I/O.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/probes/shellsnoop/Makefile | 2 | ||||
-rwxr-xr-x | runtime/probes/shellsnoop/build | 3 | ||||
-rw-r--r-- | runtime/probes/shellsnoop/dtr.c | 54 | ||||
-rwxr-xr-x | runtime/probes/shellsnoop/stp | 39 | ||||
-rw-r--r-- | runtime/probes/tasklet/Makefile | 2 | ||||
-rwxr-xr-x | runtime/probes/tasklet/stp | 39 | ||||
-rw-r--r-- | runtime/probes/tasklet/stp_tasklet.c | 23 | ||||
-rw-r--r-- | runtime/probes/test4/Makefile | 2 | ||||
-rw-r--r-- | runtime/probes/test4/dtr.c | 81 | ||||
-rwxr-xr-x | runtime/probes/test4/stp | 39 | ||||
-rw-r--r-- | runtime/probes/where_func/Makefile | 2 | ||||
-rw-r--r-- | runtime/probes/where_func/kprobe_where_funct.c | 27 | ||||
-rwxr-xr-x | runtime/probes/where_func/stp | 39 |
13 files changed, 289 insertions, 63 deletions
diff --git a/runtime/probes/shellsnoop/Makefile b/runtime/probes/shellsnoop/Makefile index 8fff0dc4..12a0f65f 100644 --- a/runtime/probes/shellsnoop/Makefile +++ b/runtime/probes/shellsnoop/Makefile @@ -3,7 +3,7 @@ # # make -C path/to/kernel/src M=`pwd` modules STP_RUNTIME=path_to_systemtap_rt -CFLAGS += -I $(STP_RUNTIME) -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \ +CFLAGS += -I $(STP_RUNTIME) -I $(STP_RUNTIME)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \ -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) obj-m := dtr.o diff --git a/runtime/probes/shellsnoop/build b/runtime/probes/shellsnoop/build index 3713f08a..fb344b37 100755 --- a/runtime/probes/shellsnoop/build +++ b/runtime/probes/shellsnoop/build @@ -4,10 +4,11 @@ KVERSION=`uname -r` echo $KVERSION KALLSYMS_LOOKUP_NAME=`grep " kallsyms_lookup_name" /boot/System.map-$KVERSION |awk '{print $1}'` KALLSYMS_LOOKUP=`grep " kallsyms_lookup$" /boot/System.map-$KVERSION |awk '{print $1}'` +KTA=`grep "__kernel_text_address" /boot/System.map-$KVERSION |awk '{print $1}'` make V=1 -C /lib/modules/`uname -r`/build M=`pwd` modules \ KALLSYMS_LOOKUP_NAME=0x$KALLSYMS_LOOKUP_NAME \ - KALLSYMS_LOOKUP=0x$KALLSYMS_LOOKUP \ + KALLSYMS_LOOKUP=0x$KALLSYMS_LOOKUP KTA=0x$KTA\ STP_RUNTIME=`pwd`/../.. diff --git a/runtime/probes/shellsnoop/dtr.c b/runtime/probes/shellsnoop/dtr.c index 92b3221f..e529b054 100644 --- a/runtime/probes/shellsnoop/dtr.c +++ b/runtime/probes/shellsnoop/dtr.c @@ -2,8 +2,10 @@ #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS) #define BUCKETS 16 /* largest histogram width */ +#define STP_NETLINK_ONLY +#define STP_NUM_STRINGS 1 + #include "runtime.h" -#include "io.c" #include "map.c" #include "copy.c" #include "probes.c" @@ -23,16 +25,18 @@ int inst_do_execve (char * filename, char __user *__user *argv, char __user *__u if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh") || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh")) { - dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename); + _stp_printf ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename); _stp_map_key_long (pids, current->pid); _stp_map_set_int64 (pids, 1); _stp_list_clear (arglist); _stp_copy_argv_from_user (arglist, argv); + foreach (arglist, ptr) - printk ("%s ", ptr->str); - printk ("\n"); + _stp_printf ("%s ", ptr->str); + + _stp_print_flush(); } jprobe_return(); return 0; @@ -42,8 +46,9 @@ struct file * inst_filp_open (const char * filename, int flags, int mode) { _stp_map_key_long (pids, current->pid); if (_stp_map_get_int64 (pids)) - dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename); - + _stp_printf ("%d\t%d\t%s\tO %s", current->pid, current->parent->pid, current->comm, filename); + + _stp_print_flush(); jprobe_return(); return 0; } @@ -52,27 +57,22 @@ asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t cou { _stp_map_key_long (pids, current->pid); if (_stp_map_get_int64 (pids)) - dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd); + _stp_printf ("%d\t%d\t%s\tR %d", current->pid, current->parent->pid, current->comm, fd); + _stp_print_flush(); jprobe_return(); return 0; } asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) { - size_t len; - char str[256]; _stp_map_key_long (pids, current->pid); if (_stp_map_get_int64 (pids)) { - if (count < 64) - len = count; - else - len = 64; - len = _stp_strncpy_from_user(str, buf, len); - if (len < 0) len = 0; - str[len] = 0; - dlog ("%d\t%d\t%s\tW %s\n", current->pid, current->parent->pid, current->comm, str); + String str = _stp_string_init (0); + _stp_string_from_user(str, buf, count); + _stp_printf ("%d\t%d\t%s\tW %s", current->pid, current->parent->pid, current->comm, str->buf); + _stp_print_flush(); } jprobe_return(); @@ -95,7 +95,7 @@ static struct jprobe dtr_probes[] = { { .kp.addr = (kprobe_opcode_t *)"sys_write", .entry = (kprobe_opcode_t *) inst_sys_write - }, + }, }; #define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe)) @@ -104,20 +104,32 @@ static int init_dtr(void) { int ret; + if (_stp_netlink_open() < 0) + return -1; + pids = _stp_map_new (10000, INT64); arglist = _stp_list_new (10, STRING); ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE); - dlog("instrumentation is enabled...\n"); + _stp_log("instrumentation is enabled... %s\n", __this_module.name); return ret; } -static void cleanup_dtr(void) +static void probe_exit (void) { _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE); + + _stp_print ("In probe_exit now."); _stp_map_del (pids); - dlog("EXIT\n"); + _stp_print_flush(); +} + + +static void cleanup_dtr(void) +{ + _stp_netlink_close(); + } module_init(init_dtr); diff --git a/runtime/probes/shellsnoop/stp b/runtime/probes/shellsnoop/stp new file mode 100755 index 00000000..d10fcaab --- /dev/null +++ b/runtime/probes/shellsnoop/stp @@ -0,0 +1,39 @@ +#!/bin/bash +if [ -n "$1" ] +then + modulename=$1 +else + echo "Usage: stp modulename" + exit +fi + +RELAYFS=`lsmod | grep relayfs |awk '{print $1}'` +if [ "$RELAYFS" != "relayfs" ] +then + /sbin/insmod ../../relayfs/relayfs.ko +fi + +if [ ! -d "/mnt/relay" ] +then + mkdir /mnt/relay +fi + +MOUNT=`mount | grep relayfs |awk '{print $1}'` +if [ "$MOUNT" != "relayfs" ] +then + mount -t relayfs relayfs /mnt/relay +fi + +/sbin/insmod $modulename + +# print to screen only, 4 8K buffers +#../../stpd/stpd -p -b 8192 -n 4 + +# print to screen and log to files, 4 8K buffers +../../stpd/stpd -b 8192 -n 4 + +# no screen or log +#../../stpd/stpd -q -b 8192 -n 4 + +# stpd will remove module when it exits +#/sbin/rmmod $modulename diff --git a/runtime/probes/tasklet/Makefile b/runtime/probes/tasklet/Makefile index 369929c4..dde45d2c 100644 --- a/runtime/probes/tasklet/Makefile +++ b/runtime/probes/tasklet/Makefile @@ -3,7 +3,7 @@ # # make -C path/to/kernel/src M=`pwd` modules STP_RUNTIME=path_to_systemtap_rt -CFLAGS += -I $(STP_RUNTIME) -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME)\ +CFLAGS += -I $(STP_RUNTIME) -I $(STP_RUNTIME)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME)\ -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) obj-m := stp_tasklet.o diff --git a/runtime/probes/tasklet/stp b/runtime/probes/tasklet/stp new file mode 100755 index 00000000..d10fcaab --- /dev/null +++ b/runtime/probes/tasklet/stp @@ -0,0 +1,39 @@ +#!/bin/bash +if [ -n "$1" ] +then + modulename=$1 +else + echo "Usage: stp modulename" + exit +fi + +RELAYFS=`lsmod | grep relayfs |awk '{print $1}'` +if [ "$RELAYFS" != "relayfs" ] +then + /sbin/insmod ../../relayfs/relayfs.ko +fi + +if [ ! -d "/mnt/relay" ] +then + mkdir /mnt/relay +fi + +MOUNT=`mount | grep relayfs |awk '{print $1}'` +if [ "$MOUNT" != "relayfs" ] +then + mount -t relayfs relayfs /mnt/relay +fi + +/sbin/insmod $modulename + +# print to screen only, 4 8K buffers +#../../stpd/stpd -p -b 8192 -n 4 + +# print to screen and log to files, 4 8K buffers +../../stpd/stpd -b 8192 -n 4 + +# no screen or log +#../../stpd/stpd -q -b 8192 -n 4 + +# stpd will remove module when it exits +#/sbin/rmmod $modulename diff --git a/runtime/probes/tasklet/stp_tasklet.c b/runtime/probes/tasklet/stp_tasklet.c index aadb0c4c..f9274281 100644 --- a/runtime/probes/tasklet/stp_tasklet.c +++ b/runtime/probes/tasklet/stp_tasklet.c @@ -6,8 +6,10 @@ #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS) #define BUCKETS 16 /* largest histogram width */ +#define STP_NETLINK_ONLY +#define STP_NUM_STRINGS 1 + #include "runtime.h" -#include "io.c" #include "probes.c" MODULE_DESCRIPTION("test jprobes of tasklets"); @@ -16,7 +18,7 @@ MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); void inst__rcu_process_callbacks(struct rcu_ctrlblk *rcp, struct rcu_state *rsp, struct rcu_data *rdp) { - dlog ("interrupt=%d\n", in_interrupt()); + _stp_log ("interrupt=%d\n", in_interrupt()); jprobe_return(); } @@ -31,15 +33,24 @@ static struct jprobe stp_probes[] = { static int init_stp(void) { - int ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES); - dlog("instrumentation is enabled...\n"); + int ret; + + if (_stp_netlink_open() < 0) + return -1; + ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES); + _stp_log ("instrumentation is enabled...\n"); return ret; } -static void cleanup_stp(void) +static void probe_exit (void) { _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES); - dlog ("EXIT\n"); + _stp_log ("EXIT\n"); + +} +static void cleanup_stp(void) +{ + _stp_netlink_close(); } module_init(init_stp); diff --git a/runtime/probes/test4/Makefile b/runtime/probes/test4/Makefile index 7afe0c0f..613eff1f 100644 --- a/runtime/probes/test4/Makefile +++ b/runtime/probes/test4/Makefile @@ -3,7 +3,7 @@ # # make -C path/to/kernel/src M=`pwd` modules STP_RUNTIME=path_to_systemtap_rt -CFLAGS += -I $(STP_RUNTIME) -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \ +CFLAGS += -I $(STP_RUNTIME) -I $(STP_RUNTIME)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \ -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) -D KTA=$(KTA) obj-m := dtr.o diff --git a/runtime/probes/test4/dtr.c b/runtime/probes/test4/dtr.c index 8c6257e2..814bb61d 100644 --- a/runtime/probes/test4/dtr.c +++ b/runtime/probes/test4/dtr.c @@ -2,15 +2,24 @@ #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS) #define BUCKETS 16 /* largest histogram width */ +#define STP_NETLINK_ONLY +#define STP_NUM_STRINGS 1 + +#include <linux/module.h> +#include <linux/interrupt.h> +#include <net/sock.h> +#include <linux/netlink.h> + #include "runtime.h" -#include "io.c" #include "map.c" #include "probes.c" +#include "stack.c" MODULE_DESCRIPTION("SystemTap probe: test4"); MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); -MAP opens, reads, writes; + +MAP opens, reads, writes, traces; asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) { @@ -36,6 +45,18 @@ asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, siz return 0; } +int inst_show_cpuinfo(struct seq_file *m, void *v) +{ + String str = _stp_string_init (0); + _stp_stack_print (0,0); + _stp_stack_print (1,0); + _stp_list_add (traces, _stp_stack_sprint(str, 0, 0)); + + jprobe_return(); + return 0; +} + + static struct jprobe dtr_probes[] = { { .kp.addr = (kprobe_opcode_t *)"sys_open", @@ -49,6 +70,10 @@ static struct jprobe dtr_probes[] = { .kp.addr = (kprobe_opcode_t *)"sys_write", .entry = (kprobe_opcode_t *) inst_sys_write }, + { + .kp.addr = (kprobe_opcode_t *)"show_cpuinfo", + .entry = (kprobe_opcode_t *) inst_show_cpuinfo, + }, }; #define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe)) @@ -57,46 +82,58 @@ static int init_dtr(void) { int ret; + if (_stp_netlink_open() < 0) + return -1; + opens = _stp_map_new (1000, INT64); reads = _stp_map_new (1000, STAT); writes = _stp_map_new (1000, STAT); + traces = _stp_list_new (1000, STRING); ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE); - dlog("instrumentation is enabled...\n"); + _stp_log("instrumentation is enabled...\n"); return ret; - } -static void cleanup_dtr(void) +static void probe_exit (void) { struct map_node_stat *st; struct map_node_int64 *ptr; + struct map_node_str *sptr; _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE); - for (ptr = (struct map_node_int64 *)_stp_map_start(opens); ptr; - ptr = (struct map_node_int64 *)_stp_map_iter (opens,(struct map_node *)ptr)) - dlog ("opens[%s] = %lld\n", key1str(ptr), ptr->val); - dlog ("\n"); - - for (st = (struct map_node_stat *)_stp_map_start(reads); st; - st = (struct map_node_stat *)_stp_map_iter (reads,(struct map_node *)st)) - dlog ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), st->stats.count, st->stats.sum, - st->stats.min, st->stats.max); - dlog ("\n"); - - for (st = (struct map_node_stat *)_stp_map_start(writes); st; - st = (struct map_node_stat *)_stp_map_iter (writes,(struct map_node *)st)) - dlog ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), st->stats.count, st->stats.sum, - st->stats.min, st->stats.max); - dlog ("\n"); + foreach (traces, sptr) { + _stp_printf ("trace: %s\n", sptr->str); + _stp_print_flush (); + } + + foreach (opens, ptr) { + _stp_printf ("opens[%s] = %lld\n", key1str(ptr), ptr->val); + _stp_print_flush (); + } + + foreach (reads, st) { + _stp_printf ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), + st->stats.count, st->stats.sum, st->stats.min, st->stats.max); + _stp_print_flush (); + } + + foreach (writes, st) { + _stp_printf ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), + st->stats.count, st->stats.sum, st->stats.min, st->stats.max); + _stp_print_flush(); + } _stp_map_del (opens); _stp_map_del (reads); _stp_map_del (writes); +} - dlog("EXIT\n"); +static void cleanup_dtr(void) +{ + _stp_netlink_close(); } module_init(init_dtr); diff --git a/runtime/probes/test4/stp b/runtime/probes/test4/stp new file mode 100755 index 00000000..d10fcaab --- /dev/null +++ b/runtime/probes/test4/stp @@ -0,0 +1,39 @@ +#!/bin/bash +if [ -n "$1" ] +then + modulename=$1 +else + echo "Usage: stp modulename" + exit +fi + +RELAYFS=`lsmod | grep relayfs |awk '{print $1}'` +if [ "$RELAYFS" != "relayfs" ] +then + /sbin/insmod ../../relayfs/relayfs.ko +fi + +if [ ! -d "/mnt/relay" ] +then + mkdir /mnt/relay +fi + +MOUNT=`mount | grep relayfs |awk '{print $1}'` +if [ "$MOUNT" != "relayfs" ] +then + mount -t relayfs relayfs /mnt/relay +fi + +/sbin/insmod $modulename + +# print to screen only, 4 8K buffers +#../../stpd/stpd -p -b 8192 -n 4 + +# print to screen and log to files, 4 8K buffers +../../stpd/stpd -b 8192 -n 4 + +# no screen or log +#../../stpd/stpd -q -b 8192 -n 4 + +# stpd will remove module when it exits +#/sbin/rmmod $modulename diff --git a/runtime/probes/where_func/Makefile b/runtime/probes/where_func/Makefile index 1e6b9d2e..431ddc4f 100644 --- a/runtime/probes/where_func/Makefile +++ b/runtime/probes/where_func/Makefile @@ -3,7 +3,7 @@ # # make -C path/to/kernel/src M=`pwd` modules STP_RUNTIME=path_to_systemtap_rt -CFLAGS += -I $(STP_RUNTIME) -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \ +CFLAGS += -I $(STP_RUNTIME) -I $(STP_RUNTIME)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) \ -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) obj-m := kprobe_where_funct.o diff --git a/runtime/probes/where_func/kprobe_where_funct.c b/runtime/probes/where_func/kprobe_where_funct.c index e527fa03..027a40de 100644 --- a/runtime/probes/where_func/kprobe_where_funct.c +++ b/runtime/probes/where_func/kprobe_where_funct.c @@ -6,9 +6,10 @@ #define HASH_TABLE_BITS 8 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS) #define BUCKETS 16 /* largest histogram width */ +#define STP_NETLINK_ONLY +#define STP_NUM_STRINGS 1 #include "runtime.h" -#include "io.c" #include "map.c" #include "probes.c" #include "current.c" @@ -47,7 +48,10 @@ static struct kprobe kp[] = { int init_module(void) { int ret; - + + if (_stp_netlink_open() < 0) + return -1; + funct_locations = _stp_map_new(1000, INT64); if (funct_name) @@ -58,23 +62,28 @@ int init_module(void) return ret; } -void cleanup_module(void) +static void probe_exit (void) { struct map_node_int64 *ptr; _stp_unregister_kprobes (kp, MAX_KPROBES); - dlog("%s() called %d times.\n", funct_name, count_funct); - dlog("NUM\tCaller Addr\tCaller Name\n", funct_name); + _stp_printf("%s() called %d times.\n", funct_name, count_funct); + _stp_printf("NUM\tCaller\n", funct_name); /* now walk the hash table and print out all the information */ foreach(funct_locations, ptr) { - _stp_scbuf_clear(); - _stp_symbol_sprint (key1int(ptr)); - dlog("%lld\t0x%p\t(%s)\n", ptr->val, key1int(ptr), _stp_scbuf); + _stp_printf("%lld\t", ptr->val); + _stp_symbol_print (key1int(ptr)); + _stp_print_flush(); } - + _stp_map_del(funct_locations); } +void cleanup_module(void) +{ + _stp_netlink_close(); +} + MODULE_LICENSE("GPL"); diff --git a/runtime/probes/where_func/stp b/runtime/probes/where_func/stp new file mode 100755 index 00000000..d10fcaab --- /dev/null +++ b/runtime/probes/where_func/stp @@ -0,0 +1,39 @@ +#!/bin/bash +if [ -n "$1" ] +then + modulename=$1 +else + echo "Usage: stp modulename" + exit +fi + +RELAYFS=`lsmod | grep relayfs |awk '{print $1}'` +if [ "$RELAYFS" != "relayfs" ] +then + /sbin/insmod ../../relayfs/relayfs.ko +fi + +if [ ! -d "/mnt/relay" ] +then + mkdir /mnt/relay +fi + +MOUNT=`mount | grep relayfs |awk '{print $1}'` +if [ "$MOUNT" != "relayfs" ] +then + mount -t relayfs relayfs /mnt/relay +fi + +/sbin/insmod $modulename + +# print to screen only, 4 8K buffers +#../../stpd/stpd -p -b 8192 -n 4 + +# print to screen and log to files, 4 8K buffers +../../stpd/stpd -b 8192 -n 4 + +# no screen or log +#../../stpd/stpd -q -b 8192 -n 4 + +# stpd will remove module when it exits +#/sbin/rmmod $modulename |