]> sourceware.org Git - systemtap.git/commitdiff
stapdyn: Add execname() using prctl(PR_GET_NAME)
authorJosh Stone <jistone@redhat.com>
Wed, 19 Sep 2012 00:20:26 +0000 (17:20 -0700)
committerJosh Stone <jistone@redhat.com>
Wed, 19 Sep 2012 00:22:58 +0000 (17:22 -0700)
tapset/dyninst/context.stp

index 757c46e257c01a2279818b9a4ab80ebc9d08bce3..668f8cd48ec090e980ddaf0ebc19d7148d70de04 100644 (file)
@@ -9,6 +9,7 @@
 // NB: functionally equivalent to linux/context.stp
 
 %{
+#include <sys/prctl.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <unistd.h>
 
 // TODO function print_regs ()
 
-// TODO function execname:string ()
+function execname:string ()
+%{
+       /* Need a 16-byte buffer, which will be 0-terminated only if shorter.
+        * Use 17 bytes to make sure we always have termination.  */
+       char arg2[17] = {0};
+       if (prctl(PR_GET_NAME, (unsigned long)arg2, 0, 0, 0) == 0)
+               strlcpy (STAP_RETVALUE, arg2, MAXSTRINGLEN);
+%}
 
 function pid:long ()
 %{ /* pure */ /* unprivileged */
This page took 0.02891 seconds and 5 git commands to generate.