]>
Commit | Line | Data |
---|---|---|
d39594e9 | 1 | #include "qemu/osdep.h" |
33189d31 TS |
2 | #include <sys/ipc.h> |
3 | #include <sys/msg.h> | |
4 | #include <sys/sem.h> | |
5 | #include <sys/shm.h> | |
6 | #include <sys/select.h> | |
74d753ac | 7 | #include <sys/mount.h> |
fb3aabf3 LV |
8 | #include <arpa/inet.h> |
9 | #include <netinet/tcp.h> | |
10 | #include <linux/if_packet.h> | |
608e5592 | 11 | #include <sched.h> |
33189d31 TS |
12 | #include "qemu.h" |
13 | ||
14 | int do_strace=0; | |
15 | ||
16 | struct syscallname { | |
17 | int nr; | |
7ccfb2eb BS |
18 | const char *name; |
19 | const char *format; | |
20 | void (*call)(const struct syscallname *, | |
c16f9ed3 FB |
21 | abi_long, abi_long, abi_long, |
22 | abi_long, abi_long, abi_long); | |
7ccfb2eb | 23 | void (*result)(const struct syscallname *, abi_long); |
33189d31 TS |
24 | }; |
25 | ||
74d753ac MW |
26 | #ifdef __GNUC__ |
27 | /* | |
28 | * It is possible that target doesn't have syscall that uses | |
29 | * following flags but we don't want the compiler to warn | |
30 | * us about them being unused. Same applies to utility print | |
31 | * functions. It is ok to keep them while not used. | |
32 | */ | |
33 | #define UNUSED __attribute__ ((unused)) | |
34 | #else | |
35 | #define UNUSED | |
36 | #endif | |
37 | ||
38 | /* | |
39 | * Structure used to translate flag values into strings. This is | |
40 | * similar that is in the actual strace tool. | |
41 | */ | |
42 | struct flags { | |
43 | abi_long f_value; /* flag */ | |
44 | const char *f_string; /* stringified flag */ | |
45 | }; | |
46 | ||
47 | /* common flags for all architectures */ | |
48 | #define FLAG_GENERIC(name) { name, #name } | |
49 | /* target specific flags (syscall_defs.h has TARGET_<flag>) */ | |
50 | #define FLAG_TARGET(name) { TARGET_ ## name, #name } | |
51 | /* end of flags array */ | |
52 | #define FLAG_END { 0, NULL } | |
53 | ||
54 | UNUSED static const char *get_comma(int); | |
55 | UNUSED static void print_pointer(abi_long, int); | |
56 | UNUSED static void print_flags(const struct flags *, abi_long, int); | |
57 | UNUSED static void print_at_dirfd(abi_long, int); | |
58 | UNUSED static void print_file_mode(abi_long, int); | |
59 | UNUSED static void print_open_flags(abi_long, int); | |
60 | UNUSED static void print_syscall_prologue(const struct syscallname *); | |
61 | UNUSED static void print_syscall_epilogue(const struct syscallname *); | |
62 | UNUSED static void print_string(abi_long, int); | |
fb3aabf3 | 63 | UNUSED static void print_buf(abi_long addr, abi_long len, int last); |
74d753ac MW |
64 | UNUSED static void print_raw_param(const char *, abi_long, int); |
65 | UNUSED static void print_timeval(abi_ulong, int); | |
66 | UNUSED static void print_number(abi_long, int); | |
608e5592 | 67 | UNUSED static void print_signal(abi_ulong, int); |
fb3aabf3 LV |
68 | UNUSED static void print_sockaddr(abi_ulong addr, abi_long addrlen); |
69 | UNUSED static void print_socket_domain(int domain); | |
70 | UNUSED static void print_socket_type(int type); | |
71 | UNUSED static void print_socket_protocol(int domain, int type, int protocol); | |
74d753ac | 72 | |
33189d31 TS |
73 | /* |
74 | * Utility functions | |
75 | */ | |
76 | static void | |
77 | print_ipc_cmd(int cmd) | |
78 | { | |
79 | #define output_cmd(val) \ | |
80 | if( cmd == val ) { \ | |
81 | gemu_log(#val); \ | |
82 | return; \ | |
83 | } | |
84 | ||
85 | cmd &= 0xff; | |
86 | ||
87 | /* General IPC commands */ | |
88 | output_cmd( IPC_RMID ); | |
89 | output_cmd( IPC_SET ); | |
90 | output_cmd( IPC_STAT ); | |
91 | output_cmd( IPC_INFO ); | |
92 | /* msgctl() commands */ | |
93 | #ifdef __USER_MISC | |
94 | output_cmd( MSG_STAT ); | |
95 | output_cmd( MSG_INFO ); | |
96 | #endif | |
97 | /* shmctl() commands */ | |
98 | output_cmd( SHM_LOCK ); | |
99 | output_cmd( SHM_UNLOCK ); | |
100 | output_cmd( SHM_STAT ); | |
101 | output_cmd( SHM_INFO ); | |
102 | /* semctl() commands */ | |
103 | output_cmd( GETPID ); | |
104 | output_cmd( GETVAL ); | |
105 | output_cmd( GETALL ); | |
106 | output_cmd( GETNCNT ); | |
107 | output_cmd( GETZCNT ); | |
108 | output_cmd( SETVAL ); | |
109 | output_cmd( SETALL ); | |
110 | output_cmd( SEM_STAT ); | |
111 | output_cmd( SEM_INFO ); | |
112 | output_cmd( IPC_RMID ); | |
113 | output_cmd( IPC_RMID ); | |
114 | output_cmd( IPC_RMID ); | |
115 | output_cmd( IPC_RMID ); | |
116 | output_cmd( IPC_RMID ); | |
117 | output_cmd( IPC_RMID ); | |
118 | output_cmd( IPC_RMID ); | |
119 | output_cmd( IPC_RMID ); | |
120 | output_cmd( IPC_RMID ); | |
121 | ||
122 | /* Some value we don't recognize */ | |
123 | gemu_log("%d",cmd); | |
124 | } | |
125 | ||
608e5592 LV |
126 | static void |
127 | print_signal(abi_ulong arg, int last) | |
128 | { | |
129 | const char *signal_name = NULL; | |
130 | switch(arg) { | |
131 | case TARGET_SIGHUP: signal_name = "SIGHUP"; break; | |
132 | case TARGET_SIGINT: signal_name = "SIGINT"; break; | |
133 | case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break; | |
134 | case TARGET_SIGILL: signal_name = "SIGILL"; break; | |
135 | case TARGET_SIGABRT: signal_name = "SIGABRT"; break; | |
136 | case TARGET_SIGFPE: signal_name = "SIGFPE"; break; | |
137 | case TARGET_SIGKILL: signal_name = "SIGKILL"; break; | |
138 | case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break; | |
139 | case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break; | |
140 | case TARGET_SIGALRM: signal_name = "SIGALRM"; break; | |
141 | case TARGET_SIGTERM: signal_name = "SIGTERM"; break; | |
142 | case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break; | |
143 | case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break; | |
144 | case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break; | |
145 | case TARGET_SIGCONT: signal_name = "SIGCONT"; break; | |
146 | case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break; | |
147 | case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break; | |
148 | case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break; | |
149 | } | |
150 | if (signal_name == NULL) { | |
abe20840 | 151 | print_raw_param("%ld", arg, last); |
608e5592 LV |
152 | return; |
153 | } | |
154 | gemu_log("%s%s", signal_name, get_comma(last)); | |
155 | } | |
156 | ||
0cb581d6 PM |
157 | static void print_si_code(int arg) |
158 | { | |
159 | const char *codename = NULL; | |
160 | ||
161 | switch (arg) { | |
162 | case SI_USER: | |
163 | codename = "SI_USER"; | |
164 | break; | |
165 | case SI_KERNEL: | |
166 | codename = "SI_KERNEL"; | |
167 | break; | |
168 | case SI_QUEUE: | |
169 | codename = "SI_QUEUE"; | |
170 | break; | |
171 | case SI_TIMER: | |
172 | codename = "SI_TIMER"; | |
173 | break; | |
174 | case SI_MESGQ: | |
175 | codename = "SI_MESGQ"; | |
176 | break; | |
177 | case SI_ASYNCIO: | |
178 | codename = "SI_ASYNCIO"; | |
179 | break; | |
180 | case SI_SIGIO: | |
181 | codename = "SI_SIGIO"; | |
182 | break; | |
183 | case SI_TKILL: | |
184 | codename = "SI_TKILL"; | |
185 | break; | |
186 | default: | |
187 | gemu_log("%d", arg); | |
188 | return; | |
189 | } | |
190 | gemu_log("%s", codename); | |
191 | } | |
192 | ||
193 | static void print_siginfo(const target_siginfo_t *tinfo) | |
194 | { | |
195 | /* Print a target_siginfo_t in the format desired for printing | |
196 | * signals being taken. We assume the target_siginfo_t is in the | |
197 | * internal form where the top 16 bits of si_code indicate which | |
198 | * part of the union is valid, rather than in the guest-visible | |
199 | * form where the bottom 16 bits are sign-extended into the top 16. | |
200 | */ | |
201 | int si_type = extract32(tinfo->si_code, 16, 16); | |
202 | int si_code = sextract32(tinfo->si_code, 0, 16); | |
203 | ||
204 | gemu_log("{si_signo="); | |
205 | print_signal(tinfo->si_signo, 1); | |
206 | gemu_log(", si_code="); | |
207 | print_si_code(si_code); | |
208 | ||
209 | switch (si_type) { | |
210 | case QEMU_SI_KILL: | |
211 | gemu_log(", si_pid = %u, si_uid = %u", | |
212 | (unsigned int)tinfo->_sifields._kill._pid, | |
213 | (unsigned int)tinfo->_sifields._kill._uid); | |
214 | break; | |
215 | case QEMU_SI_TIMER: | |
216 | gemu_log(", si_timer1 = %u, si_timer2 = %u", | |
217 | tinfo->_sifields._timer._timer1, | |
218 | tinfo->_sifields._timer._timer2); | |
219 | break; | |
220 | case QEMU_SI_POLL: | |
221 | gemu_log(", si_band = %d, si_fd = %d", | |
222 | tinfo->_sifields._sigpoll._band, | |
223 | tinfo->_sifields._sigpoll._fd); | |
224 | break; | |
225 | case QEMU_SI_FAULT: | |
226 | gemu_log(", si_addr = "); | |
227 | print_pointer(tinfo->_sifields._sigfault._addr, 1); | |
228 | break; | |
229 | case QEMU_SI_CHLD: | |
230 | gemu_log(", si_pid = %u, si_uid = %u, si_status = %d" | |
231 | ", si_utime=" TARGET_ABI_FMT_ld | |
232 | ", si_stime=" TARGET_ABI_FMT_ld, | |
233 | (unsigned int)(tinfo->_sifields._sigchld._pid), | |
234 | (unsigned int)(tinfo->_sifields._sigchld._uid), | |
235 | tinfo->_sifields._sigchld._status, | |
236 | tinfo->_sifields._sigchld._utime, | |
237 | tinfo->_sifields._sigchld._stime); | |
238 | break; | |
239 | case QEMU_SI_RT: | |
240 | gemu_log(", si_pid = %u, si_uid = %u, si_sigval = " TARGET_ABI_FMT_ld, | |
241 | (unsigned int)tinfo->_sifields._rt._pid, | |
242 | (unsigned int)tinfo->_sifields._rt._uid, | |
243 | tinfo->_sifields._rt._sigval.sival_ptr); | |
244 | break; | |
245 | default: | |
246 | g_assert_not_reached(); | |
247 | } | |
248 | gemu_log("}"); | |
249 | } | |
250 | ||
fb3aabf3 LV |
251 | static void |
252 | print_sockaddr(abi_ulong addr, abi_long addrlen) | |
253 | { | |
254 | struct target_sockaddr *sa; | |
255 | int i; | |
256 | int sa_family; | |
257 | ||
258 | sa = lock_user(VERIFY_READ, addr, addrlen, 1); | |
259 | if (sa) { | |
260 | sa_family = tswap16(sa->sa_family); | |
261 | switch (sa_family) { | |
262 | case AF_UNIX: { | |
263 | struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa; | |
264 | int i; | |
265 | gemu_log("{sun_family=AF_UNIX,sun_path=\""); | |
266 | for (i = 0; i < addrlen - | |
267 | offsetof(struct target_sockaddr_un, sun_path) && | |
268 | un->sun_path[i]; i++) { | |
269 | gemu_log("%c", un->sun_path[i]); | |
270 | } | |
271 | gemu_log("\"}"); | |
272 | break; | |
273 | } | |
274 | case AF_INET: { | |
275 | struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa; | |
276 | uint8_t *c = (uint8_t *)&in->sin_addr.s_addr; | |
277 | gemu_log("{sin_family=AF_INET,sin_port=htons(%d),", | |
278 | ntohs(in->sin_port)); | |
279 | gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", | |
280 | c[0], c[1], c[2], c[3]); | |
281 | gemu_log("}"); | |
282 | break; | |
283 | } | |
284 | case AF_PACKET: { | |
285 | struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa; | |
286 | uint8_t *c = (uint8_t *)&ll->sll_addr; | |
287 | gemu_log("{sll_family=AF_PACKET," | |
288 | "sll_protocol=htons(0x%04x),if%d,pkttype=", | |
289 | ntohs(ll->sll_protocol), ll->sll_ifindex); | |
290 | switch (ll->sll_pkttype) { | |
291 | case PACKET_HOST: | |
292 | gemu_log("PACKET_HOST"); | |
293 | break; | |
294 | case PACKET_BROADCAST: | |
295 | gemu_log("PACKET_BROADCAST"); | |
296 | break; | |
297 | case PACKET_MULTICAST: | |
298 | gemu_log("PACKET_MULTICAST"); | |
299 | break; | |
300 | case PACKET_OTHERHOST: | |
301 | gemu_log("PACKET_OTHERHOST"); | |
302 | break; | |
303 | case PACKET_OUTGOING: | |
304 | gemu_log("PACKET_OUTGOING"); | |
305 | break; | |
306 | default: | |
307 | gemu_log("%d", ll->sll_pkttype); | |
308 | break; | |
309 | } | |
310 | gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", | |
311 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); | |
312 | gemu_log("}"); | |
313 | break; | |
314 | } | |
315 | default: | |
316 | gemu_log("{sa_family=%d, sa_data={", sa->sa_family); | |
317 | for (i = 0; i < 13; i++) { | |
318 | gemu_log("%02x, ", sa->sa_data[i]); | |
319 | } | |
320 | gemu_log("%02x}", sa->sa_data[i]); | |
321 | gemu_log("}"); | |
322 | break; | |
323 | } | |
324 | unlock_user(sa, addr, 0); | |
325 | } else { | |
326 | print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); | |
327 | } | |
328 | gemu_log(", "TARGET_ABI_FMT_ld, addrlen); | |
329 | } | |
330 | ||
331 | static void | |
332 | print_socket_domain(int domain) | |
333 | { | |
334 | switch (domain) { | |
335 | case PF_UNIX: | |
336 | gemu_log("PF_UNIX"); | |
337 | break; | |
338 | case PF_INET: | |
339 | gemu_log("PF_INET"); | |
340 | break; | |
341 | case PF_PACKET: | |
342 | gemu_log("PF_PACKET"); | |
343 | break; | |
344 | default: | |
345 | gemu_log("%d", domain); | |
346 | break; | |
347 | } | |
348 | } | |
349 | ||
350 | static void | |
351 | print_socket_type(int type) | |
352 | { | |
353 | switch (type) { | |
354 | case TARGET_SOCK_DGRAM: | |
355 | gemu_log("SOCK_DGRAM"); | |
356 | break; | |
357 | case TARGET_SOCK_STREAM: | |
358 | gemu_log("SOCK_STREAM"); | |
359 | break; | |
360 | case TARGET_SOCK_RAW: | |
361 | gemu_log("SOCK_RAW"); | |
362 | break; | |
363 | case TARGET_SOCK_RDM: | |
364 | gemu_log("SOCK_RDM"); | |
365 | break; | |
366 | case TARGET_SOCK_SEQPACKET: | |
367 | gemu_log("SOCK_SEQPACKET"); | |
368 | break; | |
369 | case TARGET_SOCK_PACKET: | |
370 | gemu_log("SOCK_PACKET"); | |
371 | break; | |
372 | } | |
373 | } | |
374 | ||
375 | static void | |
376 | print_socket_protocol(int domain, int type, int protocol) | |
377 | { | |
378 | if (domain == AF_PACKET || | |
379 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
380 | switch (protocol) { | |
381 | case 0x0003: | |
382 | gemu_log("ETH_P_ALL"); | |
383 | break; | |
384 | default: | |
385 | gemu_log("%d", protocol); | |
386 | } | |
387 | return; | |
388 | } | |
389 | ||
390 | switch (protocol) { | |
391 | case IPPROTO_IP: | |
392 | gemu_log("IPPROTO_IP"); | |
393 | break; | |
394 | case IPPROTO_TCP: | |
395 | gemu_log("IPPROTO_TCP"); | |
396 | break; | |
397 | case IPPROTO_UDP: | |
398 | gemu_log("IPPROTO_UDP"); | |
399 | break; | |
400 | case IPPROTO_RAW: | |
401 | gemu_log("IPPROTO_RAW"); | |
402 | break; | |
403 | default: | |
404 | gemu_log("%d", protocol); | |
405 | break; | |
406 | } | |
407 | } | |
408 | ||
409 | ||
c16f9ed3 | 410 | #ifdef TARGET_NR__newselect |
33189d31 | 411 | static void |
c16f9ed3 | 412 | print_fdset(int n, abi_ulong target_fds_addr) |
33189d31 TS |
413 | { |
414 | int i; | |
415 | ||
416 | gemu_log("["); | |
417 | if( target_fds_addr ) { | |
579a97f7 | 418 | abi_long *target_fds; |
33189d31 | 419 | |
579a97f7 FB |
420 | target_fds = lock_user(VERIFY_READ, |
421 | target_fds_addr, | |
422 | sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), | |
423 | 1); | |
424 | ||
425 | if (!target_fds) | |
33189d31 TS |
426 | return; |
427 | ||
33189d31 | 428 | for (i=n; i>=0; i--) { |
cbb21eed | 429 | if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) |
33189d31 TS |
430 | gemu_log("%d,", i ); |
431 | } | |
432 | unlock_user(target_fds, target_fds_addr, 0); | |
433 | } | |
434 | gemu_log("]"); | |
435 | } | |
c16f9ed3 | 436 | #endif |
33189d31 TS |
437 | |
438 | /* | |
439 | * Sysycall specific output functions | |
440 | */ | |
441 | ||
442 | /* select */ | |
c16f9ed3 | 443 | #ifdef TARGET_NR__newselect |
33189d31 TS |
444 | static long newselect_arg1 = 0; |
445 | static long newselect_arg2 = 0; | |
446 | static long newselect_arg3 = 0; | |
447 | static long newselect_arg4 = 0; | |
448 | static long newselect_arg5 = 0; | |
449 | ||
450 | static void | |
7ccfb2eb | 451 | print_newselect(const struct syscallname *name, |
c16f9ed3 FB |
452 | abi_long arg1, abi_long arg2, abi_long arg3, |
453 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 454 | { |
c16f9ed3 | 455 | gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); |
33189d31 TS |
456 | print_fdset(arg1, arg2); |
457 | gemu_log(","); | |
458 | print_fdset(arg1, arg3); | |
459 | gemu_log(","); | |
460 | print_fdset(arg1, arg4); | |
461 | gemu_log(","); | |
74d753ac | 462 | print_timeval(arg5, 1); |
33189d31 TS |
463 | gemu_log(")"); |
464 | ||
465 | /* save for use in the return output function below */ | |
466 | newselect_arg1=arg1; | |
467 | newselect_arg2=arg2; | |
468 | newselect_arg3=arg3; | |
469 | newselect_arg4=arg4; | |
470 | newselect_arg5=arg5; | |
471 | } | |
c16f9ed3 | 472 | #endif |
33189d31 | 473 | |
3e46b2ef | 474 | #ifdef TARGET_NR_semctl |
33189d31 | 475 | static void |
7ccfb2eb | 476 | print_semctl(const struct syscallname *name, |
c16f9ed3 FB |
477 | abi_long arg1, abi_long arg2, abi_long arg3, |
478 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 479 | { |
c16f9ed3 | 480 | gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2); |
33189d31 | 481 | print_ipc_cmd(arg3); |
c16f9ed3 | 482 | gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
33189d31 | 483 | } |
3e46b2ef | 484 | #endif |
33189d31 TS |
485 | |
486 | static void | |
7ccfb2eb | 487 | print_execve(const struct syscallname *name, |
c16f9ed3 FB |
488 | abi_long arg1, abi_long arg2, abi_long arg3, |
489 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 490 | { |
c16f9ed3 | 491 | abi_ulong arg_ptr_addr; |
33189d31 TS |
492 | char *s; |
493 | ||
579a97f7 | 494 | if (!(s = lock_user_string(arg1))) |
33189d31 | 495 | return; |
33189d31 TS |
496 | gemu_log("%s(\"%s\",{", name->name, s); |
497 | unlock_user(s, arg1, 0); | |
498 | ||
c16f9ed3 | 499 | for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { |
98448f58 | 500 | abi_ulong *arg_ptr, arg_addr; |
33189d31 | 501 | |
c16f9ed3 | 502 | arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); |
579a97f7 | 503 | if (!arg_ptr) |
33189d31 | 504 | return; |
cbb21eed | 505 | arg_addr = tswapal(*arg_ptr); |
33189d31 TS |
506 | unlock_user(arg_ptr, arg_ptr_addr, 0); |
507 | if (!arg_addr) | |
508 | break; | |
579a97f7 FB |
509 | if ((s = lock_user_string(arg_addr))) { |
510 | gemu_log("\"%s\",", s); | |
98448f58 | 511 | unlock_user(s, arg_addr, 0); |
579a97f7 | 512 | } |
33189d31 TS |
513 | } |
514 | ||
515 | gemu_log("NULL})"); | |
516 | } | |
517 | ||
c16f9ed3 | 518 | #ifdef TARGET_NR_ipc |
33189d31 | 519 | static void |
7ccfb2eb | 520 | print_ipc(const struct syscallname *name, |
c16f9ed3 FB |
521 | abi_long arg1, abi_long arg2, abi_long arg3, |
522 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
523 | { |
524 | switch(arg1) { | |
525 | case IPCOP_semctl: | |
7ccfb2eb BS |
526 | gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2); |
527 | print_ipc_cmd(arg3); | |
528 | gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); | |
33189d31 TS |
529 | break; |
530 | default: | |
c16f9ed3 | 531 | gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")", |
33189d31 TS |
532 | name->name, arg1, arg2, arg3, arg4); |
533 | } | |
534 | } | |
c16f9ed3 | 535 | #endif |
33189d31 TS |
536 | |
537 | /* | |
538 | * Variants for the return value output function | |
539 | */ | |
540 | ||
541 | static void | |
7ccfb2eb | 542 | print_syscall_ret_addr(const struct syscallname *name, abi_long ret) |
33189d31 | 543 | { |
7dcdaeaf | 544 | const char *errstr = NULL; |
962b289e | 545 | |
2a7e1245 PM |
546 | if (ret < 0) { |
547 | errstr = target_strerror(-ret); | |
962b289e | 548 | } |
2a7e1245 PM |
549 | if (errstr) { |
550 | gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); | |
33189d31 | 551 | } else { |
29fa23e7 | 552 | gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
33189d31 TS |
553 | } |
554 | } | |
555 | ||
f3e3285d | 556 | #if 0 /* currently unused */ |
33189d31 | 557 | static void |
c16f9ed3 | 558 | print_syscall_ret_raw(struct syscallname *name, abi_long ret) |
33189d31 | 559 | { |
29fa23e7 | 560 | gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
33189d31 | 561 | } |
f3e3285d | 562 | #endif |
33189d31 | 563 | |
f3e3285d | 564 | #ifdef TARGET_NR__newselect |
33189d31 | 565 | static void |
7ccfb2eb | 566 | print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) |
33189d31 | 567 | { |
29fa23e7 | 568 | gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); |
33189d31 TS |
569 | print_fdset(newselect_arg1,newselect_arg2); |
570 | gemu_log(","); | |
571 | print_fdset(newselect_arg1,newselect_arg3); | |
572 | gemu_log(","); | |
573 | print_fdset(newselect_arg1,newselect_arg4); | |
574 | gemu_log(","); | |
74d753ac | 575 | print_timeval(newselect_arg5, 1); |
33189d31 TS |
576 | gemu_log(")\n"); |
577 | } | |
f3e3285d | 578 | #endif |
33189d31 | 579 | |
19f59bce AM |
580 | /* special meanings of adjtimex()' non-negative return values */ |
581 | #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */ | |
582 | #define TARGET_TIME_INS 1 /* insert leap second */ | |
583 | #define TARGET_TIME_DEL 2 /* delete leap second */ | |
584 | #define TARGET_TIME_OOP 3 /* leap second in progress */ | |
585 | #define TARGET_TIME_WAIT 4 /* leap second has occurred */ | |
586 | #define TARGET_TIME_ERROR 5 /* clock not synchronized */ | |
587 | static void | |
588 | print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) | |
589 | { | |
590 | const char *errstr = NULL; | |
591 | ||
592 | gemu_log(" = "); | |
593 | if (ret < 0) { | |
594 | gemu_log("-1 errno=%d", errno); | |
595 | errstr = target_strerror(-ret); | |
596 | if (errstr) { | |
597 | gemu_log(" (%s)", errstr); | |
598 | } | |
599 | } else { | |
600 | gemu_log(TARGET_ABI_FMT_ld, ret); | |
601 | switch (ret) { | |
602 | case TARGET_TIME_OK: | |
603 | gemu_log(" TIME_OK (clock synchronized, no leap second)"); | |
604 | break; | |
605 | case TARGET_TIME_INS: | |
606 | gemu_log(" TIME_INS (insert leap second)"); | |
607 | break; | |
608 | case TARGET_TIME_DEL: | |
609 | gemu_log(" TIME_DEL (delete leap second)"); | |
610 | break; | |
611 | case TARGET_TIME_OOP: | |
612 | gemu_log(" TIME_OOP (leap second in progress)"); | |
613 | break; | |
614 | case TARGET_TIME_WAIT: | |
615 | gemu_log(" TIME_WAIT (leap second has occurred)"); | |
616 | break; | |
617 | case TARGET_TIME_ERROR: | |
618 | gemu_log(" TIME_ERROR (clock not synchronized)"); | |
619 | break; | |
620 | } | |
621 | } | |
622 | ||
623 | gemu_log("\n"); | |
624 | } | |
625 | ||
74d753ac MW |
626 | UNUSED static struct flags access_flags[] = { |
627 | FLAG_GENERIC(F_OK), | |
628 | FLAG_GENERIC(R_OK), | |
629 | FLAG_GENERIC(W_OK), | |
630 | FLAG_GENERIC(X_OK), | |
631 | FLAG_END, | |
632 | }; | |
633 | ||
634 | UNUSED static struct flags at_file_flags[] = { | |
635 | #ifdef AT_EACCESS | |
636 | FLAG_GENERIC(AT_EACCESS), | |
637 | #endif | |
638 | #ifdef AT_SYMLINK_NOFOLLOW | |
639 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), | |
640 | #endif | |
641 | FLAG_END, | |
642 | }; | |
643 | ||
644 | UNUSED static struct flags unlinkat_flags[] = { | |
645 | #ifdef AT_REMOVEDIR | |
646 | FLAG_GENERIC(AT_REMOVEDIR), | |
647 | #endif | |
648 | FLAG_END, | |
649 | }; | |
650 | ||
651 | UNUSED static struct flags mode_flags[] = { | |
652 | FLAG_GENERIC(S_IFSOCK), | |
653 | FLAG_GENERIC(S_IFLNK), | |
654 | FLAG_GENERIC(S_IFREG), | |
655 | FLAG_GENERIC(S_IFBLK), | |
656 | FLAG_GENERIC(S_IFDIR), | |
657 | FLAG_GENERIC(S_IFCHR), | |
658 | FLAG_GENERIC(S_IFIFO), | |
659 | FLAG_END, | |
660 | }; | |
661 | ||
662 | UNUSED static struct flags open_access_flags[] = { | |
663 | FLAG_TARGET(O_RDONLY), | |
664 | FLAG_TARGET(O_WRONLY), | |
665 | FLAG_TARGET(O_RDWR), | |
666 | FLAG_END, | |
667 | }; | |
668 | ||
669 | UNUSED static struct flags open_flags[] = { | |
670 | FLAG_TARGET(O_APPEND), | |
671 | FLAG_TARGET(O_CREAT), | |
672 | FLAG_TARGET(O_DIRECTORY), | |
673 | FLAG_TARGET(O_EXCL), | |
674 | FLAG_TARGET(O_LARGEFILE), | |
675 | FLAG_TARGET(O_NOCTTY), | |
676 | FLAG_TARGET(O_NOFOLLOW), | |
677 | FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ | |
afc8763f RH |
678 | FLAG_TARGET(O_DSYNC), |
679 | FLAG_TARGET(__O_SYNC), | |
74d753ac MW |
680 | FLAG_TARGET(O_TRUNC), |
681 | #ifdef O_DIRECT | |
682 | FLAG_TARGET(O_DIRECT), | |
afc8763f RH |
683 | #endif |
684 | #ifdef O_NOATIME | |
685 | FLAG_TARGET(O_NOATIME), | |
686 | #endif | |
687 | #ifdef O_CLOEXEC | |
688 | FLAG_TARGET(O_CLOEXEC), | |
689 | #endif | |
690 | #ifdef O_PATH | |
691 | FLAG_TARGET(O_PATH), | |
74d753ac MW |
692 | #endif |
693 | FLAG_END, | |
694 | }; | |
695 | ||
696 | UNUSED static struct flags mount_flags[] = { | |
697 | #ifdef MS_BIND | |
698 | FLAG_GENERIC(MS_BIND), | |
699 | #endif | |
700 | #ifdef MS_DIRSYNC | |
701 | FLAG_GENERIC(MS_DIRSYNC), | |
702 | #endif | |
703 | FLAG_GENERIC(MS_MANDLOCK), | |
704 | #ifdef MS_MOVE | |
705 | FLAG_GENERIC(MS_MOVE), | |
706 | #endif | |
707 | FLAG_GENERIC(MS_NOATIME), | |
708 | FLAG_GENERIC(MS_NODEV), | |
709 | FLAG_GENERIC(MS_NODIRATIME), | |
710 | FLAG_GENERIC(MS_NOEXEC), | |
711 | FLAG_GENERIC(MS_NOSUID), | |
712 | FLAG_GENERIC(MS_RDONLY), | |
713 | #ifdef MS_RELATIME | |
714 | FLAG_GENERIC(MS_RELATIME), | |
715 | #endif | |
716 | FLAG_GENERIC(MS_REMOUNT), | |
717 | FLAG_GENERIC(MS_SYNCHRONOUS), | |
718 | FLAG_END, | |
719 | }; | |
720 | ||
721 | UNUSED static struct flags umount2_flags[] = { | |
722 | #ifdef MNT_FORCE | |
723 | FLAG_GENERIC(MNT_FORCE), | |
724 | #endif | |
725 | #ifdef MNT_DETACH | |
726 | FLAG_GENERIC(MNT_DETACH), | |
727 | #endif | |
728 | #ifdef MNT_EXPIRE | |
729 | FLAG_GENERIC(MNT_EXPIRE), | |
730 | #endif | |
731 | FLAG_END, | |
732 | }; | |
733 | ||
734 | UNUSED static struct flags mmap_prot_flags[] = { | |
735 | FLAG_GENERIC(PROT_NONE), | |
736 | FLAG_GENERIC(PROT_EXEC), | |
737 | FLAG_GENERIC(PROT_READ), | |
738 | FLAG_GENERIC(PROT_WRITE), | |
9e0b74a4 PB |
739 | FLAG_TARGET(PROT_SEM), |
740 | FLAG_GENERIC(PROT_GROWSDOWN), | |
741 | FLAG_GENERIC(PROT_GROWSUP), | |
74d753ac MW |
742 | FLAG_END, |
743 | }; | |
744 | ||
745 | UNUSED static struct flags mmap_flags[] = { | |
746 | FLAG_TARGET(MAP_SHARED), | |
747 | FLAG_TARGET(MAP_PRIVATE), | |
748 | FLAG_TARGET(MAP_ANONYMOUS), | |
749 | FLAG_TARGET(MAP_DENYWRITE), | |
750 | FLAG_TARGET(MAP_FIXED), | |
751 | FLAG_TARGET(MAP_GROWSDOWN), | |
906c1b8e | 752 | FLAG_TARGET(MAP_EXECUTABLE), |
74d753ac MW |
753 | #ifdef MAP_LOCKED |
754 | FLAG_TARGET(MAP_LOCKED), | |
755 | #endif | |
756 | #ifdef MAP_NONBLOCK | |
757 | FLAG_TARGET(MAP_NONBLOCK), | |
758 | #endif | |
759 | FLAG_TARGET(MAP_NORESERVE), | |
760 | #ifdef MAP_POPULATE | |
761 | FLAG_TARGET(MAP_POPULATE), | |
906c1b8e MF |
762 | #endif |
763 | #ifdef TARGET_MAP_UNINITIALIZED | |
764 | FLAG_TARGET(MAP_UNINITIALIZED), | |
74d753ac MW |
765 | #endif |
766 | FLAG_END, | |
767 | }; | |
768 | ||
608e5592 LV |
769 | UNUSED static struct flags clone_flags[] = { |
770 | FLAG_GENERIC(CLONE_VM), | |
771 | FLAG_GENERIC(CLONE_FS), | |
772 | FLAG_GENERIC(CLONE_FILES), | |
773 | FLAG_GENERIC(CLONE_SIGHAND), | |
774 | FLAG_GENERIC(CLONE_PTRACE), | |
775 | FLAG_GENERIC(CLONE_VFORK), | |
776 | FLAG_GENERIC(CLONE_PARENT), | |
777 | FLAG_GENERIC(CLONE_THREAD), | |
778 | FLAG_GENERIC(CLONE_NEWNS), | |
779 | FLAG_GENERIC(CLONE_SYSVSEM), | |
780 | FLAG_GENERIC(CLONE_SETTLS), | |
781 | FLAG_GENERIC(CLONE_PARENT_SETTID), | |
782 | FLAG_GENERIC(CLONE_CHILD_CLEARTID), | |
783 | FLAG_GENERIC(CLONE_DETACHED), | |
784 | FLAG_GENERIC(CLONE_UNTRACED), | |
785 | FLAG_GENERIC(CLONE_CHILD_SETTID), | |
6f11f013 | 786 | #if defined(CLONE_NEWUTS) |
608e5592 | 787 | FLAG_GENERIC(CLONE_NEWUTS), |
6f11f013 SW |
788 | #endif |
789 | #if defined(CLONE_NEWIPC) | |
608e5592 | 790 | FLAG_GENERIC(CLONE_NEWIPC), |
6f11f013 SW |
791 | #endif |
792 | #if defined(CLONE_NEWUSER) | |
608e5592 | 793 | FLAG_GENERIC(CLONE_NEWUSER), |
6f11f013 SW |
794 | #endif |
795 | #if defined(CLONE_NEWPID) | |
608e5592 | 796 | FLAG_GENERIC(CLONE_NEWPID), |
6f11f013 SW |
797 | #endif |
798 | #if defined(CLONE_NEWNET) | |
608e5592 | 799 | FLAG_GENERIC(CLONE_NEWNET), |
6f11f013 SW |
800 | #endif |
801 | #if defined(CLONE_IO) | |
608e5592 | 802 | FLAG_GENERIC(CLONE_IO), |
6f11f013 | 803 | #endif |
608e5592 LV |
804 | FLAG_END, |
805 | }; | |
806 | ||
fb3aabf3 LV |
807 | UNUSED static struct flags msg_flags[] = { |
808 | /* send */ | |
809 | FLAG_GENERIC(MSG_CONFIRM), | |
810 | FLAG_GENERIC(MSG_DONTROUTE), | |
811 | FLAG_GENERIC(MSG_DONTWAIT), | |
812 | FLAG_GENERIC(MSG_EOR), | |
813 | FLAG_GENERIC(MSG_MORE), | |
814 | FLAG_GENERIC(MSG_NOSIGNAL), | |
815 | FLAG_GENERIC(MSG_OOB), | |
816 | /* recv */ | |
817 | FLAG_GENERIC(MSG_CMSG_CLOEXEC), | |
818 | FLAG_GENERIC(MSG_ERRQUEUE), | |
819 | FLAG_GENERIC(MSG_PEEK), | |
820 | FLAG_GENERIC(MSG_TRUNC), | |
821 | FLAG_GENERIC(MSG_WAITALL), | |
822 | /* recvmsg */ | |
823 | FLAG_GENERIC(MSG_CTRUNC), | |
824 | FLAG_END, | |
825 | }; | |
826 | ||
74d753ac MW |
827 | /* |
828 | * print_xxx utility functions. These are used to print syscall | |
829 | * parameters in certain format. All of these have parameter | |
830 | * named 'last'. This parameter is used to add comma to output | |
831 | * when last == 0. | |
832 | */ | |
833 | ||
834 | static const char * | |
835 | get_comma(int last) | |
836 | { | |
837 | return ((last) ? "" : ","); | |
838 | } | |
839 | ||
840 | static void | |
d2ee72a5 | 841 | print_flags(const struct flags *f, abi_long flags, int last) |
74d753ac MW |
842 | { |
843 | const char *sep = ""; | |
74d753ac MW |
844 | int n; |
845 | ||
74d753ac MW |
846 | if ((flags == 0) && (f->f_value == 0)) { |
847 | gemu_log("%s%s", f->f_string, get_comma(last)); | |
848 | return; | |
849 | } | |
850 | for (n = 0; f->f_string != NULL; f++) { | |
851 | if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { | |
852 | gemu_log("%s%s", sep, f->f_string); | |
853 | flags &= ~f->f_value; | |
854 | sep = "|"; | |
855 | n++; | |
856 | } | |
857 | } | |
858 | ||
859 | if (n > 0) { | |
860 | /* print rest of the flags as numeric */ | |
861 | if (flags != 0) { | |
d2ee72a5 | 862 | gemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); |
74d753ac MW |
863 | } else { |
864 | gemu_log("%s", get_comma(last)); | |
865 | } | |
866 | } else { | |
867 | /* no string version of flags found, print them in hex then */ | |
d2ee72a5 | 868 | gemu_log("%#x%s", (unsigned int)flags, get_comma(last)); |
74d753ac MW |
869 | } |
870 | } | |
871 | ||
872 | static void | |
d2ee72a5 | 873 | print_at_dirfd(abi_long dirfd, int last) |
74d753ac | 874 | { |
74d753ac MW |
875 | #ifdef AT_FDCWD |
876 | if (dirfd == AT_FDCWD) { | |
877 | gemu_log("AT_FDCWD%s", get_comma(last)); | |
878 | return; | |
879 | } | |
880 | #endif | |
d2ee72a5 | 881 | gemu_log("%d%s", (int)dirfd, get_comma(last)); |
74d753ac MW |
882 | } |
883 | ||
884 | static void | |
d2ee72a5 | 885 | print_file_mode(abi_long mode, int last) |
74d753ac MW |
886 | { |
887 | const char *sep = ""; | |
888 | const struct flags *m; | |
74d753ac MW |
889 | |
890 | for (m = &mode_flags[0]; m->f_string != NULL; m++) { | |
891 | if ((m->f_value & mode) == m->f_value) { | |
892 | gemu_log("%s%s", m->f_string, sep); | |
893 | sep = "|"; | |
894 | mode &= ~m->f_value; | |
895 | break; | |
896 | } | |
897 | } | |
898 | ||
899 | mode &= ~S_IFMT; | |
900 | /* print rest of the mode as octal */ | |
901 | if (mode != 0) | |
d2ee72a5 | 902 | gemu_log("%s%#o", sep, (unsigned int)mode); |
74d753ac MW |
903 | |
904 | gemu_log("%s", get_comma(last)); | |
905 | } | |
906 | ||
907 | static void | |
d2ee72a5 | 908 | print_open_flags(abi_long flags, int last) |
74d753ac | 909 | { |
74d753ac MW |
910 | print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); |
911 | flags &= ~TARGET_O_ACCMODE; | |
912 | if (flags == 0) { | |
913 | gemu_log("%s", get_comma(last)); | |
914 | return; | |
915 | } | |
916 | gemu_log("|"); | |
917 | print_flags(open_flags, flags, last); | |
918 | } | |
919 | ||
920 | static void | |
921 | print_syscall_prologue(const struct syscallname *sc) | |
922 | { | |
923 | gemu_log("%s(", sc->name); | |
924 | } | |
925 | ||
926 | /*ARGSUSED*/ | |
927 | static void | |
928 | print_syscall_epilogue(const struct syscallname *sc) | |
929 | { | |
930 | (void)sc; | |
931 | gemu_log(")"); | |
932 | } | |
933 | ||
934 | static void | |
935 | print_string(abi_long addr, int last) | |
936 | { | |
937 | char *s; | |
938 | ||
939 | if ((s = lock_user_string(addr)) != NULL) { | |
940 | gemu_log("\"%s\"%s", s, get_comma(last)); | |
941 | unlock_user(s, addr, 0); | |
942 | } else { | |
943 | /* can't get string out of it, so print it as pointer */ | |
944 | print_pointer(addr, last); | |
945 | } | |
946 | } | |
947 | ||
fb3aabf3 LV |
948 | #define MAX_PRINT_BUF 40 |
949 | static void | |
950 | print_buf(abi_long addr, abi_long len, int last) | |
951 | { | |
952 | uint8_t *s; | |
953 | int i; | |
954 | ||
955 | s = lock_user(VERIFY_READ, addr, len, 1); | |
956 | if (s) { | |
957 | gemu_log("\""); | |
958 | for (i = 0; i < MAX_PRINT_BUF && i < len; i++) { | |
959 | if (isprint(s[i])) { | |
960 | gemu_log("%c", s[i]); | |
961 | } else { | |
962 | gemu_log("\\%o", s[i]); | |
963 | } | |
964 | } | |
965 | gemu_log("\""); | |
966 | if (i != len) { | |
967 | gemu_log("..."); | |
968 | } | |
969 | if (!last) { | |
970 | gemu_log(","); | |
971 | } | |
972 | unlock_user(s, addr, 0); | |
973 | } else { | |
974 | print_pointer(addr, last); | |
975 | } | |
976 | } | |
977 | ||
74d753ac MW |
978 | /* |
979 | * Prints out raw parameter using given format. Caller needs | |
980 | * to do byte swapping if needed. | |
981 | */ | |
982 | static void | |
983 | print_raw_param(const char *fmt, abi_long param, int last) | |
984 | { | |
985 | char format[64]; | |
986 | ||
987 | (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); | |
988 | gemu_log(format, param); | |
989 | } | |
990 | ||
991 | static void | |
992 | print_pointer(abi_long p, int last) | |
993 | { | |
994 | if (p == 0) | |
995 | gemu_log("NULL%s", get_comma(last)); | |
996 | else | |
997 | gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); | |
998 | } | |
999 | ||
1000 | /* | |
1001 | * Reads 32-bit (int) number from guest address space from | |
1002 | * address 'addr' and prints it. | |
1003 | */ | |
1004 | static void | |
1005 | print_number(abi_long addr, int last) | |
1006 | { | |
1007 | if (addr == 0) { | |
1008 | gemu_log("NULL%s", get_comma(last)); | |
1009 | } else { | |
1010 | int num; | |
1011 | ||
1012 | get_user_s32(num, addr); | |
1013 | gemu_log("[%d]%s", num, get_comma(last)); | |
1014 | } | |
1015 | } | |
1016 | ||
1017 | static void | |
1018 | print_timeval(abi_ulong tv_addr, int last) | |
1019 | { | |
1020 | if( tv_addr ) { | |
1021 | struct target_timeval *tv; | |
1022 | ||
1023 | tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); | |
1024 | if (!tv) | |
1025 | return; | |
1026 | gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", | |
910ee4e5 | 1027 | tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); |
74d753ac MW |
1028 | unlock_user(tv, tv_addr, 0); |
1029 | } else | |
1030 | gemu_log("NULL%s", get_comma(last)); | |
1031 | } | |
1032 | ||
1033 | #undef UNUSED | |
1034 | ||
1035 | #ifdef TARGET_NR_accept | |
1036 | static void | |
1037 | print_accept(const struct syscallname *name, | |
1038 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1039 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1040 | { | |
1041 | print_syscall_prologue(name); | |
d2ee72a5 | 1042 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
1043 | print_pointer(arg1, 0); |
1044 | print_number(arg2, 1); | |
1045 | print_syscall_epilogue(name); | |
1046 | } | |
1047 | #endif | |
1048 | ||
1049 | #ifdef TARGET_NR_access | |
1050 | static void | |
1051 | print_access(const struct syscallname *name, | |
1052 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1053 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1054 | { | |
1055 | print_syscall_prologue(name); | |
1056 | print_string(arg0, 0); | |
1057 | print_flags(access_flags, arg1, 1); | |
1058 | print_syscall_epilogue(name); | |
1059 | } | |
1060 | #endif | |
1061 | ||
1062 | #ifdef TARGET_NR_brk | |
1063 | static void | |
1064 | print_brk(const struct syscallname *name, | |
1065 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1066 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1067 | { | |
1068 | print_syscall_prologue(name); | |
1069 | print_pointer(arg0, 1); | |
1070 | print_syscall_epilogue(name); | |
1071 | } | |
1072 | #endif | |
1073 | ||
1074 | #ifdef TARGET_NR_chdir | |
1075 | static void | |
1076 | print_chdir(const struct syscallname *name, | |
1077 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1078 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1079 | { | |
1080 | print_syscall_prologue(name); | |
1081 | print_string(arg0, 1); | |
1082 | print_syscall_epilogue(name); | |
1083 | } | |
1084 | #endif | |
1085 | ||
1086 | #ifdef TARGET_NR_chmod | |
1087 | static void | |
1088 | print_chmod(const struct syscallname *name, | |
1089 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1090 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1091 | { | |
1092 | print_syscall_prologue(name); | |
1093 | print_string(arg0, 0); | |
1094 | print_file_mode(arg1, 1); | |
1095 | print_syscall_epilogue(name); | |
1096 | } | |
1097 | #endif | |
1098 | ||
608e5592 | 1099 | #ifdef TARGET_NR_clone |
84bd8284 LV |
1100 | static void do_print_clone(unsigned int flags, abi_ulong newsp, |
1101 | abi_ulong parent_tidptr, target_ulong newtls, | |
1102 | abi_ulong child_tidptr) | |
1103 | { | |
1104 | print_flags(clone_flags, flags, 0); | |
1105 | print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0); | |
1106 | print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0); | |
1107 | print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0); | |
1108 | print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1); | |
1109 | } | |
1110 | ||
608e5592 LV |
1111 | static void |
1112 | print_clone(const struct syscallname *name, | |
84bd8284 LV |
1113 | abi_long arg1, abi_long arg2, abi_long arg3, |
1114 | abi_long arg4, abi_long arg5, abi_long arg6) | |
608e5592 LV |
1115 | { |
1116 | print_syscall_prologue(name); | |
84bd8284 LV |
1117 | #if defined(TARGET_MICROBLAZE) |
1118 | do_print_clone(arg1, arg2, arg4, arg6, arg5); | |
1119 | #elif defined(TARGET_CLONE_BACKWARDS) | |
1120 | do_print_clone(arg1, arg2, arg3, arg4, arg5); | |
1121 | #elif defined(TARGET_CLONE_BACKWARDS2) | |
1122 | do_print_clone(arg2, arg1, arg3, arg5, arg4); | |
608e5592 | 1123 | #else |
84bd8284 | 1124 | do_print_clone(arg1, arg2, arg3, arg5, arg4); |
608e5592 LV |
1125 | #endif |
1126 | print_syscall_epilogue(name); | |
1127 | } | |
1128 | #endif | |
1129 | ||
74d753ac MW |
1130 | #ifdef TARGET_NR_creat |
1131 | static void | |
1132 | print_creat(const struct syscallname *name, | |
1133 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1134 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1135 | { | |
1136 | print_syscall_prologue(name); | |
1137 | print_string(arg0, 0); | |
1138 | print_file_mode(arg1, 1); | |
1139 | print_syscall_epilogue(name); | |
1140 | } | |
1141 | #endif | |
1142 | ||
1143 | #ifdef TARGET_NR_execv | |
1144 | static void | |
1145 | print_execv(const struct syscallname *name, | |
1146 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1147 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1148 | { | |
1149 | print_syscall_prologue(name); | |
1150 | print_string(arg0, 0); | |
d2ee72a5 | 1151 | print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1); |
74d753ac MW |
1152 | print_syscall_epilogue(name); |
1153 | } | |
1154 | #endif | |
1155 | ||
1156 | #ifdef TARGET_NR_faccessat | |
1157 | static void | |
1158 | print_faccessat(const struct syscallname *name, | |
1159 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1160 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1161 | { | |
1162 | print_syscall_prologue(name); | |
1163 | print_at_dirfd(arg0, 0); | |
1164 | print_string(arg1, 0); | |
1165 | print_flags(access_flags, arg2, 0); | |
1166 | print_flags(at_file_flags, arg3, 1); | |
1167 | print_syscall_epilogue(name); | |
1168 | } | |
1169 | #endif | |
1170 | ||
1171 | #ifdef TARGET_NR_fchmodat | |
1172 | static void | |
1173 | print_fchmodat(const struct syscallname *name, | |
1174 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1175 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1176 | { | |
1177 | print_syscall_prologue(name); | |
1178 | print_at_dirfd(arg0, 0); | |
1179 | print_string(arg1, 0); | |
1180 | print_file_mode(arg2, 0); | |
1181 | print_flags(at_file_flags, arg3, 1); | |
1182 | print_syscall_epilogue(name); | |
1183 | } | |
1184 | #endif | |
1185 | ||
1186 | #ifdef TARGET_NR_fchownat | |
1187 | static void | |
1188 | print_fchownat(const struct syscallname *name, | |
1189 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1190 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1191 | { | |
1192 | print_syscall_prologue(name); | |
1193 | print_at_dirfd(arg0, 0); | |
1194 | print_string(arg1, 0); | |
d2ee72a5 LV |
1195 | print_raw_param("%d", arg2, 0); |
1196 | print_raw_param("%d", arg3, 0); | |
74d753ac MW |
1197 | print_flags(at_file_flags, arg4, 1); |
1198 | print_syscall_epilogue(name); | |
1199 | } | |
1200 | #endif | |
1201 | ||
1202 | #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) | |
1203 | static void | |
1204 | print_fcntl(const struct syscallname *name, | |
1205 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1206 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1207 | { | |
1208 | print_syscall_prologue(name); | |
d2ee72a5 | 1209 | print_raw_param("%d", arg0, 0); |
d95ec14f LV |
1210 | switch(arg1) { |
1211 | case TARGET_F_DUPFD: | |
1212 | gemu_log("F_DUPFD,"); | |
1213 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
1214 | break; | |
1215 | case TARGET_F_GETFD: | |
1216 | gemu_log("F_GETFD"); | |
1217 | break; | |
1218 | case TARGET_F_SETFD: | |
1219 | gemu_log("F_SETFD,"); | |
1220 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
1221 | break; | |
1222 | case TARGET_F_GETFL: | |
1223 | gemu_log("F_GETFL"); | |
1224 | break; | |
1225 | case TARGET_F_SETFL: | |
1226 | gemu_log("F_SETFL,"); | |
1227 | print_open_flags(arg2, 1); | |
1228 | break; | |
1229 | case TARGET_F_GETLK: | |
1230 | gemu_log("F_GETLK,"); | |
1231 | print_pointer(arg2, 1); | |
1232 | break; | |
1233 | case TARGET_F_SETLK: | |
1234 | gemu_log("F_SETLK,"); | |
1235 | print_pointer(arg2, 1); | |
1236 | break; | |
1237 | case TARGET_F_SETLKW: | |
1238 | gemu_log("F_SETLKW,"); | |
1239 | print_pointer(arg2, 1); | |
1240 | break; | |
1241 | case TARGET_F_GETOWN: | |
1242 | gemu_log("F_GETOWN"); | |
1243 | break; | |
1244 | case TARGET_F_SETOWN: | |
1245 | gemu_log("F_SETOWN,"); | |
1246 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
1247 | break; | |
1248 | case TARGET_F_GETSIG: | |
1249 | gemu_log("F_GETSIG"); | |
1250 | break; | |
1251 | case TARGET_F_SETSIG: | |
1252 | gemu_log("F_SETSIG,"); | |
1253 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
1254 | break; | |
1255 | #if TARGET_ABI_BITS == 32 | |
1256 | case TARGET_F_GETLK64: | |
1257 | gemu_log("F_GETLK64,"); | |
1258 | print_pointer(arg2, 1); | |
1259 | break; | |
1260 | case TARGET_F_SETLK64: | |
1261 | gemu_log("F_SETLK64,"); | |
1262 | print_pointer(arg2, 1); | |
1263 | break; | |
1264 | case TARGET_F_SETLKW64: | |
1265 | gemu_log("F_SETLKW64,"); | |
1266 | print_pointer(arg2, 1); | |
1267 | break; | |
1268 | #endif | |
1269 | case TARGET_F_SETLEASE: | |
1270 | gemu_log("F_SETLEASE,"); | |
1271 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
1272 | break; | |
1273 | case TARGET_F_GETLEASE: | |
1274 | gemu_log("F_GETLEASE"); | |
1275 | break; | |
7e3b92ec PM |
1276 | case TARGET_F_SETPIPE_SZ: |
1277 | gemu_log("F_SETPIPE_SZ,"); | |
1278 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
1279 | break; | |
1280 | case TARGET_F_GETPIPE_SZ: | |
1281 | gemu_log("F_GETPIPE_SZ"); | |
1282 | break; | |
d95ec14f LV |
1283 | case TARGET_F_DUPFD_CLOEXEC: |
1284 | gemu_log("F_DUPFD_CLOEXEC,"); | |
1285 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
1286 | break; | |
1287 | case TARGET_F_NOTIFY: | |
1288 | gemu_log("F_NOTIFY,"); | |
1289 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
1290 | break; | |
1291 | default: | |
1292 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
1293 | print_pointer(arg2, 1); | |
1294 | break; | |
1295 | } | |
74d753ac MW |
1296 | print_syscall_epilogue(name); |
1297 | } | |
1298 | #define print_fcntl64 print_fcntl | |
1299 | #endif | |
1300 | ||
1301 | ||
1302 | #ifdef TARGET_NR_futimesat | |
1303 | static void | |
1304 | print_futimesat(const struct syscallname *name, | |
1305 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1306 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1307 | { | |
1308 | print_syscall_prologue(name); | |
1309 | print_at_dirfd(arg0, 0); | |
1310 | print_string(arg1, 0); | |
1311 | print_timeval(arg2, 0); | |
1312 | print_timeval(arg2 + sizeof (struct target_timeval), 1); | |
1313 | print_syscall_epilogue(name); | |
1314 | } | |
1315 | #endif | |
1316 | ||
1317 | #ifdef TARGET_NR_link | |
1318 | static void | |
1319 | print_link(const struct syscallname *name, | |
1320 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1321 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1322 | { | |
1323 | print_syscall_prologue(name); | |
1324 | print_string(arg0, 0); | |
1325 | print_string(arg1, 1); | |
1326 | print_syscall_epilogue(name); | |
1327 | } | |
1328 | #endif | |
1329 | ||
1330 | #ifdef TARGET_NR_linkat | |
1331 | static void | |
1332 | print_linkat(const struct syscallname *name, | |
1333 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1334 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1335 | { | |
1336 | print_syscall_prologue(name); | |
1337 | print_at_dirfd(arg0, 0); | |
1338 | print_string(arg1, 0); | |
1339 | print_at_dirfd(arg2, 0); | |
1340 | print_string(arg3, 0); | |
1341 | print_flags(at_file_flags, arg4, 1); | |
1342 | print_syscall_epilogue(name); | |
1343 | } | |
1344 | #endif | |
1345 | ||
608e5592 LV |
1346 | #ifdef TARGET_NR__llseek |
1347 | static void | |
1348 | print__llseek(const struct syscallname *name, | |
1349 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1350 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1351 | { | |
1352 | const char *whence = "UNKNOWN"; | |
1353 | print_syscall_prologue(name); | |
1354 | print_raw_param("%d", arg0, 0); | |
1355 | print_raw_param("%ld", arg1, 0); | |
1356 | print_raw_param("%ld", arg2, 0); | |
1357 | print_pointer(arg3, 0); | |
1358 | switch(arg4) { | |
1359 | case SEEK_SET: whence = "SEEK_SET"; break; | |
1360 | case SEEK_CUR: whence = "SEEK_CUR"; break; | |
1361 | case SEEK_END: whence = "SEEK_END"; break; | |
1362 | } | |
1363 | gemu_log("%s",whence); | |
1364 | print_syscall_epilogue(name); | |
1365 | } | |
1366 | #endif | |
1367 | ||
8997d1bd LV |
1368 | #if defined(TARGET_NR_socket) |
1369 | static void | |
1370 | print_socket(const struct syscallname *name, | |
1371 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1372 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1373 | { | |
1374 | abi_ulong domain = arg0, type = arg1, protocol = arg2; | |
1375 | ||
1376 | print_syscall_prologue(name); | |
1377 | print_socket_domain(domain); | |
1378 | gemu_log(","); | |
1379 | print_socket_type(type); | |
1380 | gemu_log(","); | |
1381 | if (domain == AF_PACKET || | |
1382 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
1383 | protocol = tswap16(protocol); | |
1384 | } | |
1385 | print_socket_protocol(domain, type, protocol); | |
1386 | print_syscall_epilogue(name); | |
1387 | } | |
1388 | ||
1389 | #endif | |
1390 | ||
fb3aabf3 LV |
1391 | #if defined(TARGET_NR_socketcall) |
1392 | ||
1393 | #define get_user_ualx(x, gaddr, idx) \ | |
1394 | get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long)) | |
1395 | ||
1396 | static void do_print_socket(const char *name, abi_long arg1) | |
1397 | { | |
1398 | abi_ulong domain, type, protocol; | |
1399 | ||
1400 | get_user_ualx(domain, arg1, 0); | |
1401 | get_user_ualx(type, arg1, 1); | |
1402 | get_user_ualx(protocol, arg1, 2); | |
1403 | gemu_log("%s(", name); | |
1404 | print_socket_domain(domain); | |
1405 | gemu_log(","); | |
1406 | print_socket_type(type); | |
1407 | gemu_log(","); | |
1408 | if (domain == AF_PACKET || | |
1409 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
1410 | protocol = tswap16(protocol); | |
1411 | } | |
1412 | print_socket_protocol(domain, type, protocol); | |
1413 | gemu_log(")"); | |
1414 | } | |
1415 | ||
1416 | static void do_print_sockaddr(const char *name, abi_long arg1) | |
1417 | { | |
1418 | abi_ulong sockfd, addr, addrlen; | |
1419 | ||
1420 | get_user_ualx(sockfd, arg1, 0); | |
1421 | get_user_ualx(addr, arg1, 1); | |
1422 | get_user_ualx(addrlen, arg1, 2); | |
1423 | ||
1424 | gemu_log("%s(", name); | |
1425 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); | |
1426 | print_sockaddr(addr, addrlen); | |
1427 | gemu_log(")"); | |
1428 | } | |
1429 | ||
1430 | static void do_print_listen(const char *name, abi_long arg1) | |
1431 | { | |
1432 | abi_ulong sockfd, backlog; | |
1433 | ||
1434 | get_user_ualx(sockfd, arg1, 0); | |
1435 | get_user_ualx(backlog, arg1, 1); | |
1436 | ||
1437 | gemu_log("%s(", name); | |
1438 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); | |
1439 | print_raw_param(TARGET_ABI_FMT_ld, backlog, 1); | |
1440 | gemu_log(")"); | |
1441 | } | |
1442 | ||
1443 | static void do_print_socketpair(const char *name, abi_long arg1) | |
1444 | { | |
1445 | abi_ulong domain, type, protocol, tab; | |
1446 | ||
1447 | get_user_ualx(domain, arg1, 0); | |
1448 | get_user_ualx(type, arg1, 1); | |
1449 | get_user_ualx(protocol, arg1, 2); | |
1450 | get_user_ualx(tab, arg1, 3); | |
1451 | ||
1452 | gemu_log("%s(", name); | |
1453 | print_socket_domain(domain); | |
1454 | gemu_log(","); | |
1455 | print_socket_type(type); | |
1456 | gemu_log(","); | |
1457 | print_socket_protocol(domain, type, protocol); | |
1458 | gemu_log(","); | |
1459 | print_raw_param(TARGET_ABI_FMT_lx, tab, 1); | |
1460 | gemu_log(")"); | |
1461 | } | |
1462 | ||
1463 | static void do_print_sendrecv(const char *name, abi_long arg1) | |
1464 | { | |
1465 | abi_ulong sockfd, msg, len, flags; | |
1466 | ||
1467 | get_user_ualx(sockfd, arg1, 0); | |
1468 | get_user_ualx(msg, arg1, 1); | |
1469 | get_user_ualx(len, arg1, 2); | |
1470 | get_user_ualx(flags, arg1, 3); | |
1471 | ||
1472 | gemu_log("%s(", name); | |
1473 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); | |
1474 | print_buf(msg, len, 0); | |
1475 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); | |
1476 | print_flags(msg_flags, flags, 1); | |
1477 | gemu_log(")"); | |
1478 | } | |
1479 | ||
1480 | static void do_print_msgaddr(const char *name, abi_long arg1) | |
1481 | { | |
1482 | abi_ulong sockfd, msg, len, flags, addr, addrlen; | |
1483 | ||
1484 | get_user_ualx(sockfd, arg1, 0); | |
1485 | get_user_ualx(msg, arg1, 1); | |
1486 | get_user_ualx(len, arg1, 2); | |
1487 | get_user_ualx(flags, arg1, 3); | |
1488 | get_user_ualx(addr, arg1, 4); | |
1489 | get_user_ualx(addrlen, arg1, 5); | |
1490 | ||
1491 | gemu_log("%s(", name); | |
1492 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); | |
1493 | print_buf(msg, len, 0); | |
1494 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); | |
1495 | print_flags(msg_flags, flags, 0); | |
1496 | print_sockaddr(addr, addrlen); | |
1497 | gemu_log(")"); | |
1498 | } | |
1499 | ||
1500 | static void do_print_shutdown(const char *name, abi_long arg1) | |
1501 | { | |
1502 | abi_ulong sockfd, how; | |
1503 | ||
1504 | get_user_ualx(sockfd, arg1, 0); | |
1505 | get_user_ualx(how, arg1, 1); | |
1506 | ||
1507 | gemu_log("shutdown("); | |
1508 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); | |
1509 | switch (how) { | |
1510 | case SHUT_RD: | |
1511 | gemu_log("SHUT_RD"); | |
1512 | break; | |
1513 | case SHUT_WR: | |
1514 | gemu_log("SHUT_WR"); | |
1515 | break; | |
1516 | case SHUT_RDWR: | |
1517 | gemu_log("SHUT_RDWR"); | |
1518 | break; | |
1519 | default: | |
1520 | print_raw_param(TARGET_ABI_FMT_ld, how, 1); | |
1521 | break; | |
1522 | } | |
1523 | gemu_log(")"); | |
1524 | } | |
1525 | ||
1526 | static void do_print_msg(const char *name, abi_long arg1) | |
1527 | { | |
1528 | abi_ulong sockfd, msg, flags; | |
1529 | ||
1530 | get_user_ualx(sockfd, arg1, 0); | |
1531 | get_user_ualx(msg, arg1, 1); | |
1532 | get_user_ualx(flags, arg1, 2); | |
1533 | ||
1534 | gemu_log("%s(", name); | |
1535 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); | |
1536 | print_pointer(msg, 0); | |
1537 | print_flags(msg_flags, flags, 1); | |
1538 | gemu_log(")"); | |
1539 | } | |
1540 | ||
1541 | static void do_print_sockopt(const char *name, abi_long arg1) | |
1542 | { | |
1543 | abi_ulong sockfd, level, optname, optval, optlen; | |
1544 | ||
1545 | get_user_ualx(sockfd, arg1, 0); | |
1546 | get_user_ualx(level, arg1, 1); | |
1547 | get_user_ualx(optname, arg1, 2); | |
1548 | get_user_ualx(optval, arg1, 3); | |
1549 | get_user_ualx(optlen, arg1, 4); | |
1550 | ||
1551 | gemu_log("%s(", name); | |
1552 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0); | |
1553 | switch (level) { | |
1554 | case SOL_TCP: | |
1555 | gemu_log("SOL_TCP,"); | |
1556 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
1557 | print_pointer(optval, 0); | |
1558 | break; | |
1559 | case SOL_IP: | |
1560 | gemu_log("SOL_IP,"); | |
1561 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
1562 | print_pointer(optval, 0); | |
1563 | break; | |
1564 | case SOL_RAW: | |
1565 | gemu_log("SOL_RAW,"); | |
1566 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
1567 | print_pointer(optval, 0); | |
1568 | break; | |
1569 | case TARGET_SOL_SOCKET: | |
1570 | gemu_log("SOL_SOCKET,"); | |
1571 | switch (optname) { | |
1572 | case TARGET_SO_DEBUG: | |
1573 | gemu_log("SO_DEBUG,"); | |
1574 | print_optint: | |
1575 | print_number(optval, 0); | |
1576 | break; | |
1577 | case TARGET_SO_REUSEADDR: | |
1578 | gemu_log("SO_REUSEADDR,"); | |
1579 | goto print_optint; | |
1580 | case TARGET_SO_TYPE: | |
1581 | gemu_log("SO_TYPE,"); | |
1582 | goto print_optint; | |
1583 | case TARGET_SO_ERROR: | |
1584 | gemu_log("SO_ERROR,"); | |
1585 | goto print_optint; | |
1586 | case TARGET_SO_DONTROUTE: | |
1587 | gemu_log("SO_DONTROUTE,"); | |
1588 | goto print_optint; | |
1589 | case TARGET_SO_BROADCAST: | |
1590 | gemu_log("SO_BROADCAST,"); | |
1591 | goto print_optint; | |
1592 | case TARGET_SO_SNDBUF: | |
1593 | gemu_log("SO_SNDBUF,"); | |
1594 | goto print_optint; | |
1595 | case TARGET_SO_RCVBUF: | |
1596 | gemu_log("SO_RCVBUF,"); | |
1597 | goto print_optint; | |
1598 | case TARGET_SO_KEEPALIVE: | |
1599 | gemu_log("SO_KEEPALIVE,"); | |
1600 | goto print_optint; | |
1601 | case TARGET_SO_OOBINLINE: | |
1602 | gemu_log("SO_OOBINLINE,"); | |
1603 | goto print_optint; | |
1604 | case TARGET_SO_NO_CHECK: | |
1605 | gemu_log("SO_NO_CHECK,"); | |
1606 | goto print_optint; | |
1607 | case TARGET_SO_PRIORITY: | |
1608 | gemu_log("SO_PRIORITY,"); | |
1609 | goto print_optint; | |
1610 | case TARGET_SO_BSDCOMPAT: | |
1611 | gemu_log("SO_BSDCOMPAT,"); | |
1612 | goto print_optint; | |
1613 | case TARGET_SO_PASSCRED: | |
1614 | gemu_log("SO_PASSCRED,"); | |
1615 | goto print_optint; | |
1616 | case TARGET_SO_TIMESTAMP: | |
1617 | gemu_log("SO_TIMESTAMP,"); | |
1618 | goto print_optint; | |
1619 | case TARGET_SO_RCVLOWAT: | |
1620 | gemu_log("SO_RCVLOWAT,"); | |
1621 | goto print_optint; | |
1622 | case TARGET_SO_RCVTIMEO: | |
1623 | gemu_log("SO_RCVTIMEO,"); | |
1624 | print_timeval(optval, 0); | |
1625 | break; | |
1626 | case TARGET_SO_SNDTIMEO: | |
1627 | gemu_log("SO_SNDTIMEO,"); | |
1628 | print_timeval(optval, 0); | |
1629 | break; | |
1630 | case TARGET_SO_ATTACH_FILTER: { | |
1631 | struct target_sock_fprog *fprog; | |
1632 | ||
1633 | gemu_log("SO_ATTACH_FILTER,"); | |
1634 | ||
1635 | if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) { | |
1636 | struct target_sock_filter *filter; | |
1637 | gemu_log("{"); | |
1638 | if (lock_user_struct(VERIFY_READ, filter, | |
1639 | tswapal(fprog->filter), 0)) { | |
1640 | int i; | |
1641 | for (i = 0; i < tswap16(fprog->len) - 1; i++) { | |
1642 | gemu_log("[%d]{0x%x,%d,%d,0x%x},", | |
1643 | i, tswap16(filter[i].code), | |
1644 | filter[i].jt, filter[i].jf, | |
1645 | tswap32(filter[i].k)); | |
1646 | } | |
1647 | gemu_log("[%d]{0x%x,%d,%d,0x%x}", | |
1648 | i, tswap16(filter[i].code), | |
1649 | filter[i].jt, filter[i].jf, | |
1650 | tswap32(filter[i].k)); | |
1651 | } else { | |
1652 | gemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter)); | |
1653 | } | |
1654 | gemu_log(",%d},", tswap16(fprog->len)); | |
1655 | unlock_user(fprog, optval, 0); | |
1656 | } else { | |
1657 | print_pointer(optval, 0); | |
1658 | } | |
1659 | break; | |
1660 | } | |
1661 | default: | |
1662 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
1663 | print_pointer(optval, 0); | |
1664 | break; | |
1665 | } | |
1666 | break; | |
1667 | default: | |
1668 | print_raw_param(TARGET_ABI_FMT_ld, level, 0); | |
1669 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
1670 | print_pointer(optval, 0); | |
1671 | break; | |
1672 | } | |
1673 | print_raw_param(TARGET_ABI_FMT_ld, optlen, 1); | |
1674 | gemu_log(")"); | |
1675 | } | |
1676 | ||
1677 | #define PRINT_SOCKOP(name, func) \ | |
ff71a454 | 1678 | [TARGET_SYS_##name] = { #name, func } |
fb3aabf3 LV |
1679 | |
1680 | static struct { | |
1681 | const char *name; | |
1682 | void (*print)(const char *, abi_long); | |
1683 | } scall[] = { | |
ff71a454 AM |
1684 | PRINT_SOCKOP(SOCKET, do_print_socket), |
1685 | PRINT_SOCKOP(BIND, do_print_sockaddr), | |
1686 | PRINT_SOCKOP(CONNECT, do_print_sockaddr), | |
1687 | PRINT_SOCKOP(LISTEN, do_print_listen), | |
1688 | PRINT_SOCKOP(ACCEPT, do_print_sockaddr), | |
1689 | PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr), | |
1690 | PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr), | |
1691 | PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair), | |
1692 | PRINT_SOCKOP(SEND, do_print_sendrecv), | |
1693 | PRINT_SOCKOP(RECV, do_print_sendrecv), | |
1694 | PRINT_SOCKOP(SENDTO, do_print_msgaddr), | |
1695 | PRINT_SOCKOP(RECVFROM, do_print_msgaddr), | |
1696 | PRINT_SOCKOP(SHUTDOWN, do_print_shutdown), | |
1697 | PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt), | |
1698 | PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt), | |
1699 | PRINT_SOCKOP(SENDMSG, do_print_msg), | |
1700 | PRINT_SOCKOP(RECVMSG, do_print_msg), | |
1701 | PRINT_SOCKOP(ACCEPT4, NULL), | |
1702 | PRINT_SOCKOP(RECVMMSG, NULL), | |
1703 | PRINT_SOCKOP(SENDMMSG, NULL), | |
fb3aabf3 LV |
1704 | }; |
1705 | ||
1706 | static void | |
1707 | print_socketcall(const struct syscallname *name, | |
1708 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1709 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1710 | { | |
1711 | if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) { | |
1712 | scall[arg0].print(scall[arg0].name, arg1); | |
1713 | return; | |
1714 | } | |
1715 | print_syscall_prologue(name); | |
1716 | print_raw_param(TARGET_ABI_FMT_ld, arg0, 0); | |
1717 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
1718 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
1719 | print_raw_param(TARGET_ABI_FMT_ld, arg3, 0); | |
1720 | print_raw_param(TARGET_ABI_FMT_ld, arg4, 0); | |
1721 | print_raw_param(TARGET_ABI_FMT_ld, arg5, 0); | |
1722 | print_syscall_epilogue(name); | |
1723 | } | |
1724 | #endif | |
1725 | ||
74d753ac MW |
1726 | #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ |
1727 | defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) | |
1728 | static void | |
1729 | print_stat(const struct syscallname *name, | |
1730 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1731 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1732 | { | |
1733 | print_syscall_prologue(name); | |
1734 | print_string(arg0, 0); | |
1735 | print_pointer(arg1, 1); | |
1736 | print_syscall_epilogue(name); | |
1737 | } | |
1738 | #define print_lstat print_stat | |
1739 | #define print_stat64 print_stat | |
1740 | #define print_lstat64 print_stat | |
1741 | #endif | |
1742 | ||
1743 | #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) | |
1744 | static void | |
1745 | print_fstat(const struct syscallname *name, | |
1746 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1747 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1748 | { | |
1749 | print_syscall_prologue(name); | |
d2ee72a5 | 1750 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
1751 | print_pointer(arg1, 1); |
1752 | print_syscall_epilogue(name); | |
1753 | } | |
1754 | #define print_fstat64 print_fstat | |
1755 | #endif | |
1756 | ||
1757 | #ifdef TARGET_NR_mkdir | |
1758 | static void | |
1759 | print_mkdir(const struct syscallname *name, | |
1760 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1761 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1762 | { | |
1763 | print_syscall_prologue(name); | |
1764 | print_string(arg0, 0); | |
1765 | print_file_mode(arg1, 1); | |
1766 | print_syscall_epilogue(name); | |
1767 | } | |
1768 | #endif | |
1769 | ||
1770 | #ifdef TARGET_NR_mkdirat | |
1771 | static void | |
1772 | print_mkdirat(const struct syscallname *name, | |
1773 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1774 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1775 | { | |
1776 | print_syscall_prologue(name); | |
1777 | print_at_dirfd(arg0, 0); | |
1778 | print_string(arg1, 0); | |
1779 | print_file_mode(arg2, 1); | |
1780 | print_syscall_epilogue(name); | |
1781 | } | |
1782 | #endif | |
1783 | ||
4de596cb LV |
1784 | #ifdef TARGET_NR_rmdir |
1785 | static void | |
1786 | print_rmdir(const struct syscallname *name, | |
1787 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1788 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1789 | { | |
1790 | print_syscall_prologue(name); | |
1791 | print_string(arg0, 0); | |
1792 | print_syscall_epilogue(name); | |
1793 | } | |
1794 | #endif | |
1795 | ||
608e5592 LV |
1796 | #ifdef TARGET_NR_rt_sigaction |
1797 | static void | |
1798 | print_rt_sigaction(const struct syscallname *name, | |
1799 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1800 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1801 | { | |
1802 | print_syscall_prologue(name); | |
1803 | print_signal(arg0, 0); | |
1804 | print_pointer(arg1, 0); | |
1805 | print_pointer(arg2, 1); | |
1806 | print_syscall_epilogue(name); | |
1807 | } | |
1808 | #endif | |
1809 | ||
1810 | #ifdef TARGET_NR_rt_sigprocmask | |
1811 | static void | |
1812 | print_rt_sigprocmask(const struct syscallname *name, | |
1813 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1814 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1815 | { | |
1816 | const char *how = "UNKNOWN"; | |
1817 | print_syscall_prologue(name); | |
1818 | switch(arg0) { | |
1819 | case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; | |
1820 | case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; | |
1821 | case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; | |
1822 | } | |
1823 | gemu_log("%s,",how); | |
1824 | print_pointer(arg1, 0); | |
1825 | print_pointer(arg2, 1); | |
1826 | print_syscall_epilogue(name); | |
1827 | } | |
1828 | #endif | |
1829 | ||
da2c8ad7 AM |
1830 | #ifdef TARGET_NR_syslog |
1831 | static void | |
1832 | print_syslog_action(abi_ulong arg, int last) | |
1833 | { | |
1834 | const char *type; | |
1835 | ||
1836 | switch (arg) { | |
1837 | case TARGET_SYSLOG_ACTION_CLOSE: { | |
1838 | type = "SYSLOG_ACTION_CLOSE"; | |
1839 | break; | |
1840 | } | |
1841 | case TARGET_SYSLOG_ACTION_OPEN: { | |
1842 | type = "SYSLOG_ACTION_OPEN"; | |
1843 | break; | |
1844 | } | |
1845 | case TARGET_SYSLOG_ACTION_READ: { | |
1846 | type = "SYSLOG_ACTION_READ"; | |
1847 | break; | |
1848 | } | |
1849 | case TARGET_SYSLOG_ACTION_READ_ALL: { | |
1850 | type = "SYSLOG_ACTION_READ_ALL"; | |
1851 | break; | |
1852 | } | |
1853 | case TARGET_SYSLOG_ACTION_READ_CLEAR: { | |
1854 | type = "SYSLOG_ACTION_READ_CLEAR"; | |
1855 | break; | |
1856 | } | |
1857 | case TARGET_SYSLOG_ACTION_CLEAR: { | |
1858 | type = "SYSLOG_ACTION_CLEAR"; | |
1859 | break; | |
1860 | } | |
1861 | case TARGET_SYSLOG_ACTION_CONSOLE_OFF: { | |
1862 | type = "SYSLOG_ACTION_CONSOLE_OFF"; | |
1863 | break; | |
1864 | } | |
1865 | case TARGET_SYSLOG_ACTION_CONSOLE_ON: { | |
1866 | type = "SYSLOG_ACTION_CONSOLE_ON"; | |
1867 | break; | |
1868 | } | |
1869 | case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: { | |
1870 | type = "SYSLOG_ACTION_CONSOLE_LEVEL"; | |
1871 | break; | |
1872 | } | |
1873 | case TARGET_SYSLOG_ACTION_SIZE_UNREAD: { | |
1874 | type = "SYSLOG_ACTION_SIZE_UNREAD"; | |
1875 | break; | |
1876 | } | |
1877 | case TARGET_SYSLOG_ACTION_SIZE_BUFFER: { | |
1878 | type = "SYSLOG_ACTION_SIZE_BUFFER"; | |
1879 | break; | |
1880 | } | |
1881 | default: { | |
1882 | print_raw_param("%ld", arg, last); | |
1883 | return; | |
1884 | } | |
1885 | } | |
1886 | gemu_log("%s%s", type, get_comma(last)); | |
1887 | } | |
1888 | ||
1889 | static void | |
1890 | print_syslog(const struct syscallname *name, | |
1891 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1892 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1893 | { | |
1894 | print_syscall_prologue(name); | |
1895 | print_syslog_action(arg0, 0); | |
1896 | print_pointer(arg1, 0); | |
1897 | print_raw_param("%d", arg2, 1); | |
1898 | print_syscall_epilogue(name); | |
1899 | } | |
1900 | #endif | |
1901 | ||
74d753ac MW |
1902 | #ifdef TARGET_NR_mknod |
1903 | static void | |
1904 | print_mknod(const struct syscallname *name, | |
1905 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1906 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1907 | { | |
d2ee72a5 | 1908 | int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
1909 | |
1910 | print_syscall_prologue(name); | |
1911 | print_string(arg0, 0); | |
1912 | print_file_mode(arg1, (hasdev == 0)); | |
1913 | if (hasdev) { | |
d2ee72a5 LV |
1914 | print_raw_param("makedev(%d", major(arg2), 0); |
1915 | print_raw_param("%d)", minor(arg2), 1); | |
74d753ac MW |
1916 | } |
1917 | print_syscall_epilogue(name); | |
1918 | } | |
1919 | #endif | |
1920 | ||
1921 | #ifdef TARGET_NR_mknodat | |
1922 | static void | |
1923 | print_mknodat(const struct syscallname *name, | |
1924 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1925 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1926 | { | |
d2ee72a5 | 1927 | int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
1928 | |
1929 | print_syscall_prologue(name); | |
1930 | print_at_dirfd(arg0, 0); | |
1931 | print_string(arg1, 0); | |
1932 | print_file_mode(arg2, (hasdev == 0)); | |
1933 | if (hasdev) { | |
d2ee72a5 LV |
1934 | print_raw_param("makedev(%d", major(arg3), 0); |
1935 | print_raw_param("%d)", minor(arg3), 1); | |
74d753ac MW |
1936 | } |
1937 | print_syscall_epilogue(name); | |
1938 | } | |
1939 | #endif | |
1940 | ||
1941 | #ifdef TARGET_NR_mq_open | |
1942 | static void | |
1943 | print_mq_open(const struct syscallname *name, | |
1944 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1945 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1946 | { | |
d2ee72a5 | 1947 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
1948 | |
1949 | print_syscall_prologue(name); | |
1950 | print_string(arg0, 0); | |
1951 | print_open_flags(arg1, (is_creat == 0)); | |
1952 | if (is_creat) { | |
1953 | print_file_mode(arg2, 0); | |
1954 | print_pointer(arg3, 1); | |
1955 | } | |
1956 | print_syscall_epilogue(name); | |
1957 | } | |
1958 | #endif | |
1959 | ||
1960 | #ifdef TARGET_NR_open | |
1961 | static void | |
1962 | print_open(const struct syscallname *name, | |
1963 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1964 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1965 | { | |
d2ee72a5 | 1966 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
1967 | |
1968 | print_syscall_prologue(name); | |
1969 | print_string(arg0, 0); | |
1970 | print_open_flags(arg1, (is_creat == 0)); | |
1971 | if (is_creat) | |
1972 | print_file_mode(arg2, 1); | |
1973 | print_syscall_epilogue(name); | |
1974 | } | |
1975 | #endif | |
1976 | ||
1977 | #ifdef TARGET_NR_openat | |
1978 | static void | |
1979 | print_openat(const struct syscallname *name, | |
1980 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1981 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1982 | { | |
d2ee72a5 | 1983 | int is_creat = (arg2 & TARGET_O_CREAT); |
74d753ac MW |
1984 | |
1985 | print_syscall_prologue(name); | |
1986 | print_at_dirfd(arg0, 0); | |
1987 | print_string(arg1, 0); | |
1988 | print_open_flags(arg2, (is_creat == 0)); | |
1989 | if (is_creat) | |
1990 | print_file_mode(arg3, 1); | |
1991 | print_syscall_epilogue(name); | |
1992 | } | |
1993 | #endif | |
1994 | ||
1995 | #ifdef TARGET_NR_mq_unlink | |
1996 | static void | |
1997 | print_mq_unlink(const struct syscallname *name, | |
1998 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1999 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2000 | { | |
2001 | print_syscall_prologue(name); | |
2002 | print_string(arg0, 1); | |
2003 | print_syscall_epilogue(name); | |
2004 | } | |
2005 | #endif | |
2006 | ||
2007 | #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) | |
2008 | static void | |
2009 | print_fstatat64(const struct syscallname *name, | |
2010 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2011 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2012 | { | |
2013 | print_syscall_prologue(name); | |
2014 | print_at_dirfd(arg0, 0); | |
2015 | print_string(arg1, 0); | |
2016 | print_pointer(arg2, 0); | |
2017 | print_flags(at_file_flags, arg3, 1); | |
2018 | print_syscall_epilogue(name); | |
2019 | } | |
2020 | #define print_newfstatat print_fstatat64 | |
2021 | #endif | |
2022 | ||
2023 | #ifdef TARGET_NR_readlink | |
2024 | static void | |
2025 | print_readlink(const struct syscallname *name, | |
2026 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2027 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2028 | { | |
2029 | print_syscall_prologue(name); | |
2030 | print_string(arg0, 0); | |
2031 | print_pointer(arg1, 0); | |
d2ee72a5 | 2032 | print_raw_param("%u", arg2, 1); |
74d753ac MW |
2033 | print_syscall_epilogue(name); |
2034 | } | |
2035 | #endif | |
2036 | ||
2037 | #ifdef TARGET_NR_readlinkat | |
2038 | static void | |
2039 | print_readlinkat(const struct syscallname *name, | |
2040 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2041 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2042 | { | |
2043 | print_syscall_prologue(name); | |
2044 | print_at_dirfd(arg0, 0); | |
2045 | print_string(arg1, 0); | |
2046 | print_pointer(arg2, 0); | |
d2ee72a5 | 2047 | print_raw_param("%u", arg3, 1); |
74d753ac MW |
2048 | print_syscall_epilogue(name); |
2049 | } | |
2050 | #endif | |
2051 | ||
2052 | #ifdef TARGET_NR_rename | |
2053 | static void | |
2054 | print_rename(const struct syscallname *name, | |
2055 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2056 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2057 | { | |
2058 | print_syscall_prologue(name); | |
2059 | print_string(arg0, 0); | |
2060 | print_string(arg1, 1); | |
2061 | print_syscall_epilogue(name); | |
2062 | } | |
2063 | #endif | |
2064 | ||
2065 | #ifdef TARGET_NR_renameat | |
2066 | static void | |
2067 | print_renameat(const struct syscallname *name, | |
2068 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2069 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2070 | { | |
2071 | print_syscall_prologue(name); | |
2072 | print_at_dirfd(arg0, 0); | |
2073 | print_string(arg1, 0); | |
2074 | print_at_dirfd(arg2, 0); | |
2075 | print_string(arg3, 1); | |
2076 | print_syscall_epilogue(name); | |
2077 | } | |
2078 | #endif | |
2079 | ||
2080 | #ifdef TARGET_NR_statfs | |
2081 | static void | |
2082 | print_statfs(const struct syscallname *name, | |
2083 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2084 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2085 | { | |
2086 | print_syscall_prologue(name); | |
2087 | print_string(arg0, 0); | |
2088 | print_pointer(arg1, 1); | |
2089 | print_syscall_epilogue(name); | |
2090 | } | |
2091 | #define print_statfs64 print_statfs | |
2092 | #endif | |
2093 | ||
2094 | #ifdef TARGET_NR_symlink | |
2095 | static void | |
2096 | print_symlink(const struct syscallname *name, | |
2097 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2098 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2099 | { | |
2100 | print_syscall_prologue(name); | |
2101 | print_string(arg0, 0); | |
2102 | print_string(arg1, 1); | |
2103 | print_syscall_epilogue(name); | |
2104 | } | |
2105 | #endif | |
2106 | ||
2107 | #ifdef TARGET_NR_symlinkat | |
2108 | static void | |
2109 | print_symlinkat(const struct syscallname *name, | |
2110 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2111 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2112 | { | |
2113 | print_syscall_prologue(name); | |
2114 | print_string(arg0, 0); | |
2115 | print_at_dirfd(arg1, 0); | |
2116 | print_string(arg2, 1); | |
2117 | print_syscall_epilogue(name); | |
2118 | } | |
2119 | #endif | |
2120 | ||
2121 | #ifdef TARGET_NR_mount | |
2122 | static void | |
2123 | print_mount(const struct syscallname *name, | |
2124 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2125 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2126 | { | |
2127 | print_syscall_prologue(name); | |
2128 | print_string(arg0, 0); | |
2129 | print_string(arg1, 0); | |
2130 | print_string(arg2, 0); | |
2131 | print_flags(mount_flags, arg3, 0); | |
2132 | print_pointer(arg4, 1); | |
2133 | print_syscall_epilogue(name); | |
2134 | } | |
2135 | #endif | |
2136 | ||
2137 | #ifdef TARGET_NR_umount | |
2138 | static void | |
2139 | print_umount(const struct syscallname *name, | |
2140 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2141 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2142 | { | |
2143 | print_syscall_prologue(name); | |
2144 | print_string(arg0, 1); | |
2145 | print_syscall_epilogue(name); | |
2146 | } | |
2147 | #endif | |
2148 | ||
2149 | #ifdef TARGET_NR_umount2 | |
2150 | static void | |
2151 | print_umount2(const struct syscallname *name, | |
2152 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2153 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2154 | { | |
2155 | print_syscall_prologue(name); | |
2156 | print_string(arg0, 0); | |
2157 | print_flags(umount2_flags, arg1, 1); | |
2158 | print_syscall_epilogue(name); | |
2159 | } | |
2160 | #endif | |
2161 | ||
2162 | #ifdef TARGET_NR_unlink | |
2163 | static void | |
2164 | print_unlink(const struct syscallname *name, | |
2165 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2166 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2167 | { | |
2168 | print_syscall_prologue(name); | |
2169 | print_string(arg0, 1); | |
2170 | print_syscall_epilogue(name); | |
2171 | } | |
2172 | #endif | |
2173 | ||
2174 | #ifdef TARGET_NR_unlinkat | |
2175 | static void | |
2176 | print_unlinkat(const struct syscallname *name, | |
2177 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2178 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2179 | { | |
2180 | print_syscall_prologue(name); | |
2181 | print_at_dirfd(arg0, 0); | |
2182 | print_string(arg1, 0); | |
2183 | print_flags(unlinkat_flags, arg2, 1); | |
2184 | print_syscall_epilogue(name); | |
2185 | } | |
2186 | #endif | |
2187 | ||
2188 | #ifdef TARGET_NR_utime | |
2189 | static void | |
2190 | print_utime(const struct syscallname *name, | |
2191 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2192 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2193 | { | |
2194 | print_syscall_prologue(name); | |
2195 | print_string(arg0, 0); | |
2196 | print_pointer(arg1, 1); | |
2197 | print_syscall_epilogue(name); | |
2198 | } | |
2199 | #endif | |
2200 | ||
2201 | #ifdef TARGET_NR_utimes | |
2202 | static void | |
2203 | print_utimes(const struct syscallname *name, | |
2204 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2205 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2206 | { | |
2207 | print_syscall_prologue(name); | |
2208 | print_string(arg0, 0); | |
2209 | print_pointer(arg1, 1); | |
2210 | print_syscall_epilogue(name); | |
2211 | } | |
2212 | #endif | |
2213 | ||
2214 | #ifdef TARGET_NR_utimensat | |
2215 | static void | |
2216 | print_utimensat(const struct syscallname *name, | |
2217 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2218 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2219 | { | |
2220 | print_syscall_prologue(name); | |
2221 | print_at_dirfd(arg0, 0); | |
2222 | print_string(arg1, 0); | |
2223 | print_pointer(arg2, 0); | |
2224 | print_flags(at_file_flags, arg3, 1); | |
2225 | print_syscall_epilogue(name); | |
2226 | } | |
2227 | #endif | |
2228 | ||
8d9016c0 | 2229 | #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) |
74d753ac MW |
2230 | static void |
2231 | print_mmap(const struct syscallname *name, | |
2232 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2233 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2234 | { | |
2235 | print_syscall_prologue(name); | |
2236 | print_pointer(arg0, 0); | |
d2ee72a5 | 2237 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
2238 | print_flags(mmap_prot_flags, arg2, 0); |
2239 | print_flags(mmap_flags, arg3, 0); | |
d2ee72a5 LV |
2240 | print_raw_param("%d", arg4, 0); |
2241 | print_raw_param("%#x", arg5, 1); | |
74d753ac MW |
2242 | print_syscall_epilogue(name); |
2243 | } | |
2244 | #define print_mmap2 print_mmap | |
2245 | #endif | |
2246 | ||
2247 | #ifdef TARGET_NR_mprotect | |
2248 | static void | |
2249 | print_mprotect(const struct syscallname *name, | |
2250 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2251 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2252 | { | |
2253 | print_syscall_prologue(name); | |
2254 | print_pointer(arg0, 0); | |
d2ee72a5 | 2255 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
2256 | print_flags(mmap_prot_flags, arg2, 1); |
2257 | print_syscall_epilogue(name); | |
2258 | } | |
2259 | #endif | |
2260 | ||
2261 | #ifdef TARGET_NR_munmap | |
2262 | static void | |
2263 | print_munmap(const struct syscallname *name, | |
2264 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2265 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2266 | { | |
2267 | print_syscall_prologue(name); | |
2268 | print_pointer(arg0, 0); | |
d2ee72a5 | 2269 | print_raw_param("%d", arg1, 1); |
74d753ac MW |
2270 | print_syscall_epilogue(name); |
2271 | } | |
2272 | #endif | |
2273 | ||
2274 | #ifdef TARGET_NR_futex | |
2275 | static void print_futex_op(abi_long tflag, int last) | |
2276 | { | |
2277 | #define print_op(val) \ | |
2278 | if( cmd == val ) { \ | |
2279 | gemu_log(#val); \ | |
2280 | return; \ | |
2281 | } | |
2282 | ||
d2ee72a5 | 2283 | int cmd = (int)tflag; |
74d753ac | 2284 | #ifdef FUTEX_PRIVATE_FLAG |
5f2243f3 | 2285 | if (cmd & FUTEX_PRIVATE_FLAG) { |
74d753ac | 2286 | gemu_log("FUTEX_PRIVATE_FLAG|"); |
5f2243f3 PB |
2287 | cmd &= ~FUTEX_PRIVATE_FLAG; |
2288 | } | |
bfb669f3 JR |
2289 | #endif |
2290 | #ifdef FUTEX_CLOCK_REALTIME | |
2291 | if (cmd & FUTEX_CLOCK_REALTIME) { | |
2292 | gemu_log("FUTEX_CLOCK_REALTIME|"); | |
2293 | cmd &= ~FUTEX_CLOCK_REALTIME; | |
2294 | } | |
74d753ac MW |
2295 | #endif |
2296 | print_op(FUTEX_WAIT) | |
2297 | print_op(FUTEX_WAKE) | |
2298 | print_op(FUTEX_FD) | |
2299 | print_op(FUTEX_REQUEUE) | |
2300 | print_op(FUTEX_CMP_REQUEUE) | |
2301 | print_op(FUTEX_WAKE_OP) | |
2302 | print_op(FUTEX_LOCK_PI) | |
2303 | print_op(FUTEX_UNLOCK_PI) | |
2304 | print_op(FUTEX_TRYLOCK_PI) | |
2305 | #ifdef FUTEX_WAIT_BITSET | |
2306 | print_op(FUTEX_WAIT_BITSET) | |
2307 | #endif | |
2308 | #ifdef FUTEX_WAKE_BITSET | |
2309 | print_op(FUTEX_WAKE_BITSET) | |
2310 | #endif | |
2311 | /* unknown values */ | |
2312 | gemu_log("%d",cmd); | |
2313 | } | |
2314 | ||
2315 | static void | |
2316 | print_futex(const struct syscallname *name, | |
2317 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2318 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2319 | { | |
2320 | print_syscall_prologue(name); | |
2321 | print_pointer(arg0, 0); | |
2322 | print_futex_op(arg1, 0); | |
d2ee72a5 | 2323 | print_raw_param(",%d", arg2, 0); |
74d753ac MW |
2324 | print_pointer(arg3, 0); /* struct timespec */ |
2325 | print_pointer(arg4, 0); | |
d2ee72a5 | 2326 | print_raw_param("%d", arg4, 1); |
74d753ac MW |
2327 | print_syscall_epilogue(name); |
2328 | } | |
2329 | #endif | |
2330 | ||
608e5592 LV |
2331 | #ifdef TARGET_NR_kill |
2332 | static void | |
2333 | print_kill(const struct syscallname *name, | |
2334 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2335 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2336 | { | |
2337 | print_syscall_prologue(name); | |
2338 | print_raw_param("%d", arg0, 0); | |
2339 | print_signal(arg1, 1); | |
2340 | print_syscall_epilogue(name); | |
2341 | } | |
2342 | #endif | |
2343 | ||
33189d31 TS |
2344 | /* |
2345 | * An array of all of the syscalls we know about | |
2346 | */ | |
2347 | ||
7ccfb2eb | 2348 | static const struct syscallname scnames[] = { |
33189d31 TS |
2349 | #include "strace.list" |
2350 | }; | |
2351 | ||
b1503cda | 2352 | static int nsyscalls = ARRAY_SIZE(scnames); |
33189d31 TS |
2353 | |
2354 | /* | |
2355 | * The public interface to this module. | |
2356 | */ | |
2357 | void | |
2358 | print_syscall(int num, | |
c16f9ed3 FB |
2359 | abi_long arg1, abi_long arg2, abi_long arg3, |
2360 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
2361 | { |
2362 | int i; | |
7ccfb2eb | 2363 | const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; |
33189d31 TS |
2364 | |
2365 | gemu_log("%d ", getpid() ); | |
2366 | ||
2367 | for(i=0;i<nsyscalls;i++) | |
2368 | if( scnames[i].nr == num ) { | |
2369 | if( scnames[i].call != NULL ) { | |
2370 | scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6); | |
2371 | } else { | |
6b23f777 FB |
2372 | /* XXX: this format system is broken because it uses |
2373 | host types and host pointers for strings */ | |
33189d31 TS |
2374 | if( scnames[i].format != NULL ) |
2375 | format = scnames[i].format; | |
2376 | gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6); | |
2377 | } | |
74c11e55 | 2378 | return; |
33189d31 | 2379 | } |
74c11e55 | 2380 | gemu_log("Unknown syscall %d\n", num); |
33189d31 TS |
2381 | } |
2382 | ||
2383 | ||
2384 | void | |
c16f9ed3 | 2385 | print_syscall_ret(int num, abi_long ret) |
33189d31 TS |
2386 | { |
2387 | int i; | |
7dcdaeaf | 2388 | const char *errstr = NULL; |
33189d31 TS |
2389 | |
2390 | for(i=0;i<nsyscalls;i++) | |
2391 | if( scnames[i].nr == num ) { | |
2392 | if( scnames[i].result != NULL ) { | |
2393 | scnames[i].result(&scnames[i],ret); | |
2394 | } else { | |
962b289e AG |
2395 | if (ret < 0) { |
2396 | errstr = target_strerror(-ret); | |
2397 | } | |
2398 | if (errstr) { | |
2399 | gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", | |
2400 | -ret, errstr); | |
33189d31 | 2401 | } else { |
c16f9ed3 | 2402 | gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); |
33189d31 TS |
2403 | } |
2404 | } | |
2405 | break; | |
2406 | } | |
2407 | } | |
0cb581d6 PM |
2408 | |
2409 | void print_taken_signal(int target_signum, const target_siginfo_t *tinfo) | |
2410 | { | |
2411 | /* Print the strace output for a signal being taken: | |
2412 | * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} --- | |
2413 | */ | |
2414 | gemu_log("--- "); | |
2415 | print_signal(target_signum, 1); | |
2416 | gemu_log(" "); | |
2417 | print_siginfo(tinfo); | |
2418 | gemu_log(" ---\n"); | |
2419 | } |