From 22ccaa9985211ad13e8486bf2845114f409df55d Mon Sep 17 00:00:00 2001 From: hunt Date: Sat, 18 Jun 2005 07:06:38 +0000 Subject: [PATCH] 2005-06-18 Martin Hunt * build: Modified to use build_probe. * build_probe: New file. This does the work of building a single probe or set of probes in a directory. * Makefile.template: New file. Template used by build_probe to create Makefiles. * agg: New set of probes to test/demonstrate Counter and Stat aggregations. * all probes modified for latest changes and new build process. --- runtime/probes/ChangeLog | 16 +++ .../{scf/Makefile => Makefile.template} | 6 +- runtime/probes/README | 6 + runtime/probes/agg/README | 3 + runtime/probes/agg/build | 2 + runtime/probes/agg/count1.c | 127 ++++++++++++++++++ runtime/probes/agg/count2.c | 107 +++++++++++++++ runtime/probes/agg/stat1.c | 97 +++++++++++++ runtime/probes/agg/stp | 45 +++++++ runtime/probes/agg/targets | 3 + runtime/probes/build | 74 +++------- runtime/probes/build_probe | 126 +++++++++++++++++ runtime/probes/scf/build | 2 + runtime/probes/scf/scf.c | 6 +- runtime/probes/scf/targets | 1 + runtime/probes/shellsnoop/Makefile | 21 --- runtime/probes/shellsnoop/build | 2 + runtime/probes/shellsnoop/shellsnoop.c | 12 +- runtime/probes/shellsnoop/targets | 1 + runtime/probes/tasklet/Makefile | 21 --- runtime/probes/tasklet/build | 2 + runtime/probes/tasklet/targets | 1 + runtime/probes/test4/Makefile | 21 --- runtime/probes/test4/build | 2 + runtime/probes/test4/targets | 1 + runtime/probes/test4/test4.c | 16 +-- runtime/probes/where_func/Makefile | 21 --- runtime/probes/where_func/README | 3 + runtime/probes/where_func/build | 2 + .../probes/where_func/kprobe_where_funct.c | 5 +- runtime/probes/where_func/targets | 1 + 31 files changed, 583 insertions(+), 170 deletions(-) create mode 100644 runtime/probes/ChangeLog rename runtime/probes/{scf/Makefile => Makefile.template} (89%) create mode 100644 runtime/probes/agg/README create mode 100755 runtime/probes/agg/build create mode 100644 runtime/probes/agg/count1.c create mode 100644 runtime/probes/agg/count2.c create mode 100644 runtime/probes/agg/stat1.c create mode 100755 runtime/probes/agg/stp create mode 100644 runtime/probes/agg/targets create mode 100755 runtime/probes/build_probe create mode 100755 runtime/probes/scf/build create mode 100644 runtime/probes/scf/targets delete mode 100644 runtime/probes/shellsnoop/Makefile create mode 100755 runtime/probes/shellsnoop/build create mode 100644 runtime/probes/shellsnoop/targets delete mode 100644 runtime/probes/tasklet/Makefile create mode 100755 runtime/probes/tasklet/build create mode 100644 runtime/probes/tasklet/targets delete mode 100644 runtime/probes/test4/Makefile create mode 100755 runtime/probes/test4/build create mode 100644 runtime/probes/test4/targets delete mode 100644 runtime/probes/where_func/Makefile create mode 100755 runtime/probes/where_func/build create mode 100644 runtime/probes/where_func/targets diff --git a/runtime/probes/ChangeLog b/runtime/probes/ChangeLog new file mode 100644 index 000000000..2464a5c38 --- /dev/null +++ b/runtime/probes/ChangeLog @@ -0,0 +1,16 @@ +2005-06-18 Martin Hunt + + * build: Modified to use build_probe. + + * build_probe: New file. This does the work of building + a single probe or set of probes in a directory. + + * Makefile.template: New file. Template used by + build_probe to create Makefiles. + + * agg: New set of probes to test/demonstrate + Counter and Stat aggregations. + + * all probes modified for latest changes and new build + process. + diff --git a/runtime/probes/scf/Makefile b/runtime/probes/Makefile.template similarity index 89% rename from runtime/probes/scf/Makefile rename to runtime/probes/Makefile.template index 3f80332b2..ccdbbdee8 100644 --- a/runtime/probes/scf/Makefile +++ b/runtime/probes/Makefile.template @@ -1,5 +1,4 @@ # Makefile - PWD := $(shell pwd) RT := $(PWD)/../.. KVERSION := $(shell uname -r) @@ -11,11 +10,10 @@ KTA := 0x$(firstword $(shell grep "__kernel_text_address" /boot/System.map-$(KVE EXTRA_CFLAGS := -I $(RT) -I $(RT)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) -DKTA=$(KTA) -obj-m := scf.o - +obj-m := XXX.o default: $(MAKE) V=1 -C $(KDIR) M=$(PWD) RT=$(RT) modules clean: - /bin/rm -rf *.o *.ko *~ *.mod.c .*.cmd .tmp_versions + /bin/rm -rf *.o *.o.d *.ko *~ *.mod.c .*.cmd .tmp_versions diff --git a/runtime/probes/README b/runtime/probes/README index dd9fcd0c7..f3cd9fb2e 100644 --- a/runtime/probes/README +++ b/runtime/probes/README @@ -2,3 +2,9 @@ This directory contains working example probes that demonstrate and test the runtime library. They are tested on i386 and x86_64. */ + +To build all probes, just type "./build" +To clean up, "./build clean" +To see a verbose build "./build -v" + +The same commands work in any probe subdirectory. diff --git a/runtime/probes/agg/README b/runtime/probes/agg/README new file mode 100644 index 000000000..b48db1b80 --- /dev/null +++ b/runtime/probes/agg/README @@ -0,0 +1,3 @@ +/** @dir agg +Test probes to use the Counter and Stat aggregations. +*/ diff --git a/runtime/probes/agg/build b/runtime/probes/agg/build new file mode 100755 index 000000000..f3e832443 --- /dev/null +++ b/runtime/probes/agg/build @@ -0,0 +1,2 @@ +#!/bin/bash +../build_probe $* diff --git a/runtime/probes/agg/count1.c b/runtime/probes/agg/count1.c new file mode 100644 index 000000000..870dc32eb --- /dev/null +++ b/runtime/probes/agg/count1.c @@ -0,0 +1,127 @@ +#define STP_NETLINK_ONLY +#define STP_NUM_STRINGS 1 + +#include "runtime.h" + +#include "counter.c" +#include "probes.c" + +MODULE_DESCRIPTION("SystemTap probe: count1"); +MODULE_AUTHOR("Martin Hunt "); + +Counter opens; +Counter reads; +Counter writes; +Counter sched; +Counter idle; + +static int inst_sys_open (struct kprobe *p, struct pt_regs *regs) +{ + _stp_counter_add (opens, 1); + return 0; +} + +static int inst_sys_read (struct kprobe *p, struct pt_regs *regs) +{ + _stp_counter_add (reads, 1); + return 0; +} + +static int inst_sys_write (struct kprobe *p, struct pt_regs *regs) +{ + _stp_counter_add (writes, 1); + return 0; +} + +static int inst_schedule(struct kprobe *p, struct pt_regs *regs) +{ + _stp_counter_add (sched, 1); + return 0; +} + +static int inst_idle_cpu(struct kprobe *p, struct pt_regs *regs) +{ + _stp_counter_add (idle, 1); + return 0; +} + +static struct kprobe stp_probes[] = { + { + .addr = "sys_open", + .pre_handler = inst_sys_open + }, + { + .addr = "sys_read", + .pre_handler = inst_sys_read + }, + { + .addr = "sys_write", + .pre_handler = inst_sys_write + }, + { + .addr = "schedule", + .pre_handler = inst_schedule + }, + { + .addr = "idle_cpu", + .pre_handler = inst_idle_cpu + }, +}; + +#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct kprobe)) + +static int pid; +module_param(pid, int, 0); +MODULE_PARM_DESC(pid, "daemon pid"); + +int init_module(void) +{ + int ret; + + if (!pid) { + printk("init: Can't start without daemon pid\n"); + return -1; + } + + if (_stp_transport_open(n_subbufs, subbuf_size, pid) < 0) { + printk("init: Couldn't open transport\n"); + return -1; + } + + opens = _stp_counter_init(); + reads = _stp_counter_init(); + writes = _stp_counter_init(); + sched = _stp_counter_init(); + idle = _stp_counter_init(); + + ret = _stp_register_kprobes (stp_probes, MAX_STP_ROUTINE); + + return ret; +} + +static void probe_exit (void) +{ + int i; + + _stp_unregister_kprobes (stp_probes, MAX_STP_ROUTINE); + + for_each_cpu(i) + _stp_printf ("sched calls for cpu %d = %lld\n", i, _stp_counter_get_cpu(sched, i, 0)); + + _stp_print ("\n\n"); + + _stp_printf ("open calls: %lld\n", _stp_counter_get(opens, 0)); + _stp_printf ("read calls: %lld\n", _stp_counter_get(reads, 0)); + _stp_printf ("write calls: %lld\n", _stp_counter_get(writes, 0)); + _stp_printf ("sched calls: %lld\n", _stp_counter_get(sched, 0)); + _stp_printf ("idle calls: %lld\n", _stp_counter_get(idle, 0)); + _stp_print_flush(); +} + +void cleanup_module(void) +{ + _stp_transport_close(); +} + +MODULE_LICENSE("GPL"); + diff --git a/runtime/probes/agg/count2.c b/runtime/probes/agg/count2.c new file mode 100644 index 000000000..ab13f5af0 --- /dev/null +++ b/runtime/probes/agg/count2.c @@ -0,0 +1,107 @@ +#define STP_NETLINK_ONLY +#define STP_NUM_STRINGS 1 +#include "runtime.h" + +#include "counter.c" +#include "probes.c" + +MODULE_DESCRIPTION("SystemTap probe: count1"); +MODULE_AUTHOR("Martin Hunt "); + +Counter opens; +Counter reads; +Counter writes; +Counter read_bytes; +Counter write_bytes; + +asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) +{ + _stp_counter_add (opens, 1); + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) +{ + _stp_counter_add (reads, 1); + _stp_counter_add (read_bytes, count); + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) +{ + _stp_counter_add (writes, 1); + _stp_counter_add (write_bytes, count); + jprobe_return(); + return 0; +} + +static struct jprobe stp_probes[] = { + { + .kp.addr = (kprobe_opcode_t *)"sys_open", + .entry = (kprobe_opcode_t *) inst_sys_open + }, + { + .kp.addr = (kprobe_opcode_t *)"sys_read", + .entry = (kprobe_opcode_t *) inst_sys_read + }, + { + .kp.addr = (kprobe_opcode_t *)"sys_write", + .entry = (kprobe_opcode_t *) inst_sys_write + }, +}; + +#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct jprobe)) + +static int pid; +module_param(pid, int, 0); +MODULE_PARM_DESC(pid, "daemon pid"); + +int init_module(void) +{ + int ret; + + if (!pid) { + printk("init: Can't start without daemon pid\n"); + return -1; + } + + if (_stp_transport_open(n_subbufs, subbuf_size, pid) < 0) { + printk("init: Couldn't open transport\n"); + return -1; + } + + opens = _stp_counter_init(); + reads = _stp_counter_init(); + writes = _stp_counter_init(); + read_bytes = _stp_counter_init(); + write_bytes = _stp_counter_init(); + + ret = _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE); + + return ret; +} + +static void probe_exit (void) +{ + int i; + + _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE); + + _stp_printf ("open calls: %lld\n", _stp_counter_get(opens, 0)); + _stp_printf ("read calls: %lld\n", _stp_counter_get(reads, 0)); + _stp_printf ("read bytes: %lld\n", _stp_counter_get(read_bytes, 0)); + _stp_printf ("write calls: %lld\n", _stp_counter_get(writes, 0)); + _stp_printf ("write bytes: %lld\n", _stp_counter_get(write_bytes, 0)); + + _stp_print_flush(); +} + +void cleanup_module(void) +{ + _stp_transport_close(); +} + +MODULE_LICENSE("GPL"); + diff --git a/runtime/probes/agg/stat1.c b/runtime/probes/agg/stat1.c new file mode 100644 index 000000000..1d3cb3b0e --- /dev/null +++ b/runtime/probes/agg/stat1.c @@ -0,0 +1,97 @@ +#define STP_NETLINK_ONLY +#define STP_NUM_STRINGS 1 +#include "runtime.h" +#include "stat.c" +#include "counter.c" +#include "probes.c" + +MODULE_DESCRIPTION("SystemTap probe: count1"); +MODULE_AUTHOR("Martin Hunt "); + + +Counter opens; +Stat reads; +Stat writes; + +asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) +{ + _stp_counter_add (opens, 1); + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) +{ + _stp_stat_add (reads, count); + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) +{ + _stp_stat_add (writes, count); + jprobe_return(); + return 0; +} + +static struct jprobe stp_probes[] = { + { + .kp.addr = (kprobe_opcode_t *)"sys_open", + .entry = (kprobe_opcode_t *) inst_sys_open + }, + { + .kp.addr = (kprobe_opcode_t *)"sys_read", + .entry = (kprobe_opcode_t *) inst_sys_read + }, + { + .kp.addr = (kprobe_opcode_t *)"sys_write", + .entry = (kprobe_opcode_t *) inst_sys_write + }, +}; + +#define MAX_STP_ROUTINE (sizeof(stp_probes)/sizeof(struct jprobe)) + +static int pid; +module_param(pid, int, 0); +MODULE_PARM_DESC(pid, "daemon pid"); + +int init_module(void) +{ + int ret; + + if (!pid) { + printk("init: Can't start without daemon pid\n"); + return -1; + } + + if (_stp_transport_open(n_subbufs, subbuf_size, pid) < 0) { + printk("init: Couldn't open transport\n"); + return -1; + } + + opens = _stp_counter_init(); + reads = _stp_stat_init(HIST_LOG,24); + writes = _stp_stat_init(HIST_LINEAR,0,1000,50); + + ret = _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE); + return ret; +} + +static void probe_exit (void) +{ + _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE); + + _stp_printf ("OPENS: %lld\n", _stp_counter_get(opens, 0)); + _stp_stat_print (reads, "READS: count:%C sum:%S avg:%A min:%m max:%M\n%H", 0); + _stp_stat_print (writes, "WRITES: count:%C sum:%S avg:%A min:%m max:%M\n%H", 0); + + _stp_print_flush(); +} + +void cleanup_module(void) +{ + _stp_transport_close(); +} + +MODULE_LICENSE("GPL"); + diff --git a/runtime/probes/agg/stp b/runtime/probes/agg/stp new file mode 100755 index 000000000..185a5905a --- /dev/null +++ b/runtime/probes/agg/stp @@ -0,0 +1,45 @@ +#!/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 + +STP_CONTROL=`lsmod | grep stp_control |awk '{print $1}'` +if [ "$STP_CONTROL" != "stp_control" ] +then + /sbin/insmod ../../transport/stp-control.ko +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 $modulename + +# 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/agg/targets b/runtime/probes/agg/targets new file mode 100644 index 000000000..614a00d27 --- /dev/null +++ b/runtime/probes/agg/targets @@ -0,0 +1,3 @@ +count1 +count2 +stat1 diff --git a/runtime/probes/build b/runtime/probes/build index ac9994a9a..584f792af 100755 --- a/runtime/probes/build +++ b/runtime/probes/build @@ -1,81 +1,37 @@ #!/usr/bin/tclsh # -*- tcl -*- -# simple script to do a make or "make clean" in each probe directory +# simple script to build each probe directory proc usage {} { - puts "Usage: build \[clean\]" + puts "Usage: build \[-v\] \[clean\]" exit } -set clean 0 +set clean "" +set verbose "" foreach arg $argv { if {$arg == "clean"} { - set clean 1 + set clean $arg + } elseif {$arg == "-v"} { + set verbose $arg } else { usage } } -set dirs {shellsnoop test4 where_func scf} +set cmd "exec ../build_probe $verbose $clean" -foreach i $dirs { - cd $i - if {$clean} { - puts "Cleaning $i" - if {[catch {exec make clean >& compile.errors} res]} { - [exec cat compile.errors] +foreach filename [lsort [glob *]] { + if {$filename != "CVS" && [file isdirectory $filename]} { + cd $filename + if {[catch {exec ../build_probe $verbose $clean} res]} { + puts $res exit } - } else { - puts "Building $i" - if {[catch {exec make >& compile.errors} res]} { - puts "\n------------ Compile error in $i -------------------\n" - if {[catch {open compile.errors r} fd]} { - puts "Compile failed for unknown reasons" - exit - } - while {[gets $fd line] >= 0} { - puts $line - } - close $fd - exit - } else { - if {![catch {open compile.errors r} fd]} { - # search for warnings - set bad 0 - while {[gets $fd line] >= 0} { - if {[regexp {[^W]*([A-Za-z][A-Za-z0-9_]*)[^\"]*\"([^\"]*)} $line match warn var]} { - if {$warn == "Warning"} { - switch $var { - _stp_ctrl_unregister - - _stp_ctrl_register - - relay_subbufs_consumed - - _stp_ctrl_send - - relay_open - - relayfs_create_dir - - relayfs_remove_dir - - relay_close {} - default { - if {$bad == 0} { - puts "\n------------ Unexpected Warnings in $i -------------------\n" - } - puts $line - set bad 1 - } - } - } - } - } - close $fd - } - if {$bad} { - exit - } - } + puts $res + cd .. } - catch {exec /bin/rm compile.errors} - cd .. } diff --git a/runtime/probes/build_probe b/runtime/probes/build_probe new file mode 100755 index 000000000..29846b2aa --- /dev/null +++ b/runtime/probes/build_probe @@ -0,0 +1,126 @@ +#!/usr/bin/tclsh +# -*- tcl -*- + +proc usage {} { + puts "Usage: build \[-v\] \[clean\]" + exit -1 +} + +# use Makefile.template to generate a Makefile +proc create_makefile {target} { + if {[catch {open ../Makefile.template r} fd]} { + puts "ERROR opening ../Makefile.template" + exit -1 + } + if {[catch {open Makefile w} mfd]} { + puts "ERROR creating Makefile" + exit -1 + } + while {[gets $fd line] >= 0} { + if {[regsub XXX $line $target newline]} { + set line $newline + } + puts $mfd $line + } + close $fd + close $mfd +} + +proc build {{target ""}} { + global clean verbose + if {$target == ""} { + set target [file tail [pwd]] + } + if {$clean} { + puts "Cleaning $target" + if {[catch {exec make clean >& compile.errors} res]} { + [exec cat compile.errors] + exit -1 + } + } else { + puts "Building $target" + if {[catch {exec make >& compile.errors} res]} { + puts "\n------------ Compile error in $target -------------------\n" + if {[catch {open compile.errors r} fd]} { + puts "Compile failed for unknown reasons" + exit -1 + } + while {[gets $fd line] >= 0} { + puts $line + } + close $fd + exit -1 + } else { + if {![catch {open compile.errors r} fd]} { + # search for warnings + set bad 0 + while {[gets $fd line] >= 0} { + if {$verbose} { + puts $line + } else { + if {[regexp {[^W]*([A-Za-z][A-Za-z0-9_]*)[^\"]*\"([^\"]*)} $line match warn var]} { + if {$warn == "Warning"} { + switch $var { + _stp_ctrl_unregister - + _stp_ctrl_register - + relay_subbufs_consumed - + _stp_ctrl_send - + relay_open - + relayfs_create_dir - + relayfs_remove_dir - + relay_close {} + default { + if {$bad == 0} { + puts "\n------------ Unexpected Warnings in $target -------------------\n" + } + puts $line + set bad 1 + } + } + } + } + } + } + close $fd + } + if {$bad} { + exit -1 + } + } + } +} + +set clean 0 +set verbose 0 + +foreach arg $argv { + if {$arg == "clean"} { + set clean 1 + } elseif {$arg == "-v"} { + set verbose 1 + } elseif {$arg != ""} { + usage + } +} + +if {![catch {open targets r} tfd]} { + while {[gets $tfd line] >= 0} { + set target [lindex $line 0] + create_makefile $target + build $target + catch {exec /bin/rm Makefile} + } + close $tfd +} else { + if {![file exists Makefile]} { + puts "Now in [pwd]" + puts "ERROR: No targets file found and no Makefile either" + exit -1 + } + build +} + +puts "Done" +catch {exec /bin/rm compile.errors} + + diff --git a/runtime/probes/scf/build b/runtime/probes/scf/build new file mode 100755 index 000000000..f3e832443 --- /dev/null +++ b/runtime/probes/scf/build @@ -0,0 +1,2 @@ +#!/bin/bash +../build_probe $* diff --git a/runtime/probes/scf/scf.c b/runtime/probes/scf/scf.c index dfdb7b0a5..a8798f511 100644 --- a/runtime/probes/scf/scf.c +++ b/runtime/probes/scf/scf.c @@ -1,14 +1,12 @@ #define STP_NETLINK_ONLY -#define STP_NUM_STRINGS 2 +#define STP_NUM_STRINGS 1 #include "runtime.h" #define MAP_STRING_LENGTH 512 +#define NEED_INT64_VALS #define KEY1_TYPE STRING #include "map-keys.c" -#define VALUE_TYPE INT64 -#include "map-values.c" - #include "map.c" #include "sym.c" #include "current.c" diff --git a/runtime/probes/scf/targets b/runtime/probes/scf/targets new file mode 100644 index 000000000..aafcca22d --- /dev/null +++ b/runtime/probes/scf/targets @@ -0,0 +1 @@ +scf diff --git a/runtime/probes/shellsnoop/Makefile b/runtime/probes/shellsnoop/Makefile deleted file mode 100644 index 74e355962..000000000 --- a/runtime/probes/shellsnoop/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile - -PWD := $(shell pwd) -RT := $(PWD)/../.. -KVERSION := $(shell uname -r) -KDIR := /lib/modules/$(KVERSION)/build include - -KALLSYMS_LOOKUP_NAME := 0x$(firstword $(shell grep " kallsyms_lookup_name" /boot/System.map-$(KVERSION))) -KALLSYMS_LOOKUP := 0x$(firstword $(shell grep " kallsyms_lookup$$" /boot/System.map-$(KVERSION))) -KTA := 0x$(firstword $(shell grep "__kernel_text_address" /boot/System.map-$(KVERSION))) - -EXTRA_CFLAGS := -I $(RT) -I $(RT)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) -DKTA=$(KTA) - -obj-m := shellsnoop.o - - -default: - $(MAKE) V=1 -C $(KDIR) M=$(PWD) RT=$(RT) modules - -clean: - /bin/rm -rf *.o *.ko *~ *.mod.c .*.cmd .tmp_versions diff --git a/runtime/probes/shellsnoop/build b/runtime/probes/shellsnoop/build new file mode 100755 index 000000000..f3e832443 --- /dev/null +++ b/runtime/probes/shellsnoop/build @@ -0,0 +1,2 @@ +#!/bin/bash +../build_probe $* diff --git a/runtime/probes/shellsnoop/shellsnoop.c b/runtime/probes/shellsnoop/shellsnoop.c index 081ac700d..86d2e54d0 100644 --- a/runtime/probes/shellsnoop/shellsnoop.c +++ b/runtime/probes/shellsnoop/shellsnoop.c @@ -1,17 +1,14 @@ #define STP_NETLINK_ONLY #define STP_NUM_STRINGS 1 - #include "runtime.h" +#define NEED_INT64_VALS +#define NEED_STRING_VALS + #define KEY1_TYPE INT64 #include "map-keys.c" -#define VALUE_TYPE INT64 -#include "map-values.c" - -#define VALUE_TYPE STRING -#include "map-values.c" - +#include "map.c" #include "list.c" #include "copy.c" #include "probes.c" @@ -24,6 +21,7 @@ MAP pids, arglist ; int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs) { struct map_node *ptr; + /* watch shells only */ /* FIXME: detect more shells, like csh, tcsh, zsh */ diff --git a/runtime/probes/shellsnoop/targets b/runtime/probes/shellsnoop/targets new file mode 100644 index 000000000..fdd0d7241 --- /dev/null +++ b/runtime/probes/shellsnoop/targets @@ -0,0 +1 @@ +shellsnoop diff --git a/runtime/probes/tasklet/Makefile b/runtime/probes/tasklet/Makefile deleted file mode 100644 index a15e643fc..000000000 --- a/runtime/probes/tasklet/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile - -PWD := $(shell pwd) -RT := $(PWD)/../.. -KVERSION := $(shell uname -r) -KDIR := /lib/modules/$(KVERSION)/build include - -KALLSYMS_LOOKUP_NAME := 0x$(firstword $(shell grep " kallsyms_lookup_name" /boot/System.map-$(KVERSION))) -KALLSYMS_LOOKUP := 0x$(firstword $(shell grep " kallsyms_lookup$$" /boot/System.map-$(KVERSION))) -KTA := 0x$(firstword $(shell grep "__kernel_text_address" /boot/System.map-$(KVERSION))) - -EXTRA_CFLAGS := -I $(RT) -I $(RT)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) - -obj-m := tasklet.o - - -default: - $(MAKE) V=1 -C $(KDIR) M=$(PWD) RT=$(RT) modules - -clean: - /bin/rm -rf *.o *.ko *~ *.mod.c .*.cmd .tmp_versions diff --git a/runtime/probes/tasklet/build b/runtime/probes/tasklet/build new file mode 100755 index 000000000..f3e832443 --- /dev/null +++ b/runtime/probes/tasklet/build @@ -0,0 +1,2 @@ +#!/bin/bash +../build_probe $* diff --git a/runtime/probes/tasklet/targets b/runtime/probes/tasklet/targets new file mode 100644 index 000000000..236dbd95c --- /dev/null +++ b/runtime/probes/tasklet/targets @@ -0,0 +1 @@ +stp_tasklet diff --git a/runtime/probes/test4/Makefile b/runtime/probes/test4/Makefile deleted file mode 100644 index 60afe8abc..000000000 --- a/runtime/probes/test4/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile - -PWD := $(shell pwd) -RT := $(PWD)/../.. -KVERSION := $(shell uname -r) -KDIR := /lib/modules/$(KVERSION)/build include - -KALLSYMS_LOOKUP_NAME := 0x$(firstword $(shell grep " kallsyms_lookup_name" /boot/System.map-$(KVERSION))) -KALLSYMS_LOOKUP := 0x$(firstword $(shell grep " kallsyms_lookup$$" /boot/System.map-$(KVERSION))) -KTA := 0x$(firstword $(shell grep "__kernel_text_address" /boot/System.map-$(KVERSION))) - -EXTRA_CFLAGS := -I $(RT) -I $(RT)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) -DKTA=$(KTA) - -obj-m := test4.o - - -default: - $(MAKE) V=1 -C $(KDIR) M=$(PWD) RT=$(RT) modules - -clean: - /bin/rm -rf *.o *.ko *~ *.mod.c .*.cmd .tmp_versions diff --git a/runtime/probes/test4/build b/runtime/probes/test4/build new file mode 100755 index 000000000..f3e832443 --- /dev/null +++ b/runtime/probes/test4/build @@ -0,0 +1,2 @@ +#!/bin/bash +../build_probe $* diff --git a/runtime/probes/test4/targets b/runtime/probes/test4/targets new file mode 100644 index 000000000..d234c5e05 --- /dev/null +++ b/runtime/probes/test4/targets @@ -0,0 +1 @@ +test4 diff --git a/runtime/probes/test4/test4.c b/runtime/probes/test4/test4.c index f89cc6b95..9867d8efd 100644 --- a/runtime/probes/test4/test4.c +++ b/runtime/probes/test4/test4.c @@ -2,15 +2,12 @@ #define STP_NUM_STRINGS 1 #include "runtime.h" +#define NEED_INT64_VALS +#define NEED_STAT_VALS + #define KEY1_TYPE STRING #include "map-keys.c" -#define VALUE_TYPE INT64 -#include "map-values.c" - -#define VALUE_TYPE STAT -#include "map-values.c" - #include "map.c" #include "probes.c" @@ -31,7 +28,7 @@ asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) { _stp_map_key_str (reads, current->comm); - _stp_map_add_int64_stat (reads, count); + _stp_map_add_int64 (reads, count); jprobe_return(); return 0; } @@ -39,7 +36,7 @@ asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t cou asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) { _stp_map_key_str (writes, current->comm); - _stp_map_add_int64_stat (writes, count); + _stp_map_add_int64 (writes, count); jprobe_return(); return 0; } @@ -78,7 +75,8 @@ int init_module(void) printk("init: Couldn't open transport\n"); return -1; } - + + /* FIXME. Check return values */ opens = _stp_map_new_str (1000, INT64); reads = _stp_map_new_str (1000, HSTAT_LOG, 8); writes = _stp_map_new_str (1000, HSTAT_LOG, 8); diff --git a/runtime/probes/where_func/Makefile b/runtime/probes/where_func/Makefile deleted file mode 100644 index c2c7d6bdb..000000000 --- a/runtime/probes/where_func/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile - -PWD := $(shell pwd) -RT := $(PWD)/../.. -KVERSION := $(shell uname -r) -KDIR := /lib/modules/$(KVERSION)/build include - -KALLSYMS_LOOKUP_NAME := 0x$(firstword $(shell grep " kallsyms_lookup_name" /boot/System.map-$(KVERSION))) -KALLSYMS_LOOKUP := 0x$(firstword $(shell grep " kallsyms_lookup$$" /boot/System.map-$(KVERSION))) -KTA := 0x$(firstword $(shell grep "__kernel_text_address" /boot/System.map-$(KVERSION))) - -EXTRA_CFLAGS := -I $(RT) -I $(RT)/relayfs -D KALLSYMS_LOOKUP_NAME=$(KALLSYMS_LOOKUP_NAME) -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP) -DKTA=$(KTA) - -obj-m := kprobe_where_funct.o - - -default: - $(MAKE) V=1 -C $(KDIR) M=$(PWD) RT=$(RT) modules - -clean: - /bin/rm -rf *.o *.ko *~ *.mod.c .*.cmd .tmp_versions diff --git a/runtime/probes/where_func/README b/runtime/probes/where_func/README index 4c57614b6..b73aca059 100644 --- a/runtime/probes/where_func/README +++ b/runtime/probes/where_func/README @@ -23,4 +23,7 @@ The instrumentation is removed as root with: /sbin/rmmod kprobe_funct_where \endcode -Will Cohen + +Note that this module is broken now because we don't pass the module parameter +tp stpd. FIXME */ diff --git a/runtime/probes/where_func/build b/runtime/probes/where_func/build new file mode 100755 index 000000000..f3e832443 --- /dev/null +++ b/runtime/probes/where_func/build @@ -0,0 +1,2 @@ +#!/bin/bash +../build_probe $* diff --git a/runtime/probes/where_func/kprobe_where_funct.c b/runtime/probes/where_func/kprobe_where_funct.c index a325693ab..e029a080f 100644 --- a/runtime/probes/where_func/kprobe_where_funct.c +++ b/runtime/probes/where_func/kprobe_where_funct.c @@ -8,12 +8,11 @@ #define STP_NUM_STRINGS 1 #include "runtime.h" +#define NEED_INT64_VALS + #define KEY1_TYPE INT64 #include "map-keys.c" -#define VALUE_TYPE INT64 -#include "map-values.c" - #include "map.c" #include "probes.c" #include "sym.c" diff --git a/runtime/probes/where_func/targets b/runtime/probes/where_func/targets new file mode 100644 index 000000000..7e8e4cf10 --- /dev/null +++ b/runtime/probes/where_func/targets @@ -0,0 +1 @@ +kprobe_where_funct -- 2.43.5