* 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.
#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[] = {
};
%}
-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);
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
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
{
--- /dev/null
+/* 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
+}
--- /dev/null
+/* 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)
+}