Dmitry V. Levin | 174bb2b | 2015-03-26 13:03:25 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | #include "xlat/sigaltstack_flags.h" |
| 3 | |
| 4 | static void |
| 5 | print_stack_t(struct tcb *tcp, unsigned long addr) |
| 6 | { |
| 7 | stack_t ss; |
| 8 | int r; |
| 9 | |
| 10 | if (!addr) { |
| 11 | tprints("NULL"); |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 |
| 16 | if (current_wordsize != sizeof(ss.ss_sp) && current_wordsize == 4) { |
| 17 | struct { |
| 18 | uint32_t ss_sp; |
| 19 | int32_t ss_flags; |
| 20 | uint32_t ss_size; |
| 21 | } ss32; |
| 22 | r = umove(tcp, addr, &ss32); |
| 23 | if (r >= 0) { |
| 24 | memset(&ss, 0, sizeof(ss)); |
| 25 | ss.ss_sp = (void*)(unsigned long) ss32.ss_sp; |
| 26 | ss.ss_flags = ss32.ss_flags; |
| 27 | ss.ss_size = (unsigned long) ss32.ss_size; |
| 28 | } |
| 29 | } else |
| 30 | #endif |
| 31 | { |
| 32 | r = umove(tcp, addr, &ss); |
| 33 | } |
| 34 | if (r < 0) { |
| 35 | tprintf("%#lx", addr); |
| 36 | } else { |
| 37 | tprintf("{ss_sp=%#lx, ss_flags=", (unsigned long) ss.ss_sp); |
| 38 | printflags(sigaltstack_flags, ss.ss_flags, "SS_???"); |
| 39 | tprintf(", ss_size=%lu}", (unsigned long) ss.ss_size); |
| 40 | } |
| 41 | } |
| 42 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame^] | 43 | SYS_FUNC(sigaltstack) |
Dmitry V. Levin | 174bb2b | 2015-03-26 13:03:25 +0000 | [diff] [blame] | 44 | { |
| 45 | if (entering(tcp)) { |
| 46 | print_stack_t(tcp, tcp->u_arg[0]); |
| 47 | } else { |
| 48 | tprints(", "); |
| 49 | print_stack_t(tcp, tcp->u_arg[1]); |
| 50 | } |
| 51 | return 0; |
| 52 | } |