From 650df512406f74227c7cb11f291764e70a282a74 Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Wed, 29 May 2013 12:34:41 -0400 Subject: [PATCH] new sample: semop-watch.stp This sample demonstrates pulling apart userspace struct/array parameters from syscall.* probe context. --- .../process/semop-watch.meta | 6 ++++ .../process/semop-watch.stp | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 testsuite/systemtap.examples/process/semop-watch.meta create mode 100755 testsuite/systemtap.examples/process/semop-watch.stp diff --git a/testsuite/systemtap.examples/process/semop-watch.meta b/testsuite/systemtap.examples/process/semop-watch.meta new file mode 100644 index 000000000..e0021412f --- /dev/null +++ b/testsuite/systemtap.examples/process/semop-watch.meta @@ -0,0 +1,6 @@ +title: Watch semop(2)/semtimedop(2) operations +name: semop-watch.stp +keywords: process locking +description: Prints a timed trace of semop(2)/semtimedop(2) syscalls +test_check: stap -p4 semop-watch.stp -c 'sleep 2' +test_installcheck: stap semop-watch.stp -c 'sleep 2' diff --git a/testsuite/systemtap.examples/process/semop-watch.stp b/testsuite/systemtap.examples/process/semop-watch.stp new file mode 100755 index 000000000..5b85b117b --- /dev/null +++ b/testsuite/systemtap.examples/process/semop-watch.stp @@ -0,0 +1,29 @@ +global threads; +global times; + +probe syscall.semop, + syscall.semtimedop +{ + sembuf_sz = & @cast(0, "struct sembuf")[1]; + res = sprintf("set %d sems", semid) + + for(i = 0; i < nsops; i++) { + offset = i * sembuf_sz; + pointer = sops_uaddr + offset; + num_addr = & @cast(pointer, "struct sembuf")->sem_num; + num = user_short(num_addr); + + res = sprintf("%s %d", res, num); + } + res = sprintf("%s\n", res); + + threads[tid()] = res; + times[tid()] = gettimeofday_us(); +} + +probe syscall.semop.return, + syscall.semtimedop.return +{ + printf("Thread %d took %dus to operate on %s\n", tid(), + gettimeofday_us() - times[tid()], threads[tid()]); +} -- 2.43.5