diff options
author | Mark Wielaard <mjw@redhat.com> | 2009-04-08 10:59:27 +0200 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2009-04-08 10:59:27 +0200 |
commit | 48cde708db9e1662047def94c2dfd7ffe28aa765 (patch) | |
tree | f6eea87ccb3cf63b94d4b310b7fad91d5bb06af2 | |
parent | a7f1270e24a77ab8338604ab14ee928a421f89a0 (diff) | |
download | systemtap-steved-48cde708db9e1662047def94c2dfd7ffe28aa765.tar.gz systemtap-steved-48cde708db9e1662047def94c2dfd7ffe28aa765.tar.xz systemtap-steved-48cde708db9e1662047def94c2dfd7ffe28aa765.zip |
Add uaddr() context tapset function.
* tapset/context.stp (uaddr): New sfunction.
* testsuite/buildok/uaddr.stp: New test.
-rw-r--r-- | tapset/context.stp | 25 | ||||
-rwxr-xr-x | testsuite/buildok/uaddr.stp | 8 |
2 files changed, 33 insertions, 0 deletions
diff --git a/tapset/context.stp b/tapset/context.stp index 9f4be0e6..36d68c8d 100644 --- a/tapset/context.stp +++ b/tapset/context.stp @@ -11,6 +11,11 @@ //provide information such as a backtrace to where the event occured and the current register values for the //processor. // </tapsetdescription> + +%{ +#include <asm/processor.h> +%} + /** * sfunction print_regs - Print a register dump. */ @@ -227,3 +232,23 @@ function stack_unused:long () %{ /* pure */ THIS->__retvalue = (long)&a & (THREAD_SIZE-1); %} +/** + * sfunction uaddr - User space address of current running task. + * + * Description: Returns the address in userspace that the current + * task was at when the probe occured. When the current running task + * isn't a user space thread, or the address cannot be found, zero + * is returned. + */ +function uaddr:long () %{ /* pure */ + int64_t addr = 0; + if (current->mm) + { + struct pt_regs *uregs; + uregs = task_pt_regs(current); + if (uregs) + addr = (int64_t) REG_IP(uregs); + } + THIS->__retvalue = addr; +%} + diff --git a/testsuite/buildok/uaddr.stp b/testsuite/buildok/uaddr.stp new file mode 100755 index 00000000..8acfc495 --- /dev/null +++ b/testsuite/buildok/uaddr.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for uaddr() +# +probe begin +{ + printf("uaddr: 0x%x\n", uaddr()) +} |