]> sourceware.org Git - systemtap.git/commitdiff
*** empty log message ***
authorhunt <hunt>
Tue, 17 May 2005 07:04:25 +0000 (07:04 +0000)
committerhunt <hunt>
Tue, 17 May 2005 07:04:25 +0000 (07:04 +0000)
runtime/probes/test4/Makefile
runtime/probes/test4/build [deleted file]
runtime/probes/test4/dtr.c [deleted file]
runtime/probes/test4/test4.c [new file with mode: 0644]

index 613eff1febabd93e369f622aecb662708d44a35d..8b973baad9e1573bdc8d93b03fba085e94a3294f 100644 (file)
@@ -1,11 +1,23 @@
 # Makefile
-#
-#
-# make -C path/to/kernel/src M=`pwd` modules STP_RUNTIME=path_to_systemtap_rt
+
+PWD     := $(shell pwd)
+KVERSION       := $(shell uname -r)
+KDIR   := /lib/modules/$(KVERSION)/build include
+
+KALLSYMS_LOOKUP_NAME   := $(firstword $(shell grep " kallsyms_lookup_name" /boot/System.map-$(KVERSION)))
+KALLSYMS_LOOKUP        := $(firstword $(shell grep " kallsyms_lookup$$" /boot/System.map-$(KVERSION)))
+KTA    := $(firstword $(shell grep "__kernel_text_address" /boot/System.map-$(KVERSION)))
 
 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
+       -D KALLSYMS_LOOKUP=$(KALLSYMS_LOOKUP)
+
+obj-m := test4.o
+
+default:
+       $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules \
+       KALLSYMS_LOOKUP_NAME=0x$(KALLSYMS_LOOKUP_NAME) \
+       KALLSYMS_LOOKUP=0x$(KALLSYMS_LOOKUP)  KTA=0x$(KTA)\
+       STP_RUNTIME=$(PWD)/../..
 
 clean:
        /bin/rm -rf *.o *.ko *~ *.mod.c .*.cmd .tmp_versions
diff --git a/runtime/probes/test4/build b/runtime/probes/test4/build
deleted file mode 100755 (executable)
index fb344b3..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-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  KTA=0x$KTA\
-       STP_RUNTIME=`pwd`/../..
-
-
-
-
-
diff --git a/runtime/probes/test4/dtr.c b/runtime/probes/test4/dtr.c
deleted file mode 100644 (file)
index 09b0f52..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-#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 <linux/module.h>
-#include <linux/interrupt.h>
-#include <net/sock.h>
-#include <linux/netlink.h>
-
-#include "runtime.h"
-#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, traces;
-
-asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode)
-{
-  _stp_map_key_str (opens, current->comm);
-  _stp_map_add_int64 (opens, 1);
-  jprobe_return();
-  return 0;
-}
-
-asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count)
-{
-  _stp_map_key_str (reads, current->comm);
-  _stp_map_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_map_key_str (writes, current->comm);
-  _stp_map_stat_add (writes, count);
-  jprobe_return();
-  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",
-    .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
-  },
-  {
-    .kp.addr = (kprobe_opcode_t *)"show_cpuinfo",
-    .entry = (kprobe_opcode_t *) inst_show_cpuinfo,
-  },
-};
-
-#define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe))
-
-static unsigned n_subbufs = 4;
-module_param(n_subbufs, uint, 0);
-MODULE_PARM_DESC(n_subbufs, "number of sub-buffers per per-cpu buffer");
-
-static unsigned subbuf_size = 65536;
-module_param(subbuf_size, uint, 0);
-MODULE_PARM_DESC(subbuf_size, "size of each per-cpu sub-buffers");
-
-static int pid;
-module_param(pid, int, 0);
-MODULE_PARM_DESC(pid, "daemon pid");
-
-static int init_dtr(void)
-{
-  int ret;
-  
-  if (!pid) {
-         printk("init_dtr: Can't start without daemon pid\n");         
-         return -1;
-  }
-
-  if (_stp_transport_open(n_subbufs, subbuf_size, pid) < 0) {
-         printk("init_dtr: Couldn't open transport\n");                
-         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);
-
-  _stp_log("instrumentation is enabled...\n");
-  return ret;
-}
-
-static int exited; /* FIXME: this is a stopgap - if we don't do this
-                   * and are manually removed, bad things happen */
-
-static void probe_exit (void)
-{
-  struct map_node_stat *st;
-  struct map_node_int64 *ptr;
-  struct map_node_str *sptr;
-
-  exited = 1;
-
-  _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE);
-
-  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);
-}
-
-static void cleanup_dtr(void)
-{
-       if (!exited)
-               probe_exit();
-       
-       _stp_transport_close();
-}
-
-module_init(init_dtr);
-module_exit(cleanup_dtr);
-MODULE_LICENSE("GPL");
-
diff --git a/runtime/probes/test4/test4.c b/runtime/probes/test4/test4.c
new file mode 100644 (file)
index 0000000..f4b6c9b
--- /dev/null
@@ -0,0 +1,110 @@
+#define STP_NETLINK_ONLY
+#define STP_NUM_STRINGS 1
+#include "runtime.h"
+
+#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"
+
+MODULE_DESCRIPTION("SystemTap probe: test4");
+MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
+
+
+MAP opens, reads, writes;
+
+asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode)
+{
+  _stp_map_key_str (opens, current->comm);
+  _stp_map_add_int64 (opens, 1);
+  jprobe_return();
+  return 0;
+}
+
+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);
+  jprobe_return();
+  return 0;
+}
+
+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);
+  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_map_new_str (1000, INT64);
+  reads = _stp_map_new_str (1000, HSTAT_LOG, 8);
+  writes = _stp_map_new_str (1000, HSTAT_LOG, 8);
+
+  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_map_print (opens,"opens");
+  _stp_map_print (reads,"reads");
+  _stp_map_print (writes,"writes");
+
+  _stp_map_del (opens);
+  _stp_map_del (reads);
+  _stp_map_del (writes);
+}
+
+void cleanup_module(void)
+{
+  _stp_transport_close();
+}
+
+MODULE_LICENSE("GPL");
+
This page took 0.035817 seconds and 5 git commands to generate.