Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. The name of the author may not be used to endorse or promote products |
| 16 | * derived from this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | #include "defs.h" |
Mike Frysinger | f1639d8 | 2014-12-30 19:08:50 -0500 | [diff] [blame] | 31 | #include <fcntl.h> |
Dmitry V. Levin | 0e946ab | 2015-07-17 23:56:54 +0000 | [diff] [blame] | 32 | #include <signal.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 33 | #include <linux/version.h> |
Wichert Akkerman | d856b99 | 2000-10-13 12:47:12 +0000 | [diff] [blame] | 34 | #include <sys/timex.h> |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 35 | |
| 36 | #ifndef UTIME_NOW |
| 37 | #define UTIME_NOW ((1l << 30) - 1l) |
| 38 | #endif |
| 39 | #ifndef UTIME_OMIT |
| 40 | #define UTIME_OMIT ((1l << 30) - 2l) |
| 41 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 42 | |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 43 | #if SUPPORTED_PERSONALITIES > 1 |
| 44 | # if defined X86_64 || defined X32 |
| 45 | # define current_time_t_is_compat (current_personality == 1) |
| 46 | # else |
| 47 | # define current_time_t_is_compat (current_wordsize == 4) |
| 48 | # endif |
| 49 | #else |
| 50 | # define current_time_t_is_compat 0 |
| 51 | #endif |
| 52 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 53 | struct timeval32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 54 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 55 | u_int32_t tv_sec, tv_usec; |
| 56 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 58 | static void |
| 59 | tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv) |
| 60 | { |
| 61 | tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec); |
| 62 | } |
| 63 | |
| 64 | static void |
| 65 | tprint_timeval(struct tcb *tcp, const struct timeval *tv) |
| 66 | { |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 67 | tprintf("{%ju, %ju}", (uintmax_t) tv->tv_sec, (uintmax_t) tv->tv_usec); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 70 | void |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 71 | printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special) |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 72 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 73 | char buf[TIMEVAL_TEXT_BUFSIZE]; |
| 74 | sprinttv(buf, tcp, addr, bitness, special); |
| 75 | tprints(buf); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 76 | } |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 77 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 78 | static char * |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 79 | do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec, |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 80 | const int special) |
| 81 | { |
| 82 | if (special) { |
| 83 | switch (usec) { |
| 84 | case UTIME_NOW: |
| 85 | return stpcpy(buf, "UTIME_NOW"); |
| 86 | case UTIME_OMIT: |
| 87 | return stpcpy(buf, "UTIME_OMIT"); |
| 88 | } |
| 89 | } |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 90 | return buf + sprintf(buf, "{%ju, %ju}", sec, usec); |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 93 | char * |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 94 | sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 95 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 96 | if (addr == 0) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 97 | return stpcpy(buf, "NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 98 | |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 99 | if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) |
Denys Vlasenko | b9c7ae6 | 2011-09-01 11:40:40 +0200 | [diff] [blame] | 100 | return buf + sprintf(buf, "%#lx", addr); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 101 | |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 102 | if (bitness == BITNESS_32 || current_time_t_is_compat) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 103 | { |
| 104 | struct timeval32 tv; |
| 105 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 106 | if (umove(tcp, addr, &tv) >= 0) |
| 107 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 108 | } else { |
| 109 | struct timeval tv; |
| 110 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 111 | if (umove(tcp, addr, &tv) >= 0) |
| 112 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 113 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 114 | |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 115 | return buf + sprintf(buf, "%#lx", addr); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 116 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 117 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 118 | void |
| 119 | print_timespec(struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 120 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 121 | char buf[TIMESPEC_TEXT_BUFSIZE]; |
| 122 | sprint_timespec(buf, tcp, addr); |
| 123 | tprints(buf); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 126 | void |
| 127 | sprint_timespec(char *buf, struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 128 | { |
| 129 | if (addr == 0) |
| 130 | strcpy(buf, "NULL"); |
| 131 | else if (!verbose(tcp)) |
| 132 | sprintf(buf, "%#lx", addr); |
| 133 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 134 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 135 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 136 | #if SUPPORTED_PERSONALITIES > 1 |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 137 | if (current_time_t_is_compat) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 138 | struct timeval32 tv; |
| 139 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 140 | rc = umove(tcp, addr, &tv); |
| 141 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 142 | sprintf(buf, "{%u, %u}", |
| 143 | tv.tv_sec, tv.tv_usec); |
| 144 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 145 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 146 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 147 | struct timespec ts; |
| 148 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 149 | rc = umove(tcp, addr, &ts); |
| 150 | if (rc >= 0) |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 151 | sprintf(buf, "{%ju, %ju}", |
| 152 | (uintmax_t) ts.tv_sec, |
| 153 | (uintmax_t) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 154 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 155 | if (rc < 0) |
| 156 | strcpy(buf, "{...}"); |
| 157 | } |
| 158 | } |
| 159 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 160 | SYS_FUNC(time) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 161 | { |
| 162 | if (exiting(tcp)) { |
Dmitry V. Levin | 1c603a9 | 2015-02-17 22:03:17 +0000 | [diff] [blame] | 163 | printnum_long(tcp, tcp->u_arg[0], "%ld"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 164 | } |
| 165 | return 0; |
| 166 | } |
| 167 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 168 | SYS_FUNC(gettimeofday) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 169 | { |
| 170 | if (exiting(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 171 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 172 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 173 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | } |
| 175 | return 0; |
| 176 | } |
| 177 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 178 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 179 | SYS_FUNC(osf_gettimeofday) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 180 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 181 | if (exiting(tcp)) { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 182 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 183 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 184 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 185 | } |
| 186 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 187 | } |
| 188 | #endif |
| 189 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 190 | SYS_FUNC(settimeofday) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 191 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 192 | printtv(tcp, tcp->u_arg[0]); |
| 193 | tprints(", "); |
| 194 | printtv(tcp, tcp->u_arg[1]); |
| 195 | |
| 196 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | } |
| 198 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 199 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 200 | SYS_FUNC(osf_settimeofday) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 201 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 202 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
| 203 | tprints(", "); |
| 204 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
| 205 | |
| 206 | return RVAL_DECODED; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 207 | } |
| 208 | #endif |
| 209 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 210 | SYS_FUNC(adjtime) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 211 | { |
| 212 | if (entering(tcp)) { |
| 213 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 214 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 215 | } else { |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 216 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 217 | } |
| 218 | return 0; |
| 219 | } |
| 220 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 221 | SYS_FUNC(nanosleep) |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 222 | { |
| 223 | if (entering(tcp)) { |
| 224 | print_timespec(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 225 | tprints(", "); |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 226 | } else { |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 227 | /* Second (returned) timespec is only significant |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 228 | * if syscall was interrupted. On success, we print |
| 229 | * only its address, since kernel doesn't modify it, |
| 230 | * and printing the value may show uninitialized data. |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 231 | */ |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 232 | switch (tcp->u_error) { |
| 233 | default: |
| 234 | /* Not interrupted (slept entire interval) */ |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 235 | printaddr(tcp->u_arg[1]); |
| 236 | break; |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 237 | case ERESTARTSYS: |
| 238 | case ERESTARTNOINTR: |
| 239 | case ERESTARTNOHAND: |
| 240 | case ERESTART_RESTARTBLOCK: |
| 241 | /* Interrupted */ |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 242 | print_timespec(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 243 | } |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 244 | } |
| 245 | return 0; |
| 246 | } |
| 247 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 248 | #include "xlat/itimer_which.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 249 | |
| 250 | static void |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 251 | printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 252 | { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 253 | if (bitness == BITNESS_32 || current_time_t_is_compat) { |
| 254 | struct { |
| 255 | struct timeval32 it_interval, it_value; |
| 256 | } itv; |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 257 | |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 258 | if (!umove_or_printaddr(tcp, addr, &itv)) { |
| 259 | tprints("{it_interval="); |
| 260 | tprint_timeval32(tcp, &itv.it_interval); |
| 261 | tprints(", it_value="); |
| 262 | tprint_timeval32(tcp, &itv.it_value); |
| 263 | tprints("}"); |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 264 | } |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 265 | } else { |
| 266 | struct itimerval itv; |
| 267 | |
| 268 | if (!umove_or_printaddr(tcp, addr, &itv)) { |
| 269 | tprints("{it_interval="); |
| 270 | tprint_timeval(tcp, &itv.it_interval); |
| 271 | tprints(", it_value="); |
| 272 | tprint_timeval(tcp, &itv.it_value); |
| 273 | tprints("}"); |
| 274 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 275 | } |
| 276 | } |
| 277 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 278 | #define printitv(tcp, addr) \ |
| 279 | printitv_bitness((tcp), (addr), BITNESS_CURRENT) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 280 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 281 | SYS_FUNC(getitimer) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 282 | { |
| 283 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 284 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 285 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 286 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 287 | printitv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 288 | } |
| 289 | return 0; |
| 290 | } |
| 291 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 292 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 293 | SYS_FUNC(osf_getitimer) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 294 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 295 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 296 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 297 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 298 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 299 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 300 | } |
| 301 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 302 | } |
| 303 | #endif |
| 304 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 305 | SYS_FUNC(setitimer) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 306 | { |
| 307 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 308 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 309 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 310 | printitv(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 311 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 312 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 313 | printitv(tcp, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 314 | } |
| 315 | return 0; |
| 316 | } |
| 317 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 318 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 319 | SYS_FUNC(osf_setitimer) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 320 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 321 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 322 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 323 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 324 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 325 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 326 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 327 | printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 328 | } |
| 329 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 330 | } |
| 331 | #endif |
| 332 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 333 | #include "xlat/adjtimex_modes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 334 | #include "xlat/adjtimex_status.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 335 | #include "xlat/adjtimex_state.h" |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 336 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 337 | #if SUPPORTED_PERSONALITIES > 1 |
| 338 | static int |
| 339 | tprint_timex32(struct tcb *tcp, long addr) |
| 340 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 341 | struct { |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 342 | unsigned int modes; |
| 343 | int offset; |
| 344 | int freq; |
| 345 | int maxerror; |
| 346 | int esterror; |
| 347 | int status; |
| 348 | int constant; |
| 349 | int precision; |
| 350 | int tolerance; |
| 351 | struct timeval32 time; |
| 352 | int tick; |
| 353 | int ppsfreq; |
| 354 | int jitter; |
| 355 | int shift; |
| 356 | int stabil; |
| 357 | int jitcnt; |
| 358 | int calcnt; |
| 359 | int errcnt; |
| 360 | int stbcnt; |
| 361 | } tx; |
| 362 | |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 363 | if (umove_or_printaddr(tcp, addr, &tx)) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 364 | return -1; |
| 365 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 366 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 367 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 368 | tprintf(", offset=%d, freq=%d, maxerror=%d, ", |
| 369 | tx.offset, tx.freq, tx.maxerror); |
| 370 | tprintf("esterror=%u, status=", tx.esterror); |
| 371 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 372 | tprintf(", constant=%d, precision=%u, ", |
| 373 | tx.constant, tx.precision); |
| 374 | tprintf("tolerance=%d, time=", tx.tolerance); |
| 375 | tprint_timeval32(tcp, &tx.time); |
| 376 | tprintf(", tick=%d, ppsfreq=%d, jitter=%d", |
| 377 | tx.tick, tx.ppsfreq, tx.jitter); |
| 378 | tprintf(", shift=%d, stabil=%d, jitcnt=%d", |
| 379 | tx.shift, tx.stabil, tx.jitcnt); |
| 380 | tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d", |
| 381 | tx.calcnt, tx.errcnt, tx.stbcnt); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 382 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 383 | return 0; |
| 384 | } |
| 385 | #endif /* SUPPORTED_PERSONALITIES > 1 */ |
| 386 | |
| 387 | static int |
| 388 | tprint_timex(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 389 | { |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 390 | struct timex tx; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 391 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 392 | #if SUPPORTED_PERSONALITIES > 1 |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 393 | if (current_time_t_is_compat) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 394 | return tprint_timex32(tcp, addr); |
| 395 | #endif |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 396 | if (umove_or_printaddr(tcp, addr, &tx)) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 397 | return -1; |
| 398 | |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 399 | tprints("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 400 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 401 | tprintf(", offset=%jd, freq=%jd, maxerror=%ju, esterror=%ju, status=", |
| 402 | (intmax_t) tx.offset, (intmax_t) tx.freq, |
| 403 | (uintmax_t) tx.maxerror, (uintmax_t) tx.esterror); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 404 | printflags(adjtimex_status, tx.status, "STA_???"); |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 405 | tprintf(", constant=%jd, precision=%ju, tolerance=%jd, time=", |
| 406 | (intmax_t) tx.constant, (uintmax_t) tx.precision, |
| 407 | (intmax_t) tx.tolerance); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 408 | tprint_timeval(tcp, &tx.time); |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 409 | tprintf(", tick=%jd, ppsfreq=%jd, jitter=%jd", |
| 410 | (intmax_t) tx.tick, (intmax_t) tx.ppsfreq, (intmax_t) tx.jitter); |
| 411 | tprintf(", shift=%d, stabil=%jd, jitcnt=%jd", |
| 412 | tx.shift, (intmax_t) tx.stabil, (intmax_t) tx.jitcnt); |
| 413 | tprintf(", calcnt=%jd, errcnt=%jd, stbcnt=%jd", |
| 414 | (intmax_t) tx.calcnt, (intmax_t) tx.errcnt, (intmax_t) tx.stbcnt); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 415 | tprints("}"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 416 | return 0; |
| 417 | } |
| 418 | |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 419 | static int |
| 420 | do_adjtimex(struct tcb *tcp, long addr) |
| 421 | { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 422 | if (tprint_timex(tcp, addr)) |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 423 | return 0; |
| 424 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 425 | if (tcp->auxstr) |
| 426 | return RVAL_STR; |
| 427 | return 0; |
| 428 | } |
| 429 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 430 | SYS_FUNC(adjtimex) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 431 | { |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 432 | if (exiting(tcp)) |
| 433 | return do_adjtimex(tcp, tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 434 | return 0; |
| 435 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 436 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 437 | #include "xlat/clockflags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 438 | #include "xlat/clocknames.h" |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 439 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 440 | static void |
| 441 | printclockname(int clockid) |
| 442 | { |
| 443 | #ifdef CLOCKID_TO_FD |
Dmitry V. Levin | d35bdca | 2014-04-26 18:10:19 +0000 | [diff] [blame] | 444 | # include "xlat/cpuclocknames.h" |
| 445 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 446 | if (clockid < 0) { |
| 447 | if ((clockid & CLOCKFD_MASK) == CLOCKFD) |
| 448 | tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid)); |
| 449 | else { |
| 450 | if(CPUCLOCK_PERTHREAD(clockid)) |
| 451 | tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 452 | else |
| 453 | tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 454 | printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???"); |
| 455 | tprints(")"); |
| 456 | } |
| 457 | } |
| 458 | else |
| 459 | #endif |
| 460 | printxval(clocknames, clockid, "CLOCK_???"); |
| 461 | } |
| 462 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 463 | SYS_FUNC(clock_settime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 464 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 465 | printclockname(tcp->u_arg[0]); |
| 466 | tprints(", "); |
| 467 | printtv(tcp, tcp->u_arg[1]); |
| 468 | |
| 469 | return RVAL_DECODED; |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 470 | } |
| 471 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 472 | SYS_FUNC(clock_gettime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 473 | { |
| 474 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 475 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 476 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 477 | } else { |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 478 | printtv(tcp, tcp->u_arg[1]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 479 | } |
| 480 | return 0; |
| 481 | } |
| 482 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 483 | SYS_FUNC(clock_nanosleep) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 484 | { |
| 485 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 486 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 487 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 488 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 489 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 490 | printtv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 491 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 492 | } else { |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 493 | printtv(tcp, tcp->u_arg[3]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 494 | } |
| 495 | return 0; |
| 496 | } |
| 497 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 498 | SYS_FUNC(clock_adjtime) |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 499 | { |
| 500 | if (exiting(tcp)) |
| 501 | return do_adjtimex(tcp, tcp->u_arg[1]); |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 502 | printclockname(tcp->u_arg[0]); |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 503 | tprints(", "); |
| 504 | return 0; |
| 505 | } |
| 506 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 507 | #ifndef SIGEV_THREAD_ID |
| 508 | # define SIGEV_THREAD_ID 4 |
| 509 | #endif |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 510 | #include "xlat/sigev_value.h" |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 511 | |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 512 | #if SUPPORTED_PERSONALITIES > 1 |
| 513 | static void |
| 514 | printsigevent32(struct tcb *tcp, long arg) |
| 515 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 516 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 517 | int sigev_value; |
| 518 | int sigev_signo; |
| 519 | int sigev_notify; |
| 520 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 521 | union { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 522 | int tid; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 523 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 524 | int function, attribute; |
| 525 | } thread; |
| 526 | } un; |
| 527 | } sev; |
| 528 | |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 529 | if (!umove_or_printaddr(tcp, arg, &sev)) { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 530 | tprintf("{%#x, ", sev.sigev_value); |
| 531 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 532 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 533 | else |
| 534 | tprintf("%u, ", sev.sigev_signo); |
Dmitry V. Levin | bae549e | 2014-02-05 01:46:10 +0000 | [diff] [blame] | 535 | printxval(sigev_value, sev.sigev_notify, "SIGEV_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 536 | tprints(", "); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 537 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 538 | tprintf("{%d}", sev.un.tid); |
| 539 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 540 | tprintf("{%#x, %#x}", |
| 541 | sev.un.thread.function, |
| 542 | sev.un.thread.attribute); |
| 543 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 544 | tprints("{...}"); |
| 545 | tprints("}"); |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 546 | } |
| 547 | } |
| 548 | #endif |
| 549 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 550 | void |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 551 | printsigevent(struct tcb *tcp, long arg) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 552 | { |
| 553 | struct sigevent sev; |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 554 | |
| 555 | #if SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 9fd4f96 | 2012-03-19 09:36:42 +0100 | [diff] [blame] | 556 | if (current_wordsize == 4) { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 557 | printsigevent32(tcp, arg); |
| 558 | return; |
| 559 | } |
| 560 | #endif |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 561 | if (!umove_or_printaddr(tcp, arg, &sev)) { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 562 | tprintf("{%p, ", sev.sigev_value.sival_ptr); |
| 563 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 564 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 565 | else |
| 566 | tprintf("%u, ", sev.sigev_signo); |
Dmitry V. Levin | bae549e | 2014-02-05 01:46:10 +0000 | [diff] [blame] | 567 | printxval(sigev_value, sev.sigev_notify, "SIGEV_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 568 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 569 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
Dmitry V. Levin | ae5aa47 | 2013-11-11 23:54:30 +0000 | [diff] [blame] | 570 | #if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 571 | /* _pad[0] is the _tid field which might not be |
| 572 | present in the userlevel definition of the |
| 573 | struct. */ |
| 574 | tprintf("{%d}", sev._sigev_un._pad[0]); |
Dmitry V. Levin | ae5aa47 | 2013-11-11 23:54:30 +0000 | [diff] [blame] | 575 | #elif defined(HAVE_STRUCT_SIGEVENT___PAD) |
| 576 | tprintf("{%d}", sev.__pad[0]); |
| 577 | #else |
| 578 | # warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding |
| 579 | tprints("{...}"); |
| 580 | #endif |
Roland McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 581 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 582 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 583 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 584 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 585 | tprints("{...}"); |
| 586 | tprints("}"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 587 | } |
| 588 | } |
| 589 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 590 | SYS_FUNC(timer_create) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 591 | { |
| 592 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 593 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 594 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 595 | printsigevent(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 596 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 597 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 598 | printnum_int(tcp, tcp->u_arg[2], "%d"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 599 | } |
| 600 | return 0; |
| 601 | } |
| 602 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 603 | SYS_FUNC(timer_settime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 604 | { |
| 605 | if (entering(tcp)) { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 606 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 607 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 608 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 609 | printitv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 610 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 611 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 612 | printitv(tcp, tcp->u_arg[3]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 613 | } |
| 614 | return 0; |
| 615 | } |
| 616 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 617 | SYS_FUNC(timer_gettime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 618 | { |
| 619 | if (entering(tcp)) { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 620 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 621 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 622 | printitv(tcp, tcp->u_arg[1]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 623 | } |
| 624 | return 0; |
| 625 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 626 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 627 | #include "xlat/timerfdflags.h" |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 628 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 629 | SYS_FUNC(timerfd) |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 630 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 631 | /* It does not matter that the kernel uses itimerspec. */ |
| 632 | tprintf("%ld, ", tcp->u_arg[0]); |
| 633 | printclockname(tcp->u_arg[0]); |
| 634 | tprints(", "); |
| 635 | printflags(timerfdflags, tcp->u_arg[2], "TFD_???"); |
| 636 | tprints(", "); |
| 637 | printitv(tcp, tcp->u_arg[3]); |
| 638 | |
Dmitry V. Levin | 07c878a | 2015-08-02 01:37:19 +0000 | [diff] [blame^] | 639 | return RVAL_DECODED | RVAL_FD; |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 640 | } |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 641 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 642 | SYS_FUNC(timerfd_create) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 643 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 644 | printclockname(tcp->u_arg[0]); |
| 645 | tprints(", "); |
| 646 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 647 | |
Dmitry V. Levin | 07c878a | 2015-08-02 01:37:19 +0000 | [diff] [blame^] | 648 | return RVAL_DECODED | RVAL_FD; |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 649 | } |
| 650 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 651 | SYS_FUNC(timerfd_settime) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 652 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 653 | printfd(tcp, tcp->u_arg[0]); |
| 654 | tprints(", "); |
| 655 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 656 | tprints(", "); |
| 657 | printitv(tcp, tcp->u_arg[2]); |
| 658 | tprints(", "); |
| 659 | printitv(tcp, tcp->u_arg[3]); |
| 660 | |
| 661 | return RVAL_DECODED; |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 662 | } |
| 663 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 664 | SYS_FUNC(timerfd_gettime) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 665 | { |
| 666 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 667 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 668 | tprints(", "); |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 669 | } else { |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 670 | printitv(tcp, tcp->u_arg[1]); |
| 671 | } |
| 672 | return 0; |
| 673 | } |