summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2005-11-09 01:00:40 +0000
committerhunt <hunt>2005-11-09 01:00:40 +0000
commitfa3f3d4d2e3d173750685ff89a0f53f8c8a2310c (patch)
tree5113b61b9b6437d65cd912199dbf560e29de080d
parente8fd2f2631965df59fdd3e263aae9ef3721306da (diff)
downloadsystemtap-steved-fa3f3d4d2e3d173750685ff89a0f53f8c8a2310c.tar.gz
systemtap-steved-fa3f3d4d2e3d173750685ff89a0f53f8c8a2310c.tar.xz
systemtap-steved-fa3f3d4d2e3d173750685ff89a0f53f8c8a2310c.zip
2005-11-08 Martin Hunt <hunt@redhat.com>
* shellsnoop/shellsnoop.c: Updated to use new map API. * where_func/kprobe_where_funct.c: Ditto. * os_timer/os_timer.c (probe_start): Ditto. * test4/test4.c: Ditto. * scf/scf.c: Ditto.
-rw-r--r--runtime/probes/ChangeLog8
-rw-r--r--runtime/probes/os_timer/os_timer.c15
-rw-r--r--runtime/probes/scf/scf.c12
-rw-r--r--runtime/probes/shellsnoop/shellsnoop.c109
-rw-r--r--runtime/probes/test4/test4.c25
-rw-r--r--runtime/probes/where_func/kprobe_where_funct.c11
6 files changed, 97 insertions, 83 deletions
diff --git a/runtime/probes/ChangeLog b/runtime/probes/ChangeLog
index 964262f4..b4382fd1 100644
--- a/runtime/probes/ChangeLog
+++ b/runtime/probes/ChangeLog
@@ -1,3 +1,11 @@
+2005-11-08 Martin Hunt <hunt@redhat.com>
+
+ * shellsnoop/shellsnoop.c: Updated to use new map API.
+ * where_func/kprobe_where_funct.c: Ditto.
+ * os_timer/os_timer.c (probe_start): Ditto.
+ * test4/test4.c: Ditto.
+ * scf/scf.c: Ditto.
+
2005-09-08 Martin Hunt <hunt@redhat.com>
* scf/scf.c (inst_smp_call_function): Add new verbose arg
diff --git a/runtime/probes/os_timer/os_timer.c b/runtime/probes/os_timer/os_timer.c
index 20aebf68..4a80d02b 100644
--- a/runtime/probes/os_timer/os_timer.c
+++ b/runtime/probes/os_timer/os_timer.c
@@ -11,11 +11,6 @@
/* os includes */
#include "linux/timer.h"
-/* define this if you don't want to use relayfs. Normally */
-/* you want relayfs, unless you need a realtime stream of data */
-
-/* #define STP_NETLINK_ONLY */
-
/* How many strings to allocate. see strings.c. Default is 0. */
#define STP_NUM_STRINGS 1
@@ -32,11 +27,10 @@
#include "runtime.h"
/* @todo since we don't have aggregation maps yet, try regular maps */
-#define NEED_INT64_VALS
-
+#define VALUE_TYPE INT64
#define KEY1_TYPE STRING
#define KEY2_TYPE INT64
-#include "map-keys.c"
+#include "map-gen.c"
#include "map.c"
@@ -61,8 +55,7 @@ void inst_async(struct pt_regs *regs)
/* Create a map of interrupted addresses seen */
/* really want a map of image name / address */
- _stp_map_key_str_int64(cur_addr, current->comm, ip);
- _stp_map_add_int64(cur_addr, 1);
+ _stp_map_add_sii(cur_addr, current->comm, ip, 1);
/* Need _stp_stack() and _stp_ustack()? */
/* _stp_image() and aggregation maps */
@@ -98,7 +91,7 @@ int probe_start(void)
{
timing = _stp_stat_init(HIST_LINEAR, 0, 5000, 250);
- cur_addr = _stp_map_new_str_int64(1000, INT64);
+ cur_addr = _stp_map_new_sii(1000);
/* register the os_timer */
init_timer(&timer);
diff --git a/runtime/probes/scf/scf.c b/runtime/probes/scf/scf.c
index b8e38318..0e29df43 100644
--- a/runtime/probes/scf/scf.c
+++ b/runtime/probes/scf/scf.c
@@ -2,9 +2,10 @@
#include "runtime.h"
#define MAP_STRING_LENGTH 512
-#define NEED_INT64_VALS
+
+#define VALUE_TYPE INT64
#define KEY1_TYPE STRING
-#include "map-keys.c"
+#include "map-gen.c"
#include "map.c"
#include "sym.c"
@@ -20,9 +21,8 @@ MAP map1;
int inst_smp_call_function (struct kprobe *p, struct pt_regs *regs)
{
String str = _stp_string_init (0);
- _stp_stack_sprint (str,regs,1);
- _stp_map_key_str(map1, _stp_string_ptr(str));
- _stp_map_add_int64 (map1, 1);
+ _stp_stack_sprint (str, regs, 1);
+ _stp_map_add_si (map1, _stp_string_ptr(str), 1);
return 0;
}
@@ -37,7 +37,7 @@ static struct kprobe stp_probes[] = {
int probe_start(void)
{
- map1 = _stp_map_new_str (100, INT64);
+ map1 = _stp_map_new_si (100);
return _stp_register_kprobes (stp_probes, MAX_STP_ROUTINE);
}
diff --git a/runtime/probes/shellsnoop/shellsnoop.c b/runtime/probes/shellsnoop/shellsnoop.c
index 6c5458f5..dd0c81b9 100644
--- a/runtime/probes/shellsnoop/shellsnoop.c
+++ b/runtime/probes/shellsnoop/shellsnoop.c
@@ -3,14 +3,15 @@
#define STP_STRING_SIZE 8192
#include "runtime.h"
-#define NEED_INT64_VALS
-#define NEED_STRING_VALS
+#define VALUE_TYPE INT64
+#define KEY1_TYPE INT64
+#include "map-gen.c"
+#define VALUE_TYPE STRING
#define KEY1_TYPE INT64
-#include "map-keys.c"
+#include "map-gen.c"
#include "map.c"
-#include "list.c"
#include "copy.c"
#include "probes.c"
@@ -19,6 +20,29 @@ MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
MAP pids, arglist ;
+void _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
+{
+ char str[128];
+ char __user *vstr;
+ int len, i = 0;
+
+ if (argv)
+ argv++;
+
+ while (argv != NULL) {
+ if (get_user (vstr, argv))
+ break;
+
+ if (vstr == NULL)
+ break;
+
+ len = _stp_strncpy_from_user(str, vstr, 128);
+ str[len] = 0;
+ _stp_map_set_is (list, i++, str);
+ argv++;
+ }
+}
+
int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs)
{
struct map_node *ptr;
@@ -30,17 +54,16 @@ int inst_do_execve (char * filename, char __user *__user *argv, char __user *__u
|| !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh"))
{
_stp_printf ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename);
-
- _stp_map_key_int64 (pids, current->pid);
- _stp_map_set_int64 (pids, 1);
- _stp_list_clear (arglist);
+ _stp_map_set_ii (pids, current->pid, 1);
+
+ _stp_map_clear (arglist);
_stp_copy_argv_from_user (arglist, argv);
foreach (arglist, ptr)
_stp_printf ("%s ", _stp_get_str(ptr));
_stp_print("\n");
-
+
_stp_print_flush();
}
jprobe_return();
@@ -49,8 +72,7 @@ int inst_do_execve (char * filename, char __user *__user *argv, char __user *__u
struct file * inst_filp_open (const char * filename, int flags, int mode)
{
- _stp_map_key_int64 (pids, current->pid);
- if (_stp_map_get_int64 (pids)) {
+ if (_stp_map_get_ii (pids, current->pid)) {
_stp_printf ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename);
_stp_print_flush();
}
@@ -60,8 +82,7 @@ struct file * inst_filp_open (const char * filename, int flags, int mode)
asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count)
{
- _stp_map_key_int64 (pids, current->pid);
- if (_stp_map_get_int64 (pids)) {
+ if (_stp_map_get_ii (pids, current->pid)) {
_stp_printf ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd);
_stp_print_flush();
}
@@ -71,15 +92,13 @@ 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_int64 (pids, current->pid);
- if (_stp_map_get_int64 (pids))
- {
- 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, _stp_string_ptr(str));
- _stp_print_flush();
- }
+ if (_stp_map_get_ii (pids, current->pid)) {
+ 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, _stp_string_ptr(str));
+ _stp_print_flush();
+ }
jprobe_return();
return 0;
@@ -109,34 +128,34 @@ static struct jprobe stp_probes[] = {
int probe_start(void)
{
- int ret;
-
- /* now initialize any data or variables */
- pids = _stp_map_new_int64 (10000, INT64);
- arglist = _stp_list_new (10, STRING);
-
- /* now we are ready to enable the probes */
- ret = _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE);
-
- if (ret < 0) {
- _stp_map_del (pids);
- _stp_map_del (arglist);
- return ret;
- }
-
- _stp_printf("instrumentation is enabled... %s\n", __this_module.name);
- _stp_print_flush();
- return ret;
+ int ret;
+
+ /* now initialize any data or variables */
+ pids = _stp_map_new_ii(10000);
+ arglist = _stp_map_new_is (10);
+
+ /* now we are ready to enable the probes */
+ ret = _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE);
+
+ if (ret < 0) {
+ _stp_map_del (pids);
+ _stp_map_del (arglist);
+ return ret;
+ }
+
+ _stp_printf("instrumentation is enabled... %s\n", __this_module.name);
+ _stp_print_flush();
+ return ret;
}
void probe_exit (void)
{
- _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE);
- _stp_map_del (pids);
- _stp_map_del (arglist);
- _stp_printf("\nDropped %d packets\n", atomic_read(&_stp_transport_failures));
- _stp_print_flush();
+ _stp_unregister_jprobes (stp_probes, MAX_STP_ROUTINE);
+ _stp_map_del (pids);
+ _stp_map_del (arglist);
+ _stp_printf("\nDropped %d packets\n", atomic_read(&_stp_transport_failures));
+ _stp_print_flush();
}
diff --git a/runtime/probes/test4/test4.c b/runtime/probes/test4/test4.c
index 48f2eca9..56027186 100644
--- a/runtime/probes/test4/test4.c
+++ b/runtime/probes/test4/test4.c
@@ -1,13 +1,13 @@
-#define STP_NETLINK_ONLY
#define STP_NUM_STRINGS 1
-
#include "runtime.h"
-#define NEED_INT64_VALS
-#define NEED_STAT_VALS
+#define VALUE_TYPE INT64
+#define KEY1_TYPE STRING
+#include "map-gen.c"
+#define VALUE_TYPE STAT
#define KEY1_TYPE STRING
-#include "map-keys.c"
+#include "map-gen.c"
#include "map.c"
#include "probes.c"
@@ -20,24 +20,21 @@ 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);
+ _stp_map_add_si (opens, current->comm, 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 (reads, count);
+ _stp_map_add_sx (reads, current->comm, 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 (writes, count);
+ _stp_map_add_sx (writes, current->comm, count);
jprobe_return();
return 0;
}
@@ -61,9 +58,9 @@ static struct jprobe stp_probes[] = {
int probe_start(void)
{
- 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);
+ opens = _stp_map_new_si (1000);
+ reads = _stp_map_new_sx (1000, HIST_LOG, 12);
+ writes = _stp_map_new_sx (1000, HIST_LOG, 12);
return _stp_register_jprobes (stp_probes, MAX_STP_ROUTINE);
}
diff --git a/runtime/probes/where_func/kprobe_where_funct.c b/runtime/probes/where_func/kprobe_where_funct.c
index 9bd4000a..680dabd8 100644
--- a/runtime/probes/where_func/kprobe_where_funct.c
+++ b/runtime/probes/where_func/kprobe_where_funct.c
@@ -4,15 +4,13 @@
Will Cohen
*/
-#define STP_NETLINK_ONLY
#define STP_NUM_STRINGS 1
#include "runtime.h"
-#define NEED_INT64_VALS
-
+#define VALUE_TYPE INT64
#define KEY1_TYPE INT64
-#include "map-keys.c"
+#include "map-gen.c"
#include "map.c"
#include "probes.c"
@@ -32,8 +30,7 @@ MAP funct_locations;
static int inst_funct(struct kprobe *p, struct pt_regs *regs)
{
long ret_addr = _stp_ret_addr(regs);
- _stp_map_key_int64(funct_locations, ret_addr);
- _stp_map_add_int64(funct_locations, 1);
+ _stp_map_add_ii(funct_locations, ret_addr, 1);
return 0;
}
@@ -48,7 +45,7 @@ static struct kprobe kp[] = {
int probe_start(void)
{
- funct_locations = _stp_map_new_int64 (1000, INT64);
+ funct_locations = _stp_map_new_ii (1000);
if (funct_name)
kp[0].addr = funct_name;