]> sourceware.org Git - systemtap.git/commitdiff
PR16716 partial fix: Better types in 'syscall.{getpriority,setpriority}'.
authorDavid Smith <dsmith@redhat.com>
Mon, 21 Apr 2014 18:43:33 +0000 (13:43 -0500)
committerDavid Smith <dsmith@redhat.com>
Mon, 21 Apr 2014 18:43:33 +0000 (13:43 -0500)
* tapset/linux/syscalls.stp: Fix types in 'syscall.getpriority'.
* tapset/linux/syscalls2.stp: Fix types in 'syscall.setpriority'.
* tapset/linux/aux_syscalls.stp (_priority_which_str): Convert to use
  _stp_lookup_str().
* testsuite/systemtap.syscall/getpriority.c: New test case.
* testsuite/systemtap.syscall/setpriority.c: Ditto.

tapset/linux/aux_syscalls.stp
tapset/linux/syscalls.stp
tapset/linux/syscalls2.stp
testsuite/systemtap.syscall/getpriority.c [new file with mode: 0644]
testsuite/systemtap.syscall/setpriority.c [new file with mode: 0644]

index 8b256e1f8ce0d03ed3d30f597ac940235ed82c12..da27b58d69db24f88a6da21e6335d8aac4c990dc 100644 (file)
@@ -1348,12 +1348,20 @@ function _sched_policy_str:string(policy:long)
 #endif                 
 %}
 
-function _priority_which_str(which) {
-   if(which==0) return "PRIO_PROCESS"
-   if(which==1) return "PRIO_PGRP"
-   if(which==2) return "PRIO_USER"
-   return sprintf("UNKNOWN VALUE: %d", which)
-}
+%{
+static const _stp_val_array const _stp_priority_which_list[] = {
+       V(PRIO_PROCESS),
+       V(PRIO_PGRP),
+       V(PRIO_USER),
+       {0, NULL}
+};
+%}
+
+function _priority_which_str:string(which:long)
+%{ /* pure */
+       _stp_lookup_str(_stp_priority_which_list, (unsigned int)STAP_ARG_which,
+                       STAP_RETVALUE, MAXSTRINGLEN);
+%}
 
 %{
 static const _stp_val_array const _stp_shutdown_how_list[] = {
@@ -1364,7 +1372,7 @@ static const _stp_val_array const _stp_shutdown_how_list[] = {
 };
 %}
 
-function _shutdown_how_str:string(how)
+function _shutdown_how_str:string(how:long)
 %{ /* pure */
        _stp_lookup_str(_stp_shutdown_how_list, (unsigned int)STAP_ARG_how,
                        STAP_RETVALUE, MAXSTRINGLEN);
index 6103b13b562f3f83ea03f7d35252cb17eb0474fb..b53baaaff71b570b21724a4cfd15339950bff8e3 100644 (file)
@@ -1829,8 +1829,8 @@ probe syscall.getppid.return = kernel.function("sys_getppid").return
 probe syscall.getpriority = kernel.function("sys_getpriority").call
 {
        name = "getpriority"
-       which = $which
-       who = $who
+       which = __int32($which)
+       who = __int32($who)
        argstr = sprintf("%s, %d", _priority_which_str(which), who)
 }
 probe syscall.getpriority.return = kernel.function("sys_getpriority").return
index 5073c9465b74f6dfc213e43f79429d7e220cd3a1..8bd211a29767cb3972a3df5cce217cd495d08815 100644 (file)
@@ -2438,11 +2438,12 @@ probe syscall.setpgid.return = kernel.function("sys_setpgid").return
 probe syscall.setpriority = kernel.function("sys_setpriority").call
 {
        name = "setpriority"
-       which = $which
-       which_str = _priority_which_str($which)
-       who = $who
-       prio = $niceval
-       argstr = sprintf("%s, %d, %d", which_str, $who, $niceval)
+       which = __int32($which)
+       which_str = _priority_which_str(__int32($which))
+       who = __int32($who)
+       prio = __int32($niceval)
+       argstr = sprintf("%s, %d, %d", which_str, __int32($who),
+                        __int32($niceval))
 }
 probe syscall.setpriority.return = kernel.function("sys_setpriority").return
 {
diff --git a/testsuite/systemtap.syscall/getpriority.c b/testsuite/systemtap.syscall/getpriority.c
new file mode 100644 (file)
index 0000000..7f4f260
--- /dev/null
@@ -0,0 +1,20 @@
+/* COVERAGE: getpriority */
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+int main()
+{
+    getpriority(PRIO_PROCESS, 0);
+    //staptest// getpriority (PRIO_PROCESS, 0) = NNNN
+
+    getpriority(PRIO_PGRP, -1);
+    //staptest// getpriority (PRIO_PGRP, -1) = -NNNN (ESRCH)
+
+    getpriority(-1, 0);
+    //staptest// getpriority (0x[f]+, 0) = -NNNN (EINVAL)
+
+    getpriority(PRIO_USER, 0);
+    //staptest// getpriority (PRIO_USER, 0) = NNNN
+}
diff --git a/testsuite/systemtap.syscall/setpriority.c b/testsuite/systemtap.syscall/setpriority.c
new file mode 100644 (file)
index 0000000..69cecee
--- /dev/null
@@ -0,0 +1,25 @@
+/* COVERAGE: setpriority */
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+int main()
+{
+    setpriority(PRIO_PROCESS, 0, 2);
+    //staptest// setpriority (PRIO_PROCESS, 0, 2) = NNNN
+
+    setpriority(-1, 0, 2);
+    //staptest// setpriority (0x[f]+, 0, 2) = -NNNN (EINVAL)
+
+    setpriority(PRIO_PGRP, -1, 2);
+    //staptest// setpriority (PRIO_PGRP, -1, 2) = -NNNN (ESRCH)
+
+    setpriority(PRIO_USER, 0, 0);
+    //staptest// setpriority (PRIO_USER, 0, 0) = NNNN
+
+    // This call might or might not fail, depending on whether we're
+    // root or not. So, ignore the return value.
+    setpriority(PRIO_PROCESS, 0, -1);
+    //staptest// setpriority (PRIO_PROCESS, 0, -1)
+}
This page took 0.045413 seconds and 5 git commands to generate.