s390x/tcg: MVST: Fix storing back the addresses to registers
[qemu/ar7.git] / linux-user / strace.c
blobc80e93b5db8a57692f1bfce633d1609d9d0be9a3
1 #include "qemu/osdep.h"
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>
7 #include <sys/mount.h>
8 #include <arpa/inet.h>
9 #include <netinet/tcp.h>
10 #include <linux/if_packet.h>
11 #include <sched.h>
12 #include "qemu.h"
14 int do_strace=0;
16 struct syscallname {
17 int nr;
18 const char *name;
19 const char *format;
20 void (*call)(const struct syscallname *,
21 abi_long, abi_long, abi_long,
22 abi_long, abi_long, abi_long);
23 void (*result)(const struct syscallname *, abi_long);
26 #ifdef __GNUC__
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.
33 #define UNUSED __attribute__ ((unused))
34 #else
35 #define UNUSED
36 #endif
39 * Structure used to translate flag values into strings. This is
40 * similar that is in the actual strace tool.
42 struct flags {
43 abi_long f_value; /* flag */
44 const char *f_string; /* stringified flag */
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 }
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);
63 UNUSED static void print_buf(abi_long addr, abi_long len, int last);
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);
67 UNUSED static void print_signal(abi_ulong, int);
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);
74 * Utility functions
76 static void
77 print_ipc_cmd(int cmd)
79 #define output_cmd(val) \
80 if( cmd == val ) { \
81 gemu_log(#val); \
82 return; \
85 cmd &= 0xff;
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 output_cmd( MSG_STAT );
94 output_cmd( MSG_INFO );
95 /* shmctl() commands */
96 output_cmd( SHM_LOCK );
97 output_cmd( SHM_UNLOCK );
98 output_cmd( SHM_STAT );
99 output_cmd( SHM_INFO );
100 /* semctl() commands */
101 output_cmd( GETPID );
102 output_cmd( GETVAL );
103 output_cmd( GETALL );
104 output_cmd( GETNCNT );
105 output_cmd( GETZCNT );
106 output_cmd( SETVAL );
107 output_cmd( SETALL );
108 output_cmd( SEM_STAT );
109 output_cmd( SEM_INFO );
110 output_cmd( IPC_RMID );
111 output_cmd( IPC_RMID );
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 );
120 /* Some value we don't recognize */
121 gemu_log("%d",cmd);
124 static void
125 print_signal(abi_ulong arg, int last)
127 const char *signal_name = NULL;
128 switch(arg) {
129 case TARGET_SIGHUP: signal_name = "SIGHUP"; break;
130 case TARGET_SIGINT: signal_name = "SIGINT"; break;
131 case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break;
132 case TARGET_SIGILL: signal_name = "SIGILL"; break;
133 case TARGET_SIGABRT: signal_name = "SIGABRT"; break;
134 case TARGET_SIGFPE: signal_name = "SIGFPE"; break;
135 case TARGET_SIGKILL: signal_name = "SIGKILL"; break;
136 case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break;
137 case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break;
138 case TARGET_SIGALRM: signal_name = "SIGALRM"; break;
139 case TARGET_SIGTERM: signal_name = "SIGTERM"; break;
140 case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break;
141 case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break;
142 case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break;
143 case TARGET_SIGCONT: signal_name = "SIGCONT"; break;
144 case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break;
145 case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break;
146 case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break;
148 if (signal_name == NULL) {
149 print_raw_param("%ld", arg, last);
150 return;
152 gemu_log("%s%s", signal_name, get_comma(last));
155 static void print_si_code(int arg)
157 const char *codename = NULL;
159 switch (arg) {
160 case SI_USER:
161 codename = "SI_USER";
162 break;
163 case SI_KERNEL:
164 codename = "SI_KERNEL";
165 break;
166 case SI_QUEUE:
167 codename = "SI_QUEUE";
168 break;
169 case SI_TIMER:
170 codename = "SI_TIMER";
171 break;
172 case SI_MESGQ:
173 codename = "SI_MESGQ";
174 break;
175 case SI_ASYNCIO:
176 codename = "SI_ASYNCIO";
177 break;
178 case SI_SIGIO:
179 codename = "SI_SIGIO";
180 break;
181 case SI_TKILL:
182 codename = "SI_TKILL";
183 break;
184 default:
185 gemu_log("%d", arg);
186 return;
188 gemu_log("%s", codename);
191 static void get_target_siginfo(target_siginfo_t *tinfo,
192 const target_siginfo_t *info)
194 abi_ulong sival_ptr;
196 int sig;
197 int si_errno;
198 int si_code;
199 int si_type;
201 __get_user(sig, &info->si_signo);
202 __get_user(si_errno, &tinfo->si_errno);
203 __get_user(si_code, &info->si_code);
205 tinfo->si_signo = sig;
206 tinfo->si_errno = si_errno;
207 tinfo->si_code = si_code;
209 /* Ensure we don't leak random junk to the guest later */
210 memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
212 /* This is awkward, because we have to use a combination of
213 * the si_code and si_signo to figure out which of the union's
214 * members are valid. (Within the host kernel it is always possible
215 * to tell, but the kernel carefully avoids giving userspace the
216 * high 16 bits of si_code, so we don't have the information to
217 * do this the easy way...) We therefore make our best guess,
218 * bearing in mind that a guest can spoof most of the si_codes
219 * via rt_sigqueueinfo() if it likes.
221 * Once we have made our guess, we record it in the top 16 bits of
222 * the si_code, so that print_siginfo() later can use it.
223 * print_siginfo() will strip these top bits out before printing
224 * the si_code.
227 switch (si_code) {
228 case SI_USER:
229 case SI_TKILL:
230 case SI_KERNEL:
231 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
232 * These are the only unspoofable si_code values.
234 __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
235 __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
236 si_type = QEMU_SI_KILL;
237 break;
238 default:
239 /* Everything else is spoofable. Make best guess based on signal */
240 switch (sig) {
241 case TARGET_SIGCHLD:
242 __get_user(tinfo->_sifields._sigchld._pid,
243 &info->_sifields._sigchld._pid);
244 __get_user(tinfo->_sifields._sigchld._uid,
245 &info->_sifields._sigchld._uid);
246 __get_user(tinfo->_sifields._sigchld._status,
247 &info->_sifields._sigchld._status);
248 __get_user(tinfo->_sifields._sigchld._utime,
249 &info->_sifields._sigchld._utime);
250 __get_user(tinfo->_sifields._sigchld._stime,
251 &info->_sifields._sigchld._stime);
252 si_type = QEMU_SI_CHLD;
253 break;
254 case TARGET_SIGIO:
255 __get_user(tinfo->_sifields._sigpoll._band,
256 &info->_sifields._sigpoll._band);
257 __get_user(tinfo->_sifields._sigpoll._fd,
258 &info->_sifields._sigpoll._fd);
259 si_type = QEMU_SI_POLL;
260 break;
261 default:
262 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
263 __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
264 __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
265 /* XXX: potential problem if 64 bit */
266 __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
267 tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
269 si_type = QEMU_SI_RT;
270 break;
272 break;
275 tinfo->si_code = deposit32(si_code, 16, 16, si_type);
278 static void print_siginfo(const target_siginfo_t *tinfo)
280 /* Print a target_siginfo_t in the format desired for printing
281 * signals being taken. We assume the target_siginfo_t is in the
282 * internal form where the top 16 bits of si_code indicate which
283 * part of the union is valid, rather than in the guest-visible
284 * form where the bottom 16 bits are sign-extended into the top 16.
286 int si_type = extract32(tinfo->si_code, 16, 16);
287 int si_code = sextract32(tinfo->si_code, 0, 16);
289 gemu_log("{si_signo=");
290 print_signal(tinfo->si_signo, 1);
291 gemu_log(", si_code=");
292 print_si_code(si_code);
294 switch (si_type) {
295 case QEMU_SI_KILL:
296 gemu_log(", si_pid=%u, si_uid=%u",
297 (unsigned int)tinfo->_sifields._kill._pid,
298 (unsigned int)tinfo->_sifields._kill._uid);
299 break;
300 case QEMU_SI_TIMER:
301 gemu_log(", si_timer1=%u, si_timer2=%u",
302 tinfo->_sifields._timer._timer1,
303 tinfo->_sifields._timer._timer2);
304 break;
305 case QEMU_SI_POLL:
306 gemu_log(", si_band=%d, si_fd=%d",
307 tinfo->_sifields._sigpoll._band,
308 tinfo->_sifields._sigpoll._fd);
309 break;
310 case QEMU_SI_FAULT:
311 gemu_log(", si_addr=");
312 print_pointer(tinfo->_sifields._sigfault._addr, 1);
313 break;
314 case QEMU_SI_CHLD:
315 gemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
316 ", si_utime=" TARGET_ABI_FMT_ld
317 ", si_stime=" TARGET_ABI_FMT_ld,
318 (unsigned int)(tinfo->_sifields._sigchld._pid),
319 (unsigned int)(tinfo->_sifields._sigchld._uid),
320 tinfo->_sifields._sigchld._status,
321 tinfo->_sifields._sigchld._utime,
322 tinfo->_sifields._sigchld._stime);
323 break;
324 case QEMU_SI_RT:
325 gemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
326 (unsigned int)tinfo->_sifields._rt._pid,
327 (unsigned int)tinfo->_sifields._rt._uid,
328 tinfo->_sifields._rt._sigval.sival_ptr);
329 break;
330 default:
331 g_assert_not_reached();
333 gemu_log("}");
336 static void
337 print_sockaddr(abi_ulong addr, abi_long addrlen)
339 struct target_sockaddr *sa;
340 int i;
341 int sa_family;
343 sa = lock_user(VERIFY_READ, addr, addrlen, 1);
344 if (sa) {
345 sa_family = tswap16(sa->sa_family);
346 switch (sa_family) {
347 case AF_UNIX: {
348 struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
349 int i;
350 gemu_log("{sun_family=AF_UNIX,sun_path=\"");
351 for (i = 0; i < addrlen -
352 offsetof(struct target_sockaddr_un, sun_path) &&
353 un->sun_path[i]; i++) {
354 gemu_log("%c", un->sun_path[i]);
356 gemu_log("\"}");
357 break;
359 case AF_INET: {
360 struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
361 uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
362 gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
363 ntohs(in->sin_port));
364 gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
365 c[0], c[1], c[2], c[3]);
366 gemu_log("}");
367 break;
369 case AF_PACKET: {
370 struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
371 uint8_t *c = (uint8_t *)&ll->sll_addr;
372 gemu_log("{sll_family=AF_PACKET,"
373 "sll_protocol=htons(0x%04x),if%d,pkttype=",
374 ntohs(ll->sll_protocol), ll->sll_ifindex);
375 switch (ll->sll_pkttype) {
376 case PACKET_HOST:
377 gemu_log("PACKET_HOST");
378 break;
379 case PACKET_BROADCAST:
380 gemu_log("PACKET_BROADCAST");
381 break;
382 case PACKET_MULTICAST:
383 gemu_log("PACKET_MULTICAST");
384 break;
385 case PACKET_OTHERHOST:
386 gemu_log("PACKET_OTHERHOST");
387 break;
388 case PACKET_OUTGOING:
389 gemu_log("PACKET_OUTGOING");
390 break;
391 default:
392 gemu_log("%d", ll->sll_pkttype);
393 break;
395 gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
396 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
397 gemu_log("}");
398 break;
400 default:
401 gemu_log("{sa_family=%d, sa_data={", sa->sa_family);
402 for (i = 0; i < 13; i++) {
403 gemu_log("%02x, ", sa->sa_data[i]);
405 gemu_log("%02x}", sa->sa_data[i]);
406 gemu_log("}");
407 break;
409 unlock_user(sa, addr, 0);
410 } else {
411 print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
413 gemu_log(", "TARGET_ABI_FMT_ld, addrlen);
416 static void
417 print_socket_domain(int domain)
419 switch (domain) {
420 case PF_UNIX:
421 gemu_log("PF_UNIX");
422 break;
423 case PF_INET:
424 gemu_log("PF_INET");
425 break;
426 case PF_PACKET:
427 gemu_log("PF_PACKET");
428 break;
429 default:
430 gemu_log("%d", domain);
431 break;
435 static void
436 print_socket_type(int type)
438 switch (type) {
439 case TARGET_SOCK_DGRAM:
440 gemu_log("SOCK_DGRAM");
441 break;
442 case TARGET_SOCK_STREAM:
443 gemu_log("SOCK_STREAM");
444 break;
445 case TARGET_SOCK_RAW:
446 gemu_log("SOCK_RAW");
447 break;
448 case TARGET_SOCK_RDM:
449 gemu_log("SOCK_RDM");
450 break;
451 case TARGET_SOCK_SEQPACKET:
452 gemu_log("SOCK_SEQPACKET");
453 break;
454 case TARGET_SOCK_PACKET:
455 gemu_log("SOCK_PACKET");
456 break;
460 static void
461 print_socket_protocol(int domain, int type, int protocol)
463 if (domain == AF_PACKET ||
464 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
465 switch (protocol) {
466 case 0x0003:
467 gemu_log("ETH_P_ALL");
468 break;
469 default:
470 gemu_log("%d", protocol);
472 return;
475 switch (protocol) {
476 case IPPROTO_IP:
477 gemu_log("IPPROTO_IP");
478 break;
479 case IPPROTO_TCP:
480 gemu_log("IPPROTO_TCP");
481 break;
482 case IPPROTO_UDP:
483 gemu_log("IPPROTO_UDP");
484 break;
485 case IPPROTO_RAW:
486 gemu_log("IPPROTO_RAW");
487 break;
488 default:
489 gemu_log("%d", protocol);
490 break;
495 #ifdef TARGET_NR__newselect
496 static void
497 print_fdset(int n, abi_ulong target_fds_addr)
499 int i;
501 gemu_log("[");
502 if( target_fds_addr ) {
503 abi_long *target_fds;
505 target_fds = lock_user(VERIFY_READ,
506 target_fds_addr,
507 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
510 if (!target_fds)
511 return;
513 for (i=n; i>=0; i--) {
514 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1)
515 gemu_log("%d,", i );
517 unlock_user(target_fds, target_fds_addr, 0);
519 gemu_log("]");
521 #endif
523 #ifdef TARGET_NR_clock_adjtime
524 /* IDs of the various system clocks */
525 #define TARGET_CLOCK_REALTIME 0
526 #define TARGET_CLOCK_MONOTONIC 1
527 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
528 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
529 #define TARGET_CLOCK_MONOTONIC_RAW 4
530 #define TARGET_CLOCK_REALTIME_COARSE 5
531 #define TARGET_CLOCK_MONOTONIC_COARSE 6
532 #define TARGET_CLOCK_BOOTTIME 7
533 #define TARGET_CLOCK_REALTIME_ALARM 8
534 #define TARGET_CLOCK_BOOTTIME_ALARM 9
535 #define TARGET_CLOCK_SGI_CYCLE 10
536 #define TARGET_CLOCK_TAI 11
538 static void
539 print_clockid(int clockid, int last)
541 switch (clockid) {
542 case TARGET_CLOCK_REALTIME:
543 gemu_log("CLOCK_REALTIME");
544 break;
545 case TARGET_CLOCK_MONOTONIC:
546 gemu_log("CLOCK_MONOTONIC");
547 break;
548 case TARGET_CLOCK_PROCESS_CPUTIME_ID:
549 gemu_log("CLOCK_PROCESS_CPUTIME_ID");
550 break;
551 case TARGET_CLOCK_THREAD_CPUTIME_ID:
552 gemu_log("CLOCK_THREAD_CPUTIME_ID");
553 break;
554 case TARGET_CLOCK_MONOTONIC_RAW:
555 gemu_log("CLOCK_MONOTONIC_RAW");
556 break;
557 case TARGET_CLOCK_REALTIME_COARSE:
558 gemu_log("CLOCK_REALTIME_COARSE");
559 break;
560 case TARGET_CLOCK_MONOTONIC_COARSE:
561 gemu_log("CLOCK_MONOTONIC_COARSE");
562 break;
563 case TARGET_CLOCK_BOOTTIME:
564 gemu_log("CLOCK_BOOTTIME");
565 break;
566 case TARGET_CLOCK_REALTIME_ALARM:
567 gemu_log("CLOCK_REALTIME_ALARM");
568 break;
569 case TARGET_CLOCK_BOOTTIME_ALARM:
570 gemu_log("CLOCK_BOOTTIME_ALARM");
571 break;
572 case TARGET_CLOCK_SGI_CYCLE:
573 gemu_log("CLOCK_SGI_CYCLE");
574 break;
575 case TARGET_CLOCK_TAI:
576 gemu_log("CLOCK_TAI");
577 break;
578 default:
579 gemu_log("%d", clockid);
580 break;
582 gemu_log("%s", get_comma(last));
584 #endif
587 * Sysycall specific output functions
590 /* select */
591 #ifdef TARGET_NR__newselect
592 static long newselect_arg1 = 0;
593 static long newselect_arg2 = 0;
594 static long newselect_arg3 = 0;
595 static long newselect_arg4 = 0;
596 static long newselect_arg5 = 0;
598 static void
599 print_newselect(const struct syscallname *name,
600 abi_long arg1, abi_long arg2, abi_long arg3,
601 abi_long arg4, abi_long arg5, abi_long arg6)
603 gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1);
604 print_fdset(arg1, arg2);
605 gemu_log(",");
606 print_fdset(arg1, arg3);
607 gemu_log(",");
608 print_fdset(arg1, arg4);
609 gemu_log(",");
610 print_timeval(arg5, 1);
611 gemu_log(")");
613 /* save for use in the return output function below */
614 newselect_arg1=arg1;
615 newselect_arg2=arg2;
616 newselect_arg3=arg3;
617 newselect_arg4=arg4;
618 newselect_arg5=arg5;
620 #endif
622 #ifdef TARGET_NR_semctl
623 static void
624 print_semctl(const struct syscallname *name,
625 abi_long arg1, abi_long arg2, abi_long arg3,
626 abi_long arg4, abi_long arg5, abi_long arg6)
628 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2);
629 print_ipc_cmd(arg3);
630 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
632 #endif
634 static void
635 print_execve(const struct syscallname *name,
636 abi_long arg1, abi_long arg2, abi_long arg3,
637 abi_long arg4, abi_long arg5, abi_long arg6)
639 abi_ulong arg_ptr_addr;
640 char *s;
642 if (!(s = lock_user_string(arg1)))
643 return;
644 gemu_log("%s(\"%s\",{", name->name, s);
645 unlock_user(s, arg1, 0);
647 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
648 abi_ulong *arg_ptr, arg_addr;
650 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
651 if (!arg_ptr)
652 return;
653 arg_addr = tswapal(*arg_ptr);
654 unlock_user(arg_ptr, arg_ptr_addr, 0);
655 if (!arg_addr)
656 break;
657 if ((s = lock_user_string(arg_addr))) {
658 gemu_log("\"%s\",", s);
659 unlock_user(s, arg_addr, 0);
663 gemu_log("NULL})");
666 #ifdef TARGET_NR_ipc
667 static void
668 print_ipc(const struct syscallname *name,
669 abi_long arg1, abi_long arg2, abi_long arg3,
670 abi_long arg4, abi_long arg5, abi_long arg6)
672 switch(arg1) {
673 case IPCOP_semctl:
674 gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2);
675 print_ipc_cmd(arg3);
676 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
677 break;
678 default:
679 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")",
680 name->name, arg1, arg2, arg3, arg4);
683 #endif
686 * Variants for the return value output function
689 static void
690 print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
692 const char *errstr = NULL;
694 if (ret < 0) {
695 errstr = target_strerror(-ret);
697 if (errstr) {
698 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr);
699 } else {
700 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
704 #if 0 /* currently unused */
705 static void
706 print_syscall_ret_raw(struct syscallname *name, abi_long ret)
708 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
710 #endif
712 #ifdef TARGET_NR__newselect
713 static void
714 print_syscall_ret_newselect(const struct syscallname *name, abi_long ret)
716 gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
717 print_fdset(newselect_arg1,newselect_arg2);
718 gemu_log(",");
719 print_fdset(newselect_arg1,newselect_arg3);
720 gemu_log(",");
721 print_fdset(newselect_arg1,newselect_arg4);
722 gemu_log(",");
723 print_timeval(newselect_arg5, 1);
724 gemu_log(")\n");
726 #endif
728 /* special meanings of adjtimex()' non-negative return values */
729 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
730 #define TARGET_TIME_INS 1 /* insert leap second */
731 #define TARGET_TIME_DEL 2 /* delete leap second */
732 #define TARGET_TIME_OOP 3 /* leap second in progress */
733 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
734 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
735 static void
736 print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret)
738 const char *errstr = NULL;
740 gemu_log(" = ");
741 if (ret < 0) {
742 gemu_log("-1 errno=%d", errno);
743 errstr = target_strerror(-ret);
744 if (errstr) {
745 gemu_log(" (%s)", errstr);
747 } else {
748 gemu_log(TARGET_ABI_FMT_ld, ret);
749 switch (ret) {
750 case TARGET_TIME_OK:
751 gemu_log(" TIME_OK (clock synchronized, no leap second)");
752 break;
753 case TARGET_TIME_INS:
754 gemu_log(" TIME_INS (insert leap second)");
755 break;
756 case TARGET_TIME_DEL:
757 gemu_log(" TIME_DEL (delete leap second)");
758 break;
759 case TARGET_TIME_OOP:
760 gemu_log(" TIME_OOP (leap second in progress)");
761 break;
762 case TARGET_TIME_WAIT:
763 gemu_log(" TIME_WAIT (leap second has occurred)");
764 break;
765 case TARGET_TIME_ERROR:
766 gemu_log(" TIME_ERROR (clock not synchronized)");
767 break;
771 gemu_log("\n");
774 UNUSED static struct flags access_flags[] = {
775 FLAG_GENERIC(F_OK),
776 FLAG_GENERIC(R_OK),
777 FLAG_GENERIC(W_OK),
778 FLAG_GENERIC(X_OK),
779 FLAG_END,
782 UNUSED static struct flags at_file_flags[] = {
783 #ifdef AT_EACCESS
784 FLAG_GENERIC(AT_EACCESS),
785 #endif
786 #ifdef AT_SYMLINK_NOFOLLOW
787 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
788 #endif
789 FLAG_END,
792 UNUSED static struct flags unlinkat_flags[] = {
793 #ifdef AT_REMOVEDIR
794 FLAG_GENERIC(AT_REMOVEDIR),
795 #endif
796 FLAG_END,
799 UNUSED static struct flags mode_flags[] = {
800 FLAG_GENERIC(S_IFSOCK),
801 FLAG_GENERIC(S_IFLNK),
802 FLAG_GENERIC(S_IFREG),
803 FLAG_GENERIC(S_IFBLK),
804 FLAG_GENERIC(S_IFDIR),
805 FLAG_GENERIC(S_IFCHR),
806 FLAG_GENERIC(S_IFIFO),
807 FLAG_END,
810 UNUSED static struct flags open_access_flags[] = {
811 FLAG_TARGET(O_RDONLY),
812 FLAG_TARGET(O_WRONLY),
813 FLAG_TARGET(O_RDWR),
814 FLAG_END,
817 UNUSED static struct flags open_flags[] = {
818 FLAG_TARGET(O_APPEND),
819 FLAG_TARGET(O_CREAT),
820 FLAG_TARGET(O_DIRECTORY),
821 FLAG_TARGET(O_EXCL),
822 FLAG_TARGET(O_LARGEFILE),
823 FLAG_TARGET(O_NOCTTY),
824 FLAG_TARGET(O_NOFOLLOW),
825 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
826 FLAG_TARGET(O_DSYNC),
827 FLAG_TARGET(__O_SYNC),
828 FLAG_TARGET(O_TRUNC),
829 #ifdef O_DIRECT
830 FLAG_TARGET(O_DIRECT),
831 #endif
832 #ifdef O_NOATIME
833 FLAG_TARGET(O_NOATIME),
834 #endif
835 #ifdef O_CLOEXEC
836 FLAG_TARGET(O_CLOEXEC),
837 #endif
838 #ifdef O_PATH
839 FLAG_TARGET(O_PATH),
840 #endif
841 #ifdef O_TMPFILE
842 FLAG_TARGET(O_TMPFILE),
843 FLAG_TARGET(__O_TMPFILE),
844 #endif
845 FLAG_END,
848 UNUSED static struct flags mount_flags[] = {
849 #ifdef MS_BIND
850 FLAG_GENERIC(MS_BIND),
851 #endif
852 #ifdef MS_DIRSYNC
853 FLAG_GENERIC(MS_DIRSYNC),
854 #endif
855 FLAG_GENERIC(MS_MANDLOCK),
856 #ifdef MS_MOVE
857 FLAG_GENERIC(MS_MOVE),
858 #endif
859 FLAG_GENERIC(MS_NOATIME),
860 FLAG_GENERIC(MS_NODEV),
861 FLAG_GENERIC(MS_NODIRATIME),
862 FLAG_GENERIC(MS_NOEXEC),
863 FLAG_GENERIC(MS_NOSUID),
864 FLAG_GENERIC(MS_RDONLY),
865 #ifdef MS_RELATIME
866 FLAG_GENERIC(MS_RELATIME),
867 #endif
868 FLAG_GENERIC(MS_REMOUNT),
869 FLAG_GENERIC(MS_SYNCHRONOUS),
870 FLAG_END,
873 UNUSED static struct flags umount2_flags[] = {
874 #ifdef MNT_FORCE
875 FLAG_GENERIC(MNT_FORCE),
876 #endif
877 #ifdef MNT_DETACH
878 FLAG_GENERIC(MNT_DETACH),
879 #endif
880 #ifdef MNT_EXPIRE
881 FLAG_GENERIC(MNT_EXPIRE),
882 #endif
883 FLAG_END,
886 UNUSED static struct flags mmap_prot_flags[] = {
887 FLAG_GENERIC(PROT_NONE),
888 FLAG_GENERIC(PROT_EXEC),
889 FLAG_GENERIC(PROT_READ),
890 FLAG_GENERIC(PROT_WRITE),
891 FLAG_TARGET(PROT_SEM),
892 FLAG_GENERIC(PROT_GROWSDOWN),
893 FLAG_GENERIC(PROT_GROWSUP),
894 FLAG_END,
897 UNUSED static struct flags mmap_flags[] = {
898 FLAG_TARGET(MAP_SHARED),
899 FLAG_TARGET(MAP_PRIVATE),
900 FLAG_TARGET(MAP_ANONYMOUS),
901 FLAG_TARGET(MAP_DENYWRITE),
902 FLAG_TARGET(MAP_FIXED),
903 FLAG_TARGET(MAP_GROWSDOWN),
904 FLAG_TARGET(MAP_EXECUTABLE),
905 #ifdef MAP_LOCKED
906 FLAG_TARGET(MAP_LOCKED),
907 #endif
908 #ifdef MAP_NONBLOCK
909 FLAG_TARGET(MAP_NONBLOCK),
910 #endif
911 FLAG_TARGET(MAP_NORESERVE),
912 #ifdef MAP_POPULATE
913 FLAG_TARGET(MAP_POPULATE),
914 #endif
915 #ifdef TARGET_MAP_UNINITIALIZED
916 FLAG_TARGET(MAP_UNINITIALIZED),
917 #endif
918 FLAG_END,
921 UNUSED static struct flags clone_flags[] = {
922 FLAG_GENERIC(CLONE_VM),
923 FLAG_GENERIC(CLONE_FS),
924 FLAG_GENERIC(CLONE_FILES),
925 FLAG_GENERIC(CLONE_SIGHAND),
926 FLAG_GENERIC(CLONE_PTRACE),
927 FLAG_GENERIC(CLONE_VFORK),
928 FLAG_GENERIC(CLONE_PARENT),
929 FLAG_GENERIC(CLONE_THREAD),
930 FLAG_GENERIC(CLONE_NEWNS),
931 FLAG_GENERIC(CLONE_SYSVSEM),
932 FLAG_GENERIC(CLONE_SETTLS),
933 FLAG_GENERIC(CLONE_PARENT_SETTID),
934 FLAG_GENERIC(CLONE_CHILD_CLEARTID),
935 FLAG_GENERIC(CLONE_DETACHED),
936 FLAG_GENERIC(CLONE_UNTRACED),
937 FLAG_GENERIC(CLONE_CHILD_SETTID),
938 #if defined(CLONE_NEWUTS)
939 FLAG_GENERIC(CLONE_NEWUTS),
940 #endif
941 #if defined(CLONE_NEWIPC)
942 FLAG_GENERIC(CLONE_NEWIPC),
943 #endif
944 #if defined(CLONE_NEWUSER)
945 FLAG_GENERIC(CLONE_NEWUSER),
946 #endif
947 #if defined(CLONE_NEWPID)
948 FLAG_GENERIC(CLONE_NEWPID),
949 #endif
950 #if defined(CLONE_NEWNET)
951 FLAG_GENERIC(CLONE_NEWNET),
952 #endif
953 #if defined(CLONE_IO)
954 FLAG_GENERIC(CLONE_IO),
955 #endif
956 FLAG_END,
959 UNUSED static struct flags msg_flags[] = {
960 /* send */
961 FLAG_GENERIC(MSG_CONFIRM),
962 FLAG_GENERIC(MSG_DONTROUTE),
963 FLAG_GENERIC(MSG_DONTWAIT),
964 FLAG_GENERIC(MSG_EOR),
965 FLAG_GENERIC(MSG_MORE),
966 FLAG_GENERIC(MSG_NOSIGNAL),
967 FLAG_GENERIC(MSG_OOB),
968 /* recv */
969 FLAG_GENERIC(MSG_CMSG_CLOEXEC),
970 FLAG_GENERIC(MSG_ERRQUEUE),
971 FLAG_GENERIC(MSG_PEEK),
972 FLAG_GENERIC(MSG_TRUNC),
973 FLAG_GENERIC(MSG_WAITALL),
974 /* recvmsg */
975 FLAG_GENERIC(MSG_CTRUNC),
976 FLAG_END,
979 UNUSED static struct flags statx_flags[] = {
980 #ifdef AT_EMPTY_PATH
981 FLAG_GENERIC(AT_EMPTY_PATH),
982 #endif
983 #ifdef AT_NO_AUTOMOUNT
984 FLAG_GENERIC(AT_NO_AUTOMOUNT),
985 #endif
986 #ifdef AT_SYMLINK_NOFOLLOW
987 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
988 #endif
989 #ifdef AT_STATX_SYNC_AS_STAT
990 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT),
991 #endif
992 #ifdef AT_STATX_FORCE_SYNC
993 FLAG_GENERIC(AT_STATX_FORCE_SYNC),
994 #endif
995 #ifdef AT_STATX_DONT_SYNC
996 FLAG_GENERIC(AT_STATX_DONT_SYNC),
997 #endif
998 FLAG_END,
1001 UNUSED static struct flags statx_mask[] = {
1002 /* This must come first, because it includes everything. */
1003 #ifdef STATX_ALL
1004 FLAG_GENERIC(STATX_ALL),
1005 #endif
1006 /* This must come second; it includes everything except STATX_BTIME. */
1007 #ifdef STATX_BASIC_STATS
1008 FLAG_GENERIC(STATX_BASIC_STATS),
1009 #endif
1010 #ifdef STATX_TYPE
1011 FLAG_GENERIC(STATX_TYPE),
1012 #endif
1013 #ifdef STATX_MODE
1014 FLAG_GENERIC(STATX_MODE),
1015 #endif
1016 #ifdef STATX_NLINK
1017 FLAG_GENERIC(STATX_NLINK),
1018 #endif
1019 #ifdef STATX_UID
1020 FLAG_GENERIC(STATX_UID),
1021 #endif
1022 #ifdef STATX_GID
1023 FLAG_GENERIC(STATX_GID),
1024 #endif
1025 #ifdef STATX_ATIME
1026 FLAG_GENERIC(STATX_ATIME),
1027 #endif
1028 #ifdef STATX_MTIME
1029 FLAG_GENERIC(STATX_MTIME),
1030 #endif
1031 #ifdef STATX_CTIME
1032 FLAG_GENERIC(STATX_CTIME),
1033 #endif
1034 #ifdef STATX_INO
1035 FLAG_GENERIC(STATX_INO),
1036 #endif
1037 #ifdef STATX_SIZE
1038 FLAG_GENERIC(STATX_SIZE),
1039 #endif
1040 #ifdef STATX_BLOCKS
1041 FLAG_GENERIC(STATX_BLOCKS),
1042 #endif
1043 #ifdef STATX_BTIME
1044 FLAG_GENERIC(STATX_BTIME),
1045 #endif
1046 FLAG_END,
1050 * print_xxx utility functions. These are used to print syscall
1051 * parameters in certain format. All of these have parameter
1052 * named 'last'. This parameter is used to add comma to output
1053 * when last == 0.
1056 static const char *
1057 get_comma(int last)
1059 return ((last) ? "" : ",");
1062 static void
1063 print_flags(const struct flags *f, abi_long flags, int last)
1065 const char *sep = "";
1066 int n;
1068 if ((flags == 0) && (f->f_value == 0)) {
1069 gemu_log("%s%s", f->f_string, get_comma(last));
1070 return;
1072 for (n = 0; f->f_string != NULL; f++) {
1073 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
1074 gemu_log("%s%s", sep, f->f_string);
1075 flags &= ~f->f_value;
1076 sep = "|";
1077 n++;
1081 if (n > 0) {
1082 /* print rest of the flags as numeric */
1083 if (flags != 0) {
1084 gemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
1085 } else {
1086 gemu_log("%s", get_comma(last));
1088 } else {
1089 /* no string version of flags found, print them in hex then */
1090 gemu_log("%#x%s", (unsigned int)flags, get_comma(last));
1094 static void
1095 print_at_dirfd(abi_long dirfd, int last)
1097 #ifdef AT_FDCWD
1098 if (dirfd == AT_FDCWD) {
1099 gemu_log("AT_FDCWD%s", get_comma(last));
1100 return;
1102 #endif
1103 gemu_log("%d%s", (int)dirfd, get_comma(last));
1106 static void
1107 print_file_mode(abi_long mode, int last)
1109 const char *sep = "";
1110 const struct flags *m;
1112 for (m = &mode_flags[0]; m->f_string != NULL; m++) {
1113 if ((m->f_value & mode) == m->f_value) {
1114 gemu_log("%s%s", m->f_string, sep);
1115 sep = "|";
1116 mode &= ~m->f_value;
1117 break;
1121 mode &= ~S_IFMT;
1122 /* print rest of the mode as octal */
1123 if (mode != 0)
1124 gemu_log("%s%#o", sep, (unsigned int)mode);
1126 gemu_log("%s", get_comma(last));
1129 static void
1130 print_open_flags(abi_long flags, int last)
1132 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
1133 flags &= ~TARGET_O_ACCMODE;
1134 if (flags == 0) {
1135 gemu_log("%s", get_comma(last));
1136 return;
1138 gemu_log("|");
1139 print_flags(open_flags, flags, last);
1142 static void
1143 print_syscall_prologue(const struct syscallname *sc)
1145 gemu_log("%s(", sc->name);
1148 /*ARGSUSED*/
1149 static void
1150 print_syscall_epilogue(const struct syscallname *sc)
1152 (void)sc;
1153 gemu_log(")");
1156 static void
1157 print_string(abi_long addr, int last)
1159 char *s;
1161 if ((s = lock_user_string(addr)) != NULL) {
1162 gemu_log("\"%s\"%s", s, get_comma(last));
1163 unlock_user(s, addr, 0);
1164 } else {
1165 /* can't get string out of it, so print it as pointer */
1166 print_pointer(addr, last);
1170 #define MAX_PRINT_BUF 40
1171 static void
1172 print_buf(abi_long addr, abi_long len, int last)
1174 uint8_t *s;
1175 int i;
1177 s = lock_user(VERIFY_READ, addr, len, 1);
1178 if (s) {
1179 gemu_log("\"");
1180 for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
1181 if (isprint(s[i])) {
1182 gemu_log("%c", s[i]);
1183 } else {
1184 gemu_log("\\%o", s[i]);
1187 gemu_log("\"");
1188 if (i != len) {
1189 gemu_log("...");
1191 if (!last) {
1192 gemu_log(",");
1194 unlock_user(s, addr, 0);
1195 } else {
1196 print_pointer(addr, last);
1201 * Prints out raw parameter using given format. Caller needs
1202 * to do byte swapping if needed.
1204 static void
1205 print_raw_param(const char *fmt, abi_long param, int last)
1207 char format[64];
1209 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
1210 gemu_log(format, param);
1213 static void
1214 print_pointer(abi_long p, int last)
1216 if (p == 0)
1217 gemu_log("NULL%s", get_comma(last));
1218 else
1219 gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
1223 * Reads 32-bit (int) number from guest address space from
1224 * address 'addr' and prints it.
1226 static void
1227 print_number(abi_long addr, int last)
1229 if (addr == 0) {
1230 gemu_log("NULL%s", get_comma(last));
1231 } else {
1232 int num;
1234 get_user_s32(num, addr);
1235 gemu_log("[%d]%s", num, get_comma(last));
1239 static void
1240 print_timeval(abi_ulong tv_addr, int last)
1242 if( tv_addr ) {
1243 struct target_timeval *tv;
1245 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
1246 if (!tv)
1247 return;
1248 gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s",
1249 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
1250 unlock_user(tv, tv_addr, 0);
1251 } else
1252 gemu_log("NULL%s", get_comma(last));
1255 #undef UNUSED
1257 #ifdef TARGET_NR_accept
1258 static void
1259 print_accept(const struct syscallname *name,
1260 abi_long arg0, abi_long arg1, abi_long arg2,
1261 abi_long arg3, abi_long arg4, abi_long arg5)
1263 print_syscall_prologue(name);
1264 print_raw_param("%d", arg0, 0);
1265 print_pointer(arg1, 0);
1266 print_number(arg2, 1);
1267 print_syscall_epilogue(name);
1269 #endif
1271 #ifdef TARGET_NR_access
1272 static void
1273 print_access(const struct syscallname *name,
1274 abi_long arg0, abi_long arg1, abi_long arg2,
1275 abi_long arg3, abi_long arg4, abi_long arg5)
1277 print_syscall_prologue(name);
1278 print_string(arg0, 0);
1279 print_flags(access_flags, arg1, 1);
1280 print_syscall_epilogue(name);
1282 #endif
1284 #ifdef TARGET_NR_brk
1285 static void
1286 print_brk(const struct syscallname *name,
1287 abi_long arg0, abi_long arg1, abi_long arg2,
1288 abi_long arg3, abi_long arg4, abi_long arg5)
1290 print_syscall_prologue(name);
1291 print_pointer(arg0, 1);
1292 print_syscall_epilogue(name);
1294 #endif
1296 #ifdef TARGET_NR_chdir
1297 static void
1298 print_chdir(const struct syscallname *name,
1299 abi_long arg0, abi_long arg1, abi_long arg2,
1300 abi_long arg3, abi_long arg4, abi_long arg5)
1302 print_syscall_prologue(name);
1303 print_string(arg0, 1);
1304 print_syscall_epilogue(name);
1306 #endif
1308 #ifdef TARGET_NR_chroot
1309 static void
1310 print_chroot(const struct syscallname *name,
1311 abi_long arg0, abi_long arg1, abi_long arg2,
1312 abi_long arg3, abi_long arg4, abi_long arg5)
1314 print_syscall_prologue(name);
1315 print_string(arg0, 1);
1316 print_syscall_epilogue(name);
1318 #endif
1320 #ifdef TARGET_NR_chmod
1321 static void
1322 print_chmod(const struct syscallname *name,
1323 abi_long arg0, abi_long arg1, abi_long arg2,
1324 abi_long arg3, abi_long arg4, abi_long arg5)
1326 print_syscall_prologue(name);
1327 print_string(arg0, 0);
1328 print_file_mode(arg1, 1);
1329 print_syscall_epilogue(name);
1331 #endif
1333 #ifdef TARGET_NR_clock_adjtime
1334 static void
1335 print_clock_adjtime(const struct syscallname *name,
1336 abi_long arg0, abi_long arg1, abi_long arg2,
1337 abi_long arg3, abi_long arg4, abi_long arg5)
1339 print_syscall_prologue(name);
1340 print_clockid(arg0, 0);
1341 print_pointer(arg1, 1);
1342 print_syscall_epilogue(name);
1344 #endif
1346 #ifdef TARGET_NR_clone
1347 static void do_print_clone(unsigned int flags, abi_ulong newsp,
1348 abi_ulong parent_tidptr, target_ulong newtls,
1349 abi_ulong child_tidptr)
1351 print_flags(clone_flags, flags, 0);
1352 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
1353 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
1354 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
1355 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
1358 static void
1359 print_clone(const struct syscallname *name,
1360 abi_long arg1, abi_long arg2, abi_long arg3,
1361 abi_long arg4, abi_long arg5, abi_long arg6)
1363 print_syscall_prologue(name);
1364 #if defined(TARGET_MICROBLAZE)
1365 do_print_clone(arg1, arg2, arg4, arg6, arg5);
1366 #elif defined(TARGET_CLONE_BACKWARDS)
1367 do_print_clone(arg1, arg2, arg3, arg4, arg5);
1368 #elif defined(TARGET_CLONE_BACKWARDS2)
1369 do_print_clone(arg2, arg1, arg3, arg5, arg4);
1370 #else
1371 do_print_clone(arg1, arg2, arg3, arg5, arg4);
1372 #endif
1373 print_syscall_epilogue(name);
1375 #endif
1377 #ifdef TARGET_NR_creat
1378 static void
1379 print_creat(const struct syscallname *name,
1380 abi_long arg0, abi_long arg1, abi_long arg2,
1381 abi_long arg3, abi_long arg4, abi_long arg5)
1383 print_syscall_prologue(name);
1384 print_string(arg0, 0);
1385 print_file_mode(arg1, 1);
1386 print_syscall_epilogue(name);
1388 #endif
1390 #ifdef TARGET_NR_execv
1391 static void
1392 print_execv(const struct syscallname *name,
1393 abi_long arg0, abi_long arg1, abi_long arg2,
1394 abi_long arg3, abi_long arg4, abi_long arg5)
1396 print_syscall_prologue(name);
1397 print_string(arg0, 0);
1398 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
1399 print_syscall_epilogue(name);
1401 #endif
1403 #ifdef TARGET_NR_faccessat
1404 static void
1405 print_faccessat(const struct syscallname *name,
1406 abi_long arg0, abi_long arg1, abi_long arg2,
1407 abi_long arg3, abi_long arg4, abi_long arg5)
1409 print_syscall_prologue(name);
1410 print_at_dirfd(arg0, 0);
1411 print_string(arg1, 0);
1412 print_flags(access_flags, arg2, 0);
1413 print_flags(at_file_flags, arg3, 1);
1414 print_syscall_epilogue(name);
1416 #endif
1418 #ifdef TARGET_NR_fchmodat
1419 static void
1420 print_fchmodat(const struct syscallname *name,
1421 abi_long arg0, abi_long arg1, abi_long arg2,
1422 abi_long arg3, abi_long arg4, abi_long arg5)
1424 print_syscall_prologue(name);
1425 print_at_dirfd(arg0, 0);
1426 print_string(arg1, 0);
1427 print_file_mode(arg2, 0);
1428 print_flags(at_file_flags, arg3, 1);
1429 print_syscall_epilogue(name);
1431 #endif
1433 #ifdef TARGET_NR_fchownat
1434 static void
1435 print_fchownat(const struct syscallname *name,
1436 abi_long arg0, abi_long arg1, abi_long arg2,
1437 abi_long arg3, abi_long arg4, abi_long arg5)
1439 print_syscall_prologue(name);
1440 print_at_dirfd(arg0, 0);
1441 print_string(arg1, 0);
1442 print_raw_param("%d", arg2, 0);
1443 print_raw_param("%d", arg3, 0);
1444 print_flags(at_file_flags, arg4, 1);
1445 print_syscall_epilogue(name);
1447 #endif
1449 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1450 static void
1451 print_fcntl(const struct syscallname *name,
1452 abi_long arg0, abi_long arg1, abi_long arg2,
1453 abi_long arg3, abi_long arg4, abi_long arg5)
1455 print_syscall_prologue(name);
1456 print_raw_param("%d", arg0, 0);
1457 switch(arg1) {
1458 case TARGET_F_DUPFD:
1459 gemu_log("F_DUPFD,");
1460 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
1461 break;
1462 case TARGET_F_GETFD:
1463 gemu_log("F_GETFD");
1464 break;
1465 case TARGET_F_SETFD:
1466 gemu_log("F_SETFD,");
1467 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
1468 break;
1469 case TARGET_F_GETFL:
1470 gemu_log("F_GETFL");
1471 break;
1472 case TARGET_F_SETFL:
1473 gemu_log("F_SETFL,");
1474 print_open_flags(arg2, 1);
1475 break;
1476 case TARGET_F_GETLK:
1477 gemu_log("F_GETLK,");
1478 print_pointer(arg2, 1);
1479 break;
1480 case TARGET_F_SETLK:
1481 gemu_log("F_SETLK,");
1482 print_pointer(arg2, 1);
1483 break;
1484 case TARGET_F_SETLKW:
1485 gemu_log("F_SETLKW,");
1486 print_pointer(arg2, 1);
1487 break;
1488 case TARGET_F_GETOWN:
1489 gemu_log("F_GETOWN");
1490 break;
1491 case TARGET_F_SETOWN:
1492 gemu_log("F_SETOWN,");
1493 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1494 break;
1495 case TARGET_F_GETSIG:
1496 gemu_log("F_GETSIG");
1497 break;
1498 case TARGET_F_SETSIG:
1499 gemu_log("F_SETSIG,");
1500 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1501 break;
1502 #if TARGET_ABI_BITS == 32
1503 case TARGET_F_GETLK64:
1504 gemu_log("F_GETLK64,");
1505 print_pointer(arg2, 1);
1506 break;
1507 case TARGET_F_SETLK64:
1508 gemu_log("F_SETLK64,");
1509 print_pointer(arg2, 1);
1510 break;
1511 case TARGET_F_SETLKW64:
1512 gemu_log("F_SETLKW64,");
1513 print_pointer(arg2, 1);
1514 break;
1515 #endif
1516 case TARGET_F_SETLEASE:
1517 gemu_log("F_SETLEASE,");
1518 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1519 break;
1520 case TARGET_F_GETLEASE:
1521 gemu_log("F_GETLEASE");
1522 break;
1523 case TARGET_F_SETPIPE_SZ:
1524 gemu_log("F_SETPIPE_SZ,");
1525 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
1526 break;
1527 case TARGET_F_GETPIPE_SZ:
1528 gemu_log("F_GETPIPE_SZ");
1529 break;
1530 case TARGET_F_DUPFD_CLOEXEC:
1531 gemu_log("F_DUPFD_CLOEXEC,");
1532 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
1533 break;
1534 case TARGET_F_NOTIFY:
1535 gemu_log("F_NOTIFY,");
1536 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1537 break;
1538 default:
1539 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
1540 print_pointer(arg2, 1);
1541 break;
1543 print_syscall_epilogue(name);
1545 #define print_fcntl64 print_fcntl
1546 #endif
1549 #ifdef TARGET_NR_futimesat
1550 static void
1551 print_futimesat(const struct syscallname *name,
1552 abi_long arg0, abi_long arg1, abi_long arg2,
1553 abi_long arg3, abi_long arg4, abi_long arg5)
1555 print_syscall_prologue(name);
1556 print_at_dirfd(arg0, 0);
1557 print_string(arg1, 0);
1558 print_timeval(arg2, 0);
1559 print_timeval(arg2 + sizeof (struct target_timeval), 1);
1560 print_syscall_epilogue(name);
1562 #endif
1564 #ifdef TARGET_NR_link
1565 static void
1566 print_link(const struct syscallname *name,
1567 abi_long arg0, abi_long arg1, abi_long arg2,
1568 abi_long arg3, abi_long arg4, abi_long arg5)
1570 print_syscall_prologue(name);
1571 print_string(arg0, 0);
1572 print_string(arg1, 1);
1573 print_syscall_epilogue(name);
1575 #endif
1577 #ifdef TARGET_NR_linkat
1578 static void
1579 print_linkat(const struct syscallname *name,
1580 abi_long arg0, abi_long arg1, abi_long arg2,
1581 abi_long arg3, abi_long arg4, abi_long arg5)
1583 print_syscall_prologue(name);
1584 print_at_dirfd(arg0, 0);
1585 print_string(arg1, 0);
1586 print_at_dirfd(arg2, 0);
1587 print_string(arg3, 0);
1588 print_flags(at_file_flags, arg4, 1);
1589 print_syscall_epilogue(name);
1591 #endif
1593 #ifdef TARGET_NR__llseek
1594 static void
1595 print__llseek(const struct syscallname *name,
1596 abi_long arg0, abi_long arg1, abi_long arg2,
1597 abi_long arg3, abi_long arg4, abi_long arg5)
1599 const char *whence = "UNKNOWN";
1600 print_syscall_prologue(name);
1601 print_raw_param("%d", arg0, 0);
1602 print_raw_param("%ld", arg1, 0);
1603 print_raw_param("%ld", arg2, 0);
1604 print_pointer(arg3, 0);
1605 switch(arg4) {
1606 case SEEK_SET: whence = "SEEK_SET"; break;
1607 case SEEK_CUR: whence = "SEEK_CUR"; break;
1608 case SEEK_END: whence = "SEEK_END"; break;
1610 gemu_log("%s",whence);
1611 print_syscall_epilogue(name);
1613 #endif
1615 #if defined(TARGET_NR_socket)
1616 static void
1617 print_socket(const struct syscallname *name,
1618 abi_long arg0, abi_long arg1, abi_long arg2,
1619 abi_long arg3, abi_long arg4, abi_long arg5)
1621 abi_ulong domain = arg0, type = arg1, protocol = arg2;
1623 print_syscall_prologue(name);
1624 print_socket_domain(domain);
1625 gemu_log(",");
1626 print_socket_type(type);
1627 gemu_log(",");
1628 if (domain == AF_PACKET ||
1629 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
1630 protocol = tswap16(protocol);
1632 print_socket_protocol(domain, type, protocol);
1633 print_syscall_epilogue(name);
1636 #endif
1638 #if defined(TARGET_NR_socketcall)
1640 #define get_user_ualx(x, gaddr, idx) \
1641 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1643 static void do_print_socket(const char *name, abi_long arg1)
1645 abi_ulong domain, type, protocol;
1647 get_user_ualx(domain, arg1, 0);
1648 get_user_ualx(type, arg1, 1);
1649 get_user_ualx(protocol, arg1, 2);
1650 gemu_log("%s(", name);
1651 print_socket_domain(domain);
1652 gemu_log(",");
1653 print_socket_type(type);
1654 gemu_log(",");
1655 if (domain == AF_PACKET ||
1656 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
1657 protocol = tswap16(protocol);
1659 print_socket_protocol(domain, type, protocol);
1660 gemu_log(")");
1663 static void do_print_sockaddr(const char *name, abi_long arg1)
1665 abi_ulong sockfd, addr, addrlen;
1667 get_user_ualx(sockfd, arg1, 0);
1668 get_user_ualx(addr, arg1, 1);
1669 get_user_ualx(addrlen, arg1, 2);
1671 gemu_log("%s(", name);
1672 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1673 print_sockaddr(addr, addrlen);
1674 gemu_log(")");
1677 static void do_print_listen(const char *name, abi_long arg1)
1679 abi_ulong sockfd, backlog;
1681 get_user_ualx(sockfd, arg1, 0);
1682 get_user_ualx(backlog, arg1, 1);
1684 gemu_log("%s(", name);
1685 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1686 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
1687 gemu_log(")");
1690 static void do_print_socketpair(const char *name, abi_long arg1)
1692 abi_ulong domain, type, protocol, tab;
1694 get_user_ualx(domain, arg1, 0);
1695 get_user_ualx(type, arg1, 1);
1696 get_user_ualx(protocol, arg1, 2);
1697 get_user_ualx(tab, arg1, 3);
1699 gemu_log("%s(", name);
1700 print_socket_domain(domain);
1701 gemu_log(",");
1702 print_socket_type(type);
1703 gemu_log(",");
1704 print_socket_protocol(domain, type, protocol);
1705 gemu_log(",");
1706 print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
1707 gemu_log(")");
1710 static void do_print_sendrecv(const char *name, abi_long arg1)
1712 abi_ulong sockfd, msg, len, flags;
1714 get_user_ualx(sockfd, arg1, 0);
1715 get_user_ualx(msg, arg1, 1);
1716 get_user_ualx(len, arg1, 2);
1717 get_user_ualx(flags, arg1, 3);
1719 gemu_log("%s(", name);
1720 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1721 print_buf(msg, len, 0);
1722 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
1723 print_flags(msg_flags, flags, 1);
1724 gemu_log(")");
1727 static void do_print_msgaddr(const char *name, abi_long arg1)
1729 abi_ulong sockfd, msg, len, flags, addr, addrlen;
1731 get_user_ualx(sockfd, arg1, 0);
1732 get_user_ualx(msg, arg1, 1);
1733 get_user_ualx(len, arg1, 2);
1734 get_user_ualx(flags, arg1, 3);
1735 get_user_ualx(addr, arg1, 4);
1736 get_user_ualx(addrlen, arg1, 5);
1738 gemu_log("%s(", name);
1739 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1740 print_buf(msg, len, 0);
1741 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
1742 print_flags(msg_flags, flags, 0);
1743 print_sockaddr(addr, addrlen);
1744 gemu_log(")");
1747 static void do_print_shutdown(const char *name, abi_long arg1)
1749 abi_ulong sockfd, how;
1751 get_user_ualx(sockfd, arg1, 0);
1752 get_user_ualx(how, arg1, 1);
1754 gemu_log("shutdown(");
1755 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1756 switch (how) {
1757 case SHUT_RD:
1758 gemu_log("SHUT_RD");
1759 break;
1760 case SHUT_WR:
1761 gemu_log("SHUT_WR");
1762 break;
1763 case SHUT_RDWR:
1764 gemu_log("SHUT_RDWR");
1765 break;
1766 default:
1767 print_raw_param(TARGET_ABI_FMT_ld, how, 1);
1768 break;
1770 gemu_log(")");
1773 static void do_print_msg(const char *name, abi_long arg1)
1775 abi_ulong sockfd, msg, flags;
1777 get_user_ualx(sockfd, arg1, 0);
1778 get_user_ualx(msg, arg1, 1);
1779 get_user_ualx(flags, arg1, 2);
1781 gemu_log("%s(", name);
1782 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1783 print_pointer(msg, 0);
1784 print_flags(msg_flags, flags, 1);
1785 gemu_log(")");
1788 static void do_print_sockopt(const char *name, abi_long arg1)
1790 abi_ulong sockfd, level, optname, optval, optlen;
1792 get_user_ualx(sockfd, arg1, 0);
1793 get_user_ualx(level, arg1, 1);
1794 get_user_ualx(optname, arg1, 2);
1795 get_user_ualx(optval, arg1, 3);
1796 get_user_ualx(optlen, arg1, 4);
1798 gemu_log("%s(", name);
1799 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1800 switch (level) {
1801 case SOL_TCP:
1802 gemu_log("SOL_TCP,");
1803 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1804 print_pointer(optval, 0);
1805 break;
1806 case SOL_IP:
1807 gemu_log("SOL_IP,");
1808 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1809 print_pointer(optval, 0);
1810 break;
1811 case SOL_RAW:
1812 gemu_log("SOL_RAW,");
1813 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1814 print_pointer(optval, 0);
1815 break;
1816 case TARGET_SOL_SOCKET:
1817 gemu_log("SOL_SOCKET,");
1818 switch (optname) {
1819 case TARGET_SO_DEBUG:
1820 gemu_log("SO_DEBUG,");
1821 print_optint:
1822 print_number(optval, 0);
1823 break;
1824 case TARGET_SO_REUSEADDR:
1825 gemu_log("SO_REUSEADDR,");
1826 goto print_optint;
1827 case TARGET_SO_REUSEPORT:
1828 gemu_log("SO_REUSEPORT,");
1829 goto print_optint;
1830 case TARGET_SO_TYPE:
1831 gemu_log("SO_TYPE,");
1832 goto print_optint;
1833 case TARGET_SO_ERROR:
1834 gemu_log("SO_ERROR,");
1835 goto print_optint;
1836 case TARGET_SO_DONTROUTE:
1837 gemu_log("SO_DONTROUTE,");
1838 goto print_optint;
1839 case TARGET_SO_BROADCAST:
1840 gemu_log("SO_BROADCAST,");
1841 goto print_optint;
1842 case TARGET_SO_SNDBUF:
1843 gemu_log("SO_SNDBUF,");
1844 goto print_optint;
1845 case TARGET_SO_RCVBUF:
1846 gemu_log("SO_RCVBUF,");
1847 goto print_optint;
1848 case TARGET_SO_KEEPALIVE:
1849 gemu_log("SO_KEEPALIVE,");
1850 goto print_optint;
1851 case TARGET_SO_OOBINLINE:
1852 gemu_log("SO_OOBINLINE,");
1853 goto print_optint;
1854 case TARGET_SO_NO_CHECK:
1855 gemu_log("SO_NO_CHECK,");
1856 goto print_optint;
1857 case TARGET_SO_PRIORITY:
1858 gemu_log("SO_PRIORITY,");
1859 goto print_optint;
1860 case TARGET_SO_BSDCOMPAT:
1861 gemu_log("SO_BSDCOMPAT,");
1862 goto print_optint;
1863 case TARGET_SO_PASSCRED:
1864 gemu_log("SO_PASSCRED,");
1865 goto print_optint;
1866 case TARGET_SO_TIMESTAMP:
1867 gemu_log("SO_TIMESTAMP,");
1868 goto print_optint;
1869 case TARGET_SO_RCVLOWAT:
1870 gemu_log("SO_RCVLOWAT,");
1871 goto print_optint;
1872 case TARGET_SO_RCVTIMEO:
1873 gemu_log("SO_RCVTIMEO,");
1874 print_timeval(optval, 0);
1875 break;
1876 case TARGET_SO_SNDTIMEO:
1877 gemu_log("SO_SNDTIMEO,");
1878 print_timeval(optval, 0);
1879 break;
1880 case TARGET_SO_ATTACH_FILTER: {
1881 struct target_sock_fprog *fprog;
1883 gemu_log("SO_ATTACH_FILTER,");
1885 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
1886 struct target_sock_filter *filter;
1887 gemu_log("{");
1888 if (lock_user_struct(VERIFY_READ, filter,
1889 tswapal(fprog->filter), 0)) {
1890 int i;
1891 for (i = 0; i < tswap16(fprog->len) - 1; i++) {
1892 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1893 i, tswap16(filter[i].code),
1894 filter[i].jt, filter[i].jf,
1895 tswap32(filter[i].k));
1897 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1898 i, tswap16(filter[i].code),
1899 filter[i].jt, filter[i].jf,
1900 tswap32(filter[i].k));
1901 } else {
1902 gemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
1904 gemu_log(",%d},", tswap16(fprog->len));
1905 unlock_user(fprog, optval, 0);
1906 } else {
1907 print_pointer(optval, 0);
1909 break;
1911 default:
1912 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1913 print_pointer(optval, 0);
1914 break;
1916 break;
1917 default:
1918 print_raw_param(TARGET_ABI_FMT_ld, level, 0);
1919 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1920 print_pointer(optval, 0);
1921 break;
1923 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
1924 gemu_log(")");
1927 #define PRINT_SOCKOP(name, func) \
1928 [TARGET_SYS_##name] = { #name, func }
1930 static struct {
1931 const char *name;
1932 void (*print)(const char *, abi_long);
1933 } scall[] = {
1934 PRINT_SOCKOP(SOCKET, do_print_socket),
1935 PRINT_SOCKOP(BIND, do_print_sockaddr),
1936 PRINT_SOCKOP(CONNECT, do_print_sockaddr),
1937 PRINT_SOCKOP(LISTEN, do_print_listen),
1938 PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
1939 PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
1940 PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
1941 PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
1942 PRINT_SOCKOP(SEND, do_print_sendrecv),
1943 PRINT_SOCKOP(RECV, do_print_sendrecv),
1944 PRINT_SOCKOP(SENDTO, do_print_msgaddr),
1945 PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
1946 PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
1947 PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
1948 PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
1949 PRINT_SOCKOP(SENDMSG, do_print_msg),
1950 PRINT_SOCKOP(RECVMSG, do_print_msg),
1951 PRINT_SOCKOP(ACCEPT4, NULL),
1952 PRINT_SOCKOP(RECVMMSG, NULL),
1953 PRINT_SOCKOP(SENDMMSG, NULL),
1956 static void
1957 print_socketcall(const struct syscallname *name,
1958 abi_long arg0, abi_long arg1, abi_long arg2,
1959 abi_long arg3, abi_long arg4, abi_long arg5)
1961 if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
1962 scall[arg0].print(scall[arg0].name, arg1);
1963 return;
1965 print_syscall_prologue(name);
1966 print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
1967 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
1968 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1969 print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
1970 print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
1971 print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
1972 print_syscall_epilogue(name);
1974 #endif
1976 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
1977 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
1978 static void
1979 print_stat(const struct syscallname *name,
1980 abi_long arg0, abi_long arg1, abi_long arg2,
1981 abi_long arg3, abi_long arg4, abi_long arg5)
1983 print_syscall_prologue(name);
1984 print_string(arg0, 0);
1985 print_pointer(arg1, 1);
1986 print_syscall_epilogue(name);
1988 #define print_lstat print_stat
1989 #define print_stat64 print_stat
1990 #define print_lstat64 print_stat
1991 #endif
1993 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
1994 static void
1995 print_fstat(const struct syscallname *name,
1996 abi_long arg0, abi_long arg1, abi_long arg2,
1997 abi_long arg3, abi_long arg4, abi_long arg5)
1999 print_syscall_prologue(name);
2000 print_raw_param("%d", arg0, 0);
2001 print_pointer(arg1, 1);
2002 print_syscall_epilogue(name);
2004 #define print_fstat64 print_fstat
2005 #endif
2007 #ifdef TARGET_NR_mkdir
2008 static void
2009 print_mkdir(const struct syscallname *name,
2010 abi_long arg0, abi_long arg1, abi_long arg2,
2011 abi_long arg3, abi_long arg4, abi_long arg5)
2013 print_syscall_prologue(name);
2014 print_string(arg0, 0);
2015 print_file_mode(arg1, 1);
2016 print_syscall_epilogue(name);
2018 #endif
2020 #ifdef TARGET_NR_mkdirat
2021 static void
2022 print_mkdirat(const struct syscallname *name,
2023 abi_long arg0, abi_long arg1, abi_long arg2,
2024 abi_long arg3, abi_long arg4, abi_long arg5)
2026 print_syscall_prologue(name);
2027 print_at_dirfd(arg0, 0);
2028 print_string(arg1, 0);
2029 print_file_mode(arg2, 1);
2030 print_syscall_epilogue(name);
2032 #endif
2034 #ifdef TARGET_NR_rmdir
2035 static void
2036 print_rmdir(const struct syscallname *name,
2037 abi_long arg0, abi_long arg1, abi_long arg2,
2038 abi_long arg3, abi_long arg4, abi_long arg5)
2040 print_syscall_prologue(name);
2041 print_string(arg0, 0);
2042 print_syscall_epilogue(name);
2044 #endif
2046 #ifdef TARGET_NR_rt_sigaction
2047 static void
2048 print_rt_sigaction(const struct syscallname *name,
2049 abi_long arg0, abi_long arg1, abi_long arg2,
2050 abi_long arg3, abi_long arg4, abi_long arg5)
2052 print_syscall_prologue(name);
2053 print_signal(arg0, 0);
2054 print_pointer(arg1, 0);
2055 print_pointer(arg2, 1);
2056 print_syscall_epilogue(name);
2058 #endif
2060 #ifdef TARGET_NR_rt_sigprocmask
2061 static void
2062 print_rt_sigprocmask(const struct syscallname *name,
2063 abi_long arg0, abi_long arg1, abi_long arg2,
2064 abi_long arg3, abi_long arg4, abi_long arg5)
2066 const char *how = "UNKNOWN";
2067 print_syscall_prologue(name);
2068 switch(arg0) {
2069 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
2070 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
2071 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
2073 gemu_log("%s,",how);
2074 print_pointer(arg1, 0);
2075 print_pointer(arg2, 1);
2076 print_syscall_epilogue(name);
2078 #endif
2080 #ifdef TARGET_NR_rt_sigqueueinfo
2081 static void
2082 print_rt_sigqueueinfo(const struct syscallname *name,
2083 abi_long arg0, abi_long arg1, abi_long arg2,
2084 abi_long arg3, abi_long arg4, abi_long arg5)
2086 void *p;
2087 target_siginfo_t uinfo;
2089 print_syscall_prologue(name);
2090 print_raw_param("%d", arg0, 0);
2091 print_signal(arg1, 0);
2092 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
2093 if (p) {
2094 get_target_siginfo(&uinfo, p);
2095 print_siginfo(&uinfo);
2097 unlock_user(p, arg2, 0);
2098 } else {
2099 print_pointer(arg2, 1);
2101 print_syscall_epilogue(name);
2103 #endif
2105 #ifdef TARGET_NR_rt_tgsigqueueinfo
2106 static void
2107 print_rt_tgsigqueueinfo(const struct syscallname *name,
2108 abi_long arg0, abi_long arg1, abi_long arg2,
2109 abi_long arg3, abi_long arg4, abi_long arg5)
2111 void *p;
2112 target_siginfo_t uinfo;
2114 print_syscall_prologue(name);
2115 print_raw_param("%d", arg0, 0);
2116 print_raw_param("%d", arg1, 0);
2117 print_signal(arg2, 0);
2118 p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
2119 if (p) {
2120 get_target_siginfo(&uinfo, p);
2121 print_siginfo(&uinfo);
2123 unlock_user(p, arg3, 0);
2124 } else {
2125 print_pointer(arg3, 1);
2127 print_syscall_epilogue(name);
2129 #endif
2131 #ifdef TARGET_NR_syslog
2132 static void
2133 print_syslog_action(abi_ulong arg, int last)
2135 const char *type;
2137 switch (arg) {
2138 case TARGET_SYSLOG_ACTION_CLOSE: {
2139 type = "SYSLOG_ACTION_CLOSE";
2140 break;
2142 case TARGET_SYSLOG_ACTION_OPEN: {
2143 type = "SYSLOG_ACTION_OPEN";
2144 break;
2146 case TARGET_SYSLOG_ACTION_READ: {
2147 type = "SYSLOG_ACTION_READ";
2148 break;
2150 case TARGET_SYSLOG_ACTION_READ_ALL: {
2151 type = "SYSLOG_ACTION_READ_ALL";
2152 break;
2154 case TARGET_SYSLOG_ACTION_READ_CLEAR: {
2155 type = "SYSLOG_ACTION_READ_CLEAR";
2156 break;
2158 case TARGET_SYSLOG_ACTION_CLEAR: {
2159 type = "SYSLOG_ACTION_CLEAR";
2160 break;
2162 case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
2163 type = "SYSLOG_ACTION_CONSOLE_OFF";
2164 break;
2166 case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
2167 type = "SYSLOG_ACTION_CONSOLE_ON";
2168 break;
2170 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
2171 type = "SYSLOG_ACTION_CONSOLE_LEVEL";
2172 break;
2174 case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
2175 type = "SYSLOG_ACTION_SIZE_UNREAD";
2176 break;
2178 case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
2179 type = "SYSLOG_ACTION_SIZE_BUFFER";
2180 break;
2182 default: {
2183 print_raw_param("%ld", arg, last);
2184 return;
2187 gemu_log("%s%s", type, get_comma(last));
2190 static void
2191 print_syslog(const struct syscallname *name,
2192 abi_long arg0, abi_long arg1, abi_long arg2,
2193 abi_long arg3, abi_long arg4, abi_long arg5)
2195 print_syscall_prologue(name);
2196 print_syslog_action(arg0, 0);
2197 print_pointer(arg1, 0);
2198 print_raw_param("%d", arg2, 1);
2199 print_syscall_epilogue(name);
2201 #endif
2203 #ifdef TARGET_NR_mknod
2204 static void
2205 print_mknod(const struct syscallname *name,
2206 abi_long arg0, abi_long arg1, abi_long arg2,
2207 abi_long arg3, abi_long arg4, abi_long arg5)
2209 int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
2211 print_syscall_prologue(name);
2212 print_string(arg0, 0);
2213 print_file_mode(arg1, (hasdev == 0));
2214 if (hasdev) {
2215 print_raw_param("makedev(%d", major(arg2), 0);
2216 print_raw_param("%d)", minor(arg2), 1);
2218 print_syscall_epilogue(name);
2220 #endif
2222 #ifdef TARGET_NR_mknodat
2223 static void
2224 print_mknodat(const struct syscallname *name,
2225 abi_long arg0, abi_long arg1, abi_long arg2,
2226 abi_long arg3, abi_long arg4, abi_long arg5)
2228 int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
2230 print_syscall_prologue(name);
2231 print_at_dirfd(arg0, 0);
2232 print_string(arg1, 0);
2233 print_file_mode(arg2, (hasdev == 0));
2234 if (hasdev) {
2235 print_raw_param("makedev(%d", major(arg3), 0);
2236 print_raw_param("%d)", minor(arg3), 1);
2238 print_syscall_epilogue(name);
2240 #endif
2242 #ifdef TARGET_NR_mq_open
2243 static void
2244 print_mq_open(const struct syscallname *name,
2245 abi_long arg0, abi_long arg1, abi_long arg2,
2246 abi_long arg3, abi_long arg4, abi_long arg5)
2248 int is_creat = (arg1 & TARGET_O_CREAT);
2250 print_syscall_prologue(name);
2251 print_string(arg0, 0);
2252 print_open_flags(arg1, (is_creat == 0));
2253 if (is_creat) {
2254 print_file_mode(arg2, 0);
2255 print_pointer(arg3, 1);
2257 print_syscall_epilogue(name);
2259 #endif
2261 #ifdef TARGET_NR_open
2262 static void
2263 print_open(const struct syscallname *name,
2264 abi_long arg0, abi_long arg1, abi_long arg2,
2265 abi_long arg3, abi_long arg4, abi_long arg5)
2267 int is_creat = (arg1 & TARGET_O_CREAT);
2269 print_syscall_prologue(name);
2270 print_string(arg0, 0);
2271 print_open_flags(arg1, (is_creat == 0));
2272 if (is_creat)
2273 print_file_mode(arg2, 1);
2274 print_syscall_epilogue(name);
2276 #endif
2278 #ifdef TARGET_NR_openat
2279 static void
2280 print_openat(const struct syscallname *name,
2281 abi_long arg0, abi_long arg1, abi_long arg2,
2282 abi_long arg3, abi_long arg4, abi_long arg5)
2284 int is_creat = (arg2 & TARGET_O_CREAT);
2286 print_syscall_prologue(name);
2287 print_at_dirfd(arg0, 0);
2288 print_string(arg1, 0);
2289 print_open_flags(arg2, (is_creat == 0));
2290 if (is_creat)
2291 print_file_mode(arg3, 1);
2292 print_syscall_epilogue(name);
2294 #endif
2296 #ifdef TARGET_NR_mq_unlink
2297 static void
2298 print_mq_unlink(const struct syscallname *name,
2299 abi_long arg0, abi_long arg1, abi_long arg2,
2300 abi_long arg3, abi_long arg4, abi_long arg5)
2302 print_syscall_prologue(name);
2303 print_string(arg0, 1);
2304 print_syscall_epilogue(name);
2306 #endif
2308 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2309 static void
2310 print_fstatat64(const struct syscallname *name,
2311 abi_long arg0, abi_long arg1, abi_long arg2,
2312 abi_long arg3, abi_long arg4, abi_long arg5)
2314 print_syscall_prologue(name);
2315 print_at_dirfd(arg0, 0);
2316 print_string(arg1, 0);
2317 print_pointer(arg2, 0);
2318 print_flags(at_file_flags, arg3, 1);
2319 print_syscall_epilogue(name);
2321 #define print_newfstatat print_fstatat64
2322 #endif
2324 #ifdef TARGET_NR_readlink
2325 static void
2326 print_readlink(const struct syscallname *name,
2327 abi_long arg0, abi_long arg1, abi_long arg2,
2328 abi_long arg3, abi_long arg4, abi_long arg5)
2330 print_syscall_prologue(name);
2331 print_string(arg0, 0);
2332 print_pointer(arg1, 0);
2333 print_raw_param("%u", arg2, 1);
2334 print_syscall_epilogue(name);
2336 #endif
2338 #ifdef TARGET_NR_readlinkat
2339 static void
2340 print_readlinkat(const struct syscallname *name,
2341 abi_long arg0, abi_long arg1, abi_long arg2,
2342 abi_long arg3, abi_long arg4, abi_long arg5)
2344 print_syscall_prologue(name);
2345 print_at_dirfd(arg0, 0);
2346 print_string(arg1, 0);
2347 print_pointer(arg2, 0);
2348 print_raw_param("%u", arg3, 1);
2349 print_syscall_epilogue(name);
2351 #endif
2353 #ifdef TARGET_NR_rename
2354 static void
2355 print_rename(const struct syscallname *name,
2356 abi_long arg0, abi_long arg1, abi_long arg2,
2357 abi_long arg3, abi_long arg4, abi_long arg5)
2359 print_syscall_prologue(name);
2360 print_string(arg0, 0);
2361 print_string(arg1, 1);
2362 print_syscall_epilogue(name);
2364 #endif
2366 #ifdef TARGET_NR_renameat
2367 static void
2368 print_renameat(const struct syscallname *name,
2369 abi_long arg0, abi_long arg1, abi_long arg2,
2370 abi_long arg3, abi_long arg4, abi_long arg5)
2372 print_syscall_prologue(name);
2373 print_at_dirfd(arg0, 0);
2374 print_string(arg1, 0);
2375 print_at_dirfd(arg2, 0);
2376 print_string(arg3, 1);
2377 print_syscall_epilogue(name);
2379 #endif
2381 #ifdef TARGET_NR_statfs
2382 static void
2383 print_statfs(const struct syscallname *name,
2384 abi_long arg0, abi_long arg1, abi_long arg2,
2385 abi_long arg3, abi_long arg4, abi_long arg5)
2387 print_syscall_prologue(name);
2388 print_string(arg0, 0);
2389 print_pointer(arg1, 1);
2390 print_syscall_epilogue(name);
2392 #endif
2394 #ifdef TARGET_NR_statfs64
2395 static void
2396 print_statfs64(const struct syscallname *name,
2397 abi_long arg0, abi_long arg1, abi_long arg2,
2398 abi_long arg3, abi_long arg4, abi_long arg5)
2400 print_syscall_prologue(name);
2401 print_string(arg0, 0);
2402 print_pointer(arg1, 1);
2403 print_syscall_epilogue(name);
2405 #endif
2407 #ifdef TARGET_NR_symlink
2408 static void
2409 print_symlink(const struct syscallname *name,
2410 abi_long arg0, abi_long arg1, abi_long arg2,
2411 abi_long arg3, abi_long arg4, abi_long arg5)
2413 print_syscall_prologue(name);
2414 print_string(arg0, 0);
2415 print_string(arg1, 1);
2416 print_syscall_epilogue(name);
2418 #endif
2420 #ifdef TARGET_NR_symlinkat
2421 static void
2422 print_symlinkat(const struct syscallname *name,
2423 abi_long arg0, abi_long arg1, abi_long arg2,
2424 abi_long arg3, abi_long arg4, abi_long arg5)
2426 print_syscall_prologue(name);
2427 print_string(arg0, 0);
2428 print_at_dirfd(arg1, 0);
2429 print_string(arg2, 1);
2430 print_syscall_epilogue(name);
2432 #endif
2434 #ifdef TARGET_NR_mount
2435 static void
2436 print_mount(const struct syscallname *name,
2437 abi_long arg0, abi_long arg1, abi_long arg2,
2438 abi_long arg3, abi_long arg4, abi_long arg5)
2440 print_syscall_prologue(name);
2441 print_string(arg0, 0);
2442 print_string(arg1, 0);
2443 print_string(arg2, 0);
2444 print_flags(mount_flags, arg3, 0);
2445 print_pointer(arg4, 1);
2446 print_syscall_epilogue(name);
2448 #endif
2450 #ifdef TARGET_NR_umount
2451 static void
2452 print_umount(const struct syscallname *name,
2453 abi_long arg0, abi_long arg1, abi_long arg2,
2454 abi_long arg3, abi_long arg4, abi_long arg5)
2456 print_syscall_prologue(name);
2457 print_string(arg0, 1);
2458 print_syscall_epilogue(name);
2460 #endif
2462 #ifdef TARGET_NR_umount2
2463 static void
2464 print_umount2(const struct syscallname *name,
2465 abi_long arg0, abi_long arg1, abi_long arg2,
2466 abi_long arg3, abi_long arg4, abi_long arg5)
2468 print_syscall_prologue(name);
2469 print_string(arg0, 0);
2470 print_flags(umount2_flags, arg1, 1);
2471 print_syscall_epilogue(name);
2473 #endif
2475 #ifdef TARGET_NR_unlink
2476 static void
2477 print_unlink(const struct syscallname *name,
2478 abi_long arg0, abi_long arg1, abi_long arg2,
2479 abi_long arg3, abi_long arg4, abi_long arg5)
2481 print_syscall_prologue(name);
2482 print_string(arg0, 1);
2483 print_syscall_epilogue(name);
2485 #endif
2487 #ifdef TARGET_NR_unlinkat
2488 static void
2489 print_unlinkat(const struct syscallname *name,
2490 abi_long arg0, abi_long arg1, abi_long arg2,
2491 abi_long arg3, abi_long arg4, abi_long arg5)
2493 print_syscall_prologue(name);
2494 print_at_dirfd(arg0, 0);
2495 print_string(arg1, 0);
2496 print_flags(unlinkat_flags, arg2, 1);
2497 print_syscall_epilogue(name);
2499 #endif
2501 #ifdef TARGET_NR_utime
2502 static void
2503 print_utime(const struct syscallname *name,
2504 abi_long arg0, abi_long arg1, abi_long arg2,
2505 abi_long arg3, abi_long arg4, abi_long arg5)
2507 print_syscall_prologue(name);
2508 print_string(arg0, 0);
2509 print_pointer(arg1, 1);
2510 print_syscall_epilogue(name);
2512 #endif
2514 #ifdef TARGET_NR_utimes
2515 static void
2516 print_utimes(const struct syscallname *name,
2517 abi_long arg0, abi_long arg1, abi_long arg2,
2518 abi_long arg3, abi_long arg4, abi_long arg5)
2520 print_syscall_prologue(name);
2521 print_string(arg0, 0);
2522 print_pointer(arg1, 1);
2523 print_syscall_epilogue(name);
2525 #endif
2527 #ifdef TARGET_NR_utimensat
2528 static void
2529 print_utimensat(const struct syscallname *name,
2530 abi_long arg0, abi_long arg1, abi_long arg2,
2531 abi_long arg3, abi_long arg4, abi_long arg5)
2533 print_syscall_prologue(name);
2534 print_at_dirfd(arg0, 0);
2535 print_string(arg1, 0);
2536 print_pointer(arg2, 0);
2537 print_flags(at_file_flags, arg3, 1);
2538 print_syscall_epilogue(name);
2540 #endif
2542 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2543 static void
2544 print_mmap(const struct syscallname *name,
2545 abi_long arg0, abi_long arg1, abi_long arg2,
2546 abi_long arg3, abi_long arg4, abi_long arg5)
2548 print_syscall_prologue(name);
2549 print_pointer(arg0, 0);
2550 print_raw_param("%d", arg1, 0);
2551 print_flags(mmap_prot_flags, arg2, 0);
2552 print_flags(mmap_flags, arg3, 0);
2553 print_raw_param("%d", arg4, 0);
2554 print_raw_param("%#x", arg5, 1);
2555 print_syscall_epilogue(name);
2557 #define print_mmap2 print_mmap
2558 #endif
2560 #ifdef TARGET_NR_mprotect
2561 static void
2562 print_mprotect(const struct syscallname *name,
2563 abi_long arg0, abi_long arg1, abi_long arg2,
2564 abi_long arg3, abi_long arg4, abi_long arg5)
2566 print_syscall_prologue(name);
2567 print_pointer(arg0, 0);
2568 print_raw_param("%d", arg1, 0);
2569 print_flags(mmap_prot_flags, arg2, 1);
2570 print_syscall_epilogue(name);
2572 #endif
2574 #ifdef TARGET_NR_munmap
2575 static void
2576 print_munmap(const struct syscallname *name,
2577 abi_long arg0, abi_long arg1, abi_long arg2,
2578 abi_long arg3, abi_long arg4, abi_long arg5)
2580 print_syscall_prologue(name);
2581 print_pointer(arg0, 0);
2582 print_raw_param("%d", arg1, 1);
2583 print_syscall_epilogue(name);
2585 #endif
2587 #ifdef TARGET_NR_futex
2588 static void print_futex_op(abi_long tflag, int last)
2590 #define print_op(val) \
2591 if( cmd == val ) { \
2592 gemu_log(#val); \
2593 return; \
2596 int cmd = (int)tflag;
2597 #ifdef FUTEX_PRIVATE_FLAG
2598 if (cmd & FUTEX_PRIVATE_FLAG) {
2599 gemu_log("FUTEX_PRIVATE_FLAG|");
2600 cmd &= ~FUTEX_PRIVATE_FLAG;
2602 #endif
2603 #ifdef FUTEX_CLOCK_REALTIME
2604 if (cmd & FUTEX_CLOCK_REALTIME) {
2605 gemu_log("FUTEX_CLOCK_REALTIME|");
2606 cmd &= ~FUTEX_CLOCK_REALTIME;
2608 #endif
2609 print_op(FUTEX_WAIT)
2610 print_op(FUTEX_WAKE)
2611 print_op(FUTEX_FD)
2612 print_op(FUTEX_REQUEUE)
2613 print_op(FUTEX_CMP_REQUEUE)
2614 print_op(FUTEX_WAKE_OP)
2615 print_op(FUTEX_LOCK_PI)
2616 print_op(FUTEX_UNLOCK_PI)
2617 print_op(FUTEX_TRYLOCK_PI)
2618 #ifdef FUTEX_WAIT_BITSET
2619 print_op(FUTEX_WAIT_BITSET)
2620 #endif
2621 #ifdef FUTEX_WAKE_BITSET
2622 print_op(FUTEX_WAKE_BITSET)
2623 #endif
2624 /* unknown values */
2625 gemu_log("%d",cmd);
2628 static void
2629 print_futex(const struct syscallname *name,
2630 abi_long arg0, abi_long arg1, abi_long arg2,
2631 abi_long arg3, abi_long arg4, abi_long arg5)
2633 print_syscall_prologue(name);
2634 print_pointer(arg0, 0);
2635 print_futex_op(arg1, 0);
2636 print_raw_param(",%d", arg2, 0);
2637 print_pointer(arg3, 0); /* struct timespec */
2638 print_pointer(arg4, 0);
2639 print_raw_param("%d", arg4, 1);
2640 print_syscall_epilogue(name);
2642 #endif
2644 #ifdef TARGET_NR_kill
2645 static void
2646 print_kill(const struct syscallname *name,
2647 abi_long arg0, abi_long arg1, abi_long arg2,
2648 abi_long arg3, abi_long arg4, abi_long arg5)
2650 print_syscall_prologue(name);
2651 print_raw_param("%d", arg0, 0);
2652 print_signal(arg1, 1);
2653 print_syscall_epilogue(name);
2655 #endif
2657 #ifdef TARGET_NR_tkill
2658 static void
2659 print_tkill(const struct syscallname *name,
2660 abi_long arg0, abi_long arg1, abi_long arg2,
2661 abi_long arg3, abi_long arg4, abi_long arg5)
2663 print_syscall_prologue(name);
2664 print_raw_param("%d", arg0, 0);
2665 print_signal(arg1, 1);
2666 print_syscall_epilogue(name);
2668 #endif
2670 #ifdef TARGET_NR_tgkill
2671 static void
2672 print_tgkill(const struct syscallname *name,
2673 abi_long arg0, abi_long arg1, abi_long arg2,
2674 abi_long arg3, abi_long arg4, abi_long arg5)
2676 print_syscall_prologue(name);
2677 print_raw_param("%d", arg0, 0);
2678 print_raw_param("%d", arg1, 0);
2679 print_signal(arg2, 1);
2680 print_syscall_epilogue(name);
2682 #endif
2684 #ifdef TARGET_NR_statx
2685 static void
2686 print_statx(const struct syscallname *name,
2687 abi_long arg0, abi_long arg1, abi_long arg2,
2688 abi_long arg3, abi_long arg4, abi_long arg5)
2690 print_syscall_prologue(name);
2691 print_at_dirfd(arg0, 0);
2692 print_string(arg1, 0);
2693 print_flags(statx_flags, arg2, 0);
2694 print_flags(statx_mask, arg3, 0);
2695 print_pointer(arg4, 1);
2696 print_syscall_epilogue(name);
2698 #endif
2701 * An array of all of the syscalls we know about
2704 static const struct syscallname scnames[] = {
2705 #include "strace.list"
2708 static int nsyscalls = ARRAY_SIZE(scnames);
2711 * The public interface to this module.
2713 void
2714 print_syscall(int num,
2715 abi_long arg1, abi_long arg2, abi_long arg3,
2716 abi_long arg4, abi_long arg5, abi_long arg6)
2718 int i;
2719 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 ")";
2721 gemu_log("%d ", getpid() );
2723 for(i=0;i<nsyscalls;i++)
2724 if( scnames[i].nr == num ) {
2725 if( scnames[i].call != NULL ) {
2726 scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6);
2727 } else {
2728 /* XXX: this format system is broken because it uses
2729 host types and host pointers for strings */
2730 if( scnames[i].format != NULL )
2731 format = scnames[i].format;
2732 gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6);
2734 return;
2736 gemu_log("Unknown syscall %d\n", num);
2740 void
2741 print_syscall_ret(int num, abi_long ret)
2743 int i;
2744 const char *errstr = NULL;
2746 for(i=0;i<nsyscalls;i++)
2747 if( scnames[i].nr == num ) {
2748 if( scnames[i].result != NULL ) {
2749 scnames[i].result(&scnames[i],ret);
2750 } else {
2751 if (ret < 0) {
2752 errstr = target_strerror(-ret);
2754 if (errstr) {
2755 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n",
2756 -ret, errstr);
2757 } else {
2758 gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
2761 break;
2765 void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
2767 /* Print the strace output for a signal being taken:
2768 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2770 gemu_log("--- ");
2771 print_signal(target_signum, 1);
2772 gemu_log(" ");
2773 print_siginfo(tinfo);
2774 gemu_log(" ---\n");