summaryrefslogtreecommitdiff
path: root/sched.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2015-07-29 07:59:56 +0000
committerDmitry V. Levin <ldv@altlinux.org>2015-07-29 09:18:26 +0000
commit3456bcca6732829c00b66745743325fc6162322f (patch)
treeaad90578f8f06acc17172ef55c5d4b92f4dab11b /sched.c
parent95b84ea641e724dff6e0f9b7d66a8a00b75c196a (diff)
downloadstrace-3456bcca6732829c00b66745743325fc6162322f.tar.gz
Implement sched_getattr and sched_setattr syscalls decoding
* xlat/sched_flags.in: New file. * sched.c: Include "xlat/sched_flags.h". (print_sched_attr, sys_sched_setattr, sys_sched_getattr): New functions. * linux/dummy.h (sys_sched_getattr, sys_sched_setattr): Remove. * tests/sched_xetattr.c: New file. * tests/sched_xetattr.test: New test. * tests/Makefile.am (check_PROGRAMS): Add sched_xetattr. (TESTS): Add sched_xetattr.test. * tests/.gitignore: Add sched_xetattr.
Diffstat (limited to 'sched.c')
-rw-r--r--sched.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/sched.c b/sched.c
index eda241fd3..e4730469a 100644
--- a/sched.c
+++ b/sched.c
@@ -3,6 +3,7 @@
#include <sched.h>
#include "xlat/schedulers.h"
+#include "xlat/sched_flags.h"
SYS_FUNC(sched_getscheduler)
{
@@ -62,3 +63,56 @@ SYS_FUNC(sched_rr_get_interval)
}
return 0;
}
+
+static void
+print_sched_attr(struct tcb *tcp, const long addr, unsigned int size)
+{
+ struct {
+ uint32_t size;
+ uint32_t sched_policy;
+ uint64_t sched_flags;
+ uint32_t sched_nice;
+ uint32_t sched_priority;
+ uint64_t sched_runtime;
+ uint64_t sched_deadline;
+ uint64_t sched_period;
+ } attr = {};
+
+ if (size > sizeof(attr))
+ size = sizeof(attr);
+ if (umoven_or_printaddr(tcp, addr, size, &attr))
+ return;
+
+ tprintf("{size=%u, sched_policy=", attr.size);
+ printxval(schedulers, attr.sched_policy, "SCHED_???");
+ tprints(", sched_flags=");
+ printflags(sched_flags, attr.sched_flags, "SCHED_FLAG_???");
+ tprintf(", sched_nice=%d", attr.sched_nice);
+ tprintf(", sched_priority=%u", attr.sched_priority);
+ tprintf(", sched_runtime=%" PRIu64, attr.sched_runtime);
+ tprintf(", sched_deadline=%" PRIu64, attr.sched_deadline);
+ tprintf(", sched_period=%" PRIu64 "}", attr.sched_period);
+}
+
+SYS_FUNC(sched_setattr)
+{
+ tprintf("%d, ", (int) tcp->u_arg[0]);
+ print_sched_attr(tcp, tcp->u_arg[1], 0x100);
+ tprintf(", %u", (unsigned int) tcp->u_arg[2]);
+
+ return RVAL_DECODED;
+}
+
+SYS_FUNC(sched_getattr)
+{
+ if (entering(tcp)) {
+ tprintf("%d, ", (int) tcp->u_arg[0]);
+ } else {
+ print_sched_attr(tcp, tcp->u_arg[1], tcp->u_arg[2]);
+ tprintf(", %u, %u",
+ (unsigned int) tcp->u_arg[2],
+ (unsigned int) tcp->u_arg[3]);
+ }
+
+ return 0;
+}