]>
Commit | Line | Data |
---|---|---|
d39594e9 | 1 | #include "qemu/osdep.h" |
a44d57a3 | 2 | |
33189d31 TS |
3 | #include <sys/ipc.h> |
4 | #include <sys/msg.h> | |
5 | #include <sys/sem.h> | |
6 | #include <sys/shm.h> | |
7 | #include <sys/select.h> | |
74d753ac | 8 | #include <sys/mount.h> |
fb3aabf3 | 9 | #include <arpa/inet.h> |
38987eab | 10 | #include <netinet/in.h> |
fb3aabf3 | 11 | #include <netinet/tcp.h> |
fe51b0a5 | 12 | #include <netinet/udp.h> |
fb3aabf3 | 13 | #include <linux/if_packet.h> |
38987eab | 14 | #include <linux/in6.h> |
814ae70f | 15 | #include <linux/netlink.h> |
608e5592 | 16 | #include <sched.h> |
33189d31 | 17 | #include "qemu.h" |
3b249d26 | 18 | #include "user-internals.h" |
a44d57a3 | 19 | #include "strace.h" |
7b72aa1d | 20 | #include "signal-common.h" |
375ce49b | 21 | #include "target_mman.h" |
33189d31 | 22 | |
33189d31 TS |
23 | struct syscallname { |
24 | int nr; | |
7ccfb2eb BS |
25 | const char *name; |
26 | const char *format; | |
a0939b89 | 27 | void (*call)(CPUArchState *, const struct syscallname *, |
c16f9ed3 FB |
28 | abi_long, abi_long, abi_long, |
29 | abi_long, abi_long, abi_long); | |
a0939b89 | 30 | void (*result)(CPUArchState *, const struct syscallname *, abi_long, |
c84be71f FB |
31 | abi_long, abi_long, abi_long, |
32 | abi_long, abi_long, abi_long); | |
33189d31 TS |
33 | }; |
34 | ||
74d753ac MW |
35 | /* |
36 | * It is possible that target doesn't have syscall that uses | |
37 | * following flags but we don't want the compiler to warn | |
38 | * us about them being unused. Same applies to utility print | |
39 | * functions. It is ok to keep them while not used. | |
40 | */ | |
41 | #define UNUSED __attribute__ ((unused)) | |
74d753ac MW |
42 | |
43 | /* | |
44 | * Structure used to translate flag values into strings. This is | |
45 | * similar that is in the actual strace tool. | |
46 | */ | |
47 | struct flags { | |
48 | abi_long f_value; /* flag */ | |
49 | const char *f_string; /* stringified flag */ | |
50 | }; | |
51 | ||
52 | /* common flags for all architectures */ | |
53 | #define FLAG_GENERIC(name) { name, #name } | |
54 | /* target specific flags (syscall_defs.h has TARGET_<flag>) */ | |
55 | #define FLAG_TARGET(name) { TARGET_ ## name, #name } | |
56 | /* end of flags array */ | |
57 | #define FLAG_END { 0, NULL } | |
58 | ||
45f56799 FB |
59 | /* Structure used to translate enumerated values into strings */ |
60 | struct enums { | |
61 | abi_long e_value; /* enum value */ | |
62 | const char *e_string; /* stringified enum */ | |
63 | }; | |
64 | ||
65 | /* common enums for all architectures */ | |
66 | #define ENUM_GENERIC(name) { name, #name } | |
67 | /* target specific enums */ | |
68 | #define ENUM_TARGET(name) { TARGET_ ## name, #name } | |
69 | /* end of enums array */ | |
70 | #define ENUM_END { 0, NULL } | |
71 | ||
74d753ac MW |
72 | UNUSED static const char *get_comma(int); |
73 | UNUSED static void print_pointer(abi_long, int); | |
74 | UNUSED static void print_flags(const struct flags *, abi_long, int); | |
45f56799 | 75 | UNUSED static void print_enums(const struct enums *, abi_long, int); |
74d753ac MW |
76 | UNUSED static void print_at_dirfd(abi_long, int); |
77 | UNUSED static void print_file_mode(abi_long, int); | |
78 | UNUSED static void print_open_flags(abi_long, int); | |
79 | UNUSED static void print_syscall_prologue(const struct syscallname *); | |
80 | UNUSED static void print_syscall_epilogue(const struct syscallname *); | |
81 | UNUSED static void print_string(abi_long, int); | |
fb3aabf3 | 82 | UNUSED static void print_buf(abi_long addr, abi_long len, int last); |
74d753ac MW |
83 | UNUSED static void print_raw_param(const char *, abi_long, int); |
84 | UNUSED static void print_timeval(abi_ulong, int); | |
1a674adf | 85 | UNUSED static void print_timespec(abi_ulong, int); |
aad43d15 | 86 | UNUSED static void print_timespec64(abi_ulong, int); |
6d33e036 | 87 | UNUSED static void print_timezone(abi_ulong, int); |
1a674adf | 88 | UNUSED static void print_itimerval(abi_ulong, int); |
74d753ac | 89 | UNUSED static void print_number(abi_long, int); |
608e5592 | 90 | UNUSED static void print_signal(abi_ulong, int); |
42b15d70 | 91 | UNUSED static void print_sockaddr(abi_ulong, abi_long, int); |
fb3aabf3 LV |
92 | UNUSED static void print_socket_domain(int domain); |
93 | UNUSED static void print_socket_type(int type); | |
94 | UNUSED static void print_socket_protocol(int domain, int type, int protocol); | |
74d753ac | 95 | |
33189d31 TS |
96 | /* |
97 | * Utility functions | |
98 | */ | |
99 | static void | |
100 | print_ipc_cmd(int cmd) | |
101 | { | |
102 | #define output_cmd(val) \ | |
103 | if( cmd == val ) { \ | |
4b25a506 | 104 | qemu_log(#val); \ |
33189d31 TS |
105 | return; \ |
106 | } | |
107 | ||
108 | cmd &= 0xff; | |
109 | ||
110 | /* General IPC commands */ | |
111 | output_cmd( IPC_RMID ); | |
112 | output_cmd( IPC_SET ); | |
113 | output_cmd( IPC_STAT ); | |
114 | output_cmd( IPC_INFO ); | |
115 | /* msgctl() commands */ | |
33189d31 TS |
116 | output_cmd( MSG_STAT ); |
117 | output_cmd( MSG_INFO ); | |
33189d31 TS |
118 | /* shmctl() commands */ |
119 | output_cmd( SHM_LOCK ); | |
120 | output_cmd( SHM_UNLOCK ); | |
121 | output_cmd( SHM_STAT ); | |
122 | output_cmd( SHM_INFO ); | |
123 | /* semctl() commands */ | |
124 | output_cmd( GETPID ); | |
125 | output_cmd( GETVAL ); | |
126 | output_cmd( GETALL ); | |
127 | output_cmd( GETNCNT ); | |
128 | output_cmd( GETZCNT ); | |
129 | output_cmd( SETVAL ); | |
130 | output_cmd( SETALL ); | |
131 | output_cmd( SEM_STAT ); | |
132 | output_cmd( SEM_INFO ); | |
133 | output_cmd( IPC_RMID ); | |
134 | output_cmd( IPC_RMID ); | |
135 | output_cmd( IPC_RMID ); | |
136 | output_cmd( IPC_RMID ); | |
137 | output_cmd( IPC_RMID ); | |
138 | output_cmd( IPC_RMID ); | |
139 | output_cmd( IPC_RMID ); | |
140 | output_cmd( IPC_RMID ); | |
141 | output_cmd( IPC_RMID ); | |
142 | ||
143 | /* Some value we don't recognize */ | |
4b25a506 | 144 | qemu_log("%d", cmd); |
33189d31 TS |
145 | } |
146 | ||
7b72aa1d HD |
147 | static const char * const target_signal_name[] = { |
148 | #define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig, | |
149 | MAKE_SIGNAL_LIST | |
150 | #undef MAKE_SIG_ENTRY | |
151 | }; | |
152 | ||
608e5592 LV |
153 | static void |
154 | print_signal(abi_ulong arg, int last) | |
155 | { | |
156 | const char *signal_name = NULL; | |
7b72aa1d HD |
157 | |
158 | if (arg < ARRAY_SIZE(target_signal_name)) { | |
159 | signal_name = target_signal_name[arg]; | |
608e5592 | 160 | } |
7b72aa1d | 161 | |
608e5592 | 162 | if (signal_name == NULL) { |
abe20840 | 163 | print_raw_param("%ld", arg, last); |
608e5592 LV |
164 | return; |
165 | } | |
4b25a506 | 166 | qemu_log("%s%s", signal_name, get_comma(last)); |
608e5592 LV |
167 | } |
168 | ||
0cb581d6 PM |
169 | static void print_si_code(int arg) |
170 | { | |
171 | const char *codename = NULL; | |
172 | ||
173 | switch (arg) { | |
174 | case SI_USER: | |
175 | codename = "SI_USER"; | |
176 | break; | |
177 | case SI_KERNEL: | |
178 | codename = "SI_KERNEL"; | |
179 | break; | |
180 | case SI_QUEUE: | |
181 | codename = "SI_QUEUE"; | |
182 | break; | |
183 | case SI_TIMER: | |
184 | codename = "SI_TIMER"; | |
185 | break; | |
186 | case SI_MESGQ: | |
187 | codename = "SI_MESGQ"; | |
188 | break; | |
189 | case SI_ASYNCIO: | |
190 | codename = "SI_ASYNCIO"; | |
191 | break; | |
192 | case SI_SIGIO: | |
193 | codename = "SI_SIGIO"; | |
194 | break; | |
195 | case SI_TKILL: | |
196 | codename = "SI_TKILL"; | |
197 | break; | |
198 | default: | |
4b25a506 | 199 | qemu_log("%d", arg); |
0cb581d6 PM |
200 | return; |
201 | } | |
4b25a506 | 202 | qemu_log("%s", codename); |
0cb581d6 PM |
203 | } |
204 | ||
ba9fcea1 MS |
205 | static void get_target_siginfo(target_siginfo_t *tinfo, |
206 | const target_siginfo_t *info) | |
207 | { | |
208 | abi_ulong sival_ptr; | |
209 | ||
210 | int sig; | |
211 | int si_errno; | |
212 | int si_code; | |
213 | int si_type; | |
214 | ||
215 | __get_user(sig, &info->si_signo); | |
216 | __get_user(si_errno, &tinfo->si_errno); | |
217 | __get_user(si_code, &info->si_code); | |
218 | ||
219 | tinfo->si_signo = sig; | |
220 | tinfo->si_errno = si_errno; | |
221 | tinfo->si_code = si_code; | |
222 | ||
223 | /* Ensure we don't leak random junk to the guest later */ | |
224 | memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad)); | |
225 | ||
226 | /* This is awkward, because we have to use a combination of | |
227 | * the si_code and si_signo to figure out which of the union's | |
228 | * members are valid. (Within the host kernel it is always possible | |
229 | * to tell, but the kernel carefully avoids giving userspace the | |
230 | * high 16 bits of si_code, so we don't have the information to | |
231 | * do this the easy way...) We therefore make our best guess, | |
232 | * bearing in mind that a guest can spoof most of the si_codes | |
233 | * via rt_sigqueueinfo() if it likes. | |
234 | * | |
235 | * Once we have made our guess, we record it in the top 16 bits of | |
236 | * the si_code, so that print_siginfo() later can use it. | |
237 | * print_siginfo() will strip these top bits out before printing | |
238 | * the si_code. | |
239 | */ | |
240 | ||
241 | switch (si_code) { | |
242 | case SI_USER: | |
243 | case SI_TKILL: | |
244 | case SI_KERNEL: | |
245 | /* Sent via kill(), tkill() or tgkill(), or direct from the kernel. | |
246 | * These are the only unspoofable si_code values. | |
247 | */ | |
248 | __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid); | |
249 | __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid); | |
250 | si_type = QEMU_SI_KILL; | |
251 | break; | |
252 | default: | |
253 | /* Everything else is spoofable. Make best guess based on signal */ | |
254 | switch (sig) { | |
255 | case TARGET_SIGCHLD: | |
256 | __get_user(tinfo->_sifields._sigchld._pid, | |
257 | &info->_sifields._sigchld._pid); | |
258 | __get_user(tinfo->_sifields._sigchld._uid, | |
259 | &info->_sifields._sigchld._uid); | |
260 | __get_user(tinfo->_sifields._sigchld._status, | |
261 | &info->_sifields._sigchld._status); | |
262 | __get_user(tinfo->_sifields._sigchld._utime, | |
263 | &info->_sifields._sigchld._utime); | |
264 | __get_user(tinfo->_sifields._sigchld._stime, | |
265 | &info->_sifields._sigchld._stime); | |
266 | si_type = QEMU_SI_CHLD; | |
267 | break; | |
268 | case TARGET_SIGIO: | |
269 | __get_user(tinfo->_sifields._sigpoll._band, | |
270 | &info->_sifields._sigpoll._band); | |
271 | __get_user(tinfo->_sifields._sigpoll._fd, | |
272 | &info->_sifields._sigpoll._fd); | |
273 | si_type = QEMU_SI_POLL; | |
274 | break; | |
275 | default: | |
276 | /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */ | |
277 | __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid); | |
278 | __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid); | |
279 | /* XXX: potential problem if 64 bit */ | |
280 | __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr); | |
281 | tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr; | |
282 | ||
283 | si_type = QEMU_SI_RT; | |
284 | break; | |
285 | } | |
286 | break; | |
287 | } | |
288 | ||
289 | tinfo->si_code = deposit32(si_code, 16, 16, si_type); | |
290 | } | |
291 | ||
0cb581d6 PM |
292 | static void print_siginfo(const target_siginfo_t *tinfo) |
293 | { | |
294 | /* Print a target_siginfo_t in the format desired for printing | |
295 | * signals being taken. We assume the target_siginfo_t is in the | |
296 | * internal form where the top 16 bits of si_code indicate which | |
297 | * part of the union is valid, rather than in the guest-visible | |
298 | * form where the bottom 16 bits are sign-extended into the top 16. | |
299 | */ | |
300 | int si_type = extract32(tinfo->si_code, 16, 16); | |
301 | int si_code = sextract32(tinfo->si_code, 0, 16); | |
302 | ||
4b25a506 | 303 | qemu_log("{si_signo="); |
0cb581d6 | 304 | print_signal(tinfo->si_signo, 1); |
4b25a506 | 305 | qemu_log(", si_code="); |
0cb581d6 PM |
306 | print_si_code(si_code); |
307 | ||
308 | switch (si_type) { | |
309 | case QEMU_SI_KILL: | |
4b25a506 | 310 | qemu_log(", si_pid=%u, si_uid=%u", |
0cb581d6 PM |
311 | (unsigned int)tinfo->_sifields._kill._pid, |
312 | (unsigned int)tinfo->_sifields._kill._uid); | |
313 | break; | |
314 | case QEMU_SI_TIMER: | |
4b25a506 | 315 | qemu_log(", si_timer1=%u, si_timer2=%u", |
0cb581d6 PM |
316 | tinfo->_sifields._timer._timer1, |
317 | tinfo->_sifields._timer._timer2); | |
318 | break; | |
319 | case QEMU_SI_POLL: | |
4b25a506 | 320 | qemu_log(", si_band=%d, si_fd=%d", |
0cb581d6 PM |
321 | tinfo->_sifields._sigpoll._band, |
322 | tinfo->_sifields._sigpoll._fd); | |
323 | break; | |
324 | case QEMU_SI_FAULT: | |
4b25a506 | 325 | qemu_log(", si_addr="); |
0cb581d6 PM |
326 | print_pointer(tinfo->_sifields._sigfault._addr, 1); |
327 | break; | |
328 | case QEMU_SI_CHLD: | |
4b25a506 | 329 | qemu_log(", si_pid=%u, si_uid=%u, si_status=%d" |
0cb581d6 PM |
330 | ", si_utime=" TARGET_ABI_FMT_ld |
331 | ", si_stime=" TARGET_ABI_FMT_ld, | |
332 | (unsigned int)(tinfo->_sifields._sigchld._pid), | |
333 | (unsigned int)(tinfo->_sifields._sigchld._uid), | |
334 | tinfo->_sifields._sigchld._status, | |
335 | tinfo->_sifields._sigchld._utime, | |
336 | tinfo->_sifields._sigchld._stime); | |
337 | break; | |
338 | case QEMU_SI_RT: | |
4b25a506 | 339 | qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld, |
0cb581d6 PM |
340 | (unsigned int)tinfo->_sifields._rt._pid, |
341 | (unsigned int)tinfo->_sifields._rt._uid, | |
342 | tinfo->_sifields._rt._sigval.sival_ptr); | |
343 | break; | |
344 | default: | |
345 | g_assert_not_reached(); | |
346 | } | |
4b25a506 | 347 | qemu_log("}"); |
0cb581d6 PM |
348 | } |
349 | ||
fb3aabf3 | 350 | static void |
42b15d70 | 351 | print_sockaddr(abi_ulong addr, abi_long addrlen, int last) |
fb3aabf3 LV |
352 | { |
353 | struct target_sockaddr *sa; | |
354 | int i; | |
355 | int sa_family; | |
356 | ||
357 | sa = lock_user(VERIFY_READ, addr, addrlen, 1); | |
358 | if (sa) { | |
359 | sa_family = tswap16(sa->sa_family); | |
360 | switch (sa_family) { | |
361 | case AF_UNIX: { | |
362 | struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa; | |
363 | int i; | |
4b25a506 | 364 | qemu_log("{sun_family=AF_UNIX,sun_path=\""); |
fb3aabf3 LV |
365 | for (i = 0; i < addrlen - |
366 | offsetof(struct target_sockaddr_un, sun_path) && | |
367 | un->sun_path[i]; i++) { | |
4b25a506 | 368 | qemu_log("%c", un->sun_path[i]); |
fb3aabf3 | 369 | } |
4b25a506 | 370 | qemu_log("\"}"); |
fb3aabf3 LV |
371 | break; |
372 | } | |
373 | case AF_INET: { | |
374 | struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa; | |
375 | uint8_t *c = (uint8_t *)&in->sin_addr.s_addr; | |
4b25a506 | 376 | qemu_log("{sin_family=AF_INET,sin_port=htons(%d),", |
fb3aabf3 | 377 | ntohs(in->sin_port)); |
4b25a506 | 378 | qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", |
fb3aabf3 | 379 | c[0], c[1], c[2], c[3]); |
4b25a506 | 380 | qemu_log("}"); |
fb3aabf3 LV |
381 | break; |
382 | } | |
383 | case AF_PACKET: { | |
384 | struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa; | |
385 | uint8_t *c = (uint8_t *)&ll->sll_addr; | |
4b25a506 | 386 | qemu_log("{sll_family=AF_PACKET," |
fb3aabf3 LV |
387 | "sll_protocol=htons(0x%04x),if%d,pkttype=", |
388 | ntohs(ll->sll_protocol), ll->sll_ifindex); | |
389 | switch (ll->sll_pkttype) { | |
390 | case PACKET_HOST: | |
4b25a506 | 391 | qemu_log("PACKET_HOST"); |
fb3aabf3 LV |
392 | break; |
393 | case PACKET_BROADCAST: | |
4b25a506 | 394 | qemu_log("PACKET_BROADCAST"); |
fb3aabf3 LV |
395 | break; |
396 | case PACKET_MULTICAST: | |
4b25a506 | 397 | qemu_log("PACKET_MULTICAST"); |
fb3aabf3 LV |
398 | break; |
399 | case PACKET_OTHERHOST: | |
4b25a506 | 400 | qemu_log("PACKET_OTHERHOST"); |
fb3aabf3 LV |
401 | break; |
402 | case PACKET_OUTGOING: | |
4b25a506 | 403 | qemu_log("PACKET_OUTGOING"); |
fb3aabf3 LV |
404 | break; |
405 | default: | |
4b25a506 | 406 | qemu_log("%d", ll->sll_pkttype); |
fb3aabf3 LV |
407 | break; |
408 | } | |
4b25a506 | 409 | qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", |
fb3aabf3 | 410 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); |
4b25a506 | 411 | qemu_log("}"); |
fb3aabf3 LV |
412 | break; |
413 | } | |
814ae70f PMD |
414 | case AF_NETLINK: { |
415 | struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa; | |
4b25a506 | 416 | qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}", |
814ae70f PMD |
417 | tswap32(nl->nl_pid), tswap32(nl->nl_groups)); |
418 | break; | |
419 | } | |
fb3aabf3 | 420 | default: |
4b25a506 | 421 | qemu_log("{sa_family=%d, sa_data={", sa->sa_family); |
fb3aabf3 | 422 | for (i = 0; i < 13; i++) { |
4b25a506 | 423 | qemu_log("%02x, ", sa->sa_data[i]); |
fb3aabf3 | 424 | } |
4b25a506 JK |
425 | qemu_log("%02x}", sa->sa_data[i]); |
426 | qemu_log("}"); | |
fb3aabf3 LV |
427 | break; |
428 | } | |
429 | unlock_user(sa, addr, 0); | |
430 | } else { | |
431 | print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); | |
432 | } | |
4b25a506 | 433 | qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); |
fb3aabf3 LV |
434 | } |
435 | ||
436 | static void | |
437 | print_socket_domain(int domain) | |
438 | { | |
439 | switch (domain) { | |
440 | case PF_UNIX: | |
4b25a506 | 441 | qemu_log("PF_UNIX"); |
fb3aabf3 LV |
442 | break; |
443 | case PF_INET: | |
4b25a506 | 444 | qemu_log("PF_INET"); |
fb3aabf3 | 445 | break; |
814ae70f | 446 | case PF_NETLINK: |
4b25a506 | 447 | qemu_log("PF_NETLINK"); |
814ae70f | 448 | break; |
fb3aabf3 | 449 | case PF_PACKET: |
4b25a506 | 450 | qemu_log("PF_PACKET"); |
fb3aabf3 LV |
451 | break; |
452 | default: | |
4b25a506 | 453 | qemu_log("%d", domain); |
fb3aabf3 LV |
454 | break; |
455 | } | |
456 | } | |
457 | ||
458 | static void | |
459 | print_socket_type(int type) | |
460 | { | |
2039b1b0 | 461 | switch (type & TARGET_SOCK_TYPE_MASK) { |
fb3aabf3 | 462 | case TARGET_SOCK_DGRAM: |
4b25a506 | 463 | qemu_log("SOCK_DGRAM"); |
fb3aabf3 LV |
464 | break; |
465 | case TARGET_SOCK_STREAM: | |
4b25a506 | 466 | qemu_log("SOCK_STREAM"); |
fb3aabf3 LV |
467 | break; |
468 | case TARGET_SOCK_RAW: | |
4b25a506 | 469 | qemu_log("SOCK_RAW"); |
fb3aabf3 LV |
470 | break; |
471 | case TARGET_SOCK_RDM: | |
4b25a506 | 472 | qemu_log("SOCK_RDM"); |
fb3aabf3 LV |
473 | break; |
474 | case TARGET_SOCK_SEQPACKET: | |
4b25a506 | 475 | qemu_log("SOCK_SEQPACKET"); |
fb3aabf3 LV |
476 | break; |
477 | case TARGET_SOCK_PACKET: | |
4b25a506 | 478 | qemu_log("SOCK_PACKET"); |
fb3aabf3 LV |
479 | break; |
480 | } | |
2039b1b0 LV |
481 | if (type & TARGET_SOCK_CLOEXEC) { |
482 | qemu_log("|SOCK_CLOEXEC"); | |
483 | } | |
484 | if (type & TARGET_SOCK_NONBLOCK) { | |
485 | qemu_log("|SOCK_NONBLOCK"); | |
486 | } | |
fb3aabf3 LV |
487 | } |
488 | ||
489 | static void | |
490 | print_socket_protocol(int domain, int type, int protocol) | |
491 | { | |
492 | if (domain == AF_PACKET || | |
493 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
494 | switch (protocol) { | |
495 | case 0x0003: | |
4b25a506 | 496 | qemu_log("ETH_P_ALL"); |
fb3aabf3 LV |
497 | break; |
498 | default: | |
4b25a506 | 499 | qemu_log("%d", protocol); |
fb3aabf3 LV |
500 | } |
501 | return; | |
502 | } | |
503 | ||
814ae70f PMD |
504 | if (domain == PF_NETLINK) { |
505 | switch (protocol) { | |
506 | case NETLINK_ROUTE: | |
4b25a506 | 507 | qemu_log("NETLINK_ROUTE"); |
814ae70f | 508 | break; |
d5dbbfe6 LR |
509 | case NETLINK_UNUSED: |
510 | qemu_log("NETLINK_UNUSED"); | |
511 | break; | |
512 | case NETLINK_USERSOCK: | |
513 | qemu_log("NETLINK_USERSOCK"); | |
514 | break; | |
515 | case NETLINK_FIREWALL: | |
516 | qemu_log("NETLINK_FIREWALL"); | |
517 | break; | |
518 | case NETLINK_SOCK_DIAG: | |
519 | qemu_log("NETLINK_SOCK_DIAG"); | |
520 | break; | |
521 | case NETLINK_NFLOG: | |
522 | qemu_log("NETLINK_NFLOG"); | |
523 | break; | |
524 | case NETLINK_XFRM: | |
525 | qemu_log("NETLINK_XFRM"); | |
526 | break; | |
527 | case NETLINK_SELINUX: | |
528 | qemu_log("NETLINK_SELINUX"); | |
529 | break; | |
530 | case NETLINK_ISCSI: | |
531 | qemu_log("NETLINK_ISCSI"); | |
532 | break; | |
814ae70f | 533 | case NETLINK_AUDIT: |
4b25a506 | 534 | qemu_log("NETLINK_AUDIT"); |
814ae70f | 535 | break; |
d5dbbfe6 LR |
536 | case NETLINK_FIB_LOOKUP: |
537 | qemu_log("NETLINK_FIB_LOOKUP"); | |
538 | break; | |
539 | case NETLINK_CONNECTOR: | |
540 | qemu_log("NETLINK_CONNECTOR"); | |
541 | break; | |
814ae70f | 542 | case NETLINK_NETFILTER: |
4b25a506 | 543 | qemu_log("NETLINK_NETFILTER"); |
814ae70f | 544 | break; |
d5dbbfe6 LR |
545 | case NETLINK_IP6_FW: |
546 | qemu_log("NETLINK_IP6_FW"); | |
547 | break; | |
548 | case NETLINK_DNRTMSG: | |
549 | qemu_log("NETLINK_DNRTMSG"); | |
550 | break; | |
814ae70f | 551 | case NETLINK_KOBJECT_UEVENT: |
4b25a506 | 552 | qemu_log("NETLINK_KOBJECT_UEVENT"); |
814ae70f | 553 | break; |
d5dbbfe6 LR |
554 | case NETLINK_GENERIC: |
555 | qemu_log("NETLINK_GENERIC"); | |
556 | break; | |
557 | case NETLINK_SCSITRANSPORT: | |
558 | qemu_log("NETLINK_SCSITRANSPORT"); | |
559 | break; | |
560 | case NETLINK_ECRYPTFS: | |
561 | qemu_log("NETLINK_ECRYPTFS"); | |
562 | break; | |
814ae70f | 563 | case NETLINK_RDMA: |
4b25a506 | 564 | qemu_log("NETLINK_RDMA"); |
814ae70f PMD |
565 | break; |
566 | case NETLINK_CRYPTO: | |
4b25a506 | 567 | qemu_log("NETLINK_CRYPTO"); |
814ae70f | 568 | break; |
d5dbbfe6 LR |
569 | case NETLINK_SMC: |
570 | qemu_log("NETLINK_SMC"); | |
571 | break; | |
814ae70f | 572 | default: |
4b25a506 | 573 | qemu_log("%d", protocol); |
814ae70f PMD |
574 | break; |
575 | } | |
576 | return; | |
577 | } | |
578 | ||
fb3aabf3 LV |
579 | switch (protocol) { |
580 | case IPPROTO_IP: | |
4b25a506 | 581 | qemu_log("IPPROTO_IP"); |
fb3aabf3 LV |
582 | break; |
583 | case IPPROTO_TCP: | |
4b25a506 | 584 | qemu_log("IPPROTO_TCP"); |
fb3aabf3 LV |
585 | break; |
586 | case IPPROTO_UDP: | |
4b25a506 | 587 | qemu_log("IPPROTO_UDP"); |
fb3aabf3 LV |
588 | break; |
589 | case IPPROTO_RAW: | |
4b25a506 | 590 | qemu_log("IPPROTO_RAW"); |
fb3aabf3 LV |
591 | break; |
592 | default: | |
4b25a506 | 593 | qemu_log("%d", protocol); |
fb3aabf3 LV |
594 | break; |
595 | } | |
596 | } | |
597 | ||
598 | ||
c16f9ed3 | 599 | #ifdef TARGET_NR__newselect |
33189d31 | 600 | static void |
c16f9ed3 | 601 | print_fdset(int n, abi_ulong target_fds_addr) |
33189d31 TS |
602 | { |
603 | int i; | |
664441ea | 604 | int first = 1; |
33189d31 | 605 | |
4b25a506 | 606 | qemu_log("["); |
33189d31 | 607 | if( target_fds_addr ) { |
579a97f7 | 608 | abi_long *target_fds; |
33189d31 | 609 | |
579a97f7 FB |
610 | target_fds = lock_user(VERIFY_READ, |
611 | target_fds_addr, | |
612 | sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), | |
613 | 1); | |
614 | ||
615 | if (!target_fds) | |
33189d31 TS |
616 | return; |
617 | ||
33189d31 | 618 | for (i=n; i>=0; i--) { |
664441ea FB |
619 | if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> |
620 | (i & (TARGET_ABI_BITS - 1))) & 1) { | |
621 | qemu_log("%s%d", get_comma(first), i); | |
622 | first = 0; | |
33189d31 | 623 | } |
664441ea | 624 | } |
33189d31 TS |
625 | unlock_user(target_fds, target_fds_addr, 0); |
626 | } | |
4b25a506 | 627 | qemu_log("]"); |
33189d31 | 628 | } |
c16f9ed3 | 629 | #endif |
33189d31 TS |
630 | |
631 | /* | |
632 | * Sysycall specific output functions | |
633 | */ | |
634 | ||
635 | /* select */ | |
c16f9ed3 | 636 | #ifdef TARGET_NR__newselect |
33189d31 | 637 | static void |
a0939b89 | 638 | print_newselect(CPUArchState *cpu_env, const struct syscallname *name, |
c16f9ed3 FB |
639 | abi_long arg1, abi_long arg2, abi_long arg3, |
640 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 641 | { |
c84be71f | 642 | print_syscall_prologue(name); |
33189d31 | 643 | print_fdset(arg1, arg2); |
4b25a506 | 644 | qemu_log(","); |
33189d31 | 645 | print_fdset(arg1, arg3); |
4b25a506 | 646 | qemu_log(","); |
33189d31 | 647 | print_fdset(arg1, arg4); |
4b25a506 | 648 | qemu_log(","); |
74d753ac | 649 | print_timeval(arg5, 1); |
c84be71f | 650 | print_syscall_epilogue(name); |
33189d31 | 651 | } |
c16f9ed3 | 652 | #endif |
33189d31 | 653 | |
3e46b2ef | 654 | #ifdef TARGET_NR_semctl |
33189d31 | 655 | static void |
a0939b89 | 656 | print_semctl(CPUArchState *cpu_env, const struct syscallname *name, |
c16f9ed3 FB |
657 | abi_long arg1, abi_long arg2, abi_long arg3, |
658 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 659 | { |
4b25a506 JK |
660 | qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", |
661 | name->name, arg1, arg2); | |
33189d31 | 662 | print_ipc_cmd(arg3); |
4b25a506 | 663 | qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
33189d31 | 664 | } |
3e46b2ef | 665 | #endif |
33189d31 | 666 | |
c16f9ed3 | 667 | #ifdef TARGET_NR_ipc |
33189d31 | 668 | static void |
a0939b89 | 669 | print_ipc(CPUArchState *cpu_env, const struct syscallname *name, |
c16f9ed3 FB |
670 | abi_long arg1, abi_long arg2, abi_long arg3, |
671 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
672 | { |
673 | switch(arg1) { | |
674 | case IPCOP_semctl: | |
4b25a506 JK |
675 | qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", |
676 | arg1, arg2); | |
7ccfb2eb | 677 | print_ipc_cmd(arg3); |
4b25a506 | 678 | qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
33189d31 TS |
679 | break; |
680 | default: | |
4b25a506 JK |
681 | qemu_log(("%s(" |
682 | TARGET_ABI_FMT_ld "," | |
683 | TARGET_ABI_FMT_ld "," | |
684 | TARGET_ABI_FMT_ld "," | |
685 | TARGET_ABI_FMT_ld | |
686 | ")"), | |
33189d31 TS |
687 | name->name, arg1, arg2, arg3, arg4); |
688 | } | |
689 | } | |
c16f9ed3 | 690 | #endif |
33189d31 TS |
691 | |
692 | /* | |
693 | * Variants for the return value output function | |
694 | */ | |
695 | ||
42b16184 | 696 | static bool |
c84be71f | 697 | print_syscall_err(abi_long ret) |
33189d31 | 698 | { |
42b16184 | 699 | const char *errstr; |
962b289e | 700 | |
c84be71f | 701 | qemu_log(" = "); |
7c75571c | 702 | if (is_error(ret)) { |
2a7e1245 | 703 | errstr = target_strerror(-ret); |
c84be71f | 704 | if (errstr) { |
42b16184 LV |
705 | qemu_log("-1 errno=%d (%s)", (int)-ret, errstr); |
706 | return true; | |
c84be71f | 707 | } |
962b289e | 708 | } |
42b16184 | 709 | return false; |
c84be71f FB |
710 | } |
711 | ||
712 | static void | |
a0939b89 | 713 | print_syscall_ret_addr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
714 | abi_long ret, abi_long arg0, abi_long arg1, |
715 | abi_long arg2, abi_long arg3, abi_long arg4, | |
716 | abi_long arg5) | |
c84be71f | 717 | { |
42b16184 LV |
718 | if (!print_syscall_err(ret)) { |
719 | qemu_log("0x" TARGET_ABI_FMT_lx, ret); | |
33189d31 | 720 | } |
42b16184 | 721 | qemu_log("\n"); |
33189d31 TS |
722 | } |
723 | ||
f3e3285d | 724 | #if 0 /* currently unused */ |
33189d31 | 725 | static void |
c16f9ed3 | 726 | print_syscall_ret_raw(struct syscallname *name, abi_long ret) |
33189d31 | 727 | { |
4b25a506 | 728 | qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
33189d31 | 729 | } |
f3e3285d | 730 | #endif |
33189d31 | 731 | |
f3e3285d | 732 | #ifdef TARGET_NR__newselect |
33189d31 | 733 | static void |
a0939b89 | 734 | print_syscall_ret_newselect(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
735 | abi_long ret, abi_long arg0, abi_long arg1, |
736 | abi_long arg2, abi_long arg3, abi_long arg4, | |
737 | abi_long arg5) | |
c84be71f | 738 | { |
42b16184 | 739 | if (!print_syscall_err(ret)) { |
c84be71f FB |
740 | qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); |
741 | print_fdset(arg0, arg1); | |
742 | qemu_log(","); | |
743 | print_fdset(arg0, arg2); | |
744 | qemu_log(","); | |
745 | print_fdset(arg0, arg3); | |
746 | qemu_log(","); | |
747 | print_timeval(arg4, 1); | |
748 | qemu_log(")"); | |
749 | } | |
750 | ||
751 | qemu_log("\n"); | |
33189d31 | 752 | } |
f3e3285d | 753 | #endif |
33189d31 | 754 | |
19f59bce AM |
755 | /* special meanings of adjtimex()' non-negative return values */ |
756 | #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */ | |
757 | #define TARGET_TIME_INS 1 /* insert leap second */ | |
758 | #define TARGET_TIME_DEL 2 /* delete leap second */ | |
759 | #define TARGET_TIME_OOP 3 /* leap second in progress */ | |
760 | #define TARGET_TIME_WAIT 4 /* leap second has occurred */ | |
761 | #define TARGET_TIME_ERROR 5 /* clock not synchronized */ | |
859e8a89 | 762 | #ifdef TARGET_NR_adjtimex |
19f59bce | 763 | static void |
a0939b89 | 764 | print_syscall_ret_adjtimex(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
765 | abi_long ret, abi_long arg0, abi_long arg1, |
766 | abi_long arg2, abi_long arg3, abi_long arg4, | |
767 | abi_long arg5) | |
19f59bce | 768 | { |
42b16184 | 769 | if (!print_syscall_err(ret)) { |
4b25a506 | 770 | qemu_log(TARGET_ABI_FMT_ld, ret); |
19f59bce AM |
771 | switch (ret) { |
772 | case TARGET_TIME_OK: | |
4b25a506 | 773 | qemu_log(" TIME_OK (clock synchronized, no leap second)"); |
19f59bce AM |
774 | break; |
775 | case TARGET_TIME_INS: | |
4b25a506 | 776 | qemu_log(" TIME_INS (insert leap second)"); |
19f59bce AM |
777 | break; |
778 | case TARGET_TIME_DEL: | |
4b25a506 | 779 | qemu_log(" TIME_DEL (delete leap second)"); |
19f59bce AM |
780 | break; |
781 | case TARGET_TIME_OOP: | |
4b25a506 | 782 | qemu_log(" TIME_OOP (leap second in progress)"); |
19f59bce AM |
783 | break; |
784 | case TARGET_TIME_WAIT: | |
4b25a506 | 785 | qemu_log(" TIME_WAIT (leap second has occurred)"); |
19f59bce AM |
786 | break; |
787 | case TARGET_TIME_ERROR: | |
4b25a506 | 788 | qemu_log(" TIME_ERROR (clock not synchronized)"); |
19f59bce AM |
789 | break; |
790 | } | |
791 | } | |
792 | ||
4b25a506 | 793 | qemu_log("\n"); |
19f59bce | 794 | } |
859e8a89 | 795 | #endif |
19f59bce | 796 | |
1a674adf FB |
797 | #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) |
798 | static void | |
a0939b89 | 799 | print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
800 | abi_long ret, abi_long arg0, abi_long arg1, |
801 | abi_long arg2, abi_long arg3, abi_long arg4, | |
802 | abi_long arg5) | |
803 | { | |
804 | if (!print_syscall_err(ret)) { | |
805 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
806 | qemu_log(" ("); | |
807 | print_timespec(arg1, 1); | |
808 | qemu_log(")"); | |
809 | } | |
810 | ||
811 | qemu_log("\n"); | |
812 | } | |
813 | #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime | |
814 | #endif | |
815 | ||
aad43d15 HD |
816 | #if defined(TARGET_NR_clock_gettime64) |
817 | static void | |
818 | print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name, | |
819 | abi_long ret, abi_long arg0, abi_long arg1, | |
820 | abi_long arg2, abi_long arg3, abi_long arg4, | |
821 | abi_long arg5) | |
822 | { | |
823 | if (!print_syscall_err(ret)) { | |
824 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
825 | qemu_log(" ("); | |
826 | print_timespec64(arg1, 1); | |
827 | qemu_log(")"); | |
828 | } | |
829 | ||
830 | qemu_log("\n"); | |
831 | } | |
832 | #endif | |
833 | ||
1a674adf FB |
834 | #ifdef TARGET_NR_gettimeofday |
835 | static void | |
a0939b89 | 836 | print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
837 | abi_long ret, abi_long arg0, abi_long arg1, |
838 | abi_long arg2, abi_long arg3, abi_long arg4, | |
839 | abi_long arg5) | |
840 | { | |
841 | if (!print_syscall_err(ret)) { | |
842 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
843 | qemu_log(" ("); | |
844 | print_timeval(arg0, 0); | |
845 | print_timezone(arg1, 1); | |
846 | qemu_log(")"); | |
847 | } | |
848 | ||
849 | qemu_log("\n"); | |
850 | } | |
851 | #endif | |
852 | ||
853 | #ifdef TARGET_NR_getitimer | |
854 | static void | |
a0939b89 | 855 | print_syscall_ret_getitimer(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
856 | abi_long ret, abi_long arg0, abi_long arg1, |
857 | abi_long arg2, abi_long arg3, abi_long arg4, | |
858 | abi_long arg5) | |
859 | { | |
860 | if (!print_syscall_err(ret)) { | |
861 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
862 | qemu_log(" ("); | |
863 | print_itimerval(arg1, 1); | |
864 | qemu_log(")"); | |
865 | } | |
866 | ||
867 | qemu_log("\n"); | |
868 | } | |
869 | #endif | |
870 | ||
871 | ||
872 | #ifdef TARGET_NR_getitimer | |
873 | static void | |
a0939b89 | 874 | print_syscall_ret_setitimer(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
875 | abi_long ret, abi_long arg0, abi_long arg1, |
876 | abi_long arg2, abi_long arg3, abi_long arg4, | |
877 | abi_long arg5) | |
878 | { | |
879 | if (!print_syscall_err(ret)) { | |
880 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
881 | qemu_log(" (old_value = "); | |
882 | print_itimerval(arg2, 1); | |
883 | qemu_log(")"); | |
884 | } | |
885 | ||
886 | qemu_log("\n"); | |
887 | } | |
888 | #endif | |
889 | ||
4fc3cdde FB |
890 | #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ |
891 | || defined(TARGGET_NR_flistxattr) | |
892 | static void | |
a0939b89 | 893 | print_syscall_ret_listxattr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
894 | abi_long ret, abi_long arg0, abi_long arg1, |
895 | abi_long arg2, abi_long arg3, abi_long arg4, | |
896 | abi_long arg5) | |
4fc3cdde | 897 | { |
42b16184 | 898 | if (!print_syscall_err(ret)) { |
4fc3cdde FB |
899 | qemu_log(TARGET_ABI_FMT_ld, ret); |
900 | qemu_log(" (list = "); | |
901 | if (arg1 != 0) { | |
902 | abi_long attr = arg1; | |
903 | while (ret) { | |
904 | if (attr != arg1) { | |
905 | qemu_log(","); | |
906 | } | |
907 | print_string(attr, 1); | |
908 | ret -= target_strlen(attr) + 1; | |
909 | attr += target_strlen(attr) + 1; | |
910 | } | |
911 | } else { | |
912 | qemu_log("NULL"); | |
913 | } | |
914 | qemu_log(")"); | |
915 | } | |
916 | ||
917 | qemu_log("\n"); | |
918 | } | |
919 | #define print_syscall_ret_llistxattr print_syscall_ret_listxattr | |
920 | #define print_syscall_ret_flistxattr print_syscall_ret_listxattr | |
921 | #endif | |
922 | ||
79482e59 FB |
923 | #ifdef TARGET_NR_ioctl |
924 | static void | |
a0939b89 | 925 | print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
926 | abi_long ret, abi_long arg0, abi_long arg1, |
927 | abi_long arg2, abi_long arg3, abi_long arg4, | |
928 | abi_long arg5) | |
79482e59 | 929 | { |
42b16184 | 930 | if (!print_syscall_err(ret)) { |
79482e59 FB |
931 | qemu_log(TARGET_ABI_FMT_ld, ret); |
932 | ||
933 | const IOCTLEntry *ie; | |
934 | const argtype *arg_type; | |
935 | void *argptr; | |
936 | int target_size; | |
937 | ||
938 | for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { | |
939 | if (ie->target_cmd == arg1) { | |
940 | break; | |
941 | } | |
942 | } | |
943 | ||
944 | if (ie->target_cmd == arg1 && | |
945 | (ie->access == IOC_R || ie->access == IOC_RW)) { | |
946 | arg_type = ie->arg_type; | |
947 | qemu_log(" ("); | |
948 | arg_type++; | |
949 | target_size = thunk_type_size(arg_type, 0); | |
950 | argptr = lock_user(VERIFY_READ, arg2, target_size, 1); | |
4c1850c1 LV |
951 | if (argptr) { |
952 | thunk_print(argptr, arg_type); | |
953 | unlock_user(argptr, arg2, target_size); | |
954 | } else { | |
955 | print_pointer(arg2, 1); | |
956 | } | |
79482e59 FB |
957 | qemu_log(")"); |
958 | } | |
959 | } | |
960 | qemu_log("\n"); | |
961 | } | |
962 | #endif | |
963 | ||
ba0fef0d | 964 | UNUSED static const struct flags access_flags[] = { |
74d753ac MW |
965 | FLAG_GENERIC(F_OK), |
966 | FLAG_GENERIC(R_OK), | |
967 | FLAG_GENERIC(W_OK), | |
968 | FLAG_GENERIC(X_OK), | |
969 | FLAG_END, | |
970 | }; | |
971 | ||
ba0fef0d | 972 | UNUSED static const struct flags at_file_flags[] = { |
74d753ac MW |
973 | #ifdef AT_EACCESS |
974 | FLAG_GENERIC(AT_EACCESS), | |
975 | #endif | |
976 | #ifdef AT_SYMLINK_NOFOLLOW | |
977 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), | |
978 | #endif | |
979 | FLAG_END, | |
980 | }; | |
981 | ||
ba0fef0d | 982 | UNUSED static const struct flags unlinkat_flags[] = { |
74d753ac MW |
983 | #ifdef AT_REMOVEDIR |
984 | FLAG_GENERIC(AT_REMOVEDIR), | |
985 | #endif | |
986 | FLAG_END, | |
987 | }; | |
988 | ||
ba0fef0d | 989 | UNUSED static const struct flags mode_flags[] = { |
74d753ac MW |
990 | FLAG_GENERIC(S_IFSOCK), |
991 | FLAG_GENERIC(S_IFLNK), | |
992 | FLAG_GENERIC(S_IFREG), | |
993 | FLAG_GENERIC(S_IFBLK), | |
994 | FLAG_GENERIC(S_IFDIR), | |
995 | FLAG_GENERIC(S_IFCHR), | |
996 | FLAG_GENERIC(S_IFIFO), | |
997 | FLAG_END, | |
998 | }; | |
999 | ||
ba0fef0d | 1000 | UNUSED static const struct flags open_access_flags[] = { |
74d753ac MW |
1001 | FLAG_TARGET(O_RDONLY), |
1002 | FLAG_TARGET(O_WRONLY), | |
1003 | FLAG_TARGET(O_RDWR), | |
1004 | FLAG_END, | |
1005 | }; | |
1006 | ||
ba0fef0d | 1007 | UNUSED static const struct flags open_flags[] = { |
74d753ac MW |
1008 | FLAG_TARGET(O_APPEND), |
1009 | FLAG_TARGET(O_CREAT), | |
1010 | FLAG_TARGET(O_DIRECTORY), | |
1011 | FLAG_TARGET(O_EXCL), | |
1012 | FLAG_TARGET(O_LARGEFILE), | |
1013 | FLAG_TARGET(O_NOCTTY), | |
1014 | FLAG_TARGET(O_NOFOLLOW), | |
1015 | FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ | |
afc8763f RH |
1016 | FLAG_TARGET(O_DSYNC), |
1017 | FLAG_TARGET(__O_SYNC), | |
74d753ac MW |
1018 | FLAG_TARGET(O_TRUNC), |
1019 | #ifdef O_DIRECT | |
1020 | FLAG_TARGET(O_DIRECT), | |
afc8763f RH |
1021 | #endif |
1022 | #ifdef O_NOATIME | |
1023 | FLAG_TARGET(O_NOATIME), | |
1024 | #endif | |
1025 | #ifdef O_CLOEXEC | |
1026 | FLAG_TARGET(O_CLOEXEC), | |
1027 | #endif | |
1028 | #ifdef O_PATH | |
1029 | FLAG_TARGET(O_PATH), | |
5f9cee46 RV |
1030 | #endif |
1031 | #ifdef O_TMPFILE | |
1032 | FLAG_TARGET(O_TMPFILE), | |
1033 | FLAG_TARGET(__O_TMPFILE), | |
74d753ac MW |
1034 | #endif |
1035 | FLAG_END, | |
1036 | }; | |
1037 | ||
ba0fef0d | 1038 | UNUSED static const struct flags mount_flags[] = { |
74d753ac MW |
1039 | #ifdef MS_BIND |
1040 | FLAG_GENERIC(MS_BIND), | |
1041 | #endif | |
1042 | #ifdef MS_DIRSYNC | |
1043 | FLAG_GENERIC(MS_DIRSYNC), | |
1044 | #endif | |
1045 | FLAG_GENERIC(MS_MANDLOCK), | |
1046 | #ifdef MS_MOVE | |
1047 | FLAG_GENERIC(MS_MOVE), | |
1048 | #endif | |
1049 | FLAG_GENERIC(MS_NOATIME), | |
1050 | FLAG_GENERIC(MS_NODEV), | |
1051 | FLAG_GENERIC(MS_NODIRATIME), | |
1052 | FLAG_GENERIC(MS_NOEXEC), | |
1053 | FLAG_GENERIC(MS_NOSUID), | |
1054 | FLAG_GENERIC(MS_RDONLY), | |
1055 | #ifdef MS_RELATIME | |
1056 | FLAG_GENERIC(MS_RELATIME), | |
1057 | #endif | |
1058 | FLAG_GENERIC(MS_REMOUNT), | |
1059 | FLAG_GENERIC(MS_SYNCHRONOUS), | |
1060 | FLAG_END, | |
1061 | }; | |
1062 | ||
ba0fef0d | 1063 | UNUSED static const struct flags umount2_flags[] = { |
74d753ac MW |
1064 | #ifdef MNT_FORCE |
1065 | FLAG_GENERIC(MNT_FORCE), | |
1066 | #endif | |
1067 | #ifdef MNT_DETACH | |
1068 | FLAG_GENERIC(MNT_DETACH), | |
1069 | #endif | |
1070 | #ifdef MNT_EXPIRE | |
1071 | FLAG_GENERIC(MNT_EXPIRE), | |
1072 | #endif | |
1073 | FLAG_END, | |
1074 | }; | |
1075 | ||
ba0fef0d | 1076 | UNUSED static const struct flags mmap_prot_flags[] = { |
74d753ac MW |
1077 | FLAG_GENERIC(PROT_NONE), |
1078 | FLAG_GENERIC(PROT_EXEC), | |
1079 | FLAG_GENERIC(PROT_READ), | |
1080 | FLAG_GENERIC(PROT_WRITE), | |
9e0b74a4 PB |
1081 | FLAG_TARGET(PROT_SEM), |
1082 | FLAG_GENERIC(PROT_GROWSDOWN), | |
1083 | FLAG_GENERIC(PROT_GROWSUP), | |
74d753ac MW |
1084 | FLAG_END, |
1085 | }; | |
1086 | ||
ba0fef0d | 1087 | UNUSED static const struct flags mmap_flags[] = { |
74d753ac MW |
1088 | FLAG_TARGET(MAP_SHARED), |
1089 | FLAG_TARGET(MAP_PRIVATE), | |
1090 | FLAG_TARGET(MAP_ANONYMOUS), | |
1091 | FLAG_TARGET(MAP_DENYWRITE), | |
1092 | FLAG_TARGET(MAP_FIXED), | |
1093 | FLAG_TARGET(MAP_GROWSDOWN), | |
906c1b8e | 1094 | FLAG_TARGET(MAP_EXECUTABLE), |
74d753ac MW |
1095 | #ifdef MAP_LOCKED |
1096 | FLAG_TARGET(MAP_LOCKED), | |
1097 | #endif | |
1098 | #ifdef MAP_NONBLOCK | |
1099 | FLAG_TARGET(MAP_NONBLOCK), | |
1100 | #endif | |
1101 | FLAG_TARGET(MAP_NORESERVE), | |
1102 | #ifdef MAP_POPULATE | |
1103 | FLAG_TARGET(MAP_POPULATE), | |
906c1b8e MF |
1104 | #endif |
1105 | #ifdef TARGET_MAP_UNINITIALIZED | |
1106 | FLAG_TARGET(MAP_UNINITIALIZED), | |
74d753ac | 1107 | #endif |
e2c649e5 HD |
1108 | FLAG_TARGET(MAP_HUGETLB), |
1109 | FLAG_TARGET(MAP_STACK), | |
74d753ac MW |
1110 | FLAG_END, |
1111 | }; | |
1112 | ||
ba0fef0d | 1113 | UNUSED static const struct flags clone_flags[] = { |
608e5592 LV |
1114 | FLAG_GENERIC(CLONE_VM), |
1115 | FLAG_GENERIC(CLONE_FS), | |
1116 | FLAG_GENERIC(CLONE_FILES), | |
1117 | FLAG_GENERIC(CLONE_SIGHAND), | |
1118 | FLAG_GENERIC(CLONE_PTRACE), | |
1119 | FLAG_GENERIC(CLONE_VFORK), | |
1120 | FLAG_GENERIC(CLONE_PARENT), | |
1121 | FLAG_GENERIC(CLONE_THREAD), | |
1122 | FLAG_GENERIC(CLONE_NEWNS), | |
1123 | FLAG_GENERIC(CLONE_SYSVSEM), | |
1124 | FLAG_GENERIC(CLONE_SETTLS), | |
1125 | FLAG_GENERIC(CLONE_PARENT_SETTID), | |
1126 | FLAG_GENERIC(CLONE_CHILD_CLEARTID), | |
1127 | FLAG_GENERIC(CLONE_DETACHED), | |
1128 | FLAG_GENERIC(CLONE_UNTRACED), | |
1129 | FLAG_GENERIC(CLONE_CHILD_SETTID), | |
6f11f013 | 1130 | #if defined(CLONE_NEWUTS) |
608e5592 | 1131 | FLAG_GENERIC(CLONE_NEWUTS), |
6f11f013 SW |
1132 | #endif |
1133 | #if defined(CLONE_NEWIPC) | |
608e5592 | 1134 | FLAG_GENERIC(CLONE_NEWIPC), |
6f11f013 SW |
1135 | #endif |
1136 | #if defined(CLONE_NEWUSER) | |
608e5592 | 1137 | FLAG_GENERIC(CLONE_NEWUSER), |
6f11f013 SW |
1138 | #endif |
1139 | #if defined(CLONE_NEWPID) | |
608e5592 | 1140 | FLAG_GENERIC(CLONE_NEWPID), |
6f11f013 SW |
1141 | #endif |
1142 | #if defined(CLONE_NEWNET) | |
608e5592 | 1143 | FLAG_GENERIC(CLONE_NEWNET), |
6f11f013 | 1144 | #endif |
5847d309 MK |
1145 | #if defined(CLONE_NEWCGROUP) |
1146 | FLAG_GENERIC(CLONE_NEWCGROUP), | |
1147 | #endif | |
1148 | #if defined(CLONE_NEWTIME) | |
1149 | FLAG_GENERIC(CLONE_NEWTIME), | |
1150 | #endif | |
6f11f013 | 1151 | #if defined(CLONE_IO) |
608e5592 | 1152 | FLAG_GENERIC(CLONE_IO), |
6f11f013 | 1153 | #endif |
608e5592 LV |
1154 | FLAG_END, |
1155 | }; | |
1156 | ||
5667a1ae DD |
1157 | UNUSED static const struct flags execveat_flags[] = { |
1158 | #ifdef AT_EMPTY_PATH | |
1159 | FLAG_GENERIC(AT_EMPTY_PATH), | |
1160 | #endif | |
1161 | #ifdef AT_SYMLINK_NOFOLLOW | |
1162 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), | |
1163 | #endif | |
1164 | FLAG_END, | |
1165 | }; | |
1166 | ||
ba0fef0d | 1167 | UNUSED static const struct flags msg_flags[] = { |
fb3aabf3 LV |
1168 | /* send */ |
1169 | FLAG_GENERIC(MSG_CONFIRM), | |
1170 | FLAG_GENERIC(MSG_DONTROUTE), | |
1171 | FLAG_GENERIC(MSG_DONTWAIT), | |
1172 | FLAG_GENERIC(MSG_EOR), | |
1173 | FLAG_GENERIC(MSG_MORE), | |
1174 | FLAG_GENERIC(MSG_NOSIGNAL), | |
1175 | FLAG_GENERIC(MSG_OOB), | |
1176 | /* recv */ | |
1177 | FLAG_GENERIC(MSG_CMSG_CLOEXEC), | |
1178 | FLAG_GENERIC(MSG_ERRQUEUE), | |
1179 | FLAG_GENERIC(MSG_PEEK), | |
1180 | FLAG_GENERIC(MSG_TRUNC), | |
1181 | FLAG_GENERIC(MSG_WAITALL), | |
1182 | /* recvmsg */ | |
1183 | FLAG_GENERIC(MSG_CTRUNC), | |
1184 | FLAG_END, | |
1185 | }; | |
1186 | ||
ba0fef0d | 1187 | UNUSED static const struct flags statx_flags[] = { |
d42744fe JW |
1188 | #ifdef AT_EMPTY_PATH |
1189 | FLAG_GENERIC(AT_EMPTY_PATH), | |
1190 | #endif | |
1191 | #ifdef AT_NO_AUTOMOUNT | |
1192 | FLAG_GENERIC(AT_NO_AUTOMOUNT), | |
1193 | #endif | |
1194 | #ifdef AT_SYMLINK_NOFOLLOW | |
1195 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), | |
1196 | #endif | |
1197 | #ifdef AT_STATX_SYNC_AS_STAT | |
1198 | FLAG_GENERIC(AT_STATX_SYNC_AS_STAT), | |
1199 | #endif | |
1200 | #ifdef AT_STATX_FORCE_SYNC | |
1201 | FLAG_GENERIC(AT_STATX_FORCE_SYNC), | |
1202 | #endif | |
1203 | #ifdef AT_STATX_DONT_SYNC | |
1204 | FLAG_GENERIC(AT_STATX_DONT_SYNC), | |
1205 | #endif | |
1206 | FLAG_END, | |
1207 | }; | |
1208 | ||
ba0fef0d | 1209 | UNUSED static const struct flags statx_mask[] = { |
d42744fe JW |
1210 | /* This must come first, because it includes everything. */ |
1211 | #ifdef STATX_ALL | |
1212 | FLAG_GENERIC(STATX_ALL), | |
1213 | #endif | |
1214 | /* This must come second; it includes everything except STATX_BTIME. */ | |
1215 | #ifdef STATX_BASIC_STATS | |
1216 | FLAG_GENERIC(STATX_BASIC_STATS), | |
1217 | #endif | |
1218 | #ifdef STATX_TYPE | |
1219 | FLAG_GENERIC(STATX_TYPE), | |
1220 | #endif | |
1221 | #ifdef STATX_MODE | |
1222 | FLAG_GENERIC(STATX_MODE), | |
1223 | #endif | |
1224 | #ifdef STATX_NLINK | |
1225 | FLAG_GENERIC(STATX_NLINK), | |
1226 | #endif | |
1227 | #ifdef STATX_UID | |
1228 | FLAG_GENERIC(STATX_UID), | |
1229 | #endif | |
1230 | #ifdef STATX_GID | |
1231 | FLAG_GENERIC(STATX_GID), | |
1232 | #endif | |
1233 | #ifdef STATX_ATIME | |
1234 | FLAG_GENERIC(STATX_ATIME), | |
1235 | #endif | |
1236 | #ifdef STATX_MTIME | |
1237 | FLAG_GENERIC(STATX_MTIME), | |
1238 | #endif | |
1239 | #ifdef STATX_CTIME | |
1240 | FLAG_GENERIC(STATX_CTIME), | |
1241 | #endif | |
1242 | #ifdef STATX_INO | |
1243 | FLAG_GENERIC(STATX_INO), | |
1244 | #endif | |
1245 | #ifdef STATX_SIZE | |
1246 | FLAG_GENERIC(STATX_SIZE), | |
1247 | #endif | |
1248 | #ifdef STATX_BLOCKS | |
1249 | FLAG_GENERIC(STATX_BLOCKS), | |
1250 | #endif | |
1251 | #ifdef STATX_BTIME | |
1252 | FLAG_GENERIC(STATX_BTIME), | |
1253 | #endif | |
1254 | FLAG_END, | |
1255 | }; | |
1256 | ||
ba0fef0d | 1257 | UNUSED static const struct flags falloc_flags[] = { |
f4d92c5e FB |
1258 | FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), |
1259 | FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), | |
1260 | #ifdef FALLOC_FL_NO_HIDE_STALE | |
1261 | FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), | |
1262 | #endif | |
1263 | #ifdef FALLOC_FL_COLLAPSE_RANGE | |
1264 | FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), | |
1265 | #endif | |
1266 | #ifdef FALLOC_FL_ZERO_RANGE | |
1267 | FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), | |
1268 | #endif | |
1269 | #ifdef FALLOC_FL_INSERT_RANGE | |
1270 | FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), | |
1271 | #endif | |
1272 | #ifdef FALLOC_FL_UNSHARE_RANGE | |
1273 | FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), | |
1274 | #endif | |
1275 | }; | |
1276 | ||
ba0fef0d | 1277 | UNUSED static const struct flags termios_iflags[] = { |
888468db FB |
1278 | FLAG_TARGET(IGNBRK), |
1279 | FLAG_TARGET(BRKINT), | |
1280 | FLAG_TARGET(IGNPAR), | |
1281 | FLAG_TARGET(PARMRK), | |
1282 | FLAG_TARGET(INPCK), | |
1283 | FLAG_TARGET(ISTRIP), | |
1284 | FLAG_TARGET(INLCR), | |
1285 | FLAG_TARGET(IGNCR), | |
1286 | FLAG_TARGET(ICRNL), | |
1287 | FLAG_TARGET(IUCLC), | |
1288 | FLAG_TARGET(IXON), | |
1289 | FLAG_TARGET(IXANY), | |
1290 | FLAG_TARGET(IXOFF), | |
1291 | FLAG_TARGET(IMAXBEL), | |
1292 | FLAG_TARGET(IUTF8), | |
1293 | FLAG_END, | |
1294 | }; | |
1295 | ||
ba0fef0d | 1296 | UNUSED static const struct flags termios_oflags[] = { |
888468db FB |
1297 | FLAG_TARGET(OPOST), |
1298 | FLAG_TARGET(OLCUC), | |
1299 | FLAG_TARGET(ONLCR), | |
1300 | FLAG_TARGET(OCRNL), | |
1301 | FLAG_TARGET(ONOCR), | |
1302 | FLAG_TARGET(ONLRET), | |
1303 | FLAG_TARGET(OFILL), | |
1304 | FLAG_TARGET(OFDEL), | |
1305 | FLAG_END, | |
1306 | }; | |
1307 | ||
1308 | UNUSED static struct enums termios_oflags_NLDLY[] = { | |
1309 | ENUM_TARGET(NL0), | |
1310 | ENUM_TARGET(NL1), | |
1311 | ENUM_END, | |
1312 | }; | |
1313 | ||
1314 | UNUSED static struct enums termios_oflags_CRDLY[] = { | |
1315 | ENUM_TARGET(CR0), | |
1316 | ENUM_TARGET(CR1), | |
1317 | ENUM_TARGET(CR2), | |
1318 | ENUM_TARGET(CR3), | |
1319 | ENUM_END, | |
1320 | }; | |
1321 | ||
1322 | UNUSED static struct enums termios_oflags_TABDLY[] = { | |
1323 | ENUM_TARGET(TAB0), | |
1324 | ENUM_TARGET(TAB1), | |
1325 | ENUM_TARGET(TAB2), | |
1326 | ENUM_TARGET(TAB3), | |
1327 | ENUM_END, | |
1328 | }; | |
1329 | ||
1330 | UNUSED static struct enums termios_oflags_VTDLY[] = { | |
1331 | ENUM_TARGET(VT0), | |
1332 | ENUM_TARGET(VT1), | |
1333 | ENUM_END, | |
1334 | }; | |
1335 | ||
1336 | UNUSED static struct enums termios_oflags_FFDLY[] = { | |
1337 | ENUM_TARGET(FF0), | |
1338 | ENUM_TARGET(FF1), | |
1339 | ENUM_END, | |
1340 | }; | |
1341 | ||
1342 | UNUSED static struct enums termios_oflags_BSDLY[] = { | |
1343 | ENUM_TARGET(BS0), | |
1344 | ENUM_TARGET(BS1), | |
1345 | ENUM_END, | |
1346 | }; | |
1347 | ||
1348 | UNUSED static struct enums termios_cflags_CBAUD[] = { | |
1349 | ENUM_TARGET(B0), | |
1350 | ENUM_TARGET(B50), | |
1351 | ENUM_TARGET(B75), | |
1352 | ENUM_TARGET(B110), | |
1353 | ENUM_TARGET(B134), | |
1354 | ENUM_TARGET(B150), | |
1355 | ENUM_TARGET(B200), | |
1356 | ENUM_TARGET(B300), | |
1357 | ENUM_TARGET(B600), | |
1358 | ENUM_TARGET(B1200), | |
1359 | ENUM_TARGET(B1800), | |
1360 | ENUM_TARGET(B2400), | |
1361 | ENUM_TARGET(B4800), | |
1362 | ENUM_TARGET(B9600), | |
1363 | ENUM_TARGET(B19200), | |
1364 | ENUM_TARGET(B38400), | |
1365 | ENUM_TARGET(B57600), | |
1366 | ENUM_TARGET(B115200), | |
1367 | ENUM_TARGET(B230400), | |
1368 | ENUM_TARGET(B460800), | |
1369 | ENUM_END, | |
1370 | }; | |
1371 | ||
1372 | UNUSED static struct enums termios_cflags_CSIZE[] = { | |
1373 | ENUM_TARGET(CS5), | |
1374 | ENUM_TARGET(CS6), | |
1375 | ENUM_TARGET(CS7), | |
1376 | ENUM_TARGET(CS8), | |
1377 | ENUM_END, | |
1378 | }; | |
1379 | ||
ba0fef0d | 1380 | UNUSED static const struct flags termios_cflags[] = { |
888468db FB |
1381 | FLAG_TARGET(CSTOPB), |
1382 | FLAG_TARGET(CREAD), | |
1383 | FLAG_TARGET(PARENB), | |
1384 | FLAG_TARGET(PARODD), | |
1385 | FLAG_TARGET(HUPCL), | |
1386 | FLAG_TARGET(CLOCAL), | |
1387 | FLAG_TARGET(CRTSCTS), | |
1388 | FLAG_END, | |
1389 | }; | |
1390 | ||
ba0fef0d | 1391 | UNUSED static const struct flags termios_lflags[] = { |
888468db FB |
1392 | FLAG_TARGET(ISIG), |
1393 | FLAG_TARGET(ICANON), | |
1394 | FLAG_TARGET(XCASE), | |
1395 | FLAG_TARGET(ECHO), | |
1396 | FLAG_TARGET(ECHOE), | |
1397 | FLAG_TARGET(ECHOK), | |
1398 | FLAG_TARGET(ECHONL), | |
1399 | FLAG_TARGET(NOFLSH), | |
1400 | FLAG_TARGET(TOSTOP), | |
1401 | FLAG_TARGET(ECHOCTL), | |
1402 | FLAG_TARGET(ECHOPRT), | |
1403 | FLAG_TARGET(ECHOKE), | |
1404 | FLAG_TARGET(FLUSHO), | |
1405 | FLAG_TARGET(PENDIN), | |
1406 | FLAG_TARGET(IEXTEN), | |
1407 | FLAG_TARGET(EXTPROC), | |
1408 | FLAG_END, | |
1409 | }; | |
1410 | ||
d237b416 MF |
1411 | #ifdef TARGET_NR_mlockall |
1412 | static const struct flags mlockall_flags[] = { | |
02e5d7d7 FB |
1413 | FLAG_TARGET(MCL_CURRENT), |
1414 | FLAG_TARGET(MCL_FUTURE), | |
1415 | #ifdef MCL_ONFAULT | |
1416 | FLAG_TARGET(MCL_ONFAULT), | |
1417 | #endif | |
1418 | FLAG_END, | |
1419 | }; | |
d237b416 | 1420 | #endif |
02e5d7d7 | 1421 | |
1a674adf FB |
1422 | /* IDs of the various system clocks */ |
1423 | #define TARGET_CLOCK_REALTIME 0 | |
1424 | #define TARGET_CLOCK_MONOTONIC 1 | |
1425 | #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 | |
1426 | #define TARGET_CLOCK_THREAD_CPUTIME_ID 3 | |
1427 | #define TARGET_CLOCK_MONOTONIC_RAW 4 | |
1428 | #define TARGET_CLOCK_REALTIME_COARSE 5 | |
1429 | #define TARGET_CLOCK_MONOTONIC_COARSE 6 | |
1430 | #define TARGET_CLOCK_BOOTTIME 7 | |
1431 | #define TARGET_CLOCK_REALTIME_ALARM 8 | |
1432 | #define TARGET_CLOCK_BOOTTIME_ALARM 9 | |
1433 | #define TARGET_CLOCK_SGI_CYCLE 10 | |
1434 | #define TARGET_CLOCK_TAI 11 | |
1435 | ||
1436 | UNUSED static struct enums clockids[] = { | |
1437 | ENUM_TARGET(CLOCK_REALTIME), | |
1438 | ENUM_TARGET(CLOCK_MONOTONIC), | |
1439 | ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID), | |
1440 | ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID), | |
1441 | ENUM_TARGET(CLOCK_MONOTONIC_RAW), | |
1442 | ENUM_TARGET(CLOCK_REALTIME_COARSE), | |
1443 | ENUM_TARGET(CLOCK_MONOTONIC_COARSE), | |
1444 | ENUM_TARGET(CLOCK_BOOTTIME), | |
1445 | ENUM_TARGET(CLOCK_REALTIME_ALARM), | |
1446 | ENUM_TARGET(CLOCK_BOOTTIME_ALARM), | |
1447 | ENUM_TARGET(CLOCK_SGI_CYCLE), | |
1448 | ENUM_TARGET(CLOCK_TAI), | |
1449 | ENUM_END, | |
1450 | }; | |
1451 | ||
1452 | UNUSED static struct enums itimer_types[] = { | |
1453 | ENUM_GENERIC(ITIMER_REAL), | |
1454 | ENUM_GENERIC(ITIMER_VIRTUAL), | |
1455 | ENUM_GENERIC(ITIMER_PROF), | |
1456 | ENUM_END, | |
1457 | }; | |
1458 | ||
74d753ac MW |
1459 | /* |
1460 | * print_xxx utility functions. These are used to print syscall | |
1461 | * parameters in certain format. All of these have parameter | |
1462 | * named 'last'. This parameter is used to add comma to output | |
1463 | * when last == 0. | |
1464 | */ | |
1465 | ||
1466 | static const char * | |
1467 | get_comma(int last) | |
1468 | { | |
1469 | return ((last) ? "" : ","); | |
1470 | } | |
1471 | ||
1472 | static void | |
d2ee72a5 | 1473 | print_flags(const struct flags *f, abi_long flags, int last) |
74d753ac MW |
1474 | { |
1475 | const char *sep = ""; | |
74d753ac MW |
1476 | int n; |
1477 | ||
74d753ac | 1478 | if ((flags == 0) && (f->f_value == 0)) { |
4b25a506 | 1479 | qemu_log("%s%s", f->f_string, get_comma(last)); |
74d753ac MW |
1480 | return; |
1481 | } | |
1482 | for (n = 0; f->f_string != NULL; f++) { | |
1483 | if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { | |
4b25a506 | 1484 | qemu_log("%s%s", sep, f->f_string); |
74d753ac MW |
1485 | flags &= ~f->f_value; |
1486 | sep = "|"; | |
1487 | n++; | |
1488 | } | |
1489 | } | |
1490 | ||
1491 | if (n > 0) { | |
1492 | /* print rest of the flags as numeric */ | |
1493 | if (flags != 0) { | |
4b25a506 | 1494 | qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); |
74d753ac | 1495 | } else { |
4b25a506 | 1496 | qemu_log("%s", get_comma(last)); |
74d753ac MW |
1497 | } |
1498 | } else { | |
1499 | /* no string version of flags found, print them in hex then */ | |
4b25a506 | 1500 | qemu_log("%#x%s", (unsigned int)flags, get_comma(last)); |
74d753ac MW |
1501 | } |
1502 | } | |
1503 | ||
45f56799 FB |
1504 | static void |
1505 | print_enums(const struct enums *e, abi_long enum_arg, int last) | |
1506 | { | |
1507 | for (; e->e_string != NULL; e++) { | |
1508 | if (e->e_value == enum_arg) { | |
1509 | qemu_log("%s", e->e_string); | |
1510 | break; | |
1511 | } | |
1512 | } | |
1513 | ||
1514 | if (e->e_string == NULL) { | |
1515 | qemu_log("%#x", (unsigned int)enum_arg); | |
1516 | } | |
1517 | ||
1518 | qemu_log("%s", get_comma(last)); | |
1519 | } | |
1520 | ||
74d753ac | 1521 | static void |
d2ee72a5 | 1522 | print_at_dirfd(abi_long dirfd, int last) |
74d753ac | 1523 | { |
74d753ac MW |
1524 | #ifdef AT_FDCWD |
1525 | if (dirfd == AT_FDCWD) { | |
4b25a506 | 1526 | qemu_log("AT_FDCWD%s", get_comma(last)); |
74d753ac MW |
1527 | return; |
1528 | } | |
1529 | #endif | |
4b25a506 | 1530 | qemu_log("%d%s", (int)dirfd, get_comma(last)); |
74d753ac MW |
1531 | } |
1532 | ||
1533 | static void | |
d2ee72a5 | 1534 | print_file_mode(abi_long mode, int last) |
74d753ac MW |
1535 | { |
1536 | const char *sep = ""; | |
1537 | const struct flags *m; | |
74d753ac | 1538 | |
105d599a HD |
1539 | if (mode == 0) { |
1540 | qemu_log("000%s", get_comma(last)); | |
1541 | return; | |
1542 | } | |
1543 | ||
74d753ac MW |
1544 | for (m = &mode_flags[0]; m->f_string != NULL; m++) { |
1545 | if ((m->f_value & mode) == m->f_value) { | |
4b25a506 | 1546 | qemu_log("%s%s", m->f_string, sep); |
74d753ac MW |
1547 | sep = "|"; |
1548 | mode &= ~m->f_value; | |
1549 | break; | |
1550 | } | |
1551 | } | |
1552 | ||
1553 | mode &= ~S_IFMT; | |
1554 | /* print rest of the mode as octal */ | |
1555 | if (mode != 0) | |
4b25a506 | 1556 | qemu_log("%s%#o", sep, (unsigned int)mode); |
74d753ac | 1557 | |
4b25a506 | 1558 | qemu_log("%s", get_comma(last)); |
74d753ac MW |
1559 | } |
1560 | ||
1561 | static void | |
d2ee72a5 | 1562 | print_open_flags(abi_long flags, int last) |
74d753ac | 1563 | { |
74d753ac MW |
1564 | print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); |
1565 | flags &= ~TARGET_O_ACCMODE; | |
1566 | if (flags == 0) { | |
4b25a506 | 1567 | qemu_log("%s", get_comma(last)); |
74d753ac MW |
1568 | return; |
1569 | } | |
4b25a506 | 1570 | qemu_log("|"); |
74d753ac MW |
1571 | print_flags(open_flags, flags, last); |
1572 | } | |
1573 | ||
1574 | static void | |
1575 | print_syscall_prologue(const struct syscallname *sc) | |
1576 | { | |
4b25a506 | 1577 | qemu_log("%s(", sc->name); |
74d753ac MW |
1578 | } |
1579 | ||
1580 | /*ARGSUSED*/ | |
1581 | static void | |
1582 | print_syscall_epilogue(const struct syscallname *sc) | |
1583 | { | |
1584 | (void)sc; | |
4b25a506 | 1585 | qemu_log(")"); |
74d753ac MW |
1586 | } |
1587 | ||
1588 | static void | |
1589 | print_string(abi_long addr, int last) | |
1590 | { | |
1591 | char *s; | |
1592 | ||
1593 | if ((s = lock_user_string(addr)) != NULL) { | |
4b25a506 | 1594 | qemu_log("\"%s\"%s", s, get_comma(last)); |
74d753ac MW |
1595 | unlock_user(s, addr, 0); |
1596 | } else { | |
1597 | /* can't get string out of it, so print it as pointer */ | |
1598 | print_pointer(addr, last); | |
1599 | } | |
1600 | } | |
1601 | ||
fb3aabf3 LV |
1602 | #define MAX_PRINT_BUF 40 |
1603 | static void | |
1604 | print_buf(abi_long addr, abi_long len, int last) | |
1605 | { | |
1606 | uint8_t *s; | |
1607 | int i; | |
1608 | ||
1609 | s = lock_user(VERIFY_READ, addr, len, 1); | |
1610 | if (s) { | |
4b25a506 | 1611 | qemu_log("\""); |
fb3aabf3 LV |
1612 | for (i = 0; i < MAX_PRINT_BUF && i < len; i++) { |
1613 | if (isprint(s[i])) { | |
4b25a506 | 1614 | qemu_log("%c", s[i]); |
fb3aabf3 | 1615 | } else { |
4b25a506 | 1616 | qemu_log("\\%o", s[i]); |
fb3aabf3 LV |
1617 | } |
1618 | } | |
4b25a506 | 1619 | qemu_log("\""); |
fb3aabf3 | 1620 | if (i != len) { |
4b25a506 | 1621 | qemu_log("..."); |
fb3aabf3 LV |
1622 | } |
1623 | if (!last) { | |
4b25a506 | 1624 | qemu_log(","); |
fb3aabf3 LV |
1625 | } |
1626 | unlock_user(s, addr, 0); | |
1627 | } else { | |
1628 | print_pointer(addr, last); | |
1629 | } | |
1630 | } | |
1631 | ||
74d753ac MW |
1632 | /* |
1633 | * Prints out raw parameter using given format. Caller needs | |
1634 | * to do byte swapping if needed. | |
1635 | */ | |
1636 | static void | |
1637 | print_raw_param(const char *fmt, abi_long param, int last) | |
1638 | { | |
1639 | char format[64]; | |
1640 | ||
1641 | (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); | |
4b25a506 | 1642 | qemu_log(format, param); |
74d753ac MW |
1643 | } |
1644 | ||
1645 | static void | |
1646 | print_pointer(abi_long p, int last) | |
1647 | { | |
1648 | if (p == 0) | |
4b25a506 | 1649 | qemu_log("NULL%s", get_comma(last)); |
74d753ac | 1650 | else |
4b25a506 | 1651 | qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); |
74d753ac MW |
1652 | } |
1653 | ||
1654 | /* | |
1655 | * Reads 32-bit (int) number from guest address space from | |
1656 | * address 'addr' and prints it. | |
1657 | */ | |
1658 | static void | |
1659 | print_number(abi_long addr, int last) | |
1660 | { | |
1661 | if (addr == 0) { | |
4b25a506 | 1662 | qemu_log("NULL%s", get_comma(last)); |
74d753ac MW |
1663 | } else { |
1664 | int num; | |
1665 | ||
1666 | get_user_s32(num, addr); | |
4b25a506 | 1667 | qemu_log("[%d]%s", num, get_comma(last)); |
74d753ac MW |
1668 | } |
1669 | } | |
1670 | ||
1671 | static void | |
1672 | print_timeval(abi_ulong tv_addr, int last) | |
1673 | { | |
1674 | if( tv_addr ) { | |
1675 | struct target_timeval *tv; | |
1676 | ||
1677 | tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); | |
8f93089d PMD |
1678 | if (!tv) { |
1679 | print_pointer(tv_addr, last); | |
74d753ac | 1680 | return; |
8f93089d | 1681 | } |
1a674adf FB |
1682 | qemu_log("{tv_sec = " TARGET_ABI_FMT_ld |
1683 | ",tv_usec = " TARGET_ABI_FMT_ld "}%s", | |
1684 | tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); | |
74d753ac MW |
1685 | unlock_user(tv, tv_addr, 0); |
1686 | } else | |
4b25a506 | 1687 | qemu_log("NULL%s", get_comma(last)); |
74d753ac MW |
1688 | } |
1689 | ||
1a674adf FB |
1690 | static void |
1691 | print_timespec(abi_ulong ts_addr, int last) | |
1692 | { | |
1693 | if (ts_addr) { | |
1694 | struct target_timespec *ts; | |
1695 | ||
1696 | ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1); | |
1697 | if (!ts) { | |
1698 | print_pointer(ts_addr, last); | |
1699 | return; | |
1700 | } | |
1701 | qemu_log("{tv_sec = " TARGET_ABI_FMT_ld | |
1702 | ",tv_nsec = " TARGET_ABI_FMT_ld "}%s", | |
1703 | tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last)); | |
1704 | unlock_user(ts, ts_addr, 0); | |
1705 | } else { | |
1706 | qemu_log("NULL%s", get_comma(last)); | |
1707 | } | |
1708 | } | |
1709 | ||
aad43d15 HD |
1710 | static void |
1711 | print_timespec64(abi_ulong ts_addr, int last) | |
1712 | { | |
1713 | if (ts_addr) { | |
1714 | struct target__kernel_timespec *ts; | |
1715 | ||
1716 | ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1); | |
1717 | if (!ts) { | |
1718 | print_pointer(ts_addr, last); | |
1719 | return; | |
1720 | } | |
1721 | qemu_log("{tv_sec = %lld" | |
1722 | ",tv_nsec = %lld}%s", | |
1723 | (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec), | |
1724 | get_comma(last)); | |
1725 | unlock_user(ts, ts_addr, 0); | |
1726 | } else { | |
1727 | qemu_log("NULL%s", get_comma(last)); | |
1728 | } | |
1729 | } | |
1730 | ||
6d33e036 PMD |
1731 | static void |
1732 | print_timezone(abi_ulong tz_addr, int last) | |
1733 | { | |
1734 | if (tz_addr) { | |
1735 | struct target_timezone *tz; | |
1736 | ||
1737 | tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1); | |
1738 | if (!tz) { | |
1739 | print_pointer(tz_addr, last); | |
1740 | return; | |
1741 | } | |
4b25a506 | 1742 | qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest), |
6d33e036 PMD |
1743 | tswap32(tz->tz_dsttime), get_comma(last)); |
1744 | unlock_user(tz, tz_addr, 0); | |
1745 | } else { | |
4b25a506 | 1746 | qemu_log("NULL%s", get_comma(last)); |
6d33e036 PMD |
1747 | } |
1748 | } | |
1749 | ||
1a674adf FB |
1750 | static void |
1751 | print_itimerval(abi_ulong it_addr, int last) | |
1752 | { | |
1753 | if (it_addr) { | |
1754 | qemu_log("{it_interval="); | |
1755 | print_timeval(it_addr + | |
1756 | offsetof(struct target_itimerval, it_interval), 0); | |
1757 | qemu_log("it_value="); | |
1758 | print_timeval(it_addr + | |
1759 | offsetof(struct target_itimerval, it_value), 0); | |
1760 | qemu_log("}%s", get_comma(last)); | |
1761 | } else { | |
1762 | qemu_log("NULL%s", get_comma(last)); | |
1763 | } | |
1764 | } | |
1765 | ||
888468db FB |
1766 | void |
1767 | print_termios(void *arg) | |
1768 | { | |
1769 | const struct target_termios *target = arg; | |
1770 | ||
1771 | target_tcflag_t iflags = tswap32(target->c_iflag); | |
1772 | target_tcflag_t oflags = tswap32(target->c_oflag); | |
1773 | target_tcflag_t cflags = tswap32(target->c_cflag); | |
1774 | target_tcflag_t lflags = tswap32(target->c_lflag); | |
1775 | ||
1776 | qemu_log("{"); | |
1777 | ||
1778 | qemu_log("c_iflag = "); | |
1779 | print_flags(termios_iflags, iflags, 0); | |
1780 | ||
1781 | qemu_log("c_oflag = "); | |
1782 | target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY | | |
1783 | TARGET_TABDLY | TARGET_BSDLY | | |
1784 | TARGET_VTDLY | TARGET_FFDLY); | |
1785 | print_flags(termios_oflags, oflags_clean, 0); | |
1786 | if (oflags & TARGET_NLDLY) { | |
1787 | print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0); | |
1788 | } | |
1789 | if (oflags & TARGET_CRDLY) { | |
1790 | print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0); | |
1791 | } | |
1792 | if (oflags & TARGET_TABDLY) { | |
1793 | print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0); | |
1794 | } | |
1795 | if (oflags & TARGET_BSDLY) { | |
1796 | print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0); | |
1797 | } | |
1798 | if (oflags & TARGET_VTDLY) { | |
1799 | print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0); | |
1800 | } | |
1801 | if (oflags & TARGET_FFDLY) { | |
1802 | print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0); | |
1803 | } | |
1804 | ||
1805 | qemu_log("c_cflag = "); | |
1806 | if (cflags & TARGET_CBAUD) { | |
1807 | print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0); | |
1808 | } | |
1809 | if (cflags & TARGET_CSIZE) { | |
1810 | print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0); | |
1811 | } | |
1812 | target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE); | |
1813 | print_flags(termios_cflags, cflags_clean, 0); | |
1814 | ||
1815 | qemu_log("c_lflag = "); | |
1816 | print_flags(termios_lflags, lflags, 0); | |
1817 | ||
1818 | qemu_log("c_cc = "); | |
1819 | qemu_log("\"%s\",", target->c_cc); | |
1820 | ||
1821 | qemu_log("c_line = "); | |
1822 | print_raw_param("\'%c\'", target->c_line, 1); | |
1823 | ||
1824 | qemu_log("}"); | |
1825 | } | |
1826 | ||
74d753ac MW |
1827 | #undef UNUSED |
1828 | ||
1829 | #ifdef TARGET_NR_accept | |
1830 | static void | |
a0939b89 | 1831 | print_accept(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1832 | abi_long arg0, abi_long arg1, abi_long arg2, |
1833 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
1834 | { |
1835 | print_syscall_prologue(name); | |
d2ee72a5 | 1836 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
1837 | print_pointer(arg1, 0); |
1838 | print_number(arg2, 1); | |
1839 | print_syscall_epilogue(name); | |
1840 | } | |
1841 | #endif | |
1842 | ||
1843 | #ifdef TARGET_NR_access | |
1844 | static void | |
a0939b89 | 1845 | print_access(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1846 | abi_long arg0, abi_long arg1, abi_long arg2, |
1847 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
1848 | { |
1849 | print_syscall_prologue(name); | |
1850 | print_string(arg0, 0); | |
1851 | print_flags(access_flags, arg1, 1); | |
1852 | print_syscall_epilogue(name); | |
1853 | } | |
1854 | #endif | |
1855 | ||
c42569f6 FB |
1856 | #ifdef TARGET_NR_acct |
1857 | static void | |
a0939b89 | 1858 | print_acct(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1859 | abi_long arg0, abi_long arg1, abi_long arg2, |
1860 | abi_long arg3, abi_long arg4, abi_long arg5) | |
c42569f6 FB |
1861 | { |
1862 | print_syscall_prologue(name); | |
1863 | print_string(arg0, 1); | |
1864 | print_syscall_epilogue(name); | |
1865 | } | |
1866 | #endif | |
1867 | ||
74d753ac MW |
1868 | #ifdef TARGET_NR_brk |
1869 | static void | |
a0939b89 | 1870 | print_brk(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1871 | abi_long arg0, abi_long arg1, abi_long arg2, |
1872 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
1873 | { |
1874 | print_syscall_prologue(name); | |
1875 | print_pointer(arg0, 1); | |
1876 | print_syscall_epilogue(name); | |
1877 | } | |
1878 | #endif | |
1879 | ||
1880 | #ifdef TARGET_NR_chdir | |
1881 | static void | |
a0939b89 | 1882 | print_chdir(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1883 | abi_long arg0, abi_long arg1, abi_long arg2, |
1884 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
1885 | { |
1886 | print_syscall_prologue(name); | |
1887 | print_string(arg0, 1); | |
1888 | print_syscall_epilogue(name); | |
1889 | } | |
1890 | #endif | |
1891 | ||
1b7695fe HD |
1892 | #ifdef TARGET_NR_chroot |
1893 | static void | |
a0939b89 | 1894 | print_chroot(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1895 | abi_long arg0, abi_long arg1, abi_long arg2, |
1896 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1b7695fe HD |
1897 | { |
1898 | print_syscall_prologue(name); | |
1899 | print_string(arg0, 1); | |
1900 | print_syscall_epilogue(name); | |
1901 | } | |
1902 | #endif | |
1903 | ||
74d753ac MW |
1904 | #ifdef TARGET_NR_chmod |
1905 | static void | |
a0939b89 | 1906 | print_chmod(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1907 | abi_long arg0, abi_long arg1, abi_long arg2, |
1908 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
1909 | { |
1910 | print_syscall_prologue(name); | |
1911 | print_string(arg0, 0); | |
1912 | print_file_mode(arg1, 1); | |
1913 | print_syscall_epilogue(name); | |
1914 | } | |
1915 | #endif | |
1916 | ||
5844f4bc FB |
1917 | #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) |
1918 | static void | |
a0939b89 | 1919 | print_chown(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1920 | abi_long arg0, abi_long arg1, abi_long arg2, |
1921 | abi_long arg3, abi_long arg4, abi_long arg5) | |
5844f4bc FB |
1922 | { |
1923 | print_syscall_prologue(name); | |
1924 | print_string(arg0, 0); | |
1925 | print_raw_param("%d", arg1, 0); | |
1926 | print_raw_param("%d", arg2, 1); | |
1927 | print_syscall_epilogue(name); | |
1928 | } | |
1929 | #define print_lchown print_chown | |
1930 | #endif | |
1931 | ||
38860a03 AM |
1932 | #ifdef TARGET_NR_clock_adjtime |
1933 | static void | |
a0939b89 | 1934 | print_clock_adjtime(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1935 | abi_long arg0, abi_long arg1, abi_long arg2, |
1936 | abi_long arg3, abi_long arg4, abi_long arg5) | |
38860a03 AM |
1937 | { |
1938 | print_syscall_prologue(name); | |
1a674adf | 1939 | print_enums(clockids, arg0, 0); |
38860a03 AM |
1940 | print_pointer(arg1, 1); |
1941 | print_syscall_epilogue(name); | |
1942 | } | |
1943 | #endif | |
1944 | ||
608e5592 | 1945 | #ifdef TARGET_NR_clone |
84bd8284 LV |
1946 | static void do_print_clone(unsigned int flags, abi_ulong newsp, |
1947 | abi_ulong parent_tidptr, target_ulong newtls, | |
1948 | abi_ulong child_tidptr) | |
1949 | { | |
1950 | print_flags(clone_flags, flags, 0); | |
1951 | print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0); | |
1952 | print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0); | |
1953 | print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0); | |
1954 | print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1); | |
1955 | } | |
1956 | ||
608e5592 | 1957 | static void |
a0939b89 | 1958 | print_clone(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1959 | abi_long arg1, abi_long arg2, abi_long arg3, |
1960 | abi_long arg4, abi_long arg5, abi_long arg6) | |
608e5592 LV |
1961 | { |
1962 | print_syscall_prologue(name); | |
84bd8284 LV |
1963 | #if defined(TARGET_MICROBLAZE) |
1964 | do_print_clone(arg1, arg2, arg4, arg6, arg5); | |
1965 | #elif defined(TARGET_CLONE_BACKWARDS) | |
1966 | do_print_clone(arg1, arg2, arg3, arg4, arg5); | |
1967 | #elif defined(TARGET_CLONE_BACKWARDS2) | |
1968 | do_print_clone(arg2, arg1, arg3, arg5, arg4); | |
608e5592 | 1969 | #else |
84bd8284 | 1970 | do_print_clone(arg1, arg2, arg3, arg5, arg4); |
608e5592 LV |
1971 | #endif |
1972 | print_syscall_epilogue(name); | |
1973 | } | |
1974 | #endif | |
1975 | ||
74d753ac MW |
1976 | #ifdef TARGET_NR_creat |
1977 | static void | |
a0939b89 | 1978 | print_creat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1979 | abi_long arg0, abi_long arg1, abi_long arg2, |
1980 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
1981 | { |
1982 | print_syscall_prologue(name); | |
1983 | print_string(arg0, 0); | |
1984 | print_file_mode(arg1, 1); | |
1985 | print_syscall_epilogue(name); | |
1986 | } | |
1987 | #endif | |
1988 | ||
1989 | #ifdef TARGET_NR_execv | |
1990 | static void | |
a0939b89 | 1991 | print_execv(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
1992 | abi_long arg0, abi_long arg1, abi_long arg2, |
1993 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
1994 | { |
1995 | print_syscall_prologue(name); | |
1996 | print_string(arg0, 0); | |
d2ee72a5 | 1997 | print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1); |
74d753ac MW |
1998 | print_syscall_epilogue(name); |
1999 | } | |
2000 | #endif | |
2001 | ||
24acb7b4 DD |
2002 | static void |
2003 | print_execve_argv(abi_long argv, int last) | |
2004 | { | |
2005 | abi_ulong arg_ptr_addr; | |
2006 | char *s; | |
2007 | ||
2008 | qemu_log("{"); | |
2009 | for (arg_ptr_addr = argv; ; arg_ptr_addr += sizeof(abi_ulong)) { | |
2010 | abi_ulong *arg_ptr, arg_addr; | |
2011 | ||
2012 | arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); | |
2013 | if (!arg_ptr) { | |
2014 | return; | |
2015 | } | |
2016 | arg_addr = tswapal(*arg_ptr); | |
2017 | unlock_user(arg_ptr, arg_ptr_addr, 0); | |
2018 | if (!arg_addr) { | |
2019 | break; | |
2020 | } | |
2021 | s = lock_user_string(arg_addr); | |
2022 | if (s) { | |
2023 | qemu_log("\"%s\",", s); | |
2024 | unlock_user(s, arg_addr, 0); | |
2025 | } | |
2026 | } | |
2027 | qemu_log("NULL}%s", get_comma(last)); | |
2028 | } | |
2029 | ||
2030 | static void | |
2031 | print_execve(CPUArchState *cpu_env, const struct syscallname *name, | |
2032 | abi_long arg1, abi_long arg2, abi_long arg3, | |
2033 | abi_long arg4, abi_long arg5, abi_long arg6) | |
2034 | { | |
2035 | print_syscall_prologue(name); | |
2036 | print_string(arg1, 0); | |
2037 | print_execve_argv(arg2, 1); | |
2038 | print_syscall_epilogue(name); | |
2039 | } | |
2040 | ||
5667a1ae DD |
2041 | static void |
2042 | print_execveat(CPUArchState *cpu_env, const struct syscallname *name, | |
2043 | abi_long arg1, abi_long arg2, abi_long arg3, | |
2044 | abi_long arg4, abi_long arg5, abi_long arg6) | |
2045 | { | |
2046 | print_syscall_prologue(name); | |
2047 | print_at_dirfd(arg1, 0); | |
2048 | print_string(arg2, 0); | |
2049 | print_execve_argv(arg3, 0); | |
2050 | print_flags(execveat_flags, arg5, 1); | |
2051 | print_syscall_epilogue(name); | |
2052 | } | |
2053 | ||
35a2c85f | 2054 | #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2) |
74d753ac | 2055 | static void |
a0939b89 | 2056 | print_faccessat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2057 | abi_long arg0, abi_long arg1, abi_long arg2, |
2058 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
2059 | { |
2060 | print_syscall_prologue(name); | |
2061 | print_at_dirfd(arg0, 0); | |
2062 | print_string(arg1, 0); | |
2063 | print_flags(access_flags, arg2, 0); | |
2064 | print_flags(at_file_flags, arg3, 1); | |
2065 | print_syscall_epilogue(name); | |
2066 | } | |
2067 | #endif | |
2068 | ||
f4d92c5e FB |
2069 | #ifdef TARGET_NR_fallocate |
2070 | static void | |
a0939b89 | 2071 | print_fallocate(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2072 | abi_long arg0, abi_long arg1, abi_long arg2, |
2073 | abi_long arg3, abi_long arg4, abi_long arg5) | |
f4d92c5e FB |
2074 | { |
2075 | print_syscall_prologue(name); | |
2076 | print_raw_param("%d", arg0, 0); | |
2077 | print_flags(falloc_flags, arg1, 0); | |
2078 | #if TARGET_ABI_BITS == 32 | |
2079 | print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); | |
2080 | print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); | |
2081 | #else | |
2082 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
2083 | print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); | |
2084 | #endif | |
2085 | print_syscall_epilogue(name); | |
2086 | } | |
2087 | #endif | |
2088 | ||
74d753ac MW |
2089 | #ifdef TARGET_NR_fchmodat |
2090 | static void | |
a0939b89 | 2091 | print_fchmodat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2092 | abi_long arg0, abi_long arg1, abi_long arg2, |
2093 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
2094 | { |
2095 | print_syscall_prologue(name); | |
2096 | print_at_dirfd(arg0, 0); | |
2097 | print_string(arg1, 0); | |
2098 | print_file_mode(arg2, 0); | |
2099 | print_flags(at_file_flags, arg3, 1); | |
2100 | print_syscall_epilogue(name); | |
2101 | } | |
2102 | #endif | |
2103 | ||
2104 | #ifdef TARGET_NR_fchownat | |
2105 | static void | |
a0939b89 | 2106 | print_fchownat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2107 | abi_long arg0, abi_long arg1, abi_long arg2, |
2108 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
2109 | { |
2110 | print_syscall_prologue(name); | |
2111 | print_at_dirfd(arg0, 0); | |
2112 | print_string(arg1, 0); | |
d2ee72a5 LV |
2113 | print_raw_param("%d", arg2, 0); |
2114 | print_raw_param("%d", arg3, 0); | |
74d753ac MW |
2115 | print_flags(at_file_flags, arg4, 1); |
2116 | print_syscall_epilogue(name); | |
2117 | } | |
2118 | #endif | |
2119 | ||
2120 | #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) | |
2121 | static void | |
a0939b89 | 2122 | print_fcntl(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2123 | abi_long arg0, abi_long arg1, abi_long arg2, |
2124 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
2125 | { |
2126 | print_syscall_prologue(name); | |
d2ee72a5 | 2127 | print_raw_param("%d", arg0, 0); |
d95ec14f LV |
2128 | switch(arg1) { |
2129 | case TARGET_F_DUPFD: | |
4b25a506 | 2130 | qemu_log("F_DUPFD,"); |
d95ec14f LV |
2131 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
2132 | break; | |
2133 | case TARGET_F_GETFD: | |
4b25a506 | 2134 | qemu_log("F_GETFD"); |
d95ec14f LV |
2135 | break; |
2136 | case TARGET_F_SETFD: | |
4b25a506 | 2137 | qemu_log("F_SETFD,"); |
d95ec14f LV |
2138 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
2139 | break; | |
2140 | case TARGET_F_GETFL: | |
4b25a506 | 2141 | qemu_log("F_GETFL"); |
d95ec14f LV |
2142 | break; |
2143 | case TARGET_F_SETFL: | |
4b25a506 | 2144 | qemu_log("F_SETFL,"); |
d95ec14f LV |
2145 | print_open_flags(arg2, 1); |
2146 | break; | |
2147 | case TARGET_F_GETLK: | |
4b25a506 | 2148 | qemu_log("F_GETLK,"); |
d95ec14f LV |
2149 | print_pointer(arg2, 1); |
2150 | break; | |
2151 | case TARGET_F_SETLK: | |
4b25a506 | 2152 | qemu_log("F_SETLK,"); |
d95ec14f LV |
2153 | print_pointer(arg2, 1); |
2154 | break; | |
2155 | case TARGET_F_SETLKW: | |
4b25a506 | 2156 | qemu_log("F_SETLKW,"); |
d95ec14f LV |
2157 | print_pointer(arg2, 1); |
2158 | break; | |
2159 | case TARGET_F_GETOWN: | |
4b25a506 | 2160 | qemu_log("F_GETOWN"); |
d95ec14f LV |
2161 | break; |
2162 | case TARGET_F_SETOWN: | |
4b25a506 | 2163 | qemu_log("F_SETOWN,"); |
d95ec14f LV |
2164 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
2165 | break; | |
2166 | case TARGET_F_GETSIG: | |
4b25a506 | 2167 | qemu_log("F_GETSIG"); |
d95ec14f LV |
2168 | break; |
2169 | case TARGET_F_SETSIG: | |
4b25a506 | 2170 | qemu_log("F_SETSIG,"); |
d95ec14f LV |
2171 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
2172 | break; | |
2173 | #if TARGET_ABI_BITS == 32 | |
2174 | case TARGET_F_GETLK64: | |
4b25a506 | 2175 | qemu_log("F_GETLK64,"); |
d95ec14f LV |
2176 | print_pointer(arg2, 1); |
2177 | break; | |
2178 | case TARGET_F_SETLK64: | |
4b25a506 | 2179 | qemu_log("F_SETLK64,"); |
d95ec14f LV |
2180 | print_pointer(arg2, 1); |
2181 | break; | |
2182 | case TARGET_F_SETLKW64: | |
4b25a506 | 2183 | qemu_log("F_SETLKW64,"); |
d95ec14f LV |
2184 | print_pointer(arg2, 1); |
2185 | break; | |
2186 | #endif | |
38be863d MG |
2187 | case TARGET_F_OFD_GETLK: |
2188 | qemu_log("F_OFD_GETLK,"); | |
2189 | print_pointer(arg2, 1); | |
2190 | break; | |
2191 | case TARGET_F_OFD_SETLK: | |
2192 | qemu_log("F_OFD_SETLK,"); | |
2193 | print_pointer(arg2, 1); | |
2194 | break; | |
2195 | case TARGET_F_OFD_SETLKW: | |
2196 | qemu_log("F_OFD_SETLKW,"); | |
2197 | print_pointer(arg2, 1); | |
2198 | break; | |
d95ec14f | 2199 | case TARGET_F_SETLEASE: |
4b25a506 | 2200 | qemu_log("F_SETLEASE,"); |
2bb963ff | 2201 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
d95ec14f LV |
2202 | break; |
2203 | case TARGET_F_GETLEASE: | |
4b25a506 | 2204 | qemu_log("F_GETLEASE"); |
d95ec14f | 2205 | break; |
2bb963ff SCW |
2206 | #ifdef F_DUPFD_CLOEXEC |
2207 | case TARGET_F_DUPFD_CLOEXEC: | |
2208 | qemu_log("F_DUPFD_CLOEXEC,"); | |
2209 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
2210 | break; | |
2211 | #endif | |
2212 | case TARGET_F_NOTIFY: | |
2213 | qemu_log("F_NOTIFY,"); | |
2214 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
2215 | break; | |
2216 | #ifdef F_GETOWN_EX | |
2217 | case TARGET_F_GETOWN_EX: | |
2218 | qemu_log("F_GETOWN_EX,"); | |
2219 | print_pointer(arg2, 1); | |
2220 | break; | |
2221 | #endif | |
2222 | #ifdef F_SETOWN_EX | |
2223 | case TARGET_F_SETOWN_EX: | |
2224 | qemu_log("F_SETOWN_EX,"); | |
2225 | print_pointer(arg2, 1); | |
2226 | break; | |
2227 | #endif | |
2228 | #ifdef F_SETPIPE_SZ | |
7e3b92ec | 2229 | case TARGET_F_SETPIPE_SZ: |
4b25a506 | 2230 | qemu_log("F_SETPIPE_SZ,"); |
7e3b92ec PM |
2231 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
2232 | break; | |
2233 | case TARGET_F_GETPIPE_SZ: | |
4b25a506 | 2234 | qemu_log("F_GETPIPE_SZ"); |
7e3b92ec | 2235 | break; |
2bb963ff SCW |
2236 | #endif |
2237 | #ifdef F_ADD_SEALS | |
2238 | case TARGET_F_ADD_SEALS: | |
2239 | qemu_log("F_ADD_SEALS,"); | |
2240 | print_raw_param("0x"TARGET_ABI_FMT_lx, arg2, 1); | |
d95ec14f | 2241 | break; |
2bb963ff SCW |
2242 | case TARGET_F_GET_SEALS: |
2243 | qemu_log("F_GET_SEALS"); | |
d95ec14f | 2244 | break; |
2bb963ff | 2245 | #endif |
d95ec14f LV |
2246 | default: |
2247 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
2248 | print_pointer(arg2, 1); | |
2249 | break; | |
2250 | } | |
74d753ac MW |
2251 | print_syscall_epilogue(name); |
2252 | } | |
2253 | #define print_fcntl64 print_fcntl | |
2254 | #endif | |
2255 | ||
4fc3cdde FB |
2256 | #ifdef TARGET_NR_fgetxattr |
2257 | static void | |
a0939b89 | 2258 | print_fgetxattr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2259 | abi_long arg0, abi_long arg1, abi_long arg2, |
2260 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4fc3cdde FB |
2261 | { |
2262 | print_syscall_prologue(name); | |
2263 | print_raw_param("%d", arg0, 0); | |
2264 | print_string(arg1, 0); | |
2265 | print_pointer(arg2, 0); | |
2266 | print_raw_param(TARGET_FMT_lu, arg3, 1); | |
2267 | print_syscall_epilogue(name); | |
2268 | } | |
2269 | #endif | |
2270 | ||
2271 | #ifdef TARGET_NR_flistxattr | |
2272 | static void | |
a0939b89 | 2273 | print_flistxattr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2274 | abi_long arg0, abi_long arg1, abi_long arg2, |
2275 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4fc3cdde FB |
2276 | { |
2277 | print_syscall_prologue(name); | |
2278 | print_raw_param("%d", arg0, 0); | |
2279 | print_pointer(arg1, 0); | |
2280 | print_raw_param(TARGET_FMT_lu, arg2, 1); | |
2281 | print_syscall_epilogue(name); | |
2282 | } | |
2283 | #endif | |
2284 | ||
2285 | #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) | |
2286 | static void | |
a0939b89 | 2287 | print_getxattr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2288 | abi_long arg0, abi_long arg1, abi_long arg2, |
2289 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4fc3cdde FB |
2290 | { |
2291 | print_syscall_prologue(name); | |
2292 | print_string(arg0, 0); | |
2293 | print_string(arg1, 0); | |
2294 | print_pointer(arg2, 0); | |
2295 | print_raw_param(TARGET_FMT_lu, arg3, 1); | |
2296 | print_syscall_epilogue(name); | |
2297 | } | |
2298 | #define print_lgetxattr print_getxattr | |
2299 | #endif | |
2300 | ||
2301 | #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) | |
2302 | static void | |
a0939b89 | 2303 | print_listxattr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2304 | abi_long arg0, abi_long arg1, abi_long arg2, |
2305 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4fc3cdde FB |
2306 | { |
2307 | print_syscall_prologue(name); | |
2308 | print_string(arg0, 0); | |
2309 | print_pointer(arg1, 0); | |
2310 | print_raw_param(TARGET_FMT_lu, arg2, 1); | |
2311 | print_syscall_epilogue(name); | |
2312 | } | |
2313 | #define print_llistxattr print_listxattr | |
2314 | #endif | |
2315 | ||
2316 | #if defined(TARGET_NR_fremovexattr) | |
2317 | static void | |
a0939b89 | 2318 | print_fremovexattr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2319 | abi_long arg0, abi_long arg1, abi_long arg2, |
2320 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4fc3cdde FB |
2321 | { |
2322 | print_syscall_prologue(name); | |
2323 | print_raw_param("%d", arg0, 0); | |
2324 | print_string(arg1, 1); | |
2325 | print_syscall_epilogue(name); | |
2326 | } | |
2327 | #endif | |
2328 | ||
2329 | #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr) | |
2330 | static void | |
a0939b89 | 2331 | print_removexattr(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2332 | abi_long arg0, abi_long arg1, abi_long arg2, |
2333 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4fc3cdde FB |
2334 | { |
2335 | print_syscall_prologue(name); | |
2336 | print_string(arg0, 0); | |
2337 | print_string(arg1, 1); | |
2338 | print_syscall_epilogue(name); | |
2339 | } | |
2340 | #define print_lremovexattr print_removexattr | |
2341 | #endif | |
2342 | ||
74d753ac MW |
2343 | #ifdef TARGET_NR_futimesat |
2344 | static void | |
a0939b89 | 2345 | print_futimesat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2346 | abi_long arg0, abi_long arg1, abi_long arg2, |
2347 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
2348 | { |
2349 | print_syscall_prologue(name); | |
2350 | print_at_dirfd(arg0, 0); | |
2351 | print_string(arg1, 0); | |
2352 | print_timeval(arg2, 0); | |
2353 | print_timeval(arg2 + sizeof (struct target_timeval), 1); | |
2354 | print_syscall_epilogue(name); | |
2355 | } | |
2356 | #endif | |
2357 | ||
1a674adf FB |
2358 | #ifdef TARGET_NR_gettimeofday |
2359 | static void | |
a0939b89 | 2360 | print_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
2361 | abi_long arg0, abi_long arg1, abi_long arg2, |
2362 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2363 | { | |
2364 | print_syscall_prologue(name); | |
2365 | print_pointer(arg0, 0); | |
2366 | print_pointer(arg1, 1); | |
2367 | print_syscall_epilogue(name); | |
2368 | } | |
2369 | #endif | |
2370 | ||
0d2187c4 PMD |
2371 | #ifdef TARGET_NR_settimeofday |
2372 | static void | |
a0939b89 | 2373 | print_settimeofday(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2374 | abi_long arg0, abi_long arg1, abi_long arg2, |
2375 | abi_long arg3, abi_long arg4, abi_long arg5) | |
0d2187c4 PMD |
2376 | { |
2377 | print_syscall_prologue(name); | |
2378 | print_timeval(arg0, 0); | |
2379 | print_timezone(arg1, 1); | |
2380 | print_syscall_epilogue(name); | |
2381 | } | |
2382 | #endif | |
2383 | ||
1a674adf FB |
2384 | #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) |
2385 | static void | |
a0939b89 | 2386 | print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
2387 | abi_long arg0, abi_long arg1, abi_long arg2, |
2388 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2389 | { | |
2390 | print_syscall_prologue(name); | |
2391 | print_enums(clockids, arg0, 0); | |
2392 | print_pointer(arg1, 1); | |
2393 | print_syscall_epilogue(name); | |
2394 | } | |
2395 | #define print_clock_getres print_clock_gettime | |
2396 | #endif | |
2397 | ||
aad43d15 HD |
2398 | #if defined(TARGET_NR_clock_gettime64) |
2399 | static void | |
2400 | print_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name, | |
2401 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2402 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2403 | { | |
2404 | print_syscall_prologue(name); | |
2405 | print_enums(clockids, arg0, 0); | |
2406 | print_pointer(arg1, 1); | |
2407 | print_syscall_epilogue(name); | |
2408 | } | |
2409 | #endif | |
2410 | ||
1a674adf FB |
2411 | #ifdef TARGET_NR_clock_settime |
2412 | static void | |
a0939b89 | 2413 | print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
2414 | abi_long arg0, abi_long arg1, abi_long arg2, |
2415 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2416 | { | |
2417 | print_syscall_prologue(name); | |
2418 | print_enums(clockids, arg0, 0); | |
2419 | print_timespec(arg1, 1); | |
2420 | print_syscall_epilogue(name); | |
2421 | } | |
2422 | #endif | |
2423 | ||
2424 | #ifdef TARGET_NR_getitimer | |
2425 | static void | |
a0939b89 | 2426 | print_getitimer(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
2427 | abi_long arg0, abi_long arg1, abi_long arg2, |
2428 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2429 | { | |
2430 | print_syscall_prologue(name); | |
2431 | print_enums(itimer_types, arg0, 0); | |
2432 | print_pointer(arg1, 1); | |
2433 | print_syscall_epilogue(name); | |
2434 | } | |
2435 | #endif | |
2436 | ||
2437 | #ifdef TARGET_NR_setitimer | |
2438 | static void | |
a0939b89 | 2439 | print_setitimer(CPUArchState *cpu_env, const struct syscallname *name, |
1a674adf FB |
2440 | abi_long arg0, abi_long arg1, abi_long arg2, |
2441 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2442 | { | |
2443 | print_syscall_prologue(name); | |
2444 | print_enums(itimer_types, arg0, 0); | |
2445 | print_itimerval(arg1, 0); | |
2446 | print_pointer(arg2, 1); | |
2447 | print_syscall_epilogue(name); | |
2448 | } | |
2449 | #endif | |
2450 | ||
74d753ac MW |
2451 | #ifdef TARGET_NR_link |
2452 | static void | |
a0939b89 | 2453 | print_link(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2454 | abi_long arg0, abi_long arg1, abi_long arg2, |
2455 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
2456 | { |
2457 | print_syscall_prologue(name); | |
2458 | print_string(arg0, 0); | |
2459 | print_string(arg1, 1); | |
2460 | print_syscall_epilogue(name); | |
2461 | } | |
2462 | #endif | |
2463 | ||
2464 | #ifdef TARGET_NR_linkat | |
2465 | static void | |
a0939b89 | 2466 | print_linkat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2467 | abi_long arg0, abi_long arg1, abi_long arg2, |
2468 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
2469 | { |
2470 | print_syscall_prologue(name); | |
2471 | print_at_dirfd(arg0, 0); | |
2472 | print_string(arg1, 0); | |
2473 | print_at_dirfd(arg2, 0); | |
2474 | print_string(arg3, 0); | |
2475 | print_flags(at_file_flags, arg4, 1); | |
2476 | print_syscall_epilogue(name); | |
2477 | } | |
2478 | #endif | |
2479 | ||
9f771ad8 | 2480 | #if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek) |
608e5592 | 2481 | static void |
a0939b89 | 2482 | print__llseek(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2483 | abi_long arg0, abi_long arg1, abi_long arg2, |
2484 | abi_long arg3, abi_long arg4, abi_long arg5) | |
608e5592 LV |
2485 | { |
2486 | const char *whence = "UNKNOWN"; | |
2487 | print_syscall_prologue(name); | |
2488 | print_raw_param("%d", arg0, 0); | |
2489 | print_raw_param("%ld", arg1, 0); | |
2490 | print_raw_param("%ld", arg2, 0); | |
2491 | print_pointer(arg3, 0); | |
2492 | switch(arg4) { | |
2493 | case SEEK_SET: whence = "SEEK_SET"; break; | |
2494 | case SEEK_CUR: whence = "SEEK_CUR"; break; | |
2495 | case SEEK_END: whence = "SEEK_END"; break; | |
2496 | } | |
4b25a506 | 2497 | qemu_log("%s", whence); |
608e5592 LV |
2498 | print_syscall_epilogue(name); |
2499 | } | |
9f771ad8 | 2500 | #define print_llseek print__llseek |
608e5592 LV |
2501 | #endif |
2502 | ||
af861dea FB |
2503 | #ifdef TARGET_NR_lseek |
2504 | static void | |
a0939b89 | 2505 | print_lseek(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
2506 | abi_long arg0, abi_long arg1, abi_long arg2, |
2507 | abi_long arg3, abi_long arg4, abi_long arg5) | |
af861dea FB |
2508 | { |
2509 | print_syscall_prologue(name); | |
2510 | print_raw_param("%d", arg0, 0); | |
2511 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
2512 | switch (arg2) { | |
2513 | case SEEK_SET: | |
2514 | qemu_log("SEEK_SET"); break; | |
2515 | case SEEK_CUR: | |
2516 | qemu_log("SEEK_CUR"); break; | |
2517 | case SEEK_END: | |
2518 | qemu_log("SEEK_END"); break; | |
2519 | #ifdef SEEK_DATA | |
2520 | case SEEK_DATA: | |
2521 | qemu_log("SEEK_DATA"); break; | |
2522 | #endif | |
2523 | #ifdef SEEK_HOLE | |
2524 | case SEEK_HOLE: | |
2525 | qemu_log("SEEK_HOLE"); break; | |
2526 | #endif | |
2527 | default: | |
2528 | print_raw_param("%#x", arg2, 1); | |
2529 | } | |
2530 | print_syscall_epilogue(name); | |
2531 | } | |
2532 | #endif | |
2533 | ||
7c89f343 FB |
2534 | #ifdef TARGET_NR_truncate |
2535 | static void | |
a0939b89 | 2536 | print_truncate(CPUArchState *cpu_env, const struct syscallname *name, |
7c89f343 FB |
2537 | abi_long arg0, abi_long arg1, abi_long arg2, |
2538 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2539 | { | |
2540 | print_syscall_prologue(name); | |
2541 | print_string(arg0, 0); | |
2542 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 1); | |
2543 | print_syscall_epilogue(name); | |
2544 | } | |
2545 | #endif | |
2546 | ||
2547 | #ifdef TARGET_NR_truncate64 | |
2548 | static void | |
a0939b89 | 2549 | print_truncate64(CPUArchState *cpu_env, const struct syscallname *name, |
7c89f343 FB |
2550 | abi_long arg0, abi_long arg1, abi_long arg2, |
2551 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2552 | { | |
2553 | print_syscall_prologue(name); | |
2554 | print_string(arg0, 0); | |
2555 | if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { | |
2556 | arg1 = arg2; | |
2557 | arg2 = arg3; | |
2558 | } | |
2559 | print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); | |
2560 | print_syscall_epilogue(name); | |
2561 | } | |
2562 | #endif | |
2563 | ||
2564 | #ifdef TARGET_NR_ftruncate64 | |
2565 | static void | |
a0939b89 | 2566 | print_ftruncate64(CPUArchState *cpu_env, const struct syscallname *name, |
7c89f343 FB |
2567 | abi_long arg0, abi_long arg1, abi_long arg2, |
2568 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2569 | { | |
2570 | print_syscall_prologue(name); | |
2571 | print_raw_param("%d", arg0, 0); | |
2572 | if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { | |
2573 | arg1 = arg2; | |
2574 | arg2 = arg3; | |
2575 | } | |
2576 | print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); | |
2577 | print_syscall_epilogue(name); | |
2578 | } | |
2579 | #endif | |
2580 | ||
02e5d7d7 FB |
2581 | #ifdef TARGET_NR_mlockall |
2582 | static void | |
a0939b89 | 2583 | print_mlockall(CPUArchState *cpu_env, const struct syscallname *name, |
02e5d7d7 FB |
2584 | abi_long arg0, abi_long arg1, abi_long arg2, |
2585 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2586 | { | |
2587 | print_syscall_prologue(name); | |
2588 | print_flags(mlockall_flags, arg0, 1); | |
2589 | print_syscall_epilogue(name); | |
2590 | } | |
2591 | #endif | |
2592 | ||
8997d1bd LV |
2593 | #if defined(TARGET_NR_socket) |
2594 | static void | |
a0939b89 | 2595 | print_socket(CPUArchState *cpu_env, const struct syscallname *name, |
8997d1bd LV |
2596 | abi_long arg0, abi_long arg1, abi_long arg2, |
2597 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2598 | { | |
2599 | abi_ulong domain = arg0, type = arg1, protocol = arg2; | |
2600 | ||
2601 | print_syscall_prologue(name); | |
2602 | print_socket_domain(domain); | |
4b25a506 | 2603 | qemu_log(","); |
8997d1bd | 2604 | print_socket_type(type); |
4b25a506 | 2605 | qemu_log(","); |
8997d1bd LV |
2606 | if (domain == AF_PACKET || |
2607 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
2608 | protocol = tswap16(protocol); | |
2609 | } | |
2610 | print_socket_protocol(domain, type, protocol); | |
2611 | print_syscall_epilogue(name); | |
2612 | } | |
2613 | ||
2614 | #endif | |
2615 | ||
bb10540e | 2616 | #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind) |
fb3aabf3 | 2617 | |
d84fe1ed PMD |
2618 | static void print_sockfd(abi_long sockfd, int last) |
2619 | { | |
2620 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, last); | |
2621 | } | |
2622 | ||
2623 | #endif | |
2624 | ||
2625 | #if defined(TARGET_NR_socketcall) | |
2626 | ||
fb3aabf3 LV |
2627 | #define get_user_ualx(x, gaddr, idx) \ |
2628 | get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long)) | |
2629 | ||
2630 | static void do_print_socket(const char *name, abi_long arg1) | |
2631 | { | |
2632 | abi_ulong domain, type, protocol; | |
2633 | ||
2634 | get_user_ualx(domain, arg1, 0); | |
2635 | get_user_ualx(type, arg1, 1); | |
2636 | get_user_ualx(protocol, arg1, 2); | |
4b25a506 | 2637 | qemu_log("%s(", name); |
fb3aabf3 | 2638 | print_socket_domain(domain); |
4b25a506 | 2639 | qemu_log(","); |
fb3aabf3 | 2640 | print_socket_type(type); |
4b25a506 | 2641 | qemu_log(","); |
fb3aabf3 LV |
2642 | if (domain == AF_PACKET || |
2643 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
2644 | protocol = tswap16(protocol); | |
2645 | } | |
2646 | print_socket_protocol(domain, type, protocol); | |
4b25a506 | 2647 | qemu_log(")"); |
fb3aabf3 LV |
2648 | } |
2649 | ||
2650 | static void do_print_sockaddr(const char *name, abi_long arg1) | |
2651 | { | |
2652 | abi_ulong sockfd, addr, addrlen; | |
2653 | ||
2654 | get_user_ualx(sockfd, arg1, 0); | |
2655 | get_user_ualx(addr, arg1, 1); | |
2656 | get_user_ualx(addrlen, arg1, 2); | |
2657 | ||
4b25a506 | 2658 | qemu_log("%s(", name); |
d84fe1ed | 2659 | print_sockfd(sockfd, 0); |
42b15d70 | 2660 | print_sockaddr(addr, addrlen, 0); |
4b25a506 | 2661 | qemu_log(")"); |
fb3aabf3 LV |
2662 | } |
2663 | ||
2664 | static void do_print_listen(const char *name, abi_long arg1) | |
2665 | { | |
2666 | abi_ulong sockfd, backlog; | |
2667 | ||
2668 | get_user_ualx(sockfd, arg1, 0); | |
2669 | get_user_ualx(backlog, arg1, 1); | |
2670 | ||
4b25a506 | 2671 | qemu_log("%s(", name); |
d84fe1ed | 2672 | print_sockfd(sockfd, 0); |
fb3aabf3 | 2673 | print_raw_param(TARGET_ABI_FMT_ld, backlog, 1); |
4b25a506 | 2674 | qemu_log(")"); |
fb3aabf3 LV |
2675 | } |
2676 | ||
2677 | static void do_print_socketpair(const char *name, abi_long arg1) | |
2678 | { | |
2679 | abi_ulong domain, type, protocol, tab; | |
2680 | ||
2681 | get_user_ualx(domain, arg1, 0); | |
2682 | get_user_ualx(type, arg1, 1); | |
2683 | get_user_ualx(protocol, arg1, 2); | |
2684 | get_user_ualx(tab, arg1, 3); | |
2685 | ||
4b25a506 | 2686 | qemu_log("%s(", name); |
fb3aabf3 | 2687 | print_socket_domain(domain); |
4b25a506 | 2688 | qemu_log(","); |
fb3aabf3 | 2689 | print_socket_type(type); |
4b25a506 | 2690 | qemu_log(","); |
fb3aabf3 | 2691 | print_socket_protocol(domain, type, protocol); |
4b25a506 | 2692 | qemu_log(","); |
fb3aabf3 | 2693 | print_raw_param(TARGET_ABI_FMT_lx, tab, 1); |
4b25a506 | 2694 | qemu_log(")"); |
fb3aabf3 LV |
2695 | } |
2696 | ||
2697 | static void do_print_sendrecv(const char *name, abi_long arg1) | |
2698 | { | |
2699 | abi_ulong sockfd, msg, len, flags; | |
2700 | ||
2701 | get_user_ualx(sockfd, arg1, 0); | |
2702 | get_user_ualx(msg, arg1, 1); | |
2703 | get_user_ualx(len, arg1, 2); | |
2704 | get_user_ualx(flags, arg1, 3); | |
2705 | ||
4b25a506 | 2706 | qemu_log("%s(", name); |
d84fe1ed | 2707 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2708 | print_buf(msg, len, 0); |
2709 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); | |
2710 | print_flags(msg_flags, flags, 1); | |
4b25a506 | 2711 | qemu_log(")"); |
fb3aabf3 LV |
2712 | } |
2713 | ||
2714 | static void do_print_msgaddr(const char *name, abi_long arg1) | |
2715 | { | |
2716 | abi_ulong sockfd, msg, len, flags, addr, addrlen; | |
2717 | ||
2718 | get_user_ualx(sockfd, arg1, 0); | |
2719 | get_user_ualx(msg, arg1, 1); | |
2720 | get_user_ualx(len, arg1, 2); | |
2721 | get_user_ualx(flags, arg1, 3); | |
2722 | get_user_ualx(addr, arg1, 4); | |
2723 | get_user_ualx(addrlen, arg1, 5); | |
2724 | ||
4b25a506 | 2725 | qemu_log("%s(", name); |
d84fe1ed | 2726 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2727 | print_buf(msg, len, 0); |
2728 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); | |
2729 | print_flags(msg_flags, flags, 0); | |
42b15d70 | 2730 | print_sockaddr(addr, addrlen, 0); |
4b25a506 | 2731 | qemu_log(")"); |
fb3aabf3 LV |
2732 | } |
2733 | ||
2734 | static void do_print_shutdown(const char *name, abi_long arg1) | |
2735 | { | |
2736 | abi_ulong sockfd, how; | |
2737 | ||
2738 | get_user_ualx(sockfd, arg1, 0); | |
2739 | get_user_ualx(how, arg1, 1); | |
2740 | ||
4b25a506 | 2741 | qemu_log("shutdown("); |
d84fe1ed | 2742 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2743 | switch (how) { |
2744 | case SHUT_RD: | |
4b25a506 | 2745 | qemu_log("SHUT_RD"); |
fb3aabf3 LV |
2746 | break; |
2747 | case SHUT_WR: | |
4b25a506 | 2748 | qemu_log("SHUT_WR"); |
fb3aabf3 LV |
2749 | break; |
2750 | case SHUT_RDWR: | |
4b25a506 | 2751 | qemu_log("SHUT_RDWR"); |
fb3aabf3 LV |
2752 | break; |
2753 | default: | |
2754 | print_raw_param(TARGET_ABI_FMT_ld, how, 1); | |
2755 | break; | |
2756 | } | |
4b25a506 | 2757 | qemu_log(")"); |
fb3aabf3 LV |
2758 | } |
2759 | ||
2760 | static void do_print_msg(const char *name, abi_long arg1) | |
2761 | { | |
2762 | abi_ulong sockfd, msg, flags; | |
2763 | ||
2764 | get_user_ualx(sockfd, arg1, 0); | |
2765 | get_user_ualx(msg, arg1, 1); | |
2766 | get_user_ualx(flags, arg1, 2); | |
2767 | ||
4b25a506 | 2768 | qemu_log("%s(", name); |
d84fe1ed | 2769 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2770 | print_pointer(msg, 0); |
2771 | print_flags(msg_flags, flags, 1); | |
4b25a506 | 2772 | qemu_log(")"); |
fb3aabf3 LV |
2773 | } |
2774 | ||
2775 | static void do_print_sockopt(const char *name, abi_long arg1) | |
2776 | { | |
2777 | abi_ulong sockfd, level, optname, optval, optlen; | |
2778 | ||
2779 | get_user_ualx(sockfd, arg1, 0); | |
2780 | get_user_ualx(level, arg1, 1); | |
2781 | get_user_ualx(optname, arg1, 2); | |
2782 | get_user_ualx(optval, arg1, 3); | |
2783 | get_user_ualx(optlen, arg1, 4); | |
2784 | ||
4b25a506 | 2785 | qemu_log("%s(", name); |
d84fe1ed | 2786 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2787 | switch (level) { |
2788 | case SOL_TCP: | |
4b25a506 | 2789 | qemu_log("SOL_TCP,"); |
fb3aabf3 LV |
2790 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
2791 | print_pointer(optval, 0); | |
fe51b0a5 SCW |
2792 | break; |
2793 | case SOL_UDP: | |
2794 | qemu_log("SOL_UDP,"); | |
2795 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
2796 | print_pointer(optval, 0); | |
fb3aabf3 LV |
2797 | break; |
2798 | case SOL_IP: | |
4b25a506 | 2799 | qemu_log("SOL_IP,"); |
fb3aabf3 LV |
2800 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
2801 | print_pointer(optval, 0); | |
2802 | break; | |
2803 | case SOL_RAW: | |
4b25a506 | 2804 | qemu_log("SOL_RAW,"); |
fb3aabf3 LV |
2805 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
2806 | print_pointer(optval, 0); | |
2807 | break; | |
2808 | case TARGET_SOL_SOCKET: | |
4b25a506 | 2809 | qemu_log("SOL_SOCKET,"); |
fb3aabf3 LV |
2810 | switch (optname) { |
2811 | case TARGET_SO_DEBUG: | |
4b25a506 | 2812 | qemu_log("SO_DEBUG,"); |
fb3aabf3 LV |
2813 | print_optint: |
2814 | print_number(optval, 0); | |
2815 | break; | |
2816 | case TARGET_SO_REUSEADDR: | |
4b25a506 | 2817 | qemu_log("SO_REUSEADDR,"); |
fb3aabf3 | 2818 | goto print_optint; |
113a9dd7 | 2819 | case TARGET_SO_REUSEPORT: |
4b25a506 | 2820 | qemu_log("SO_REUSEPORT,"); |
113a9dd7 | 2821 | goto print_optint; |
fb3aabf3 | 2822 | case TARGET_SO_TYPE: |
4b25a506 | 2823 | qemu_log("SO_TYPE,"); |
fb3aabf3 LV |
2824 | goto print_optint; |
2825 | case TARGET_SO_ERROR: | |
4b25a506 | 2826 | qemu_log("SO_ERROR,"); |
fb3aabf3 LV |
2827 | goto print_optint; |
2828 | case TARGET_SO_DONTROUTE: | |
4b25a506 | 2829 | qemu_log("SO_DONTROUTE,"); |
fb3aabf3 LV |
2830 | goto print_optint; |
2831 | case TARGET_SO_BROADCAST: | |
4b25a506 | 2832 | qemu_log("SO_BROADCAST,"); |
fb3aabf3 LV |
2833 | goto print_optint; |
2834 | case TARGET_SO_SNDBUF: | |
4b25a506 | 2835 | qemu_log("SO_SNDBUF,"); |
fb3aabf3 LV |
2836 | goto print_optint; |
2837 | case TARGET_SO_RCVBUF: | |
4b25a506 | 2838 | qemu_log("SO_RCVBUF,"); |
fb3aabf3 LV |
2839 | goto print_optint; |
2840 | case TARGET_SO_KEEPALIVE: | |
4b25a506 | 2841 | qemu_log("SO_KEEPALIVE,"); |
fb3aabf3 LV |
2842 | goto print_optint; |
2843 | case TARGET_SO_OOBINLINE: | |
4b25a506 | 2844 | qemu_log("SO_OOBINLINE,"); |
fb3aabf3 LV |
2845 | goto print_optint; |
2846 | case TARGET_SO_NO_CHECK: | |
4b25a506 | 2847 | qemu_log("SO_NO_CHECK,"); |
fb3aabf3 LV |
2848 | goto print_optint; |
2849 | case TARGET_SO_PRIORITY: | |
4b25a506 | 2850 | qemu_log("SO_PRIORITY,"); |
fb3aabf3 LV |
2851 | goto print_optint; |
2852 | case TARGET_SO_BSDCOMPAT: | |
4b25a506 | 2853 | qemu_log("SO_BSDCOMPAT,"); |
fb3aabf3 LV |
2854 | goto print_optint; |
2855 | case TARGET_SO_PASSCRED: | |
4b25a506 | 2856 | qemu_log("SO_PASSCRED,"); |
fb3aabf3 LV |
2857 | goto print_optint; |
2858 | case TARGET_SO_TIMESTAMP: | |
4b25a506 | 2859 | qemu_log("SO_TIMESTAMP,"); |
fb3aabf3 LV |
2860 | goto print_optint; |
2861 | case TARGET_SO_RCVLOWAT: | |
4b25a506 | 2862 | qemu_log("SO_RCVLOWAT,"); |
fb3aabf3 LV |
2863 | goto print_optint; |
2864 | case TARGET_SO_RCVTIMEO: | |
4b25a506 | 2865 | qemu_log("SO_RCVTIMEO,"); |
fb3aabf3 LV |
2866 | print_timeval(optval, 0); |
2867 | break; | |
2868 | case TARGET_SO_SNDTIMEO: | |
4b25a506 | 2869 | qemu_log("SO_SNDTIMEO,"); |
fb3aabf3 LV |
2870 | print_timeval(optval, 0); |
2871 | break; | |
2872 | case TARGET_SO_ATTACH_FILTER: { | |
2873 | struct target_sock_fprog *fprog; | |
2874 | ||
4b25a506 | 2875 | qemu_log("SO_ATTACH_FILTER,"); |
fb3aabf3 LV |
2876 | |
2877 | if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) { | |
2878 | struct target_sock_filter *filter; | |
4b25a506 | 2879 | qemu_log("{"); |
fb3aabf3 LV |
2880 | if (lock_user_struct(VERIFY_READ, filter, |
2881 | tswapal(fprog->filter), 0)) { | |
2882 | int i; | |
2883 | for (i = 0; i < tswap16(fprog->len) - 1; i++) { | |
4b25a506 | 2884 | qemu_log("[%d]{0x%x,%d,%d,0x%x},", |
fb3aabf3 LV |
2885 | i, tswap16(filter[i].code), |
2886 | filter[i].jt, filter[i].jf, | |
2887 | tswap32(filter[i].k)); | |
2888 | } | |
4b25a506 | 2889 | qemu_log("[%d]{0x%x,%d,%d,0x%x}", |
fb3aabf3 LV |
2890 | i, tswap16(filter[i].code), |
2891 | filter[i].jt, filter[i].jf, | |
2892 | tswap32(filter[i].k)); | |
2893 | } else { | |
4b25a506 | 2894 | qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter)); |
fb3aabf3 | 2895 | } |
4b25a506 | 2896 | qemu_log(",%d},", tswap16(fprog->len)); |
fb3aabf3 LV |
2897 | unlock_user(fprog, optval, 0); |
2898 | } else { | |
2899 | print_pointer(optval, 0); | |
2900 | } | |
2901 | break; | |
2902 | } | |
2903 | default: | |
2904 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
2905 | print_pointer(optval, 0); | |
2906 | break; | |
2907 | } | |
2908 | break; | |
38987eab SCW |
2909 | case SOL_IPV6: |
2910 | qemu_log("SOL_IPV6,"); | |
2911 | switch (optname) { | |
2912 | case IPV6_MTU_DISCOVER: | |
2913 | qemu_log("IPV6_MTU_DISCOVER,"); | |
2914 | goto print_optint; | |
2915 | case IPV6_MTU: | |
2916 | qemu_log("IPV6_MTU,"); | |
2917 | goto print_optint; | |
2918 | case IPV6_V6ONLY: | |
2919 | qemu_log("IPV6_V6ONLY,"); | |
2920 | goto print_optint; | |
2921 | case IPV6_RECVPKTINFO: | |
2922 | qemu_log("IPV6_RECVPKTINFO,"); | |
2923 | goto print_optint; | |
2924 | case IPV6_UNICAST_HOPS: | |
2925 | qemu_log("IPV6_UNICAST_HOPS,"); | |
2926 | goto print_optint; | |
2927 | case IPV6_MULTICAST_HOPS: | |
2928 | qemu_log("IPV6_MULTICAST_HOPS,"); | |
2929 | goto print_optint; | |
2930 | case IPV6_MULTICAST_LOOP: | |
2931 | qemu_log("IPV6_MULTICAST_LOOP,"); | |
2932 | goto print_optint; | |
2933 | case IPV6_RECVERR: | |
2934 | qemu_log("IPV6_RECVERR,"); | |
2935 | goto print_optint; | |
2936 | case IPV6_RECVHOPLIMIT: | |
2937 | qemu_log("IPV6_RECVHOPLIMIT,"); | |
2938 | goto print_optint; | |
2939 | case IPV6_2292HOPLIMIT: | |
2940 | qemu_log("IPV6_2292HOPLIMIT,"); | |
2941 | goto print_optint; | |
2942 | case IPV6_CHECKSUM: | |
2943 | qemu_log("IPV6_CHECKSUM,"); | |
2944 | goto print_optint; | |
2945 | case IPV6_ADDRFORM: | |
2946 | qemu_log("IPV6_ADDRFORM,"); | |
2947 | goto print_optint; | |
2948 | case IPV6_2292PKTINFO: | |
2949 | qemu_log("IPV6_2292PKTINFO,"); | |
2950 | goto print_optint; | |
2951 | case IPV6_RECVTCLASS: | |
2952 | qemu_log("IPV6_RECVTCLASS,"); | |
2953 | goto print_optint; | |
2954 | case IPV6_RECVRTHDR: | |
2955 | qemu_log("IPV6_RECVRTHDR,"); | |
2956 | goto print_optint; | |
2957 | case IPV6_2292RTHDR: | |
2958 | qemu_log("IPV6_2292RTHDR,"); | |
2959 | goto print_optint; | |
2960 | case IPV6_RECVHOPOPTS: | |
2961 | qemu_log("IPV6_RECVHOPOPTS,"); | |
2962 | goto print_optint; | |
2963 | case IPV6_2292HOPOPTS: | |
2964 | qemu_log("IPV6_2292HOPOPTS,"); | |
2965 | goto print_optint; | |
2966 | case IPV6_RECVDSTOPTS: | |
2967 | qemu_log("IPV6_RECVDSTOPTS,"); | |
2968 | goto print_optint; | |
2969 | case IPV6_2292DSTOPTS: | |
2970 | qemu_log("IPV6_2292DSTOPTS,"); | |
2971 | goto print_optint; | |
2972 | case IPV6_TCLASS: | |
2973 | qemu_log("IPV6_TCLASS,"); | |
2974 | goto print_optint; | |
2975 | case IPV6_ADDR_PREFERENCES: | |
2976 | qemu_log("IPV6_ADDR_PREFERENCES,"); | |
2977 | goto print_optint; | |
2978 | #ifdef IPV6_RECVPATHMTU | |
2979 | case IPV6_RECVPATHMTU: | |
2980 | qemu_log("IPV6_RECVPATHMTU,"); | |
2981 | goto print_optint; | |
2982 | #endif | |
2983 | #ifdef IPV6_TRANSPARENT | |
2984 | case IPV6_TRANSPARENT: | |
2985 | qemu_log("IPV6_TRANSPARENT,"); | |
2986 | goto print_optint; | |
2987 | #endif | |
2988 | #ifdef IPV6_FREEBIND | |
2989 | case IPV6_FREEBIND: | |
2990 | qemu_log("IPV6_FREEBIND,"); | |
2991 | goto print_optint; | |
2992 | #endif | |
2993 | #ifdef IPV6_RECVORIGDSTADDR | |
2994 | case IPV6_RECVORIGDSTADDR: | |
2995 | qemu_log("IPV6_RECVORIGDSTADDR,"); | |
2996 | goto print_optint; | |
2997 | #endif | |
2998 | case IPV6_PKTINFO: | |
2999 | qemu_log("IPV6_PKTINFO,"); | |
3000 | print_pointer(optval, 0); | |
3001 | break; | |
3002 | case IPV6_ADD_MEMBERSHIP: | |
3003 | qemu_log("IPV6_ADD_MEMBERSHIP,"); | |
3004 | print_pointer(optval, 0); | |
3005 | break; | |
3006 | case IPV6_DROP_MEMBERSHIP: | |
3007 | qemu_log("IPV6_DROP_MEMBERSHIP,"); | |
3008 | print_pointer(optval, 0); | |
3009 | break; | |
3010 | default: | |
3011 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
3012 | print_pointer(optval, 0); | |
3013 | break; | |
3014 | } | |
3015 | break; | |
fb3aabf3 LV |
3016 | default: |
3017 | print_raw_param(TARGET_ABI_FMT_ld, level, 0); | |
3018 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
3019 | print_pointer(optval, 0); | |
3020 | break; | |
3021 | } | |
3022 | print_raw_param(TARGET_ABI_FMT_ld, optlen, 1); | |
4b25a506 | 3023 | qemu_log(")"); |
fb3aabf3 LV |
3024 | } |
3025 | ||
3026 | #define PRINT_SOCKOP(name, func) \ | |
ff71a454 | 3027 | [TARGET_SYS_##name] = { #name, func } |
fb3aabf3 LV |
3028 | |
3029 | static struct { | |
3030 | const char *name; | |
3031 | void (*print)(const char *, abi_long); | |
3032 | } scall[] = { | |
ff71a454 AM |
3033 | PRINT_SOCKOP(SOCKET, do_print_socket), |
3034 | PRINT_SOCKOP(BIND, do_print_sockaddr), | |
3035 | PRINT_SOCKOP(CONNECT, do_print_sockaddr), | |
3036 | PRINT_SOCKOP(LISTEN, do_print_listen), | |
3037 | PRINT_SOCKOP(ACCEPT, do_print_sockaddr), | |
3038 | PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr), | |
3039 | PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr), | |
3040 | PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair), | |
3041 | PRINT_SOCKOP(SEND, do_print_sendrecv), | |
3042 | PRINT_SOCKOP(RECV, do_print_sendrecv), | |
3043 | PRINT_SOCKOP(SENDTO, do_print_msgaddr), | |
3044 | PRINT_SOCKOP(RECVFROM, do_print_msgaddr), | |
3045 | PRINT_SOCKOP(SHUTDOWN, do_print_shutdown), | |
3046 | PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt), | |
3047 | PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt), | |
3048 | PRINT_SOCKOP(SENDMSG, do_print_msg), | |
3049 | PRINT_SOCKOP(RECVMSG, do_print_msg), | |
3050 | PRINT_SOCKOP(ACCEPT4, NULL), | |
3051 | PRINT_SOCKOP(RECVMMSG, NULL), | |
3052 | PRINT_SOCKOP(SENDMMSG, NULL), | |
fb3aabf3 LV |
3053 | }; |
3054 | ||
3055 | static void | |
a0939b89 | 3056 | print_socketcall(CPUArchState *cpu_env, const struct syscallname *name, |
fb3aabf3 LV |
3057 | abi_long arg0, abi_long arg1, abi_long arg2, |
3058 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3059 | { | |
3060 | if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) { | |
3061 | scall[arg0].print(scall[arg0].name, arg1); | |
3062 | return; | |
3063 | } | |
3064 | print_syscall_prologue(name); | |
3065 | print_raw_param(TARGET_ABI_FMT_ld, arg0, 0); | |
3066 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
3067 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
3068 | print_raw_param(TARGET_ABI_FMT_ld, arg3, 0); | |
3069 | print_raw_param(TARGET_ABI_FMT_ld, arg4, 0); | |
3070 | print_raw_param(TARGET_ABI_FMT_ld, arg5, 0); | |
3071 | print_syscall_epilogue(name); | |
3072 | } | |
3073 | #endif | |
3074 | ||
bb10540e PMD |
3075 | #if defined(TARGET_NR_bind) |
3076 | static void | |
a0939b89 | 3077 | print_bind(CPUArchState *cpu_env, const struct syscallname *name, |
bb10540e PMD |
3078 | abi_long arg0, abi_long arg1, abi_long arg2, |
3079 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3080 | { | |
3081 | print_syscall_prologue(name); | |
3082 | print_sockfd(arg0, 0); | |
3083 | print_sockaddr(arg1, arg2, 1); | |
3084 | print_syscall_epilogue(name); | |
3085 | } | |
3086 | #endif | |
3087 | ||
74d753ac MW |
3088 | #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ |
3089 | defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) | |
3090 | static void | |
a0939b89 | 3091 | print_stat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3092 | abi_long arg0, abi_long arg1, abi_long arg2, |
3093 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3094 | { |
3095 | print_syscall_prologue(name); | |
3096 | print_string(arg0, 0); | |
3097 | print_pointer(arg1, 1); | |
3098 | print_syscall_epilogue(name); | |
3099 | } | |
3100 | #define print_lstat print_stat | |
3101 | #define print_stat64 print_stat | |
3102 | #define print_lstat64 print_stat | |
3103 | #endif | |
3104 | ||
375ce49b IL |
3105 | #if defined(TARGET_NR_madvise) |
3106 | static struct enums madvise_advice[] = { | |
3107 | ENUM_TARGET(MADV_NORMAL), | |
3108 | ENUM_TARGET(MADV_RANDOM), | |
3109 | ENUM_TARGET(MADV_SEQUENTIAL), | |
3110 | ENUM_TARGET(MADV_WILLNEED), | |
3111 | ENUM_TARGET(MADV_DONTNEED), | |
3112 | ENUM_TARGET(MADV_FREE), | |
3113 | ENUM_TARGET(MADV_REMOVE), | |
3114 | ENUM_TARGET(MADV_DONTFORK), | |
3115 | ENUM_TARGET(MADV_DOFORK), | |
3116 | ENUM_TARGET(MADV_MERGEABLE), | |
3117 | ENUM_TARGET(MADV_UNMERGEABLE), | |
3118 | ENUM_TARGET(MADV_HUGEPAGE), | |
3119 | ENUM_TARGET(MADV_NOHUGEPAGE), | |
3120 | ENUM_TARGET(MADV_DONTDUMP), | |
3121 | ENUM_TARGET(MADV_DODUMP), | |
3122 | ENUM_TARGET(MADV_WIPEONFORK), | |
3123 | ENUM_TARGET(MADV_KEEPONFORK), | |
3124 | ENUM_TARGET(MADV_COLD), | |
3125 | ENUM_TARGET(MADV_PAGEOUT), | |
3126 | ENUM_TARGET(MADV_POPULATE_READ), | |
3127 | ENUM_TARGET(MADV_POPULATE_WRITE), | |
3128 | ENUM_TARGET(MADV_DONTNEED_LOCKED), | |
3129 | ENUM_END, | |
3130 | }; | |
3131 | ||
3132 | static void | |
3133 | print_madvise(CPUArchState *cpu_env, const struct syscallname *name, | |
3134 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3135 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3136 | { | |
3137 | print_syscall_prologue(name); | |
3138 | print_pointer(arg0, 0); | |
3139 | print_raw_param("%d", arg1, 0); | |
3140 | print_enums(madvise_advice, arg2, 1); | |
3141 | print_syscall_epilogue(name); | |
3142 | } | |
3143 | #endif | |
3144 | ||
74d753ac MW |
3145 | #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) |
3146 | static void | |
a0939b89 | 3147 | print_fstat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3148 | abi_long arg0, abi_long arg1, abi_long arg2, |
3149 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3150 | { |
3151 | print_syscall_prologue(name); | |
d2ee72a5 | 3152 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
3153 | print_pointer(arg1, 1); |
3154 | print_syscall_epilogue(name); | |
3155 | } | |
3156 | #define print_fstat64 print_fstat | |
3157 | #endif | |
3158 | ||
3159 | #ifdef TARGET_NR_mkdir | |
3160 | static void | |
a0939b89 | 3161 | print_mkdir(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3162 | abi_long arg0, abi_long arg1, abi_long arg2, |
3163 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3164 | { |
3165 | print_syscall_prologue(name); | |
3166 | print_string(arg0, 0); | |
3167 | print_file_mode(arg1, 1); | |
3168 | print_syscall_epilogue(name); | |
3169 | } | |
3170 | #endif | |
3171 | ||
3172 | #ifdef TARGET_NR_mkdirat | |
3173 | static void | |
a0939b89 | 3174 | print_mkdirat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3175 | abi_long arg0, abi_long arg1, abi_long arg2, |
3176 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3177 | { |
3178 | print_syscall_prologue(name); | |
3179 | print_at_dirfd(arg0, 0); | |
3180 | print_string(arg1, 0); | |
3181 | print_file_mode(arg2, 1); | |
3182 | print_syscall_epilogue(name); | |
3183 | } | |
3184 | #endif | |
3185 | ||
4de596cb LV |
3186 | #ifdef TARGET_NR_rmdir |
3187 | static void | |
a0939b89 | 3188 | print_rmdir(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3189 | abi_long arg0, abi_long arg1, abi_long arg2, |
3190 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4de596cb LV |
3191 | { |
3192 | print_syscall_prologue(name); | |
3193 | print_string(arg0, 0); | |
3194 | print_syscall_epilogue(name); | |
3195 | } | |
3196 | #endif | |
3197 | ||
608e5592 LV |
3198 | #ifdef TARGET_NR_rt_sigaction |
3199 | static void | |
a0939b89 | 3200 | print_rt_sigaction(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3201 | abi_long arg0, abi_long arg1, abi_long arg2, |
3202 | abi_long arg3, abi_long arg4, abi_long arg5) | |
608e5592 LV |
3203 | { |
3204 | print_syscall_prologue(name); | |
3205 | print_signal(arg0, 0); | |
3206 | print_pointer(arg1, 0); | |
3207 | print_pointer(arg2, 1); | |
3208 | print_syscall_epilogue(name); | |
3209 | } | |
3210 | #endif | |
3211 | ||
3212 | #ifdef TARGET_NR_rt_sigprocmask | |
3213 | static void | |
a0939b89 | 3214 | print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3215 | abi_long arg0, abi_long arg1, abi_long arg2, |
3216 | abi_long arg3, abi_long arg4, abi_long arg5) | |
608e5592 LV |
3217 | { |
3218 | const char *how = "UNKNOWN"; | |
3219 | print_syscall_prologue(name); | |
3220 | switch(arg0) { | |
3221 | case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; | |
3222 | case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; | |
3223 | case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; | |
3224 | } | |
4b25a506 | 3225 | qemu_log("%s,", how); |
608e5592 | 3226 | print_pointer(arg1, 0); |
7020e2fd HD |
3227 | print_pointer(arg2, 0); |
3228 | print_raw_param("%u", arg3, 1); | |
608e5592 LV |
3229 | print_syscall_epilogue(name); |
3230 | } | |
3231 | #endif | |
3232 | ||
5162264e MS |
3233 | #ifdef TARGET_NR_rt_sigqueueinfo |
3234 | static void | |
a0939b89 | 3235 | print_rt_sigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3236 | abi_long arg0, abi_long arg1, abi_long arg2, |
3237 | abi_long arg3, abi_long arg4, abi_long arg5) | |
5162264e | 3238 | { |
ba9fcea1 MS |
3239 | void *p; |
3240 | target_siginfo_t uinfo; | |
3241 | ||
5162264e MS |
3242 | print_syscall_prologue(name); |
3243 | print_raw_param("%d", arg0, 0); | |
3244 | print_signal(arg1, 0); | |
ba9fcea1 MS |
3245 | p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); |
3246 | if (p) { | |
3247 | get_target_siginfo(&uinfo, p); | |
3248 | print_siginfo(&uinfo); | |
3249 | ||
3250 | unlock_user(p, arg2, 0); | |
3251 | } else { | |
3252 | print_pointer(arg2, 1); | |
3253 | } | |
5162264e MS |
3254 | print_syscall_epilogue(name); |
3255 | } | |
3256 | #endif | |
3257 | ||
243e0fe5 MS |
3258 | #ifdef TARGET_NR_rt_tgsigqueueinfo |
3259 | static void | |
a0939b89 | 3260 | print_rt_tgsigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3261 | abi_long arg0, abi_long arg1, abi_long arg2, |
3262 | abi_long arg3, abi_long arg4, abi_long arg5) | |
243e0fe5 | 3263 | { |
ba9fcea1 MS |
3264 | void *p; |
3265 | target_siginfo_t uinfo; | |
3266 | ||
243e0fe5 MS |
3267 | print_syscall_prologue(name); |
3268 | print_raw_param("%d", arg0, 0); | |
3269 | print_raw_param("%d", arg1, 0); | |
3270 | print_signal(arg2, 0); | |
ba9fcea1 MS |
3271 | p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); |
3272 | if (p) { | |
3273 | get_target_siginfo(&uinfo, p); | |
3274 | print_siginfo(&uinfo); | |
3275 | ||
3276 | unlock_user(p, arg3, 0); | |
3277 | } else { | |
3278 | print_pointer(arg3, 1); | |
3279 | } | |
243e0fe5 MS |
3280 | print_syscall_epilogue(name); |
3281 | } | |
3282 | #endif | |
3283 | ||
da2c8ad7 AM |
3284 | #ifdef TARGET_NR_syslog |
3285 | static void | |
3286 | print_syslog_action(abi_ulong arg, int last) | |
3287 | { | |
3288 | const char *type; | |
3289 | ||
3290 | switch (arg) { | |
3291 | case TARGET_SYSLOG_ACTION_CLOSE: { | |
3292 | type = "SYSLOG_ACTION_CLOSE"; | |
3293 | break; | |
3294 | } | |
3295 | case TARGET_SYSLOG_ACTION_OPEN: { | |
3296 | type = "SYSLOG_ACTION_OPEN"; | |
3297 | break; | |
3298 | } | |
3299 | case TARGET_SYSLOG_ACTION_READ: { | |
3300 | type = "SYSLOG_ACTION_READ"; | |
3301 | break; | |
3302 | } | |
3303 | case TARGET_SYSLOG_ACTION_READ_ALL: { | |
3304 | type = "SYSLOG_ACTION_READ_ALL"; | |
3305 | break; | |
3306 | } | |
3307 | case TARGET_SYSLOG_ACTION_READ_CLEAR: { | |
3308 | type = "SYSLOG_ACTION_READ_CLEAR"; | |
3309 | break; | |
3310 | } | |
3311 | case TARGET_SYSLOG_ACTION_CLEAR: { | |
3312 | type = "SYSLOG_ACTION_CLEAR"; | |
3313 | break; | |
3314 | } | |
3315 | case TARGET_SYSLOG_ACTION_CONSOLE_OFF: { | |
3316 | type = "SYSLOG_ACTION_CONSOLE_OFF"; | |
3317 | break; | |
3318 | } | |
3319 | case TARGET_SYSLOG_ACTION_CONSOLE_ON: { | |
3320 | type = "SYSLOG_ACTION_CONSOLE_ON"; | |
3321 | break; | |
3322 | } | |
3323 | case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: { | |
3324 | type = "SYSLOG_ACTION_CONSOLE_LEVEL"; | |
3325 | break; | |
3326 | } | |
3327 | case TARGET_SYSLOG_ACTION_SIZE_UNREAD: { | |
3328 | type = "SYSLOG_ACTION_SIZE_UNREAD"; | |
3329 | break; | |
3330 | } | |
3331 | case TARGET_SYSLOG_ACTION_SIZE_BUFFER: { | |
3332 | type = "SYSLOG_ACTION_SIZE_BUFFER"; | |
3333 | break; | |
3334 | } | |
3335 | default: { | |
3336 | print_raw_param("%ld", arg, last); | |
3337 | return; | |
3338 | } | |
3339 | } | |
4b25a506 | 3340 | qemu_log("%s%s", type, get_comma(last)); |
da2c8ad7 AM |
3341 | } |
3342 | ||
3343 | static void | |
a0939b89 | 3344 | print_syslog(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3345 | abi_long arg0, abi_long arg1, abi_long arg2, |
3346 | abi_long arg3, abi_long arg4, abi_long arg5) | |
da2c8ad7 AM |
3347 | { |
3348 | print_syscall_prologue(name); | |
3349 | print_syslog_action(arg0, 0); | |
3350 | print_pointer(arg1, 0); | |
3351 | print_raw_param("%d", arg2, 1); | |
3352 | print_syscall_epilogue(name); | |
3353 | } | |
3354 | #endif | |
3355 | ||
74d753ac MW |
3356 | #ifdef TARGET_NR_mknod |
3357 | static void | |
a0939b89 | 3358 | print_mknod(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3359 | abi_long arg0, abi_long arg1, abi_long arg2, |
3360 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac | 3361 | { |
d2ee72a5 | 3362 | int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
3363 | |
3364 | print_syscall_prologue(name); | |
3365 | print_string(arg0, 0); | |
3366 | print_file_mode(arg1, (hasdev == 0)); | |
3367 | if (hasdev) { | |
d2ee72a5 LV |
3368 | print_raw_param("makedev(%d", major(arg2), 0); |
3369 | print_raw_param("%d)", minor(arg2), 1); | |
74d753ac MW |
3370 | } |
3371 | print_syscall_epilogue(name); | |
3372 | } | |
3373 | #endif | |
3374 | ||
3375 | #ifdef TARGET_NR_mknodat | |
3376 | static void | |
a0939b89 | 3377 | print_mknodat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3378 | abi_long arg0, abi_long arg1, abi_long arg2, |
3379 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac | 3380 | { |
d2ee72a5 | 3381 | int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
3382 | |
3383 | print_syscall_prologue(name); | |
3384 | print_at_dirfd(arg0, 0); | |
3385 | print_string(arg1, 0); | |
3386 | print_file_mode(arg2, (hasdev == 0)); | |
3387 | if (hasdev) { | |
d2ee72a5 LV |
3388 | print_raw_param("makedev(%d", major(arg3), 0); |
3389 | print_raw_param("%d)", minor(arg3), 1); | |
74d753ac MW |
3390 | } |
3391 | print_syscall_epilogue(name); | |
3392 | } | |
3393 | #endif | |
3394 | ||
3395 | #ifdef TARGET_NR_mq_open | |
3396 | static void | |
a0939b89 | 3397 | print_mq_open(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3398 | abi_long arg0, abi_long arg1, abi_long arg2, |
3399 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac | 3400 | { |
d2ee72a5 | 3401 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
3402 | |
3403 | print_syscall_prologue(name); | |
3404 | print_string(arg0, 0); | |
3405 | print_open_flags(arg1, (is_creat == 0)); | |
3406 | if (is_creat) { | |
3407 | print_file_mode(arg2, 0); | |
3408 | print_pointer(arg3, 1); | |
3409 | } | |
3410 | print_syscall_epilogue(name); | |
3411 | } | |
3412 | #endif | |
3413 | ||
3414 | #ifdef TARGET_NR_open | |
3415 | static void | |
a0939b89 | 3416 | print_open(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3417 | abi_long arg0, abi_long arg1, abi_long arg2, |
3418 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac | 3419 | { |
d2ee72a5 | 3420 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
3421 | |
3422 | print_syscall_prologue(name); | |
3423 | print_string(arg0, 0); | |
3424 | print_open_flags(arg1, (is_creat == 0)); | |
3425 | if (is_creat) | |
3426 | print_file_mode(arg2, 1); | |
3427 | print_syscall_epilogue(name); | |
3428 | } | |
3429 | #endif | |
3430 | ||
3431 | #ifdef TARGET_NR_openat | |
3432 | static void | |
a0939b89 | 3433 | print_openat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3434 | abi_long arg0, abi_long arg1, abi_long arg2, |
3435 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac | 3436 | { |
d2ee72a5 | 3437 | int is_creat = (arg2 & TARGET_O_CREAT); |
74d753ac MW |
3438 | |
3439 | print_syscall_prologue(name); | |
3440 | print_at_dirfd(arg0, 0); | |
3441 | print_string(arg1, 0); | |
3442 | print_open_flags(arg2, (is_creat == 0)); | |
3443 | if (is_creat) | |
3444 | print_file_mode(arg3, 1); | |
3445 | print_syscall_epilogue(name); | |
3446 | } | |
3447 | #endif | |
3448 | ||
cc054c6f HD |
3449 | #ifdef TARGET_NR_pidfd_send_signal |
3450 | static void | |
3451 | print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name, | |
3452 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3453 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3454 | { | |
3455 | void *p; | |
3456 | target_siginfo_t uinfo; | |
3457 | ||
3458 | print_syscall_prologue(name); | |
3459 | print_raw_param("%d", arg0, 0); | |
3460 | print_signal(arg1, 0); | |
3461 | ||
3462 | p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); | |
3463 | if (p) { | |
3464 | get_target_siginfo(&uinfo, p); | |
3465 | print_siginfo(&uinfo); | |
3466 | ||
3467 | unlock_user(p, arg2, 0); | |
3468 | } else { | |
46187d70 | 3469 | print_pointer(arg2, 0); |
cc054c6f HD |
3470 | } |
3471 | ||
46187d70 | 3472 | print_raw_param("%u", arg3, 1); |
cc054c6f HD |
3473 | print_syscall_epilogue(name); |
3474 | } | |
3475 | #endif | |
3476 | ||
74d753ac MW |
3477 | #ifdef TARGET_NR_mq_unlink |
3478 | static void | |
a0939b89 | 3479 | print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3480 | abi_long arg0, abi_long arg1, abi_long arg2, |
3481 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3482 | { |
3483 | print_syscall_prologue(name); | |
3484 | print_string(arg0, 1); | |
3485 | print_syscall_epilogue(name); | |
3486 | } | |
3487 | #endif | |
3488 | ||
3489 | #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) | |
3490 | static void | |
a0939b89 | 3491 | print_fstatat64(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3492 | abi_long arg0, abi_long arg1, abi_long arg2, |
3493 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3494 | { |
3495 | print_syscall_prologue(name); | |
3496 | print_at_dirfd(arg0, 0); | |
3497 | print_string(arg1, 0); | |
3498 | print_pointer(arg2, 0); | |
3499 | print_flags(at_file_flags, arg3, 1); | |
3500 | print_syscall_epilogue(name); | |
3501 | } | |
3502 | #define print_newfstatat print_fstatat64 | |
3503 | #endif | |
3504 | ||
3505 | #ifdef TARGET_NR_readlink | |
3506 | static void | |
a0939b89 | 3507 | print_readlink(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3508 | abi_long arg0, abi_long arg1, abi_long arg2, |
3509 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3510 | { |
3511 | print_syscall_prologue(name); | |
3512 | print_string(arg0, 0); | |
3513 | print_pointer(arg1, 0); | |
d2ee72a5 | 3514 | print_raw_param("%u", arg2, 1); |
74d753ac MW |
3515 | print_syscall_epilogue(name); |
3516 | } | |
3517 | #endif | |
3518 | ||
3519 | #ifdef TARGET_NR_readlinkat | |
3520 | static void | |
a0939b89 | 3521 | print_readlinkat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3522 | abi_long arg0, abi_long arg1, abi_long arg2, |
3523 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3524 | { |
3525 | print_syscall_prologue(name); | |
3526 | print_at_dirfd(arg0, 0); | |
3527 | print_string(arg1, 0); | |
3528 | print_pointer(arg2, 0); | |
d2ee72a5 | 3529 | print_raw_param("%u", arg3, 1); |
74d753ac MW |
3530 | print_syscall_epilogue(name); |
3531 | } | |
3532 | #endif | |
3533 | ||
3534 | #ifdef TARGET_NR_rename | |
3535 | static void | |
a0939b89 | 3536 | print_rename(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3537 | abi_long arg0, abi_long arg1, abi_long arg2, |
3538 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3539 | { |
3540 | print_syscall_prologue(name); | |
3541 | print_string(arg0, 0); | |
3542 | print_string(arg1, 1); | |
3543 | print_syscall_epilogue(name); | |
3544 | } | |
3545 | #endif | |
3546 | ||
3547 | #ifdef TARGET_NR_renameat | |
3548 | static void | |
a0939b89 | 3549 | print_renameat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3550 | abi_long arg0, abi_long arg1, abi_long arg2, |
3551 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3552 | { |
3553 | print_syscall_prologue(name); | |
3554 | print_at_dirfd(arg0, 0); | |
3555 | print_string(arg1, 0); | |
3556 | print_at_dirfd(arg2, 0); | |
3557 | print_string(arg3, 1); | |
3558 | print_syscall_epilogue(name); | |
3559 | } | |
3560 | #endif | |
3561 | ||
3562 | #ifdef TARGET_NR_statfs | |
3563 | static void | |
a0939b89 | 3564 | print_statfs(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3565 | abi_long arg0, abi_long arg1, abi_long arg2, |
3566 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3567 | { |
3568 | print_syscall_prologue(name); | |
3569 | print_string(arg0, 0); | |
3570 | print_pointer(arg1, 1); | |
3571 | print_syscall_epilogue(name); | |
3572 | } | |
4f7f8924 AR |
3573 | #endif |
3574 | ||
3575 | #ifdef TARGET_NR_statfs64 | |
3576 | static void | |
a0939b89 | 3577 | print_statfs64(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3578 | abi_long arg0, abi_long arg1, abi_long arg2, |
3579 | abi_long arg3, abi_long arg4, abi_long arg5) | |
4f7f8924 AR |
3580 | { |
3581 | print_syscall_prologue(name); | |
3582 | print_string(arg0, 0); | |
3583 | print_pointer(arg1, 1); | |
3584 | print_syscall_epilogue(name); | |
3585 | } | |
74d753ac MW |
3586 | #endif |
3587 | ||
3588 | #ifdef TARGET_NR_symlink | |
3589 | static void | |
a0939b89 | 3590 | print_symlink(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3591 | abi_long arg0, abi_long arg1, abi_long arg2, |
3592 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3593 | { |
3594 | print_syscall_prologue(name); | |
3595 | print_string(arg0, 0); | |
3596 | print_string(arg1, 1); | |
3597 | print_syscall_epilogue(name); | |
3598 | } | |
3599 | #endif | |
3600 | ||
3601 | #ifdef TARGET_NR_symlinkat | |
3602 | static void | |
a0939b89 | 3603 | print_symlinkat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3604 | abi_long arg0, abi_long arg1, abi_long arg2, |
3605 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3606 | { |
3607 | print_syscall_prologue(name); | |
3608 | print_string(arg0, 0); | |
3609 | print_at_dirfd(arg1, 0); | |
3610 | print_string(arg2, 1); | |
3611 | print_syscall_epilogue(name); | |
3612 | } | |
3613 | #endif | |
3614 | ||
3615 | #ifdef TARGET_NR_mount | |
3616 | static void | |
a0939b89 | 3617 | print_mount(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3618 | abi_long arg0, abi_long arg1, abi_long arg2, |
3619 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3620 | { |
3621 | print_syscall_prologue(name); | |
3622 | print_string(arg0, 0); | |
3623 | print_string(arg1, 0); | |
3624 | print_string(arg2, 0); | |
3625 | print_flags(mount_flags, arg3, 0); | |
3626 | print_pointer(arg4, 1); | |
3627 | print_syscall_epilogue(name); | |
3628 | } | |
3629 | #endif | |
3630 | ||
3631 | #ifdef TARGET_NR_umount | |
3632 | static void | |
a0939b89 | 3633 | print_umount(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3634 | abi_long arg0, abi_long arg1, abi_long arg2, |
3635 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3636 | { |
3637 | print_syscall_prologue(name); | |
3638 | print_string(arg0, 1); | |
3639 | print_syscall_epilogue(name); | |
3640 | } | |
3641 | #endif | |
3642 | ||
3643 | #ifdef TARGET_NR_umount2 | |
3644 | static void | |
a0939b89 | 3645 | print_umount2(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3646 | abi_long arg0, abi_long arg1, abi_long arg2, |
3647 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3648 | { |
3649 | print_syscall_prologue(name); | |
3650 | print_string(arg0, 0); | |
3651 | print_flags(umount2_flags, arg1, 1); | |
3652 | print_syscall_epilogue(name); | |
3653 | } | |
3654 | #endif | |
3655 | ||
3656 | #ifdef TARGET_NR_unlink | |
3657 | static void | |
a0939b89 | 3658 | print_unlink(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3659 | abi_long arg0, abi_long arg1, abi_long arg2, |
3660 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3661 | { |
3662 | print_syscall_prologue(name); | |
3663 | print_string(arg0, 1); | |
3664 | print_syscall_epilogue(name); | |
3665 | } | |
3666 | #endif | |
3667 | ||
3668 | #ifdef TARGET_NR_unlinkat | |
3669 | static void | |
a0939b89 | 3670 | print_unlinkat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3671 | abi_long arg0, abi_long arg1, abi_long arg2, |
3672 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3673 | { |
3674 | print_syscall_prologue(name); | |
3675 | print_at_dirfd(arg0, 0); | |
3676 | print_string(arg1, 0); | |
3677 | print_flags(unlinkat_flags, arg2, 1); | |
3678 | print_syscall_epilogue(name); | |
3679 | } | |
3680 | #endif | |
3681 | ||
5847d309 MK |
3682 | #ifdef TARGET_NR_unshare |
3683 | static void | |
a0939b89 | 3684 | print_unshare(CPUArchState *cpu_env, const struct syscallname *name, |
5847d309 MK |
3685 | abi_long arg0, abi_long arg1, abi_long arg2, |
3686 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3687 | { | |
3688 | print_syscall_prologue(name); | |
3689 | print_flags(clone_flags, arg0, 1); | |
3690 | print_syscall_epilogue(name); | |
3691 | } | |
3692 | #endif | |
3693 | ||
05f3adc9 HD |
3694 | #ifdef TARGET_NR_clock_nanosleep |
3695 | static void | |
3696 | print_clock_nanosleep(CPUArchState *cpu_env, const struct syscallname *name, | |
3697 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3698 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3699 | { | |
3700 | print_syscall_prologue(name); | |
3701 | print_enums(clockids, arg0, 0); | |
3702 | print_raw_param("%d", arg1, 0); | |
3703 | print_timespec(arg2, 0); | |
3704 | print_timespec(arg3, 1); | |
3705 | print_syscall_epilogue(name); | |
3706 | } | |
3707 | #endif | |
3708 | ||
74d753ac MW |
3709 | #ifdef TARGET_NR_utime |
3710 | static void | |
a0939b89 | 3711 | print_utime(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3712 | abi_long arg0, abi_long arg1, abi_long arg2, |
3713 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3714 | { |
3715 | print_syscall_prologue(name); | |
3716 | print_string(arg0, 0); | |
3717 | print_pointer(arg1, 1); | |
3718 | print_syscall_epilogue(name); | |
3719 | } | |
3720 | #endif | |
3721 | ||
3722 | #ifdef TARGET_NR_utimes | |
3723 | static void | |
a0939b89 | 3724 | print_utimes(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3725 | abi_long arg0, abi_long arg1, abi_long arg2, |
3726 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3727 | { |
3728 | print_syscall_prologue(name); | |
3729 | print_string(arg0, 0); | |
3730 | print_pointer(arg1, 1); | |
3731 | print_syscall_epilogue(name); | |
3732 | } | |
3733 | #endif | |
3734 | ||
3735 | #ifdef TARGET_NR_utimensat | |
3736 | static void | |
a0939b89 | 3737 | print_utimensat(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3738 | abi_long arg0, abi_long arg1, abi_long arg2, |
3739 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3740 | { |
3741 | print_syscall_prologue(name); | |
3742 | print_at_dirfd(arg0, 0); | |
3743 | print_string(arg1, 0); | |
3744 | print_pointer(arg2, 0); | |
3745 | print_flags(at_file_flags, arg3, 1); | |
3746 | print_syscall_epilogue(name); | |
3747 | } | |
3748 | #endif | |
3749 | ||
8d9016c0 | 3750 | #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) |
74d753ac | 3751 | static void |
a0939b89 | 3752 | print_mmap(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3753 | abi_long arg0, abi_long arg1, abi_long arg2, |
3754 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3755 | { |
3756 | print_syscall_prologue(name); | |
3757 | print_pointer(arg0, 0); | |
d2ee72a5 | 3758 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
3759 | print_flags(mmap_prot_flags, arg2, 0); |
3760 | print_flags(mmap_flags, arg3, 0); | |
d2ee72a5 LV |
3761 | print_raw_param("%d", arg4, 0); |
3762 | print_raw_param("%#x", arg5, 1); | |
74d753ac MW |
3763 | print_syscall_epilogue(name); |
3764 | } | |
3765 | #define print_mmap2 print_mmap | |
3766 | #endif | |
3767 | ||
3768 | #ifdef TARGET_NR_mprotect | |
3769 | static void | |
a0939b89 | 3770 | print_mprotect(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3771 | abi_long arg0, abi_long arg1, abi_long arg2, |
3772 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3773 | { |
3774 | print_syscall_prologue(name); | |
3775 | print_pointer(arg0, 0); | |
d2ee72a5 | 3776 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
3777 | print_flags(mmap_prot_flags, arg2, 1); |
3778 | print_syscall_epilogue(name); | |
3779 | } | |
3780 | #endif | |
3781 | ||
3782 | #ifdef TARGET_NR_munmap | |
3783 | static void | |
a0939b89 | 3784 | print_munmap(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3785 | abi_long arg0, abi_long arg1, abi_long arg2, |
3786 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac MW |
3787 | { |
3788 | print_syscall_prologue(name); | |
3789 | print_pointer(arg0, 0); | |
d2ee72a5 | 3790 | print_raw_param("%d", arg1, 1); |
74d753ac MW |
3791 | print_syscall_epilogue(name); |
3792 | } | |
3793 | #endif | |
3794 | ||
3795 | #ifdef TARGET_NR_futex | |
53b578f3 RH |
3796 | static void print_futex_op(int cmd, int last) |
3797 | { | |
3798 | static const char * const futex_names[] = { | |
3799 | #define NAME(X) [X] = #X | |
3800 | NAME(FUTEX_WAIT), | |
3801 | NAME(FUTEX_WAKE), | |
3802 | NAME(FUTEX_FD), | |
3803 | NAME(FUTEX_REQUEUE), | |
3804 | NAME(FUTEX_CMP_REQUEUE), | |
3805 | NAME(FUTEX_WAKE_OP), | |
3806 | NAME(FUTEX_LOCK_PI), | |
3807 | NAME(FUTEX_UNLOCK_PI), | |
3808 | NAME(FUTEX_TRYLOCK_PI), | |
3809 | NAME(FUTEX_WAIT_BITSET), | |
3810 | NAME(FUTEX_WAKE_BITSET), | |
3811 | NAME(FUTEX_WAIT_REQUEUE_PI), | |
3812 | NAME(FUTEX_CMP_REQUEUE_PI), | |
3813 | NAME(FUTEX_LOCK_PI2), | |
3814 | #undef NAME | |
3815 | }; | |
3816 | ||
3817 | unsigned base_cmd = cmd & FUTEX_CMD_MASK; | |
3818 | ||
3819 | if (base_cmd < ARRAY_SIZE(futex_names)) { | |
3820 | qemu_log("%s%s%s", | |
3821 | (cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""), | |
3822 | (cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""), | |
3823 | futex_names[base_cmd]); | |
3824 | } else { | |
3825 | qemu_log("0x%x", cmd); | |
bfb669f3 | 3826 | } |
74d753ac MW |
3827 | } |
3828 | ||
3829 | static void | |
a0939b89 | 3830 | print_futex(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3831 | abi_long arg0, abi_long arg1, abi_long arg2, |
3832 | abi_long arg3, abi_long arg4, abi_long arg5) | |
74d753ac | 3833 | { |
811ee5cf | 3834 | abi_long op = arg1 & FUTEX_CMD_MASK; |
74d753ac MW |
3835 | print_syscall_prologue(name); |
3836 | print_pointer(arg0, 0); | |
3837 | print_futex_op(arg1, 0); | |
d2ee72a5 | 3838 | print_raw_param(",%d", arg2, 0); |
811ee5cf HD |
3839 | switch (op) { |
3840 | case FUTEX_WAIT: | |
3841 | case FUTEX_WAIT_BITSET: | |
53b578f3 RH |
3842 | case FUTEX_LOCK_PI: |
3843 | case FUTEX_LOCK_PI2: | |
3844 | case FUTEX_WAIT_REQUEUE_PI: | |
811ee5cf HD |
3845 | print_timespec(arg3, 0); |
3846 | break; | |
3847 | default: | |
3848 | print_pointer(arg3, 0); | |
3849 | break; | |
3850 | } | |
74d753ac | 3851 | print_pointer(arg4, 0); |
d2ee72a5 | 3852 | print_raw_param("%d", arg4, 1); |
74d753ac MW |
3853 | print_syscall_epilogue(name); |
3854 | } | |
3855 | #endif | |
3856 | ||
608e5592 LV |
3857 | #ifdef TARGET_NR_kill |
3858 | static void | |
a0939b89 | 3859 | print_kill(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3860 | abi_long arg0, abi_long arg1, abi_long arg2, |
3861 | abi_long arg3, abi_long arg4, abi_long arg5) | |
608e5592 LV |
3862 | { |
3863 | print_syscall_prologue(name); | |
3864 | print_raw_param("%d", arg0, 0); | |
3865 | print_signal(arg1, 1); | |
3866 | print_syscall_epilogue(name); | |
3867 | } | |
3868 | #endif | |
3869 | ||
5162264e MS |
3870 | #ifdef TARGET_NR_tkill |
3871 | static void | |
a0939b89 | 3872 | print_tkill(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3873 | abi_long arg0, abi_long arg1, abi_long arg2, |
3874 | abi_long arg3, abi_long arg4, abi_long arg5) | |
5162264e MS |
3875 | { |
3876 | print_syscall_prologue(name); | |
3877 | print_raw_param("%d", arg0, 0); | |
3878 | print_signal(arg1, 1); | |
3879 | print_syscall_epilogue(name); | |
3880 | } | |
3881 | #endif | |
3882 | ||
3883 | #ifdef TARGET_NR_tgkill | |
3884 | static void | |
a0939b89 | 3885 | print_tgkill(CPUArchState *cpu_env, const struct syscallname *name, |
e400e119 FB |
3886 | abi_long arg0, abi_long arg1, abi_long arg2, |
3887 | abi_long arg3, abi_long arg4, abi_long arg5) | |
5162264e MS |
3888 | { |
3889 | print_syscall_prologue(name); | |
3890 | print_raw_param("%d", arg0, 0); | |
3891 | print_raw_param("%d", arg1, 0); | |
3892 | print_signal(arg2, 1); | |
3893 | print_syscall_epilogue(name); | |
3894 | } | |
3895 | #endif | |
3896 | ||
d42744fe JW |
3897 | #ifdef TARGET_NR_statx |
3898 | static void | |
a0939b89 | 3899 | print_statx(CPUArchState *cpu_env, const struct syscallname *name, |
d42744fe JW |
3900 | abi_long arg0, abi_long arg1, abi_long arg2, |
3901 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3902 | { | |
3903 | print_syscall_prologue(name); | |
3904 | print_at_dirfd(arg0, 0); | |
3905 | print_string(arg1, 0); | |
3906 | print_flags(statx_flags, arg2, 0); | |
3907 | print_flags(statx_mask, arg3, 0); | |
3908 | print_pointer(arg4, 1); | |
3909 | print_syscall_epilogue(name); | |
3910 | } | |
3911 | #endif | |
3912 | ||
79482e59 FB |
3913 | #ifdef TARGET_NR_ioctl |
3914 | static void | |
a0939b89 | 3915 | print_ioctl(CPUArchState *cpu_env, const struct syscallname *name, |
79482e59 FB |
3916 | abi_long arg0, abi_long arg1, abi_long arg2, |
3917 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3918 | { | |
3919 | print_syscall_prologue(name); | |
3920 | print_raw_param("%d", arg0, 0); | |
3921 | ||
3922 | const IOCTLEntry *ie; | |
3923 | const argtype *arg_type; | |
3924 | void *argptr; | |
3925 | int target_size; | |
3926 | ||
3927 | for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { | |
3928 | if (ie->target_cmd == arg1) { | |
3929 | break; | |
3930 | } | |
3931 | } | |
3932 | ||
3933 | if (ie->target_cmd == 0) { | |
3934 | print_raw_param("%#x", arg1, 0); | |
3935 | print_raw_param("%#x", arg2, 1); | |
3936 | } else { | |
3937 | qemu_log("%s", ie->name); | |
3938 | arg_type = ie->arg_type; | |
3939 | ||
3940 | if (arg_type[0] != TYPE_NULL) { | |
3941 | qemu_log(","); | |
3942 | ||
3943 | switch (arg_type[0]) { | |
3944 | case TYPE_PTRVOID: | |
3945 | print_pointer(arg2, 1); | |
3946 | break; | |
3947 | case TYPE_CHAR: | |
3948 | case TYPE_SHORT: | |
3949 | case TYPE_INT: | |
3950 | print_raw_param("%d", arg2, 1); | |
3951 | break; | |
3952 | case TYPE_LONG: | |
3953 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
3954 | break; | |
3955 | case TYPE_ULONG: | |
3956 | print_raw_param(TARGET_ABI_FMT_lu, arg2, 1); | |
3957 | break; | |
3958 | case TYPE_PTR: | |
3959 | switch (ie->access) { | |
3960 | case IOC_R: | |
3961 | print_pointer(arg2, 1); | |
3962 | break; | |
3963 | case IOC_W: | |
3964 | case IOC_RW: | |
3965 | arg_type++; | |
3966 | target_size = thunk_type_size(arg_type, 0); | |
3967 | argptr = lock_user(VERIFY_READ, arg2, target_size, 1); | |
4c1850c1 LV |
3968 | if (argptr) { |
3969 | thunk_print(argptr, arg_type); | |
3970 | unlock_user(argptr, arg2, target_size); | |
3971 | } else { | |
3972 | print_pointer(arg2, 1); | |
3973 | } | |
79482e59 FB |
3974 | break; |
3975 | } | |
3976 | break; | |
3977 | default: | |
3978 | g_assert_not_reached(); | |
3979 | } | |
3980 | } | |
3981 | } | |
3982 | print_syscall_epilogue(name); | |
3983 | } | |
3984 | #endif | |
3985 | ||
33189d31 TS |
3986 | /* |
3987 | * An array of all of the syscalls we know about | |
3988 | */ | |
3989 | ||
7ccfb2eb | 3990 | static const struct syscallname scnames[] = { |
33189d31 TS |
3991 | #include "strace.list" |
3992 | }; | |
3993 | ||
b1503cda | 3994 | static int nsyscalls = ARRAY_SIZE(scnames); |
33189d31 TS |
3995 | |
3996 | /* | |
3997 | * The public interface to this module. | |
3998 | */ | |
3999 | void | |
a0939b89 | 4000 | print_syscall(CPUArchState *cpu_env, int num, |
c16f9ed3 FB |
4001 | abi_long arg1, abi_long arg2, abi_long arg3, |
4002 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
4003 | { |
4004 | int i; | |
c5a1c6b8 RH |
4005 | FILE *f; |
4006 | const char *format = "%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," | |
4007 | TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," | |
4008 | TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; | |
33189d31 | 4009 | |
c5a1c6b8 RH |
4010 | f = qemu_log_trylock(); |
4011 | if (!f) { | |
4012 | return; | |
4013 | } | |
4014 | fprintf(f, "%d ", getpid()); | |
33189d31 | 4015 | |
c5a1c6b8 RH |
4016 | for (i = 0; i < nsyscalls; i++) { |
4017 | if (scnames[i].nr == num) { | |
4018 | if (scnames[i].call != NULL) { | |
4019 | scnames[i].call(cpu_env, &scnames[i], arg1, arg2, arg3, | |
4020 | arg4, arg5, arg6); | |
33189d31 | 4021 | } else { |
6b23f777 FB |
4022 | /* XXX: this format system is broken because it uses |
4023 | host types and host pointers for strings */ | |
c5a1c6b8 | 4024 | if (scnames[i].format != NULL) { |
33189d31 | 4025 | format = scnames[i].format; |
c5a1c6b8 RH |
4026 | } |
4027 | fprintf(f, format, scnames[i].name, arg1, arg2, | |
4028 | arg3, arg4, arg5, arg6); | |
33189d31 | 4029 | } |
c5a1c6b8 | 4030 | qemu_log_unlock(f); |
74c11e55 | 4031 | return; |
33189d31 | 4032 | } |
c5a1c6b8 RH |
4033 | } |
4034 | fprintf(f, "Unknown syscall %d\n", num); | |
4035 | qemu_log_unlock(f); | |
33189d31 TS |
4036 | } |
4037 | ||
4038 | ||
4039 | void | |
a0939b89 | 4040 | print_syscall_ret(CPUArchState *cpu_env, int num, abi_long ret, |
c84be71f FB |
4041 | abi_long arg1, abi_long arg2, abi_long arg3, |
4042 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
4043 | { |
4044 | int i; | |
c5a1c6b8 RH |
4045 | FILE *f; |
4046 | ||
4047 | f = qemu_log_trylock(); | |
4048 | if (!f) { | |
4049 | return; | |
4050 | } | |
33189d31 | 4051 | |
c5a1c6b8 RH |
4052 | for (i = 0; i < nsyscalls; i++) { |
4053 | if (scnames[i].nr == num) { | |
4054 | if (scnames[i].result != NULL) { | |
e400e119 | 4055 | scnames[i].result(cpu_env, &scnames[i], ret, |
c84be71f FB |
4056 | arg1, arg2, arg3, |
4057 | arg4, arg5, arg6); | |
33189d31 | 4058 | } else { |
42b16184 | 4059 | if (!print_syscall_err(ret)) { |
c5a1c6b8 | 4060 | fprintf(f, TARGET_ABI_FMT_ld, ret); |
33189d31 | 4061 | } |
c5a1c6b8 | 4062 | fprintf(f, "\n"); |
33189d31 TS |
4063 | } |
4064 | break; | |
4065 | } | |
c5a1c6b8 RH |
4066 | } |
4067 | qemu_log_unlock(f); | |
33189d31 | 4068 | } |
0cb581d6 PM |
4069 | |
4070 | void print_taken_signal(int target_signum, const target_siginfo_t *tinfo) | |
4071 | { | |
4072 | /* Print the strace output for a signal being taken: | |
4073 | * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} --- | |
4074 | */ | |
c5a1c6b8 RH |
4075 | FILE *f; |
4076 | ||
4077 | f = qemu_log_trylock(); | |
4078 | if (!f) { | |
4079 | return; | |
4080 | } | |
4081 | ||
4082 | fprintf(f, "--- "); | |
0cb581d6 | 4083 | print_signal(target_signum, 1); |
c5a1c6b8 | 4084 | fprintf(f, " "); |
0cb581d6 | 4085 | print_siginfo(tinfo); |
c5a1c6b8 RH |
4086 | fprintf(f, " ---\n"); |
4087 | qemu_log_unlock(f); | |
0cb581d6 | 4088 | } |