blob: 42cdd6cc6ebf3db55f8d8b587a9093bd3c0bda7d [file] [log] [blame]
Dmitry V. Levinb94b9832014-12-11 19:25:02 +00001#include "defs.h"
2
3static void
Dmitry V. Levina52375f2015-07-20 19:22:10 +00004print_affinitylist(struct tcb *tcp, const unsigned long addr, const unsigned int len)
Dmitry V. Levinb94b9832014-12-11 19:25:02 +00005{
Dmitry V. Levina52375f2015-07-20 19:22:10 +00006 unsigned long w;
7 const unsigned int size = len * sizeof(w);
8 const unsigned long end = addr + size;
9 unsigned long cur, abbrev_end;
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000010
Dmitry V. Levina52375f2015-07-20 19:22:10 +000011 if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
12 !addr || !len || size / sizeof(w) != len || end < addr) {
13 printaddr(addr);
14 return;
15 }
16
17 if (abbrev(tcp)) {
18 abbrev_end = addr + max_strlen * sizeof(w);
19 if (abbrev_end < addr)
20 abbrev_end = end;
21 } else {
22 abbrev_end = end;
23 }
24
25 tprints("[");
26 for (cur = addr; cur < end; cur += sizeof(w)) {
27 if (cur > addr)
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000028 tprints(", ");
Dmitry V. Levina52375f2015-07-20 19:22:10 +000029 if (cur >= abbrev_end) {
30 tprints("...");
31 break;
32 }
33 if (umove_or_printaddr(tcp, cur, &w))
34 break;
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000035 tprintf("%lx", w);
36 }
Dmitry V. Levina52375f2015-07-20 19:22:10 +000037 tprints("]");
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000038}
39
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000040SYS_FUNC(sched_setaffinity)
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000041{
Dmitry V. Levin8aa2a812015-07-20 19:24:43 +000042 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
43 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_arg[1]);
44
45 return RVAL_DECODED;
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000046}
47
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000048SYS_FUNC(sched_getaffinity)
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000049{
50 if (entering(tcp)) {
51 tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
52 } else {
Dmitry V. Levina52375f2015-07-20 19:22:10 +000053 print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval);
Dmitry V. Levinb94b9832014-12-11 19:25:02 +000054 }
55 return 0;
56}