Dmitry V. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | static void |
Dmitry V. Levin | a52375f | 2015-07-20 19:22:10 +0000 | [diff] [blame] | 4 | print_affinitylist(struct tcb *tcp, const unsigned long addr, const unsigned int len) |
Dmitry V. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 5 | { |
Dmitry V. Levin | a52375f | 2015-07-20 19:22:10 +0000 | [diff] [blame] | 6 | 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. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 10 | |
Dmitry V. Levin | a52375f | 2015-07-20 19:22:10 +0000 | [diff] [blame] | 11 | 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. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 28 | tprints(", "); |
Dmitry V. Levin | a52375f | 2015-07-20 19:22:10 +0000 | [diff] [blame] | 29 | if (cur >= abbrev_end) { |
| 30 | tprints("..."); |
| 31 | break; |
| 32 | } |
| 33 | if (umove_or_printaddr(tcp, cur, &w)) |
| 34 | break; |
Dmitry V. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 35 | tprintf("%lx", w); |
| 36 | } |
Dmitry V. Levin | a52375f | 2015-07-20 19:22:10 +0000 | [diff] [blame] | 37 | tprints("]"); |
Dmitry V. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 40 | SYS_FUNC(sched_setaffinity) |
Dmitry V. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 41 | { |
Dmitry V. Levin | 8aa2a81 | 2015-07-20 19:24:43 +0000 | [diff] [blame] | 42 | 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. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 48 | SYS_FUNC(sched_getaffinity) |
Dmitry V. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 49 | { |
| 50 | if (entering(tcp)) { |
| 51 | tprintf("%ld, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 52 | } else { |
Dmitry V. Levin | a52375f | 2015-07-20 19:22:10 +0000 | [diff] [blame] | 53 | print_affinitylist(tcp, tcp->u_arg[2], tcp->u_rval); |
Dmitry V. Levin | b94b983 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 54 | } |
| 55 | return 0; |
| 56 | } |