summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/deref.stp
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.base/deref.stp')
-rw-r--r--testsuite/systemtap.base/deref.stp45
1 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/deref.stp b/testsuite/systemtap.base/deref.stp
new file mode 100644
index 00000000..6fb59f2c
--- /dev/null
+++ b/testsuite/systemtap.base/deref.stp
@@ -0,0 +1,45 @@
+/*
+ * deref.stp
+ *
+ * Check that the deref mechanisms work correctly.
+ */
+
+probe begin { log("systemtap starting probe") }
+probe end { log("systemtap ending probe") }
+
+
+function call_deref:long(val:long) %{
+ if ((uint64_t)THIS->val < 0x100ULL) {
+ uint8_t local8 = (uint8_t)THIS->val;
+ THIS->__retvalue = (uint8_t)deref(sizeof(local8), &local8);
+ } else if ((uint64_t)THIS->val < 0x10000ULL) {
+ uint16_t local16 = (uint16_t)THIS->val;
+ THIS->__retvalue = (uint16_t)deref(sizeof(local16), &local16);
+ } else if ((uint64_t)THIS->val < 0x100000000ULL) {
+ uint32_t local32 = (uint32_t)THIS->val;
+ THIS->__retvalue = (uint32_t)deref(sizeof(local32), &local32);
+ } else {
+ uint64_t local64 = (uint64_t)THIS->val;
+ THIS->__retvalue = (uint64_t)deref(sizeof(local64), &local64);
+ }
+ if (0) {
+deref_fault:
+ CONTEXT->last_error = "pointer dereference error";
+ }
+%}
+
+function check_deref(val) {
+ deref = call_deref(val)
+ if (deref == val)
+ log("systemtap test success")
+ else
+ printf("systemtap test failure - %#x != %#x\n", deref, val)
+}
+
+probe end(1) {
+ check_deref(0xDEADBEEFBAADF00D)
+ check_deref(0xDEADBEEF)
+ check_deref(0xBEEF)
+ check_deref(0x42)
+}
+