summaryrefslogtreecommitdiffstats
path: root/runtime/loc2c-runtime.h
diff options
context:
space:
mode:
authorjistone <jistone>2007-01-23 02:57:01 +0000
committerjistone <jistone>2007-01-23 02:57:01 +0000
commit6dd0aa5face6fc1091841a31ff86280b7e7da96d (patch)
treecfdd93f9ea61c0fba3309eed9228e55874ca77e7 /runtime/loc2c-runtime.h
parent27b0b07c7fba8675c9476e32ce868f71a181840d (diff)
downloadsystemtap-steved-6dd0aa5face6fc1091841a31ff86280b7e7da96d.tar.gz
systemtap-steved-6dd0aa5face6fc1091841a31ff86280b7e7da96d.tar.xz
systemtap-steved-6dd0aa5face6fc1091841a31ff86280b7e7da96d.zip
2007-01-22 Josh Stone <joshua.i.stone@intel.com>
runtime/ * loc2c-runtime.h (kread, kwrite): Tweaks to work better with reading and writing pointer values. testsuite/ * systemtap.base/deref.stp: Rewrite test, and now also check the ability to read/write pointers.
Diffstat (limited to 'runtime/loc2c-runtime.h')
-rw-r--r--runtime/loc2c-runtime.h44
1 files changed, 24 insertions, 20 deletions
diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h
index 4617f697..ce6d04b7 100644
--- a/runtime/loc2c-runtime.h
+++ b/runtime/loc2c-runtime.h
@@ -468,27 +468,25 @@
/* x86 can't do 8-byte put/get_user_asm, so we have to split it */
#define kread(ptr) \
- ({ \
- typeof(*(ptr)) _r; \
- if (sizeof(*(ptr)) == 8) { \
- union { u64 q; u32 l[2]; } _q; \
- _q.l[0] = (u32) deref(4, &((u32 *)(ptr))[0]); \
- _q.l[1] = (u32) deref(4, &((u32 *)(ptr))[1]); \
- _r = (typeof(*(ptr))) _q.q; \
- } else \
- _r = (typeof(*(ptr))) deref(sizeof(*(ptr)), (ptr)); \
- _r; \
+ ({ \
+ union { typeof(*(ptr)) v; u32 l[2]; } _kr; \
+ if (sizeof(*(ptr)) == 8) { \
+ _kr.l[0] = (u32) deref(4, &((u32 *)(ptr))[0]); \
+ _kr.l[1] = (u32) deref(4, &((u32 *)(ptr))[1]); \
+ } else \
+ _kr.v = (typeof(*(ptr))) deref(sizeof(*(ptr)), (ptr)); \
+ _kr.v; \
})
-#define kwrite(ptr, value) \
- ({ \
- if (sizeof(*(ptr)) == 8) { \
- union { u64 q; u32 l[2]; } _q; \
- _q.q = (u64)(typeof(*(ptr)))(value); \
- store_deref(4, &((u32 *)(ptr))[0], _q.l[0]); \
- store_deref(4, &((u32 *)(ptr))[1], _q.l[1]); \
- } else \
- store_deref(sizeof(*(ptr)), (ptr), (typeof(*(ptr)))(value)); \
+#define kwrite(ptr, value) \
+ ({ \
+ if (sizeof(*(ptr)) == 8) { \
+ union { typeof(*(ptr)) v; u32 l[2]; } _kw; \
+ _kw.v = (typeof(*(ptr)))(value); \
+ store_deref(4, &((u32 *)(ptr))[0], _kw.l[0]); \
+ store_deref(4, &((u32 *)(ptr))[1], _kw.l[1]); \
+ } else \
+ store_deref(sizeof(*(ptr)), (ptr), (long)(typeof(*(ptr)))(value)); \
})
#else
@@ -496,6 +494,12 @@
#define kread(ptr) \
( (typeof(*(ptr))) deref(sizeof(*(ptr)), (ptr)) )
#define kwrite(ptr, value) \
- ( store_deref(sizeof(*(ptr)), (ptr), (typeof(*(ptr)))(value)) )
+ ( store_deref(sizeof(*(ptr)), (ptr), (long)(typeof(*(ptr)))(value)) )
#endif
+
+#define CATCH_DEREF_FAULT() \
+ if (0) { \
+deref_fault: \
+ CONTEXT->last_error = "pointer dereference fault"; \
+ }