1 #include "qemu/osdep.h"
6 #include <sys/select.h>
9 #include <netinet/tcp.h>
10 #include <linux/if_packet.h>
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
);
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))
39 * Structure used to translate flag values into strings. This is
40 * similar that is in the actual strace tool.
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
);
77 print_ipc_cmd(int cmd
)
79 #define output_cmd(val) \
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 */
125 print_signal(abi_ulong arg
, int last
)
127 const char *signal_name
= NULL
;
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
);
152 gemu_log("%s%s", signal_name
, get_comma(last
));
155 static void print_si_code(int arg
)
157 const char *codename
= NULL
;
161 codename
= "SI_USER";
164 codename
= "SI_KERNEL";
167 codename
= "SI_QUEUE";
170 codename
= "SI_TIMER";
173 codename
= "SI_MESGQ";
176 codename
= "SI_ASYNCIO";
179 codename
= "SI_SIGIO";
182 codename
= "SI_TKILL";
188 gemu_log("%s", codename
);
191 static void print_siginfo(const target_siginfo_t
*tinfo
)
193 /* Print a target_siginfo_t in the format desired for printing
194 * signals being taken. We assume the target_siginfo_t is in the
195 * internal form where the top 16 bits of si_code indicate which
196 * part of the union is valid, rather than in the guest-visible
197 * form where the bottom 16 bits are sign-extended into the top 16.
199 int si_type
= extract32(tinfo
->si_code
, 16, 16);
200 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
202 gemu_log("{si_signo=");
203 print_signal(tinfo
->si_signo
, 1);
204 gemu_log(", si_code=");
205 print_si_code(si_code
);
209 gemu_log(", si_pid = %u, si_uid = %u",
210 (unsigned int)tinfo
->_sifields
._kill
._pid
,
211 (unsigned int)tinfo
->_sifields
._kill
._uid
);
214 gemu_log(", si_timer1 = %u, si_timer2 = %u",
215 tinfo
->_sifields
._timer
._timer1
,
216 tinfo
->_sifields
._timer
._timer2
);
219 gemu_log(", si_band = %d, si_fd = %d",
220 tinfo
->_sifields
._sigpoll
._band
,
221 tinfo
->_sifields
._sigpoll
._fd
);
224 gemu_log(", si_addr = ");
225 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
228 gemu_log(", si_pid = %u, si_uid = %u, si_status = %d"
229 ", si_utime=" TARGET_ABI_FMT_ld
230 ", si_stime=" TARGET_ABI_FMT_ld
,
231 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
232 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
233 tinfo
->_sifields
._sigchld
._status
,
234 tinfo
->_sifields
._sigchld
._utime
,
235 tinfo
->_sifields
._sigchld
._stime
);
238 gemu_log(", si_pid = %u, si_uid = %u, si_sigval = " TARGET_ABI_FMT_ld
,
239 (unsigned int)tinfo
->_sifields
._rt
._pid
,
240 (unsigned int)tinfo
->_sifields
._rt
._uid
,
241 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
244 g_assert_not_reached();
250 print_sockaddr(abi_ulong addr
, abi_long addrlen
)
252 struct target_sockaddr
*sa
;
256 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
258 sa_family
= tswap16(sa
->sa_family
);
261 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
263 gemu_log("{sun_family=AF_UNIX,sun_path=\"");
264 for (i
= 0; i
< addrlen
-
265 offsetof(struct target_sockaddr_un
, sun_path
) &&
266 un
->sun_path
[i
]; i
++) {
267 gemu_log("%c", un
->sun_path
[i
]);
273 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
274 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
275 gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
276 ntohs(in
->sin_port
));
277 gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
278 c
[0], c
[1], c
[2], c
[3]);
283 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
284 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
285 gemu_log("{sll_family=AF_PACKET,"
286 "sll_protocol=htons(0x%04x),if%d,pkttype=",
287 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
288 switch (ll
->sll_pkttype
) {
290 gemu_log("PACKET_HOST");
292 case PACKET_BROADCAST
:
293 gemu_log("PACKET_BROADCAST");
295 case PACKET_MULTICAST
:
296 gemu_log("PACKET_MULTICAST");
298 case PACKET_OTHERHOST
:
299 gemu_log("PACKET_OTHERHOST");
301 case PACKET_OUTGOING
:
302 gemu_log("PACKET_OUTGOING");
305 gemu_log("%d", ll
->sll_pkttype
);
308 gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
309 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
314 gemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
315 for (i
= 0; i
< 13; i
++) {
316 gemu_log("%02x, ", sa
->sa_data
[i
]);
318 gemu_log("%02x}", sa
->sa_data
[i
]);
322 unlock_user(sa
, addr
, 0);
324 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
326 gemu_log(", "TARGET_ABI_FMT_ld
, addrlen
);
330 print_socket_domain(int domain
)
340 gemu_log("PF_PACKET");
343 gemu_log("%d", domain
);
349 print_socket_type(int type
)
352 case TARGET_SOCK_DGRAM
:
353 gemu_log("SOCK_DGRAM");
355 case TARGET_SOCK_STREAM
:
356 gemu_log("SOCK_STREAM");
358 case TARGET_SOCK_RAW
:
359 gemu_log("SOCK_RAW");
361 case TARGET_SOCK_RDM
:
362 gemu_log("SOCK_RDM");
364 case TARGET_SOCK_SEQPACKET
:
365 gemu_log("SOCK_SEQPACKET");
367 case TARGET_SOCK_PACKET
:
368 gemu_log("SOCK_PACKET");
374 print_socket_protocol(int domain
, int type
, int protocol
)
376 if (domain
== AF_PACKET
||
377 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
380 gemu_log("ETH_P_ALL");
383 gemu_log("%d", protocol
);
390 gemu_log("IPPROTO_IP");
393 gemu_log("IPPROTO_TCP");
396 gemu_log("IPPROTO_UDP");
399 gemu_log("IPPROTO_RAW");
402 gemu_log("%d", protocol
);
408 #ifdef TARGET_NR__newselect
410 print_fdset(int n
, abi_ulong target_fds_addr
)
415 if( target_fds_addr
) {
416 abi_long
*target_fds
;
418 target_fds
= lock_user(VERIFY_READ
,
420 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
426 for (i
=n
; i
>=0; i
--) {
427 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
430 unlock_user(target_fds
, target_fds_addr
, 0);
436 #ifdef TARGET_NR_clock_adjtime
437 /* IDs of the various system clocks */
438 #define TARGET_CLOCK_REALTIME 0
439 #define TARGET_CLOCK_MONOTONIC 1
440 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
441 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
442 #define TARGET_CLOCK_MONOTONIC_RAW 4
443 #define TARGET_CLOCK_REALTIME_COARSE 5
444 #define TARGET_CLOCK_MONOTONIC_COARSE 6
445 #define TARGET_CLOCK_BOOTTIME 7
446 #define TARGET_CLOCK_REALTIME_ALARM 8
447 #define TARGET_CLOCK_BOOTTIME_ALARM 9
448 #define TARGET_CLOCK_SGI_CYCLE 10
449 #define TARGET_CLOCK_TAI 11
452 print_clockid(int clockid
, int last
)
455 case TARGET_CLOCK_REALTIME
:
456 gemu_log("CLOCK_REALTIME");
458 case TARGET_CLOCK_MONOTONIC
:
459 gemu_log("CLOCK_MONOTONIC");
461 case TARGET_CLOCK_PROCESS_CPUTIME_ID
:
462 gemu_log("CLOCK_PROCESS_CPUTIME_ID");
464 case TARGET_CLOCK_THREAD_CPUTIME_ID
:
465 gemu_log("CLOCK_THREAD_CPUTIME_ID");
467 case TARGET_CLOCK_MONOTONIC_RAW
:
468 gemu_log("CLOCK_MONOTONIC_RAW");
470 case TARGET_CLOCK_REALTIME_COARSE
:
471 gemu_log("CLOCK_REALTIME_COARSE");
473 case TARGET_CLOCK_MONOTONIC_COARSE
:
474 gemu_log("CLOCK_MONOTONIC_COARSE");
476 case TARGET_CLOCK_BOOTTIME
:
477 gemu_log("CLOCK_BOOTTIME");
479 case TARGET_CLOCK_REALTIME_ALARM
:
480 gemu_log("CLOCK_REALTIME_ALARM");
482 case TARGET_CLOCK_BOOTTIME_ALARM
:
483 gemu_log("CLOCK_BOOTTIME_ALARM");
485 case TARGET_CLOCK_SGI_CYCLE
:
486 gemu_log("CLOCK_SGI_CYCLE");
488 case TARGET_CLOCK_TAI
:
489 gemu_log("CLOCK_TAI");
492 gemu_log("%d", clockid
);
495 gemu_log("%s", get_comma(last
));
500 * Sysycall specific output functions
504 #ifdef TARGET_NR__newselect
505 static long newselect_arg1
= 0;
506 static long newselect_arg2
= 0;
507 static long newselect_arg3
= 0;
508 static long newselect_arg4
= 0;
509 static long newselect_arg5
= 0;
512 print_newselect(const struct syscallname
*name
,
513 abi_long arg1
, abi_long arg2
, abi_long arg3
,
514 abi_long arg4
, abi_long arg5
, abi_long arg6
)
516 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
517 print_fdset(arg1
, arg2
);
519 print_fdset(arg1
, arg3
);
521 print_fdset(arg1
, arg4
);
523 print_timeval(arg5
, 1);
526 /* save for use in the return output function below */
535 #ifdef TARGET_NR_semctl
537 print_semctl(const struct syscallname
*name
,
538 abi_long arg1
, abi_long arg2
, abi_long arg3
,
539 abi_long arg4
, abi_long arg5
, abi_long arg6
)
541 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
543 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
548 print_execve(const struct syscallname
*name
,
549 abi_long arg1
, abi_long arg2
, abi_long arg3
,
550 abi_long arg4
, abi_long arg5
, abi_long arg6
)
552 abi_ulong arg_ptr_addr
;
555 if (!(s
= lock_user_string(arg1
)))
557 gemu_log("%s(\"%s\",{", name
->name
, s
);
558 unlock_user(s
, arg1
, 0);
560 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
561 abi_ulong
*arg_ptr
, arg_addr
;
563 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
566 arg_addr
= tswapal(*arg_ptr
);
567 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
570 if ((s
= lock_user_string(arg_addr
))) {
571 gemu_log("\"%s\",", s
);
572 unlock_user(s
, arg_addr
, 0);
581 print_ipc(const struct syscallname
*name
,
582 abi_long arg1
, abi_long arg2
, abi_long arg3
,
583 abi_long arg4
, abi_long arg5
, abi_long arg6
)
587 gemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", arg1
, arg2
);
589 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
592 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
593 name
->name
, arg1
, arg2
, arg3
, arg4
);
599 * Variants for the return value output function
603 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
605 const char *errstr
= NULL
;
608 errstr
= target_strerror(-ret
);
611 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret
, errstr
);
613 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
617 #if 0 /* currently unused */
619 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
621 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
625 #ifdef TARGET_NR__newselect
627 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
629 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
630 print_fdset(newselect_arg1
,newselect_arg2
);
632 print_fdset(newselect_arg1
,newselect_arg3
);
634 print_fdset(newselect_arg1
,newselect_arg4
);
636 print_timeval(newselect_arg5
, 1);
641 /* special meanings of adjtimex()' non-negative return values */
642 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
643 #define TARGET_TIME_INS 1 /* insert leap second */
644 #define TARGET_TIME_DEL 2 /* delete leap second */
645 #define TARGET_TIME_OOP 3 /* leap second in progress */
646 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
647 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
649 print_syscall_ret_adjtimex(const struct syscallname
*name
, abi_long ret
)
651 const char *errstr
= NULL
;
655 gemu_log("-1 errno=%d", errno
);
656 errstr
= target_strerror(-ret
);
658 gemu_log(" (%s)", errstr
);
661 gemu_log(TARGET_ABI_FMT_ld
, ret
);
664 gemu_log(" TIME_OK (clock synchronized, no leap second)");
666 case TARGET_TIME_INS
:
667 gemu_log(" TIME_INS (insert leap second)");
669 case TARGET_TIME_DEL
:
670 gemu_log(" TIME_DEL (delete leap second)");
672 case TARGET_TIME_OOP
:
673 gemu_log(" TIME_OOP (leap second in progress)");
675 case TARGET_TIME_WAIT
:
676 gemu_log(" TIME_WAIT (leap second has occurred)");
678 case TARGET_TIME_ERROR
:
679 gemu_log(" TIME_ERROR (clock not synchronized)");
687 UNUSED
static struct flags access_flags
[] = {
695 UNUSED
static struct flags at_file_flags
[] = {
697 FLAG_GENERIC(AT_EACCESS
),
699 #ifdef AT_SYMLINK_NOFOLLOW
700 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
705 UNUSED
static struct flags unlinkat_flags
[] = {
707 FLAG_GENERIC(AT_REMOVEDIR
),
712 UNUSED
static struct flags mode_flags
[] = {
713 FLAG_GENERIC(S_IFSOCK
),
714 FLAG_GENERIC(S_IFLNK
),
715 FLAG_GENERIC(S_IFREG
),
716 FLAG_GENERIC(S_IFBLK
),
717 FLAG_GENERIC(S_IFDIR
),
718 FLAG_GENERIC(S_IFCHR
),
719 FLAG_GENERIC(S_IFIFO
),
723 UNUSED
static struct flags open_access_flags
[] = {
724 FLAG_TARGET(O_RDONLY
),
725 FLAG_TARGET(O_WRONLY
),
730 UNUSED
static struct flags open_flags
[] = {
731 FLAG_TARGET(O_APPEND
),
732 FLAG_TARGET(O_CREAT
),
733 FLAG_TARGET(O_DIRECTORY
),
735 FLAG_TARGET(O_LARGEFILE
),
736 FLAG_TARGET(O_NOCTTY
),
737 FLAG_TARGET(O_NOFOLLOW
),
738 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
739 FLAG_TARGET(O_DSYNC
),
740 FLAG_TARGET(__O_SYNC
),
741 FLAG_TARGET(O_TRUNC
),
743 FLAG_TARGET(O_DIRECT
),
746 FLAG_TARGET(O_NOATIME
),
749 FLAG_TARGET(O_CLOEXEC
),
757 UNUSED
static struct flags mount_flags
[] = {
759 FLAG_GENERIC(MS_BIND
),
762 FLAG_GENERIC(MS_DIRSYNC
),
764 FLAG_GENERIC(MS_MANDLOCK
),
766 FLAG_GENERIC(MS_MOVE
),
768 FLAG_GENERIC(MS_NOATIME
),
769 FLAG_GENERIC(MS_NODEV
),
770 FLAG_GENERIC(MS_NODIRATIME
),
771 FLAG_GENERIC(MS_NOEXEC
),
772 FLAG_GENERIC(MS_NOSUID
),
773 FLAG_GENERIC(MS_RDONLY
),
775 FLAG_GENERIC(MS_RELATIME
),
777 FLAG_GENERIC(MS_REMOUNT
),
778 FLAG_GENERIC(MS_SYNCHRONOUS
),
782 UNUSED
static struct flags umount2_flags
[] = {
784 FLAG_GENERIC(MNT_FORCE
),
787 FLAG_GENERIC(MNT_DETACH
),
790 FLAG_GENERIC(MNT_EXPIRE
),
795 UNUSED
static struct flags mmap_prot_flags
[] = {
796 FLAG_GENERIC(PROT_NONE
),
797 FLAG_GENERIC(PROT_EXEC
),
798 FLAG_GENERIC(PROT_READ
),
799 FLAG_GENERIC(PROT_WRITE
),
800 FLAG_TARGET(PROT_SEM
),
801 FLAG_GENERIC(PROT_GROWSDOWN
),
802 FLAG_GENERIC(PROT_GROWSUP
),
806 UNUSED
static struct flags mmap_flags
[] = {
807 FLAG_TARGET(MAP_SHARED
),
808 FLAG_TARGET(MAP_PRIVATE
),
809 FLAG_TARGET(MAP_ANONYMOUS
),
810 FLAG_TARGET(MAP_DENYWRITE
),
811 FLAG_TARGET(MAP_FIXED
),
812 FLAG_TARGET(MAP_GROWSDOWN
),
813 FLAG_TARGET(MAP_EXECUTABLE
),
815 FLAG_TARGET(MAP_LOCKED
),
818 FLAG_TARGET(MAP_NONBLOCK
),
820 FLAG_TARGET(MAP_NORESERVE
),
822 FLAG_TARGET(MAP_POPULATE
),
824 #ifdef TARGET_MAP_UNINITIALIZED
825 FLAG_TARGET(MAP_UNINITIALIZED
),
830 UNUSED
static struct flags clone_flags
[] = {
831 FLAG_GENERIC(CLONE_VM
),
832 FLAG_GENERIC(CLONE_FS
),
833 FLAG_GENERIC(CLONE_FILES
),
834 FLAG_GENERIC(CLONE_SIGHAND
),
835 FLAG_GENERIC(CLONE_PTRACE
),
836 FLAG_GENERIC(CLONE_VFORK
),
837 FLAG_GENERIC(CLONE_PARENT
),
838 FLAG_GENERIC(CLONE_THREAD
),
839 FLAG_GENERIC(CLONE_NEWNS
),
840 FLAG_GENERIC(CLONE_SYSVSEM
),
841 FLAG_GENERIC(CLONE_SETTLS
),
842 FLAG_GENERIC(CLONE_PARENT_SETTID
),
843 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
844 FLAG_GENERIC(CLONE_DETACHED
),
845 FLAG_GENERIC(CLONE_UNTRACED
),
846 FLAG_GENERIC(CLONE_CHILD_SETTID
),
847 #if defined(CLONE_NEWUTS)
848 FLAG_GENERIC(CLONE_NEWUTS
),
850 #if defined(CLONE_NEWIPC)
851 FLAG_GENERIC(CLONE_NEWIPC
),
853 #if defined(CLONE_NEWUSER)
854 FLAG_GENERIC(CLONE_NEWUSER
),
856 #if defined(CLONE_NEWPID)
857 FLAG_GENERIC(CLONE_NEWPID
),
859 #if defined(CLONE_NEWNET)
860 FLAG_GENERIC(CLONE_NEWNET
),
862 #if defined(CLONE_IO)
863 FLAG_GENERIC(CLONE_IO
),
868 UNUSED
static struct flags msg_flags
[] = {
870 FLAG_GENERIC(MSG_CONFIRM
),
871 FLAG_GENERIC(MSG_DONTROUTE
),
872 FLAG_GENERIC(MSG_DONTWAIT
),
873 FLAG_GENERIC(MSG_EOR
),
874 FLAG_GENERIC(MSG_MORE
),
875 FLAG_GENERIC(MSG_NOSIGNAL
),
876 FLAG_GENERIC(MSG_OOB
),
878 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
879 FLAG_GENERIC(MSG_ERRQUEUE
),
880 FLAG_GENERIC(MSG_PEEK
),
881 FLAG_GENERIC(MSG_TRUNC
),
882 FLAG_GENERIC(MSG_WAITALL
),
884 FLAG_GENERIC(MSG_CTRUNC
),
889 * print_xxx utility functions. These are used to print syscall
890 * parameters in certain format. All of these have parameter
891 * named 'last'. This parameter is used to add comma to output
898 return ((last
) ? "" : ",");
902 print_flags(const struct flags
*f
, abi_long flags
, int last
)
904 const char *sep
= "";
907 if ((flags
== 0) && (f
->f_value
== 0)) {
908 gemu_log("%s%s", f
->f_string
, get_comma(last
));
911 for (n
= 0; f
->f_string
!= NULL
; f
++) {
912 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
913 gemu_log("%s%s", sep
, f
->f_string
);
914 flags
&= ~f
->f_value
;
921 /* print rest of the flags as numeric */
923 gemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
925 gemu_log("%s", get_comma(last
));
928 /* no string version of flags found, print them in hex then */
929 gemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
934 print_at_dirfd(abi_long dirfd
, int last
)
937 if (dirfd
== AT_FDCWD
) {
938 gemu_log("AT_FDCWD%s", get_comma(last
));
942 gemu_log("%d%s", (int)dirfd
, get_comma(last
));
946 print_file_mode(abi_long mode
, int last
)
948 const char *sep
= "";
949 const struct flags
*m
;
951 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
952 if ((m
->f_value
& mode
) == m
->f_value
) {
953 gemu_log("%s%s", m
->f_string
, sep
);
961 /* print rest of the mode as octal */
963 gemu_log("%s%#o", sep
, (unsigned int)mode
);
965 gemu_log("%s", get_comma(last
));
969 print_open_flags(abi_long flags
, int last
)
971 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
972 flags
&= ~TARGET_O_ACCMODE
;
974 gemu_log("%s", get_comma(last
));
978 print_flags(open_flags
, flags
, last
);
982 print_syscall_prologue(const struct syscallname
*sc
)
984 gemu_log("%s(", sc
->name
);
989 print_syscall_epilogue(const struct syscallname
*sc
)
996 print_string(abi_long addr
, int last
)
1000 if ((s
= lock_user_string(addr
)) != NULL
) {
1001 gemu_log("\"%s\"%s", s
, get_comma(last
));
1002 unlock_user(s
, addr
, 0);
1004 /* can't get string out of it, so print it as pointer */
1005 print_pointer(addr
, last
);
1009 #define MAX_PRINT_BUF 40
1011 print_buf(abi_long addr
, abi_long len
, int last
)
1016 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1019 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1020 if (isprint(s
[i
])) {
1021 gemu_log("%c", s
[i
]);
1023 gemu_log("\\%o", s
[i
]);
1033 unlock_user(s
, addr
, 0);
1035 print_pointer(addr
, last
);
1040 * Prints out raw parameter using given format. Caller needs
1041 * to do byte swapping if needed.
1044 print_raw_param(const char *fmt
, abi_long param
, int last
)
1048 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1049 gemu_log(format
, param
);
1053 print_pointer(abi_long p
, int last
)
1056 gemu_log("NULL%s", get_comma(last
));
1058 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1062 * Reads 32-bit (int) number from guest address space from
1063 * address 'addr' and prints it.
1066 print_number(abi_long addr
, int last
)
1069 gemu_log("NULL%s", get_comma(last
));
1073 get_user_s32(num
, addr
);
1074 gemu_log("[%d]%s", num
, get_comma(last
));
1079 print_timeval(abi_ulong tv_addr
, int last
)
1082 struct target_timeval
*tv
;
1084 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1087 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
1088 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1089 unlock_user(tv
, tv_addr
, 0);
1091 gemu_log("NULL%s", get_comma(last
));
1096 #ifdef TARGET_NR_accept
1098 print_accept(const struct syscallname
*name
,
1099 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1100 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1102 print_syscall_prologue(name
);
1103 print_raw_param("%d", arg0
, 0);
1104 print_pointer(arg1
, 0);
1105 print_number(arg2
, 1);
1106 print_syscall_epilogue(name
);
1110 #ifdef TARGET_NR_access
1112 print_access(const struct syscallname
*name
,
1113 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1114 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1116 print_syscall_prologue(name
);
1117 print_string(arg0
, 0);
1118 print_flags(access_flags
, arg1
, 1);
1119 print_syscall_epilogue(name
);
1123 #ifdef TARGET_NR_brk
1125 print_brk(const struct syscallname
*name
,
1126 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1127 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1129 print_syscall_prologue(name
);
1130 print_pointer(arg0
, 1);
1131 print_syscall_epilogue(name
);
1135 #ifdef TARGET_NR_chdir
1137 print_chdir(const struct syscallname
*name
,
1138 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1139 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1141 print_syscall_prologue(name
);
1142 print_string(arg0
, 1);
1143 print_syscall_epilogue(name
);
1147 #ifdef TARGET_NR_chmod
1149 print_chmod(const struct syscallname
*name
,
1150 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1151 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1153 print_syscall_prologue(name
);
1154 print_string(arg0
, 0);
1155 print_file_mode(arg1
, 1);
1156 print_syscall_epilogue(name
);
1160 #ifdef TARGET_NR_clock_adjtime
1162 print_clock_adjtime(const struct syscallname
*name
,
1163 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1164 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1166 print_syscall_prologue(name
);
1167 print_clockid(arg0
, 0);
1168 print_pointer(arg1
, 1);
1169 print_syscall_epilogue(name
);
1173 #ifdef TARGET_NR_clone
1174 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1175 abi_ulong parent_tidptr
, target_ulong newtls
,
1176 abi_ulong child_tidptr
)
1178 print_flags(clone_flags
, flags
, 0);
1179 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1180 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1181 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1182 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1186 print_clone(const struct syscallname
*name
,
1187 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1188 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1190 print_syscall_prologue(name
);
1191 #if defined(TARGET_MICROBLAZE)
1192 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1193 #elif defined(TARGET_CLONE_BACKWARDS)
1194 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1195 #elif defined(TARGET_CLONE_BACKWARDS2)
1196 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1198 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1200 print_syscall_epilogue(name
);
1204 #ifdef TARGET_NR_creat
1206 print_creat(const struct syscallname
*name
,
1207 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1208 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1210 print_syscall_prologue(name
);
1211 print_string(arg0
, 0);
1212 print_file_mode(arg1
, 1);
1213 print_syscall_epilogue(name
);
1217 #ifdef TARGET_NR_execv
1219 print_execv(const struct syscallname
*name
,
1220 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1221 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1223 print_syscall_prologue(name
);
1224 print_string(arg0
, 0);
1225 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1226 print_syscall_epilogue(name
);
1230 #ifdef TARGET_NR_faccessat
1232 print_faccessat(const struct syscallname
*name
,
1233 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1234 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1236 print_syscall_prologue(name
);
1237 print_at_dirfd(arg0
, 0);
1238 print_string(arg1
, 0);
1239 print_flags(access_flags
, arg2
, 0);
1240 print_flags(at_file_flags
, arg3
, 1);
1241 print_syscall_epilogue(name
);
1245 #ifdef TARGET_NR_fchmodat
1247 print_fchmodat(const struct syscallname
*name
,
1248 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1249 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1251 print_syscall_prologue(name
);
1252 print_at_dirfd(arg0
, 0);
1253 print_string(arg1
, 0);
1254 print_file_mode(arg2
, 0);
1255 print_flags(at_file_flags
, arg3
, 1);
1256 print_syscall_epilogue(name
);
1260 #ifdef TARGET_NR_fchownat
1262 print_fchownat(const struct syscallname
*name
,
1263 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1264 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1266 print_syscall_prologue(name
);
1267 print_at_dirfd(arg0
, 0);
1268 print_string(arg1
, 0);
1269 print_raw_param("%d", arg2
, 0);
1270 print_raw_param("%d", arg3
, 0);
1271 print_flags(at_file_flags
, arg4
, 1);
1272 print_syscall_epilogue(name
);
1276 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1278 print_fcntl(const struct syscallname
*name
,
1279 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1280 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1282 print_syscall_prologue(name
);
1283 print_raw_param("%d", arg0
, 0);
1285 case TARGET_F_DUPFD
:
1286 gemu_log("F_DUPFD,");
1287 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1289 case TARGET_F_GETFD
:
1290 gemu_log("F_GETFD");
1292 case TARGET_F_SETFD
:
1293 gemu_log("F_SETFD,");
1294 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1296 case TARGET_F_GETFL
:
1297 gemu_log("F_GETFL");
1299 case TARGET_F_SETFL
:
1300 gemu_log("F_SETFL,");
1301 print_open_flags(arg2
, 1);
1303 case TARGET_F_GETLK
:
1304 gemu_log("F_GETLK,");
1305 print_pointer(arg2
, 1);
1307 case TARGET_F_SETLK
:
1308 gemu_log("F_SETLK,");
1309 print_pointer(arg2
, 1);
1311 case TARGET_F_SETLKW
:
1312 gemu_log("F_SETLKW,");
1313 print_pointer(arg2
, 1);
1315 case TARGET_F_GETOWN
:
1316 gemu_log("F_GETOWN");
1318 case TARGET_F_SETOWN
:
1319 gemu_log("F_SETOWN,");
1320 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1322 case TARGET_F_GETSIG
:
1323 gemu_log("F_GETSIG");
1325 case TARGET_F_SETSIG
:
1326 gemu_log("F_SETSIG,");
1327 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1329 #if TARGET_ABI_BITS == 32
1330 case TARGET_F_GETLK64
:
1331 gemu_log("F_GETLK64,");
1332 print_pointer(arg2
, 1);
1334 case TARGET_F_SETLK64
:
1335 gemu_log("F_SETLK64,");
1336 print_pointer(arg2
, 1);
1338 case TARGET_F_SETLKW64
:
1339 gemu_log("F_SETLKW64,");
1340 print_pointer(arg2
, 1);
1343 case TARGET_F_SETLEASE
:
1344 gemu_log("F_SETLEASE,");
1345 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1347 case TARGET_F_GETLEASE
:
1348 gemu_log("F_GETLEASE");
1350 case TARGET_F_SETPIPE_SZ
:
1351 gemu_log("F_SETPIPE_SZ,");
1352 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1354 case TARGET_F_GETPIPE_SZ
:
1355 gemu_log("F_GETPIPE_SZ");
1357 case TARGET_F_DUPFD_CLOEXEC
:
1358 gemu_log("F_DUPFD_CLOEXEC,");
1359 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1361 case TARGET_F_NOTIFY
:
1362 gemu_log("F_NOTIFY,");
1363 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1366 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1367 print_pointer(arg2
, 1);
1370 print_syscall_epilogue(name
);
1372 #define print_fcntl64 print_fcntl
1376 #ifdef TARGET_NR_futimesat
1378 print_futimesat(const struct syscallname
*name
,
1379 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1380 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1382 print_syscall_prologue(name
);
1383 print_at_dirfd(arg0
, 0);
1384 print_string(arg1
, 0);
1385 print_timeval(arg2
, 0);
1386 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
1387 print_syscall_epilogue(name
);
1391 #ifdef TARGET_NR_link
1393 print_link(const struct syscallname
*name
,
1394 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1395 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1397 print_syscall_prologue(name
);
1398 print_string(arg0
, 0);
1399 print_string(arg1
, 1);
1400 print_syscall_epilogue(name
);
1404 #ifdef TARGET_NR_linkat
1406 print_linkat(const struct syscallname
*name
,
1407 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1408 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1410 print_syscall_prologue(name
);
1411 print_at_dirfd(arg0
, 0);
1412 print_string(arg1
, 0);
1413 print_at_dirfd(arg2
, 0);
1414 print_string(arg3
, 0);
1415 print_flags(at_file_flags
, arg4
, 1);
1416 print_syscall_epilogue(name
);
1420 #ifdef TARGET_NR__llseek
1422 print__llseek(const struct syscallname
*name
,
1423 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1424 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1426 const char *whence
= "UNKNOWN";
1427 print_syscall_prologue(name
);
1428 print_raw_param("%d", arg0
, 0);
1429 print_raw_param("%ld", arg1
, 0);
1430 print_raw_param("%ld", arg2
, 0);
1431 print_pointer(arg3
, 0);
1433 case SEEK_SET
: whence
= "SEEK_SET"; break;
1434 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
1435 case SEEK_END
: whence
= "SEEK_END"; break;
1437 gemu_log("%s",whence
);
1438 print_syscall_epilogue(name
);
1442 #if defined(TARGET_NR_socket)
1444 print_socket(const struct syscallname
*name
,
1445 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1446 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1448 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
1450 print_syscall_prologue(name
);
1451 print_socket_domain(domain
);
1453 print_socket_type(type
);
1455 if (domain
== AF_PACKET
||
1456 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1457 protocol
= tswap16(protocol
);
1459 print_socket_protocol(domain
, type
, protocol
);
1460 print_syscall_epilogue(name
);
1465 #if defined(TARGET_NR_socketcall)
1467 #define get_user_ualx(x, gaddr, idx) \
1468 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1470 static void do_print_socket(const char *name
, abi_long arg1
)
1472 abi_ulong domain
, type
, protocol
;
1474 get_user_ualx(domain
, arg1
, 0);
1475 get_user_ualx(type
, arg1
, 1);
1476 get_user_ualx(protocol
, arg1
, 2);
1477 gemu_log("%s(", name
);
1478 print_socket_domain(domain
);
1480 print_socket_type(type
);
1482 if (domain
== AF_PACKET
||
1483 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1484 protocol
= tswap16(protocol
);
1486 print_socket_protocol(domain
, type
, protocol
);
1490 static void do_print_sockaddr(const char *name
, abi_long arg1
)
1492 abi_ulong sockfd
, addr
, addrlen
;
1494 get_user_ualx(sockfd
, arg1
, 0);
1495 get_user_ualx(addr
, arg1
, 1);
1496 get_user_ualx(addrlen
, arg1
, 2);
1498 gemu_log("%s(", name
);
1499 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1500 print_sockaddr(addr
, addrlen
);
1504 static void do_print_listen(const char *name
, abi_long arg1
)
1506 abi_ulong sockfd
, backlog
;
1508 get_user_ualx(sockfd
, arg1
, 0);
1509 get_user_ualx(backlog
, arg1
, 1);
1511 gemu_log("%s(", name
);
1512 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1513 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
1517 static void do_print_socketpair(const char *name
, abi_long arg1
)
1519 abi_ulong domain
, type
, protocol
, tab
;
1521 get_user_ualx(domain
, arg1
, 0);
1522 get_user_ualx(type
, arg1
, 1);
1523 get_user_ualx(protocol
, arg1
, 2);
1524 get_user_ualx(tab
, arg1
, 3);
1526 gemu_log("%s(", name
);
1527 print_socket_domain(domain
);
1529 print_socket_type(type
);
1531 print_socket_protocol(domain
, type
, protocol
);
1533 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
1537 static void do_print_sendrecv(const char *name
, abi_long arg1
)
1539 abi_ulong sockfd
, msg
, len
, flags
;
1541 get_user_ualx(sockfd
, arg1
, 0);
1542 get_user_ualx(msg
, arg1
, 1);
1543 get_user_ualx(len
, arg1
, 2);
1544 get_user_ualx(flags
, arg1
, 3);
1546 gemu_log("%s(", name
);
1547 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1548 print_buf(msg
, len
, 0);
1549 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1550 print_flags(msg_flags
, flags
, 1);
1554 static void do_print_msgaddr(const char *name
, abi_long arg1
)
1556 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
1558 get_user_ualx(sockfd
, arg1
, 0);
1559 get_user_ualx(msg
, arg1
, 1);
1560 get_user_ualx(len
, arg1
, 2);
1561 get_user_ualx(flags
, arg1
, 3);
1562 get_user_ualx(addr
, arg1
, 4);
1563 get_user_ualx(addrlen
, arg1
, 5);
1565 gemu_log("%s(", name
);
1566 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1567 print_buf(msg
, len
, 0);
1568 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1569 print_flags(msg_flags
, flags
, 0);
1570 print_sockaddr(addr
, addrlen
);
1574 static void do_print_shutdown(const char *name
, abi_long arg1
)
1576 abi_ulong sockfd
, how
;
1578 get_user_ualx(sockfd
, arg1
, 0);
1579 get_user_ualx(how
, arg1
, 1);
1581 gemu_log("shutdown(");
1582 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1585 gemu_log("SHUT_RD");
1588 gemu_log("SHUT_WR");
1591 gemu_log("SHUT_RDWR");
1594 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
1600 static void do_print_msg(const char *name
, abi_long arg1
)
1602 abi_ulong sockfd
, msg
, flags
;
1604 get_user_ualx(sockfd
, arg1
, 0);
1605 get_user_ualx(msg
, arg1
, 1);
1606 get_user_ualx(flags
, arg1
, 2);
1608 gemu_log("%s(", name
);
1609 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1610 print_pointer(msg
, 0);
1611 print_flags(msg_flags
, flags
, 1);
1615 static void do_print_sockopt(const char *name
, abi_long arg1
)
1617 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
1619 get_user_ualx(sockfd
, arg1
, 0);
1620 get_user_ualx(level
, arg1
, 1);
1621 get_user_ualx(optname
, arg1
, 2);
1622 get_user_ualx(optval
, arg1
, 3);
1623 get_user_ualx(optlen
, arg1
, 4);
1625 gemu_log("%s(", name
);
1626 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1629 gemu_log("SOL_TCP,");
1630 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1631 print_pointer(optval
, 0);
1634 gemu_log("SOL_IP,");
1635 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1636 print_pointer(optval
, 0);
1639 gemu_log("SOL_RAW,");
1640 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1641 print_pointer(optval
, 0);
1643 case TARGET_SOL_SOCKET
:
1644 gemu_log("SOL_SOCKET,");
1646 case TARGET_SO_DEBUG
:
1647 gemu_log("SO_DEBUG,");
1649 print_number(optval
, 0);
1651 case TARGET_SO_REUSEADDR
:
1652 gemu_log("SO_REUSEADDR,");
1654 case TARGET_SO_TYPE
:
1655 gemu_log("SO_TYPE,");
1657 case TARGET_SO_ERROR
:
1658 gemu_log("SO_ERROR,");
1660 case TARGET_SO_DONTROUTE
:
1661 gemu_log("SO_DONTROUTE,");
1663 case TARGET_SO_BROADCAST
:
1664 gemu_log("SO_BROADCAST,");
1666 case TARGET_SO_SNDBUF
:
1667 gemu_log("SO_SNDBUF,");
1669 case TARGET_SO_RCVBUF
:
1670 gemu_log("SO_RCVBUF,");
1672 case TARGET_SO_KEEPALIVE
:
1673 gemu_log("SO_KEEPALIVE,");
1675 case TARGET_SO_OOBINLINE
:
1676 gemu_log("SO_OOBINLINE,");
1678 case TARGET_SO_NO_CHECK
:
1679 gemu_log("SO_NO_CHECK,");
1681 case TARGET_SO_PRIORITY
:
1682 gemu_log("SO_PRIORITY,");
1684 case TARGET_SO_BSDCOMPAT
:
1685 gemu_log("SO_BSDCOMPAT,");
1687 case TARGET_SO_PASSCRED
:
1688 gemu_log("SO_PASSCRED,");
1690 case TARGET_SO_TIMESTAMP
:
1691 gemu_log("SO_TIMESTAMP,");
1693 case TARGET_SO_RCVLOWAT
:
1694 gemu_log("SO_RCVLOWAT,");
1696 case TARGET_SO_RCVTIMEO
:
1697 gemu_log("SO_RCVTIMEO,");
1698 print_timeval(optval
, 0);
1700 case TARGET_SO_SNDTIMEO
:
1701 gemu_log("SO_SNDTIMEO,");
1702 print_timeval(optval
, 0);
1704 case TARGET_SO_ATTACH_FILTER
: {
1705 struct target_sock_fprog
*fprog
;
1707 gemu_log("SO_ATTACH_FILTER,");
1709 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
1710 struct target_sock_filter
*filter
;
1712 if (lock_user_struct(VERIFY_READ
, filter
,
1713 tswapal(fprog
->filter
), 0)) {
1715 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
1716 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1717 i
, tswap16(filter
[i
].code
),
1718 filter
[i
].jt
, filter
[i
].jf
,
1719 tswap32(filter
[i
].k
));
1721 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1722 i
, tswap16(filter
[i
].code
),
1723 filter
[i
].jt
, filter
[i
].jf
,
1724 tswap32(filter
[i
].k
));
1726 gemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
1728 gemu_log(",%d},", tswap16(fprog
->len
));
1729 unlock_user(fprog
, optval
, 0);
1731 print_pointer(optval
, 0);
1736 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1737 print_pointer(optval
, 0);
1742 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
1743 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1744 print_pointer(optval
, 0);
1747 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
1751 #define PRINT_SOCKOP(name, func) \
1752 [TARGET_SYS_##name] = { #name, func }
1756 void (*print
)(const char *, abi_long
);
1758 PRINT_SOCKOP(SOCKET
, do_print_socket
),
1759 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
1760 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
1761 PRINT_SOCKOP(LISTEN
, do_print_listen
),
1762 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
1763 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
1764 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
1765 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
1766 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
1767 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
1768 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
1769 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
1770 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
1771 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
1772 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
1773 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
1774 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
1775 PRINT_SOCKOP(ACCEPT4
, NULL
),
1776 PRINT_SOCKOP(RECVMMSG
, NULL
),
1777 PRINT_SOCKOP(SENDMMSG
, NULL
),
1781 print_socketcall(const struct syscallname
*name
,
1782 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1783 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1785 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
1786 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
1789 print_syscall_prologue(name
);
1790 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
1791 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1792 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1793 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
1794 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
1795 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
1796 print_syscall_epilogue(name
);
1800 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
1801 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
1803 print_stat(const struct syscallname
*name
,
1804 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1805 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1807 print_syscall_prologue(name
);
1808 print_string(arg0
, 0);
1809 print_pointer(arg1
, 1);
1810 print_syscall_epilogue(name
);
1812 #define print_lstat print_stat
1813 #define print_stat64 print_stat
1814 #define print_lstat64 print_stat
1817 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
1819 print_fstat(const struct syscallname
*name
,
1820 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1821 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1823 print_syscall_prologue(name
);
1824 print_raw_param("%d", arg0
, 0);
1825 print_pointer(arg1
, 1);
1826 print_syscall_epilogue(name
);
1828 #define print_fstat64 print_fstat
1831 #ifdef TARGET_NR_mkdir
1833 print_mkdir(const struct syscallname
*name
,
1834 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1835 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1837 print_syscall_prologue(name
);
1838 print_string(arg0
, 0);
1839 print_file_mode(arg1
, 1);
1840 print_syscall_epilogue(name
);
1844 #ifdef TARGET_NR_mkdirat
1846 print_mkdirat(const struct syscallname
*name
,
1847 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1848 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1850 print_syscall_prologue(name
);
1851 print_at_dirfd(arg0
, 0);
1852 print_string(arg1
, 0);
1853 print_file_mode(arg2
, 1);
1854 print_syscall_epilogue(name
);
1858 #ifdef TARGET_NR_rmdir
1860 print_rmdir(const struct syscallname
*name
,
1861 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1862 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1864 print_syscall_prologue(name
);
1865 print_string(arg0
, 0);
1866 print_syscall_epilogue(name
);
1870 #ifdef TARGET_NR_rt_sigaction
1872 print_rt_sigaction(const struct syscallname
*name
,
1873 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1874 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1876 print_syscall_prologue(name
);
1877 print_signal(arg0
, 0);
1878 print_pointer(arg1
, 0);
1879 print_pointer(arg2
, 1);
1880 print_syscall_epilogue(name
);
1884 #ifdef TARGET_NR_rt_sigprocmask
1886 print_rt_sigprocmask(const struct syscallname
*name
,
1887 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1888 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1890 const char *how
= "UNKNOWN";
1891 print_syscall_prologue(name
);
1893 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
1894 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
1895 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
1897 gemu_log("%s,",how
);
1898 print_pointer(arg1
, 0);
1899 print_pointer(arg2
, 1);
1900 print_syscall_epilogue(name
);
1904 #ifdef TARGET_NR_syslog
1906 print_syslog_action(abi_ulong arg
, int last
)
1911 case TARGET_SYSLOG_ACTION_CLOSE
: {
1912 type
= "SYSLOG_ACTION_CLOSE";
1915 case TARGET_SYSLOG_ACTION_OPEN
: {
1916 type
= "SYSLOG_ACTION_OPEN";
1919 case TARGET_SYSLOG_ACTION_READ
: {
1920 type
= "SYSLOG_ACTION_READ";
1923 case TARGET_SYSLOG_ACTION_READ_ALL
: {
1924 type
= "SYSLOG_ACTION_READ_ALL";
1927 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
1928 type
= "SYSLOG_ACTION_READ_CLEAR";
1931 case TARGET_SYSLOG_ACTION_CLEAR
: {
1932 type
= "SYSLOG_ACTION_CLEAR";
1935 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
1936 type
= "SYSLOG_ACTION_CONSOLE_OFF";
1939 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
1940 type
= "SYSLOG_ACTION_CONSOLE_ON";
1943 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
1944 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
1947 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
1948 type
= "SYSLOG_ACTION_SIZE_UNREAD";
1951 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
1952 type
= "SYSLOG_ACTION_SIZE_BUFFER";
1956 print_raw_param("%ld", arg
, last
);
1960 gemu_log("%s%s", type
, get_comma(last
));
1964 print_syslog(const struct syscallname
*name
,
1965 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1966 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1968 print_syscall_prologue(name
);
1969 print_syslog_action(arg0
, 0);
1970 print_pointer(arg1
, 0);
1971 print_raw_param("%d", arg2
, 1);
1972 print_syscall_epilogue(name
);
1976 #ifdef TARGET_NR_mknod
1978 print_mknod(const struct syscallname
*name
,
1979 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1980 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1982 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
1984 print_syscall_prologue(name
);
1985 print_string(arg0
, 0);
1986 print_file_mode(arg1
, (hasdev
== 0));
1988 print_raw_param("makedev(%d", major(arg2
), 0);
1989 print_raw_param("%d)", minor(arg2
), 1);
1991 print_syscall_epilogue(name
);
1995 #ifdef TARGET_NR_mknodat
1997 print_mknodat(const struct syscallname
*name
,
1998 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1999 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2001 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
2003 print_syscall_prologue(name
);
2004 print_at_dirfd(arg0
, 0);
2005 print_string(arg1
, 0);
2006 print_file_mode(arg2
, (hasdev
== 0));
2008 print_raw_param("makedev(%d", major(arg3
), 0);
2009 print_raw_param("%d)", minor(arg3
), 1);
2011 print_syscall_epilogue(name
);
2015 #ifdef TARGET_NR_mq_open
2017 print_mq_open(const struct syscallname
*name
,
2018 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2019 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2021 int is_creat
= (arg1
& TARGET_O_CREAT
);
2023 print_syscall_prologue(name
);
2024 print_string(arg0
, 0);
2025 print_open_flags(arg1
, (is_creat
== 0));
2027 print_file_mode(arg2
, 0);
2028 print_pointer(arg3
, 1);
2030 print_syscall_epilogue(name
);
2034 #ifdef TARGET_NR_open
2036 print_open(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 int is_creat
= (arg1
& TARGET_O_CREAT
);
2042 print_syscall_prologue(name
);
2043 print_string(arg0
, 0);
2044 print_open_flags(arg1
, (is_creat
== 0));
2046 print_file_mode(arg2
, 1);
2047 print_syscall_epilogue(name
);
2051 #ifdef TARGET_NR_openat
2053 print_openat(const struct syscallname
*name
,
2054 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2055 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2057 int is_creat
= (arg2
& TARGET_O_CREAT
);
2059 print_syscall_prologue(name
);
2060 print_at_dirfd(arg0
, 0);
2061 print_string(arg1
, 0);
2062 print_open_flags(arg2
, (is_creat
== 0));
2064 print_file_mode(arg3
, 1);
2065 print_syscall_epilogue(name
);
2069 #ifdef TARGET_NR_mq_unlink
2071 print_mq_unlink(const struct syscallname
*name
,
2072 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2073 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2075 print_syscall_prologue(name
);
2076 print_string(arg0
, 1);
2077 print_syscall_epilogue(name
);
2081 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2083 print_fstatat64(const struct syscallname
*name
,
2084 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2085 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2087 print_syscall_prologue(name
);
2088 print_at_dirfd(arg0
, 0);
2089 print_string(arg1
, 0);
2090 print_pointer(arg2
, 0);
2091 print_flags(at_file_flags
, arg3
, 1);
2092 print_syscall_epilogue(name
);
2094 #define print_newfstatat print_fstatat64
2097 #ifdef TARGET_NR_readlink
2099 print_readlink(const struct syscallname
*name
,
2100 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2101 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2103 print_syscall_prologue(name
);
2104 print_string(arg0
, 0);
2105 print_pointer(arg1
, 0);
2106 print_raw_param("%u", arg2
, 1);
2107 print_syscall_epilogue(name
);
2111 #ifdef TARGET_NR_readlinkat
2113 print_readlinkat(const struct syscallname
*name
,
2114 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2115 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2117 print_syscall_prologue(name
);
2118 print_at_dirfd(arg0
, 0);
2119 print_string(arg1
, 0);
2120 print_pointer(arg2
, 0);
2121 print_raw_param("%u", arg3
, 1);
2122 print_syscall_epilogue(name
);
2126 #ifdef TARGET_NR_rename
2128 print_rename(const struct syscallname
*name
,
2129 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2130 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2132 print_syscall_prologue(name
);
2133 print_string(arg0
, 0);
2134 print_string(arg1
, 1);
2135 print_syscall_epilogue(name
);
2139 #ifdef TARGET_NR_renameat
2141 print_renameat(const struct syscallname
*name
,
2142 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2143 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2145 print_syscall_prologue(name
);
2146 print_at_dirfd(arg0
, 0);
2147 print_string(arg1
, 0);
2148 print_at_dirfd(arg2
, 0);
2149 print_string(arg3
, 1);
2150 print_syscall_epilogue(name
);
2154 #ifdef TARGET_NR_statfs
2156 print_statfs(const struct syscallname
*name
,
2157 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2158 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2160 print_syscall_prologue(name
);
2161 print_string(arg0
, 0);
2162 print_pointer(arg1
, 1);
2163 print_syscall_epilogue(name
);
2165 #define print_statfs64 print_statfs
2168 #ifdef TARGET_NR_symlink
2170 print_symlink(const struct syscallname
*name
,
2171 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2172 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2174 print_syscall_prologue(name
);
2175 print_string(arg0
, 0);
2176 print_string(arg1
, 1);
2177 print_syscall_epilogue(name
);
2181 #ifdef TARGET_NR_symlinkat
2183 print_symlinkat(const struct syscallname
*name
,
2184 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2185 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2187 print_syscall_prologue(name
);
2188 print_string(arg0
, 0);
2189 print_at_dirfd(arg1
, 0);
2190 print_string(arg2
, 1);
2191 print_syscall_epilogue(name
);
2195 #ifdef TARGET_NR_mount
2197 print_mount(const struct syscallname
*name
,
2198 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2199 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2201 print_syscall_prologue(name
);
2202 print_string(arg0
, 0);
2203 print_string(arg1
, 0);
2204 print_string(arg2
, 0);
2205 print_flags(mount_flags
, arg3
, 0);
2206 print_pointer(arg4
, 1);
2207 print_syscall_epilogue(name
);
2211 #ifdef TARGET_NR_umount
2213 print_umount(const struct syscallname
*name
,
2214 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2215 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2217 print_syscall_prologue(name
);
2218 print_string(arg0
, 1);
2219 print_syscall_epilogue(name
);
2223 #ifdef TARGET_NR_umount2
2225 print_umount2(const struct syscallname
*name
,
2226 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2227 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2229 print_syscall_prologue(name
);
2230 print_string(arg0
, 0);
2231 print_flags(umount2_flags
, arg1
, 1);
2232 print_syscall_epilogue(name
);
2236 #ifdef TARGET_NR_unlink
2238 print_unlink(const struct syscallname
*name
,
2239 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2240 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2242 print_syscall_prologue(name
);
2243 print_string(arg0
, 1);
2244 print_syscall_epilogue(name
);
2248 #ifdef TARGET_NR_unlinkat
2250 print_unlinkat(const struct syscallname
*name
,
2251 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2252 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2254 print_syscall_prologue(name
);
2255 print_at_dirfd(arg0
, 0);
2256 print_string(arg1
, 0);
2257 print_flags(unlinkat_flags
, arg2
, 1);
2258 print_syscall_epilogue(name
);
2262 #ifdef TARGET_NR_utime
2264 print_utime(const struct syscallname
*name
,
2265 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2266 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2268 print_syscall_prologue(name
);
2269 print_string(arg0
, 0);
2270 print_pointer(arg1
, 1);
2271 print_syscall_epilogue(name
);
2275 #ifdef TARGET_NR_utimes
2277 print_utimes(const struct syscallname
*name
,
2278 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2279 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2281 print_syscall_prologue(name
);
2282 print_string(arg0
, 0);
2283 print_pointer(arg1
, 1);
2284 print_syscall_epilogue(name
);
2288 #ifdef TARGET_NR_utimensat
2290 print_utimensat(const struct syscallname
*name
,
2291 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2292 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2294 print_syscall_prologue(name
);
2295 print_at_dirfd(arg0
, 0);
2296 print_string(arg1
, 0);
2297 print_pointer(arg2
, 0);
2298 print_flags(at_file_flags
, arg3
, 1);
2299 print_syscall_epilogue(name
);
2303 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2305 print_mmap(const struct syscallname
*name
,
2306 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2307 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2309 print_syscall_prologue(name
);
2310 print_pointer(arg0
, 0);
2311 print_raw_param("%d", arg1
, 0);
2312 print_flags(mmap_prot_flags
, arg2
, 0);
2313 print_flags(mmap_flags
, arg3
, 0);
2314 print_raw_param("%d", arg4
, 0);
2315 print_raw_param("%#x", arg5
, 1);
2316 print_syscall_epilogue(name
);
2318 #define print_mmap2 print_mmap
2321 #ifdef TARGET_NR_mprotect
2323 print_mprotect(const struct syscallname
*name
,
2324 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2325 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2327 print_syscall_prologue(name
);
2328 print_pointer(arg0
, 0);
2329 print_raw_param("%d", arg1
, 0);
2330 print_flags(mmap_prot_flags
, arg2
, 1);
2331 print_syscall_epilogue(name
);
2335 #ifdef TARGET_NR_munmap
2337 print_munmap(const struct syscallname
*name
,
2338 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2339 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2341 print_syscall_prologue(name
);
2342 print_pointer(arg0
, 0);
2343 print_raw_param("%d", arg1
, 1);
2344 print_syscall_epilogue(name
);
2348 #ifdef TARGET_NR_futex
2349 static void print_futex_op(abi_long tflag
, int last
)
2351 #define print_op(val) \
2352 if( cmd == val ) { \
2357 int cmd
= (int)tflag
;
2358 #ifdef FUTEX_PRIVATE_FLAG
2359 if (cmd
& FUTEX_PRIVATE_FLAG
) {
2360 gemu_log("FUTEX_PRIVATE_FLAG|");
2361 cmd
&= ~FUTEX_PRIVATE_FLAG
;
2364 #ifdef FUTEX_CLOCK_REALTIME
2365 if (cmd
& FUTEX_CLOCK_REALTIME
) {
2366 gemu_log("FUTEX_CLOCK_REALTIME|");
2367 cmd
&= ~FUTEX_CLOCK_REALTIME
;
2370 print_op(FUTEX_WAIT
)
2371 print_op(FUTEX_WAKE
)
2373 print_op(FUTEX_REQUEUE
)
2374 print_op(FUTEX_CMP_REQUEUE
)
2375 print_op(FUTEX_WAKE_OP
)
2376 print_op(FUTEX_LOCK_PI
)
2377 print_op(FUTEX_UNLOCK_PI
)
2378 print_op(FUTEX_TRYLOCK_PI
)
2379 #ifdef FUTEX_WAIT_BITSET
2380 print_op(FUTEX_WAIT_BITSET
)
2382 #ifdef FUTEX_WAKE_BITSET
2383 print_op(FUTEX_WAKE_BITSET
)
2385 /* unknown values */
2390 print_futex(const struct syscallname
*name
,
2391 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2392 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2394 print_syscall_prologue(name
);
2395 print_pointer(arg0
, 0);
2396 print_futex_op(arg1
, 0);
2397 print_raw_param(",%d", arg2
, 0);
2398 print_pointer(arg3
, 0); /* struct timespec */
2399 print_pointer(arg4
, 0);
2400 print_raw_param("%d", arg4
, 1);
2401 print_syscall_epilogue(name
);
2405 #ifdef TARGET_NR_kill
2407 print_kill(const struct syscallname
*name
,
2408 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2409 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2411 print_syscall_prologue(name
);
2412 print_raw_param("%d", arg0
, 0);
2413 print_signal(arg1
, 1);
2414 print_syscall_epilogue(name
);
2419 * An array of all of the syscalls we know about
2422 static const struct syscallname scnames
[] = {
2423 #include "strace.list"
2426 static int nsyscalls
= ARRAY_SIZE(scnames
);
2429 * The public interface to this module.
2432 print_syscall(int num
,
2433 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2434 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2437 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
")";
2439 gemu_log("%d ", getpid() );
2441 for(i
=0;i
<nsyscalls
;i
++)
2442 if( scnames
[i
].nr
== num
) {
2443 if( scnames
[i
].call
!= NULL
) {
2444 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2446 /* XXX: this format system is broken because it uses
2447 host types and host pointers for strings */
2448 if( scnames
[i
].format
!= NULL
)
2449 format
= scnames
[i
].format
;
2450 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2454 gemu_log("Unknown syscall %d\n", num
);
2459 print_syscall_ret(int num
, abi_long ret
)
2462 const char *errstr
= NULL
;
2464 for(i
=0;i
<nsyscalls
;i
++)
2465 if( scnames
[i
].nr
== num
) {
2466 if( scnames
[i
].result
!= NULL
) {
2467 scnames
[i
].result(&scnames
[i
],ret
);
2470 errstr
= target_strerror(-ret
);
2473 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n",
2476 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);
2483 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
2485 /* Print the strace output for a signal being taken:
2486 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2489 print_signal(target_signum
, 1);
2491 print_siginfo(tinfo
);