]> sourceware.org Git - systemtap.git/commitdiff
Add kprobes-common.{h,c}, which is analogous to uprobes-common.{h,c}
authorStan Cox <scox@redhat.com>
Fri, 28 May 2010 20:42:45 +0000 (16:42 -0400)
committerStan Cox <scox@redhat.com>
Fri, 28 May 2010 20:42:45 +0000 (16:42 -0400)
runtime/kprobes-common.c [new file with mode: 0644]
runtime/kprobes-common.h [new file with mode: 0644]

diff --git a/runtime/kprobes-common.c b/runtime/kprobes-common.c
new file mode 100644 (file)
index 0000000..878b9e0
--- /dev/null
@@ -0,0 +1,61 @@
+/* -*- linux-c -*- 
+ * kprobe Functions
+ * Copyright (C) 2010 Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software.  You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#ifndef _KPROBE_COMMON_C_
+#define _KPROBE_COMMON_C_
+
+/* The task_finder_callback */
+static int stap_kprobe_process_found (struct stap_task_finder_target *finder, struct task_struct *tsk, int register_p, int process_p) {
+  struct stap_dwarf_probe *p = container_of(finder, struct stap_dwarf_probe, finder);
+  unsigned short sdt_semaphore = 0;
+  if (! process_p) return 0; /* ignore threads */
+  #ifdef DEBUG_TASK_FINDER_VMA
+  _stp_dbug (__FUNCTION__,__LINE__, "%cproc pid %d stf %p %p path %s\n", register_p?'+':'-', tsk->tgid, finder, p, p->pathname);
+  #endif
+  p->tsk = tsk;
+  p->sdt_sem_address = p->sdt_sem_offset;
+  if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {
+    sdt_semaphore ++;
+    #ifdef DEBUG_UPROBES
+    _stp_dbug (__FUNCTION__,__LINE__, "+semaphore %#x @ %#lx\n", sdt_semaphore, p->sdt_sem_address);
+    #endif
+    put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);
+  }
+  return 0;
+}
+
+/* The task_finder_mmap_callback */
+static int stap_kprobe_mmap_found (struct stap_task_finder_target *finder, struct task_struct *tsk, char *path, unsigned long addr, unsigned long length, unsigned long offset, unsigned long vm_flags) {
+  struct stap_dwarf_probe *p = container_of(finder, struct stap_dwarf_probe, finder);
+  int rc = 0;
+  if (path == NULL || strcmp (path, p->pathname)) return 0;
+  if (p->sdt_sem_offset && p->sdt_sem_address == 0) {
+    p->tsk = tsk;
+    if (vm_flags & VM_EXECUTABLE) {
+      p->sdt_sem_address = addr + p->sdt_sem_offset;
+    }
+    else {
+      p->sdt_sem_address = (addr - offset) + p->sdt_sem_offset;
+    }
+  }
+  if (p->sdt_sem_address && (vm_flags & VM_WRITE)) {
+    unsigned short sdt_semaphore = 0;
+    if (get_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address) == 0) {
+      sdt_semaphore ++;
+      #ifdef DEBUG_UPROBES
+      _stp_dbug (__FUNCTION__,__LINE__, "+semaphore %#x @ %#lx\n", sdt_semaphore, p->sdt_sem_address);
+      #endif
+      put_user (sdt_semaphore, (unsigned short __user *) p->sdt_sem_address);
+    }
+  }
+  return 0;
+}
+
+#endif /* _KPROBE_COMMON_C_ */
diff --git a/runtime/kprobes-common.h b/runtime/kprobes-common.h
new file mode 100644 (file)
index 0000000..0827668
--- /dev/null
@@ -0,0 +1,23 @@
+/* -*- linux-c -*- 
+ * Copyright (C) 2010 Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software.  You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#ifndef _KPROBE_COMMON_H_
+#define _KPROBE_COMMON_H_
+
+struct stap_dwarf_kprobe {
+  union { struct kprobe kp; struct kretprobe krp; } u;
+  #ifdef __ia64__
+  struct kprobe dummy;
+  #endif
+};
+
+static int stap_kprobe_process_found (struct stap_task_finder_target *finder, struct task_struct *tsk, int register_p, int process_p);
+static int stap_kprobe_mmap_found (struct stap_task_finder_target *finder, struct task_struct *tsk, char *path, unsigned long addr, unsigned long length, unsigned long offset, unsigned long vm_flags);
+
+#endif /* _KPROBE_COMMON_H_ */
This page took 0.029216 seconds and 5 git commands to generate.