summaryrefslogtreecommitdiffstats
path: root/runtime/probes.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-06-27 18:07:32 +0000
committerhunt <hunt>2005-06-27 18:07:32 +0000
commit07aa4b3863b5bf4a8c62f7dab767ecfd8ebecfc2 (patch)
treebfc38e9a2daec31b78c892c3b1acb71ebb8420af /runtime/probes.c
parentec4373ff517576f1c99aa93980d5e0b211c5071d (diff)
downloadsystemtap-steved-07aa4b3863b5bf4a8c62f7dab767ecfd8ebecfc2.tar.gz
systemtap-steved-07aa4b3863b5bf4a8c62f7dab767ecfd8ebecfc2.tar.xz
systemtap-steved-07aa4b3863b5bf4a8c62f7dab767ecfd8ebecfc2.zip
2005-06-27 Martin Hunt <hunt@redhat.com>
* Doxyfile (PREDEFINED): Added USE_RET_PROBES. * probes.c (_stp_register_kretprobes): New function. (_stp_unregister_kretprobes): New function.
Diffstat (limited to 'runtime/probes.c')
-rw-r--r--runtime/probes.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/runtime/probes.c b/runtime/probes.c
index 144445d6..7922c133 100644
--- a/runtime/probes.c
+++ b/runtime/probes.c
@@ -70,12 +70,26 @@ void _stp_unregister_kprobes (struct kprobe *probes, int num_probes)
_stp_log ("All kprobes removed\n");
}
+
+#ifdef USE_RET_PROBES
+/** Unregister a group of return probes.
+ * @param probes Pointer to an array of struct kretprobe.
+ * @param num_probes Number of probes in the array.
+ */
+void _stp_unregister_kretprobes (struct kretprobe *probes, int num_probes)
+{
+ int i;
+ for (i = 0; i < num_probes; i++)
+ unregister_kretprobe(&probes[i]);
+ _stp_log ("All kretprobes removed\n");
+}
+#endif
+
/** Register a group of kprobes.
* @param probes Pointer to an array of struct kprobe.
* @param num_probes Number of probes in the array.
* @return 0 on success.
*/
-
int _stp_register_kprobes (struct kprobe *probes, int num_probes)
{
int i, ret ;
@@ -102,4 +116,36 @@ out:
return ret;
}
+#ifdef USE_RET_PROBES
+/** Register a group of return probes.
+ * @param probes Pointer to an array of struct kretprobe.
+ * @param num_probes Number of probes in the array.
+ * @return 0 on success.
+ */
+int _stp_register_kretprobes (struct kretprobe *probes, int num_probes)
+{
+ int i, ret ;
+ unsigned long addr;
+
+ for (i = 0; i < num_probes; i++) {
+ addr =_stp_lookup_name((char *)probes[i].kp.addr);
+ if (addr == 0) {
+ _stp_log ("ERROR: function %s not found!\n",
+ (char *)probes[i].kp.addr);
+ ret = -1; /* FIXME */
+ goto out;
+ }
+ _stp_log("inserting kretprobe at %s (%p)\n", probes[i].kp.addr, addr);
+ probes[i].kp.addr = (kprobe_opcode_t *)addr;
+ ret = register_kretprobe(&probes[i]);
+ if (ret)
+ goto out;
+ }
+ return 0;
+out:
+ _stp_log ("probe module initialization failed. Exiting...\n");
+ _stp_unregister_kretprobes(probes, i);
+ return ret;
+}
+#endif
#endif /* _PROBES_C */