diff options
-rw-r--r-- | runtime/ChangeLog | 4 | ||||
-rw-r--r-- | runtime/loc2c-runtime.h | 16 | ||||
-rw-r--r-- | testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/deref.stp | 36 |
4 files changed, 50 insertions, 10 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 95cf3483..d56a64a7 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,7 @@ +2007-02-06 Josh Stone <joshua.i.stone@intel.com> + + * loc2c-runtime.h (kread): Let it work with const types. + 2007-01-31 Martin Hunt <hunt@redhat.com> * string.c (_stp_string_init): Deleted. diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h index 7ed9d415..8ccc9826 100644 --- a/runtime/loc2c-runtime.h +++ b/runtime/loc2c-runtime.h @@ -467,16 +467,12 @@ /* x86 can't do 8-byte put/get_user_asm, so we have to split it */ -#define kread(ptr) \ - ({ \ - 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 kread(ptr) \ + ((sizeof(*(ptr)) == 8) ? \ + *(typeof(ptr))&(u32[2]) { \ + (u32) deref(4, &((u32 *)(ptr))[0]), \ + (u32) deref(4, &((u32 *)(ptr))[1]) } \ + : (typeof(*(ptr))) deref(sizeof(*(ptr)), (ptr))) #define kwrite(ptr, value) \ ({ \ diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index fcae70c3..18226d54 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-02-06 Josh Stone <joshua.i.stone@intel.com> + + * systemtap.base/deref.stp: Test kread with const sources. + 2007-02-06 Frank Ch. Eigler <fche@elastic.org> * buildok/conversions.stp: Build-test all conversions.stp functions. diff --git a/testsuite/systemtap.base/deref.stp b/testsuite/systemtap.base/deref.stp index d2399589..b003d657 100644 --- a/testsuite/systemtap.base/deref.stp +++ b/testsuite/systemtap.base/deref.stp @@ -14,6 +14,12 @@ probe end(1) { log_test("kread u64", kread_u64()) log_test("kread ptr", kread_ptr()) + log_test("kread const u8", kread_const_u8()) + log_test("kread const u16", kread_const_u16()) + log_test("kread const u32", kread_const_u32()) + log_test("kread const u64", kread_const_u64()) + log_test("kread const ptr", kread_const_ptr()) + log_test("kwrite u8", kwrite_u8()) log_test("kwrite u16", kwrite_u16()) log_test("kwrite u32", kwrite_u32()) @@ -58,6 +64,36 @@ function kread_ptr:long() %{ CATCH_DEREF_FAULT(); %} +function kread_const_u8:long() %{ + const uint8_t local = 0x42; + THIS->__retvalue = (local == kread(&local)); + CATCH_DEREF_FAULT(); +%} + +function kread_const_u16:long() %{ + const uint16_t local = 0xBEEF; + THIS->__retvalue = (local == kread(&local)); + CATCH_DEREF_FAULT(); +%} + +function kread_const_u32:long() %{ + const uint32_t local = 0xDEADBEEF; + THIS->__retvalue = (local == kread(&local)); + CATCH_DEREF_FAULT(); +%} + +function kread_const_u64:long() %{ + const uint64_t local = 0xDEADBEEFBAADF00DLL; + THIS->__retvalue = (local == kread(&local)); + CATCH_DEREF_FAULT(); +%} + +function kread_const_ptr:long() %{ + const struct task_struct *local = current; + THIS->__retvalue = (local == kread(&local)); + CATCH_DEREF_FAULT(); +%} + // NB: kwrite uses system macros with inline asm, with this comment: // // Tell gcc we read from memory instead of writing: this is because we do not |