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 */
94 output_cmd( MSG_STAT
);
95 output_cmd( MSG_INFO
);
97 /* shmctl() commands */
98 output_cmd( SHM_LOCK
);
99 output_cmd( SHM_UNLOCK
);
100 output_cmd( SHM_STAT
);
101 output_cmd( SHM_INFO
);
102 /* semctl() commands */
103 output_cmd( GETPID
);
104 output_cmd( GETVAL
);
105 output_cmd( GETALL
);
106 output_cmd( GETNCNT
);
107 output_cmd( GETZCNT
);
108 output_cmd( SETVAL
);
109 output_cmd( SETALL
);
110 output_cmd( SEM_STAT
);
111 output_cmd( SEM_INFO
);
112 output_cmd( IPC_RMID
);
113 output_cmd( IPC_RMID
);
114 output_cmd( IPC_RMID
);
115 output_cmd( IPC_RMID
);
116 output_cmd( IPC_RMID
);
117 output_cmd( IPC_RMID
);
118 output_cmd( IPC_RMID
);
119 output_cmd( IPC_RMID
);
120 output_cmd( IPC_RMID
);
122 /* Some value we don't recognize */
127 print_signal(abi_ulong arg
, int last
)
129 const char *signal_name
= NULL
;
131 case TARGET_SIGHUP
: signal_name
= "SIGHUP"; break;
132 case TARGET_SIGINT
: signal_name
= "SIGINT"; break;
133 case TARGET_SIGQUIT
: signal_name
= "SIGQUIT"; break;
134 case TARGET_SIGILL
: signal_name
= "SIGILL"; break;
135 case TARGET_SIGABRT
: signal_name
= "SIGABRT"; break;
136 case TARGET_SIGFPE
: signal_name
= "SIGFPE"; break;
137 case TARGET_SIGKILL
: signal_name
= "SIGKILL"; break;
138 case TARGET_SIGSEGV
: signal_name
= "SIGSEGV"; break;
139 case TARGET_SIGPIPE
: signal_name
= "SIGPIPE"; break;
140 case TARGET_SIGALRM
: signal_name
= "SIGALRM"; break;
141 case TARGET_SIGTERM
: signal_name
= "SIGTERM"; break;
142 case TARGET_SIGUSR1
: signal_name
= "SIGUSR1"; break;
143 case TARGET_SIGUSR2
: signal_name
= "SIGUSR2"; break;
144 case TARGET_SIGCHLD
: signal_name
= "SIGCHLD"; break;
145 case TARGET_SIGCONT
: signal_name
= "SIGCONT"; break;
146 case TARGET_SIGSTOP
: signal_name
= "SIGSTOP"; break;
147 case TARGET_SIGTTIN
: signal_name
= "SIGTTIN"; break;
148 case TARGET_SIGTTOU
: signal_name
= "SIGTTOU"; break;
150 if (signal_name
== NULL
) {
151 print_raw_param("%ld", arg
, last
);
154 gemu_log("%s%s", signal_name
, get_comma(last
));
157 static void print_si_code(int arg
)
159 const char *codename
= NULL
;
163 codename
= "SI_USER";
166 codename
= "SI_KERNEL";
169 codename
= "SI_QUEUE";
172 codename
= "SI_TIMER";
175 codename
= "SI_MESGQ";
178 codename
= "SI_ASYNCIO";
181 codename
= "SI_SIGIO";
184 codename
= "SI_TKILL";
190 gemu_log("%s", codename
);
193 static void print_siginfo(const target_siginfo_t
*tinfo
)
195 /* Print a target_siginfo_t in the format desired for printing
196 * signals being taken. We assume the target_siginfo_t is in the
197 * internal form where the top 16 bits of si_code indicate which
198 * part of the union is valid, rather than in the guest-visible
199 * form where the bottom 16 bits are sign-extended into the top 16.
201 int si_type
= extract32(tinfo
->si_code
, 16, 16);
202 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
204 gemu_log("{si_signo=");
205 print_signal(tinfo
->si_signo
, 1);
206 gemu_log(", si_code=");
207 print_si_code(si_code
);
211 gemu_log(", si_pid = %u, si_uid = %u",
212 (unsigned int)tinfo
->_sifields
._kill
._pid
,
213 (unsigned int)tinfo
->_sifields
._kill
._uid
);
216 gemu_log(", si_timer1 = %u, si_timer2 = %u",
217 tinfo
->_sifields
._timer
._timer1
,
218 tinfo
->_sifields
._timer
._timer2
);
221 gemu_log(", si_band = %d, si_fd = %d",
222 tinfo
->_sifields
._sigpoll
._band
,
223 tinfo
->_sifields
._sigpoll
._fd
);
226 gemu_log(", si_addr = ");
227 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
230 gemu_log(", si_pid = %u, si_uid = %u, si_status = %d"
231 ", si_utime=" TARGET_ABI_FMT_ld
232 ", si_stime=" TARGET_ABI_FMT_ld
,
233 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
234 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
235 tinfo
->_sifields
._sigchld
._status
,
236 tinfo
->_sifields
._sigchld
._utime
,
237 tinfo
->_sifields
._sigchld
._stime
);
240 gemu_log(", si_pid = %u, si_uid = %u, si_sigval = " TARGET_ABI_FMT_ld
,
241 (unsigned int)tinfo
->_sifields
._rt
._pid
,
242 (unsigned int)tinfo
->_sifields
._rt
._uid
,
243 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
246 g_assert_not_reached();
252 print_sockaddr(abi_ulong addr
, abi_long addrlen
)
254 struct target_sockaddr
*sa
;
258 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
260 sa_family
= tswap16(sa
->sa_family
);
263 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
265 gemu_log("{sun_family=AF_UNIX,sun_path=\"");
266 for (i
= 0; i
< addrlen
-
267 offsetof(struct target_sockaddr_un
, sun_path
) &&
268 un
->sun_path
[i
]; i
++) {
269 gemu_log("%c", un
->sun_path
[i
]);
275 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
276 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
277 gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
278 ntohs(in
->sin_port
));
279 gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
280 c
[0], c
[1], c
[2], c
[3]);
285 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
286 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
287 gemu_log("{sll_family=AF_PACKET,"
288 "sll_protocol=htons(0x%04x),if%d,pkttype=",
289 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
290 switch (ll
->sll_pkttype
) {
292 gemu_log("PACKET_HOST");
294 case PACKET_BROADCAST
:
295 gemu_log("PACKET_BROADCAST");
297 case PACKET_MULTICAST
:
298 gemu_log("PACKET_MULTICAST");
300 case PACKET_OTHERHOST
:
301 gemu_log("PACKET_OTHERHOST");
303 case PACKET_OUTGOING
:
304 gemu_log("PACKET_OUTGOING");
307 gemu_log("%d", ll
->sll_pkttype
);
310 gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
311 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
316 gemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
317 for (i
= 0; i
< 13; i
++) {
318 gemu_log("%02x, ", sa
->sa_data
[i
]);
320 gemu_log("%02x}", sa
->sa_data
[i
]);
324 unlock_user(sa
, addr
, 0);
326 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
328 gemu_log(", "TARGET_ABI_FMT_ld
, addrlen
);
332 print_socket_domain(int domain
)
342 gemu_log("PF_PACKET");
345 gemu_log("%d", domain
);
351 print_socket_type(int type
)
354 case TARGET_SOCK_DGRAM
:
355 gemu_log("SOCK_DGRAM");
357 case TARGET_SOCK_STREAM
:
358 gemu_log("SOCK_STREAM");
360 case TARGET_SOCK_RAW
:
361 gemu_log("SOCK_RAW");
363 case TARGET_SOCK_RDM
:
364 gemu_log("SOCK_RDM");
366 case TARGET_SOCK_SEQPACKET
:
367 gemu_log("SOCK_SEQPACKET");
369 case TARGET_SOCK_PACKET
:
370 gemu_log("SOCK_PACKET");
376 print_socket_protocol(int domain
, int type
, int protocol
)
378 if (domain
== AF_PACKET
||
379 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
382 gemu_log("ETH_P_ALL");
385 gemu_log("%d", protocol
);
392 gemu_log("IPPROTO_IP");
395 gemu_log("IPPROTO_TCP");
398 gemu_log("IPPROTO_UDP");
401 gemu_log("IPPROTO_RAW");
404 gemu_log("%d", protocol
);
410 #ifdef TARGET_NR__newselect
412 print_fdset(int n
, abi_ulong target_fds_addr
)
417 if( target_fds_addr
) {
418 abi_long
*target_fds
;
420 target_fds
= lock_user(VERIFY_READ
,
422 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
428 for (i
=n
; i
>=0; i
--) {
429 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
432 unlock_user(target_fds
, target_fds_addr
, 0);
438 #ifdef TARGET_NR_clock_adjtime
439 /* IDs of the various system clocks */
440 #define TARGET_CLOCK_REALTIME 0
441 #define TARGET_CLOCK_MONOTONIC 1
442 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
443 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
444 #define TARGET_CLOCK_MONOTONIC_RAW 4
445 #define TARGET_CLOCK_REALTIME_COARSE 5
446 #define TARGET_CLOCK_MONOTONIC_COARSE 6
447 #define TARGET_CLOCK_BOOTTIME 7
448 #define TARGET_CLOCK_REALTIME_ALARM 8
449 #define TARGET_CLOCK_BOOTTIME_ALARM 9
450 #define TARGET_CLOCK_SGI_CYCLE 10
451 #define TARGET_CLOCK_TAI 11
454 print_clockid(int clockid
, int last
)
457 case TARGET_CLOCK_REALTIME
:
458 gemu_log("CLOCK_REALTIME");
460 case TARGET_CLOCK_MONOTONIC
:
461 gemu_log("CLOCK_MONOTONIC");
463 case TARGET_CLOCK_PROCESS_CPUTIME_ID
:
464 gemu_log("CLOCK_PROCESS_CPUTIME_ID");
466 case TARGET_CLOCK_THREAD_CPUTIME_ID
:
467 gemu_log("CLOCK_THREAD_CPUTIME_ID");
469 case TARGET_CLOCK_MONOTONIC_RAW
:
470 gemu_log("CLOCK_MONOTONIC_RAW");
472 case TARGET_CLOCK_REALTIME_COARSE
:
473 gemu_log("CLOCK_REALTIME_COARSE");
475 case TARGET_CLOCK_MONOTONIC_COARSE
:
476 gemu_log("CLOCK_MONOTONIC_COARSE");
478 case TARGET_CLOCK_BOOTTIME
:
479 gemu_log("CLOCK_BOOTTIME");
481 case TARGET_CLOCK_REALTIME_ALARM
:
482 gemu_log("CLOCK_REALTIME_ALARM");
484 case TARGET_CLOCK_BOOTTIME_ALARM
:
485 gemu_log("CLOCK_BOOTTIME_ALARM");
487 case TARGET_CLOCK_SGI_CYCLE
:
488 gemu_log("CLOCK_SGI_CYCLE");
490 case TARGET_CLOCK_TAI
:
491 gemu_log("CLOCK_TAI");
494 gemu_log("%d", clockid
);
497 gemu_log("%s", get_comma(last
));
502 * Sysycall specific output functions
506 #ifdef TARGET_NR__newselect
507 static long newselect_arg1
= 0;
508 static long newselect_arg2
= 0;
509 static long newselect_arg3
= 0;
510 static long newselect_arg4
= 0;
511 static long newselect_arg5
= 0;
514 print_newselect(const struct syscallname
*name
,
515 abi_long arg1
, abi_long arg2
, abi_long arg3
,
516 abi_long arg4
, abi_long arg5
, abi_long arg6
)
518 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
519 print_fdset(arg1
, arg2
);
521 print_fdset(arg1
, arg3
);
523 print_fdset(arg1
, arg4
);
525 print_timeval(arg5
, 1);
528 /* save for use in the return output function below */
537 #ifdef TARGET_NR_semctl
539 print_semctl(const struct syscallname
*name
,
540 abi_long arg1
, abi_long arg2
, abi_long arg3
,
541 abi_long arg4
, abi_long arg5
, abi_long arg6
)
543 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
545 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
550 print_execve(const struct syscallname
*name
,
551 abi_long arg1
, abi_long arg2
, abi_long arg3
,
552 abi_long arg4
, abi_long arg5
, abi_long arg6
)
554 abi_ulong arg_ptr_addr
;
557 if (!(s
= lock_user_string(arg1
)))
559 gemu_log("%s(\"%s\",{", name
->name
, s
);
560 unlock_user(s
, arg1
, 0);
562 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
563 abi_ulong
*arg_ptr
, arg_addr
;
565 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
568 arg_addr
= tswapal(*arg_ptr
);
569 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
572 if ((s
= lock_user_string(arg_addr
))) {
573 gemu_log("\"%s\",", s
);
574 unlock_user(s
, arg_addr
, 0);
583 print_ipc(const struct syscallname
*name
,
584 abi_long arg1
, abi_long arg2
, abi_long arg3
,
585 abi_long arg4
, abi_long arg5
, abi_long arg6
)
589 gemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", arg1
, arg2
);
591 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
594 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
595 name
->name
, arg1
, arg2
, arg3
, arg4
);
601 * Variants for the return value output function
605 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
607 const char *errstr
= NULL
;
610 errstr
= target_strerror(-ret
);
613 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret
, errstr
);
615 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
619 #if 0 /* currently unused */
621 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
623 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
627 #ifdef TARGET_NR__newselect
629 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
631 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
632 print_fdset(newselect_arg1
,newselect_arg2
);
634 print_fdset(newselect_arg1
,newselect_arg3
);
636 print_fdset(newselect_arg1
,newselect_arg4
);
638 print_timeval(newselect_arg5
, 1);
643 /* special meanings of adjtimex()' non-negative return values */
644 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
645 #define TARGET_TIME_INS 1 /* insert leap second */
646 #define TARGET_TIME_DEL 2 /* delete leap second */
647 #define TARGET_TIME_OOP 3 /* leap second in progress */
648 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
649 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
651 print_syscall_ret_adjtimex(const struct syscallname
*name
, abi_long ret
)
653 const char *errstr
= NULL
;
657 gemu_log("-1 errno=%d", errno
);
658 errstr
= target_strerror(-ret
);
660 gemu_log(" (%s)", errstr
);
663 gemu_log(TARGET_ABI_FMT_ld
, ret
);
666 gemu_log(" TIME_OK (clock synchronized, no leap second)");
668 case TARGET_TIME_INS
:
669 gemu_log(" TIME_INS (insert leap second)");
671 case TARGET_TIME_DEL
:
672 gemu_log(" TIME_DEL (delete leap second)");
674 case TARGET_TIME_OOP
:
675 gemu_log(" TIME_OOP (leap second in progress)");
677 case TARGET_TIME_WAIT
:
678 gemu_log(" TIME_WAIT (leap second has occurred)");
680 case TARGET_TIME_ERROR
:
681 gemu_log(" TIME_ERROR (clock not synchronized)");
689 UNUSED
static struct flags access_flags
[] = {
697 UNUSED
static struct flags at_file_flags
[] = {
699 FLAG_GENERIC(AT_EACCESS
),
701 #ifdef AT_SYMLINK_NOFOLLOW
702 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
707 UNUSED
static struct flags unlinkat_flags
[] = {
709 FLAG_GENERIC(AT_REMOVEDIR
),
714 UNUSED
static struct flags mode_flags
[] = {
715 FLAG_GENERIC(S_IFSOCK
),
716 FLAG_GENERIC(S_IFLNK
),
717 FLAG_GENERIC(S_IFREG
),
718 FLAG_GENERIC(S_IFBLK
),
719 FLAG_GENERIC(S_IFDIR
),
720 FLAG_GENERIC(S_IFCHR
),
721 FLAG_GENERIC(S_IFIFO
),
725 UNUSED
static struct flags open_access_flags
[] = {
726 FLAG_TARGET(O_RDONLY
),
727 FLAG_TARGET(O_WRONLY
),
732 UNUSED
static struct flags open_flags
[] = {
733 FLAG_TARGET(O_APPEND
),
734 FLAG_TARGET(O_CREAT
),
735 FLAG_TARGET(O_DIRECTORY
),
737 FLAG_TARGET(O_LARGEFILE
),
738 FLAG_TARGET(O_NOCTTY
),
739 FLAG_TARGET(O_NOFOLLOW
),
740 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
741 FLAG_TARGET(O_DSYNC
),
742 FLAG_TARGET(__O_SYNC
),
743 FLAG_TARGET(O_TRUNC
),
745 FLAG_TARGET(O_DIRECT
),
748 FLAG_TARGET(O_NOATIME
),
751 FLAG_TARGET(O_CLOEXEC
),
759 UNUSED
static struct flags mount_flags
[] = {
761 FLAG_GENERIC(MS_BIND
),
764 FLAG_GENERIC(MS_DIRSYNC
),
766 FLAG_GENERIC(MS_MANDLOCK
),
768 FLAG_GENERIC(MS_MOVE
),
770 FLAG_GENERIC(MS_NOATIME
),
771 FLAG_GENERIC(MS_NODEV
),
772 FLAG_GENERIC(MS_NODIRATIME
),
773 FLAG_GENERIC(MS_NOEXEC
),
774 FLAG_GENERIC(MS_NOSUID
),
775 FLAG_GENERIC(MS_RDONLY
),
777 FLAG_GENERIC(MS_RELATIME
),
779 FLAG_GENERIC(MS_REMOUNT
),
780 FLAG_GENERIC(MS_SYNCHRONOUS
),
784 UNUSED
static struct flags umount2_flags
[] = {
786 FLAG_GENERIC(MNT_FORCE
),
789 FLAG_GENERIC(MNT_DETACH
),
792 FLAG_GENERIC(MNT_EXPIRE
),
797 UNUSED
static struct flags mmap_prot_flags
[] = {
798 FLAG_GENERIC(PROT_NONE
),
799 FLAG_GENERIC(PROT_EXEC
),
800 FLAG_GENERIC(PROT_READ
),
801 FLAG_GENERIC(PROT_WRITE
),
802 FLAG_TARGET(PROT_SEM
),
803 FLAG_GENERIC(PROT_GROWSDOWN
),
804 FLAG_GENERIC(PROT_GROWSUP
),
808 UNUSED
static struct flags mmap_flags
[] = {
809 FLAG_TARGET(MAP_SHARED
),
810 FLAG_TARGET(MAP_PRIVATE
),
811 FLAG_TARGET(MAP_ANONYMOUS
),
812 FLAG_TARGET(MAP_DENYWRITE
),
813 FLAG_TARGET(MAP_FIXED
),
814 FLAG_TARGET(MAP_GROWSDOWN
),
815 FLAG_TARGET(MAP_EXECUTABLE
),
817 FLAG_TARGET(MAP_LOCKED
),
820 FLAG_TARGET(MAP_NONBLOCK
),
822 FLAG_TARGET(MAP_NORESERVE
),
824 FLAG_TARGET(MAP_POPULATE
),
826 #ifdef TARGET_MAP_UNINITIALIZED
827 FLAG_TARGET(MAP_UNINITIALIZED
),
832 UNUSED
static struct flags clone_flags
[] = {
833 FLAG_GENERIC(CLONE_VM
),
834 FLAG_GENERIC(CLONE_FS
),
835 FLAG_GENERIC(CLONE_FILES
),
836 FLAG_GENERIC(CLONE_SIGHAND
),
837 FLAG_GENERIC(CLONE_PTRACE
),
838 FLAG_GENERIC(CLONE_VFORK
),
839 FLAG_GENERIC(CLONE_PARENT
),
840 FLAG_GENERIC(CLONE_THREAD
),
841 FLAG_GENERIC(CLONE_NEWNS
),
842 FLAG_GENERIC(CLONE_SYSVSEM
),
843 FLAG_GENERIC(CLONE_SETTLS
),
844 FLAG_GENERIC(CLONE_PARENT_SETTID
),
845 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
846 FLAG_GENERIC(CLONE_DETACHED
),
847 FLAG_GENERIC(CLONE_UNTRACED
),
848 FLAG_GENERIC(CLONE_CHILD_SETTID
),
849 #if defined(CLONE_NEWUTS)
850 FLAG_GENERIC(CLONE_NEWUTS
),
852 #if defined(CLONE_NEWIPC)
853 FLAG_GENERIC(CLONE_NEWIPC
),
855 #if defined(CLONE_NEWUSER)
856 FLAG_GENERIC(CLONE_NEWUSER
),
858 #if defined(CLONE_NEWPID)
859 FLAG_GENERIC(CLONE_NEWPID
),
861 #if defined(CLONE_NEWNET)
862 FLAG_GENERIC(CLONE_NEWNET
),
864 #if defined(CLONE_IO)
865 FLAG_GENERIC(CLONE_IO
),
870 UNUSED
static struct flags msg_flags
[] = {
872 FLAG_GENERIC(MSG_CONFIRM
),
873 FLAG_GENERIC(MSG_DONTROUTE
),
874 FLAG_GENERIC(MSG_DONTWAIT
),
875 FLAG_GENERIC(MSG_EOR
),
876 FLAG_GENERIC(MSG_MORE
),
877 FLAG_GENERIC(MSG_NOSIGNAL
),
878 FLAG_GENERIC(MSG_OOB
),
880 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
881 FLAG_GENERIC(MSG_ERRQUEUE
),
882 FLAG_GENERIC(MSG_PEEK
),
883 FLAG_GENERIC(MSG_TRUNC
),
884 FLAG_GENERIC(MSG_WAITALL
),
886 FLAG_GENERIC(MSG_CTRUNC
),
891 * print_xxx utility functions. These are used to print syscall
892 * parameters in certain format. All of these have parameter
893 * named 'last'. This parameter is used to add comma to output
900 return ((last
) ? "" : ",");
904 print_flags(const struct flags
*f
, abi_long flags
, int last
)
906 const char *sep
= "";
909 if ((flags
== 0) && (f
->f_value
== 0)) {
910 gemu_log("%s%s", f
->f_string
, get_comma(last
));
913 for (n
= 0; f
->f_string
!= NULL
; f
++) {
914 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
915 gemu_log("%s%s", sep
, f
->f_string
);
916 flags
&= ~f
->f_value
;
923 /* print rest of the flags as numeric */
925 gemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
927 gemu_log("%s", get_comma(last
));
930 /* no string version of flags found, print them in hex then */
931 gemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
936 print_at_dirfd(abi_long dirfd
, int last
)
939 if (dirfd
== AT_FDCWD
) {
940 gemu_log("AT_FDCWD%s", get_comma(last
));
944 gemu_log("%d%s", (int)dirfd
, get_comma(last
));
948 print_file_mode(abi_long mode
, int last
)
950 const char *sep
= "";
951 const struct flags
*m
;
953 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
954 if ((m
->f_value
& mode
) == m
->f_value
) {
955 gemu_log("%s%s", m
->f_string
, sep
);
963 /* print rest of the mode as octal */
965 gemu_log("%s%#o", sep
, (unsigned int)mode
);
967 gemu_log("%s", get_comma(last
));
971 print_open_flags(abi_long flags
, int last
)
973 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
974 flags
&= ~TARGET_O_ACCMODE
;
976 gemu_log("%s", get_comma(last
));
980 print_flags(open_flags
, flags
, last
);
984 print_syscall_prologue(const struct syscallname
*sc
)
986 gemu_log("%s(", sc
->name
);
991 print_syscall_epilogue(const struct syscallname
*sc
)
998 print_string(abi_long addr
, int last
)
1002 if ((s
= lock_user_string(addr
)) != NULL
) {
1003 gemu_log("\"%s\"%s", s
, get_comma(last
));
1004 unlock_user(s
, addr
, 0);
1006 /* can't get string out of it, so print it as pointer */
1007 print_pointer(addr
, last
);
1011 #define MAX_PRINT_BUF 40
1013 print_buf(abi_long addr
, abi_long len
, int last
)
1018 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1021 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1022 if (isprint(s
[i
])) {
1023 gemu_log("%c", s
[i
]);
1025 gemu_log("\\%o", s
[i
]);
1035 unlock_user(s
, addr
, 0);
1037 print_pointer(addr
, last
);
1042 * Prints out raw parameter using given format. Caller needs
1043 * to do byte swapping if needed.
1046 print_raw_param(const char *fmt
, abi_long param
, int last
)
1050 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1051 gemu_log(format
, param
);
1055 print_pointer(abi_long p
, int last
)
1058 gemu_log("NULL%s", get_comma(last
));
1060 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1064 * Reads 32-bit (int) number from guest address space from
1065 * address 'addr' and prints it.
1068 print_number(abi_long addr
, int last
)
1071 gemu_log("NULL%s", get_comma(last
));
1075 get_user_s32(num
, addr
);
1076 gemu_log("[%d]%s", num
, get_comma(last
));
1081 print_timeval(abi_ulong tv_addr
, int last
)
1084 struct target_timeval
*tv
;
1086 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1089 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
1090 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1091 unlock_user(tv
, tv_addr
, 0);
1093 gemu_log("NULL%s", get_comma(last
));
1098 #ifdef TARGET_NR_accept
1100 print_accept(const struct syscallname
*name
,
1101 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1102 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1104 print_syscall_prologue(name
);
1105 print_raw_param("%d", arg0
, 0);
1106 print_pointer(arg1
, 0);
1107 print_number(arg2
, 1);
1108 print_syscall_epilogue(name
);
1112 #ifdef TARGET_NR_access
1114 print_access(const struct syscallname
*name
,
1115 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1116 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1118 print_syscall_prologue(name
);
1119 print_string(arg0
, 0);
1120 print_flags(access_flags
, arg1
, 1);
1121 print_syscall_epilogue(name
);
1125 #ifdef TARGET_NR_brk
1127 print_brk(const struct syscallname
*name
,
1128 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1129 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1131 print_syscall_prologue(name
);
1132 print_pointer(arg0
, 1);
1133 print_syscall_epilogue(name
);
1137 #ifdef TARGET_NR_chdir
1139 print_chdir(const struct syscallname
*name
,
1140 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1141 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1143 print_syscall_prologue(name
);
1144 print_string(arg0
, 1);
1145 print_syscall_epilogue(name
);
1149 #ifdef TARGET_NR_chmod
1151 print_chmod(const struct syscallname
*name
,
1152 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1153 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1155 print_syscall_prologue(name
);
1156 print_string(arg0
, 0);
1157 print_file_mode(arg1
, 1);
1158 print_syscall_epilogue(name
);
1162 #ifdef TARGET_NR_clock_adjtime
1164 print_clock_adjtime(const struct syscallname
*name
,
1165 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1166 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1168 print_syscall_prologue(name
);
1169 print_clockid(arg0
, 0);
1170 print_pointer(arg1
, 1);
1171 print_syscall_epilogue(name
);
1175 #ifdef TARGET_NR_clone
1176 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1177 abi_ulong parent_tidptr
, target_ulong newtls
,
1178 abi_ulong child_tidptr
)
1180 print_flags(clone_flags
, flags
, 0);
1181 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1182 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1183 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1184 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1188 print_clone(const struct syscallname
*name
,
1189 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1190 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1192 print_syscall_prologue(name
);
1193 #if defined(TARGET_MICROBLAZE)
1194 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1195 #elif defined(TARGET_CLONE_BACKWARDS)
1196 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1197 #elif defined(TARGET_CLONE_BACKWARDS2)
1198 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1200 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1202 print_syscall_epilogue(name
);
1206 #ifdef TARGET_NR_creat
1208 print_creat(const struct syscallname
*name
,
1209 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1210 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1212 print_syscall_prologue(name
);
1213 print_string(arg0
, 0);
1214 print_file_mode(arg1
, 1);
1215 print_syscall_epilogue(name
);
1219 #ifdef TARGET_NR_execv
1221 print_execv(const struct syscallname
*name
,
1222 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1223 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1225 print_syscall_prologue(name
);
1226 print_string(arg0
, 0);
1227 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1228 print_syscall_epilogue(name
);
1232 #ifdef TARGET_NR_faccessat
1234 print_faccessat(const struct syscallname
*name
,
1235 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1236 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1238 print_syscall_prologue(name
);
1239 print_at_dirfd(arg0
, 0);
1240 print_string(arg1
, 0);
1241 print_flags(access_flags
, arg2
, 0);
1242 print_flags(at_file_flags
, arg3
, 1);
1243 print_syscall_epilogue(name
);
1247 #ifdef TARGET_NR_fchmodat
1249 print_fchmodat(const struct syscallname
*name
,
1250 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1251 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1253 print_syscall_prologue(name
);
1254 print_at_dirfd(arg0
, 0);
1255 print_string(arg1
, 0);
1256 print_file_mode(arg2
, 0);
1257 print_flags(at_file_flags
, arg3
, 1);
1258 print_syscall_epilogue(name
);
1262 #ifdef TARGET_NR_fchownat
1264 print_fchownat(const struct syscallname
*name
,
1265 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1266 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1268 print_syscall_prologue(name
);
1269 print_at_dirfd(arg0
, 0);
1270 print_string(arg1
, 0);
1271 print_raw_param("%d", arg2
, 0);
1272 print_raw_param("%d", arg3
, 0);
1273 print_flags(at_file_flags
, arg4
, 1);
1274 print_syscall_epilogue(name
);
1278 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1280 print_fcntl(const struct syscallname
*name
,
1281 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1282 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1284 print_syscall_prologue(name
);
1285 print_raw_param("%d", arg0
, 0);
1287 case TARGET_F_DUPFD
:
1288 gemu_log("F_DUPFD,");
1289 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1291 case TARGET_F_GETFD
:
1292 gemu_log("F_GETFD");
1294 case TARGET_F_SETFD
:
1295 gemu_log("F_SETFD,");
1296 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1298 case TARGET_F_GETFL
:
1299 gemu_log("F_GETFL");
1301 case TARGET_F_SETFL
:
1302 gemu_log("F_SETFL,");
1303 print_open_flags(arg2
, 1);
1305 case TARGET_F_GETLK
:
1306 gemu_log("F_GETLK,");
1307 print_pointer(arg2
, 1);
1309 case TARGET_F_SETLK
:
1310 gemu_log("F_SETLK,");
1311 print_pointer(arg2
, 1);
1313 case TARGET_F_SETLKW
:
1314 gemu_log("F_SETLKW,");
1315 print_pointer(arg2
, 1);
1317 case TARGET_F_GETOWN
:
1318 gemu_log("F_GETOWN");
1320 case TARGET_F_SETOWN
:
1321 gemu_log("F_SETOWN,");
1322 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1324 case TARGET_F_GETSIG
:
1325 gemu_log("F_GETSIG");
1327 case TARGET_F_SETSIG
:
1328 gemu_log("F_SETSIG,");
1329 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1331 #if TARGET_ABI_BITS == 32
1332 case TARGET_F_GETLK64
:
1333 gemu_log("F_GETLK64,");
1334 print_pointer(arg2
, 1);
1336 case TARGET_F_SETLK64
:
1337 gemu_log("F_SETLK64,");
1338 print_pointer(arg2
, 1);
1340 case TARGET_F_SETLKW64
:
1341 gemu_log("F_SETLKW64,");
1342 print_pointer(arg2
, 1);
1345 case TARGET_F_SETLEASE
:
1346 gemu_log("F_SETLEASE,");
1347 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1349 case TARGET_F_GETLEASE
:
1350 gemu_log("F_GETLEASE");
1352 case TARGET_F_SETPIPE_SZ
:
1353 gemu_log("F_SETPIPE_SZ,");
1354 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1356 case TARGET_F_GETPIPE_SZ
:
1357 gemu_log("F_GETPIPE_SZ");
1359 case TARGET_F_DUPFD_CLOEXEC
:
1360 gemu_log("F_DUPFD_CLOEXEC,");
1361 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1363 case TARGET_F_NOTIFY
:
1364 gemu_log("F_NOTIFY,");
1365 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1368 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1369 print_pointer(arg2
, 1);
1372 print_syscall_epilogue(name
);
1374 #define print_fcntl64 print_fcntl
1378 #ifdef TARGET_NR_futimesat
1380 print_futimesat(const struct syscallname
*name
,
1381 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1382 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1384 print_syscall_prologue(name
);
1385 print_at_dirfd(arg0
, 0);
1386 print_string(arg1
, 0);
1387 print_timeval(arg2
, 0);
1388 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
1389 print_syscall_epilogue(name
);
1393 #ifdef TARGET_NR_link
1395 print_link(const struct syscallname
*name
,
1396 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1397 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1399 print_syscall_prologue(name
);
1400 print_string(arg0
, 0);
1401 print_string(arg1
, 1);
1402 print_syscall_epilogue(name
);
1406 #ifdef TARGET_NR_linkat
1408 print_linkat(const struct syscallname
*name
,
1409 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1410 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1412 print_syscall_prologue(name
);
1413 print_at_dirfd(arg0
, 0);
1414 print_string(arg1
, 0);
1415 print_at_dirfd(arg2
, 0);
1416 print_string(arg3
, 0);
1417 print_flags(at_file_flags
, arg4
, 1);
1418 print_syscall_epilogue(name
);
1422 #ifdef TARGET_NR__llseek
1424 print__llseek(const struct syscallname
*name
,
1425 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1426 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1428 const char *whence
= "UNKNOWN";
1429 print_syscall_prologue(name
);
1430 print_raw_param("%d", arg0
, 0);
1431 print_raw_param("%ld", arg1
, 0);
1432 print_raw_param("%ld", arg2
, 0);
1433 print_pointer(arg3
, 0);
1435 case SEEK_SET
: whence
= "SEEK_SET"; break;
1436 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
1437 case SEEK_END
: whence
= "SEEK_END"; break;
1439 gemu_log("%s",whence
);
1440 print_syscall_epilogue(name
);
1444 #if defined(TARGET_NR_socket)
1446 print_socket(const struct syscallname
*name
,
1447 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1448 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1450 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
1452 print_syscall_prologue(name
);
1453 print_socket_domain(domain
);
1455 print_socket_type(type
);
1457 if (domain
== AF_PACKET
||
1458 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1459 protocol
= tswap16(protocol
);
1461 print_socket_protocol(domain
, type
, protocol
);
1462 print_syscall_epilogue(name
);
1467 #if defined(TARGET_NR_socketcall)
1469 #define get_user_ualx(x, gaddr, idx) \
1470 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1472 static void do_print_socket(const char *name
, abi_long arg1
)
1474 abi_ulong domain
, type
, protocol
;
1476 get_user_ualx(domain
, arg1
, 0);
1477 get_user_ualx(type
, arg1
, 1);
1478 get_user_ualx(protocol
, arg1
, 2);
1479 gemu_log("%s(", name
);
1480 print_socket_domain(domain
);
1482 print_socket_type(type
);
1484 if (domain
== AF_PACKET
||
1485 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1486 protocol
= tswap16(protocol
);
1488 print_socket_protocol(domain
, type
, protocol
);
1492 static void do_print_sockaddr(const char *name
, abi_long arg1
)
1494 abi_ulong sockfd
, addr
, addrlen
;
1496 get_user_ualx(sockfd
, arg1
, 0);
1497 get_user_ualx(addr
, arg1
, 1);
1498 get_user_ualx(addrlen
, arg1
, 2);
1500 gemu_log("%s(", name
);
1501 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1502 print_sockaddr(addr
, addrlen
);
1506 static void do_print_listen(const char *name
, abi_long arg1
)
1508 abi_ulong sockfd
, backlog
;
1510 get_user_ualx(sockfd
, arg1
, 0);
1511 get_user_ualx(backlog
, arg1
, 1);
1513 gemu_log("%s(", name
);
1514 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1515 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
1519 static void do_print_socketpair(const char *name
, abi_long arg1
)
1521 abi_ulong domain
, type
, protocol
, tab
;
1523 get_user_ualx(domain
, arg1
, 0);
1524 get_user_ualx(type
, arg1
, 1);
1525 get_user_ualx(protocol
, arg1
, 2);
1526 get_user_ualx(tab
, arg1
, 3);
1528 gemu_log("%s(", name
);
1529 print_socket_domain(domain
);
1531 print_socket_type(type
);
1533 print_socket_protocol(domain
, type
, protocol
);
1535 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
1539 static void do_print_sendrecv(const char *name
, abi_long arg1
)
1541 abi_ulong sockfd
, msg
, len
, flags
;
1543 get_user_ualx(sockfd
, arg1
, 0);
1544 get_user_ualx(msg
, arg1
, 1);
1545 get_user_ualx(len
, arg1
, 2);
1546 get_user_ualx(flags
, arg1
, 3);
1548 gemu_log("%s(", name
);
1549 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1550 print_buf(msg
, len
, 0);
1551 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1552 print_flags(msg_flags
, flags
, 1);
1556 static void do_print_msgaddr(const char *name
, abi_long arg1
)
1558 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
1560 get_user_ualx(sockfd
, arg1
, 0);
1561 get_user_ualx(msg
, arg1
, 1);
1562 get_user_ualx(len
, arg1
, 2);
1563 get_user_ualx(flags
, arg1
, 3);
1564 get_user_ualx(addr
, arg1
, 4);
1565 get_user_ualx(addrlen
, arg1
, 5);
1567 gemu_log("%s(", name
);
1568 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1569 print_buf(msg
, len
, 0);
1570 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1571 print_flags(msg_flags
, flags
, 0);
1572 print_sockaddr(addr
, addrlen
);
1576 static void do_print_shutdown(const char *name
, abi_long arg1
)
1578 abi_ulong sockfd
, how
;
1580 get_user_ualx(sockfd
, arg1
, 0);
1581 get_user_ualx(how
, arg1
, 1);
1583 gemu_log("shutdown(");
1584 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1587 gemu_log("SHUT_RD");
1590 gemu_log("SHUT_WR");
1593 gemu_log("SHUT_RDWR");
1596 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
1602 static void do_print_msg(const char *name
, abi_long arg1
)
1604 abi_ulong sockfd
, msg
, flags
;
1606 get_user_ualx(sockfd
, arg1
, 0);
1607 get_user_ualx(msg
, arg1
, 1);
1608 get_user_ualx(flags
, arg1
, 2);
1610 gemu_log("%s(", name
);
1611 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1612 print_pointer(msg
, 0);
1613 print_flags(msg_flags
, flags
, 1);
1617 static void do_print_sockopt(const char *name
, abi_long arg1
)
1619 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
1621 get_user_ualx(sockfd
, arg1
, 0);
1622 get_user_ualx(level
, arg1
, 1);
1623 get_user_ualx(optname
, arg1
, 2);
1624 get_user_ualx(optval
, arg1
, 3);
1625 get_user_ualx(optlen
, arg1
, 4);
1627 gemu_log("%s(", name
);
1628 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1631 gemu_log("SOL_TCP,");
1632 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1633 print_pointer(optval
, 0);
1636 gemu_log("SOL_IP,");
1637 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1638 print_pointer(optval
, 0);
1641 gemu_log("SOL_RAW,");
1642 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1643 print_pointer(optval
, 0);
1645 case TARGET_SOL_SOCKET
:
1646 gemu_log("SOL_SOCKET,");
1648 case TARGET_SO_DEBUG
:
1649 gemu_log("SO_DEBUG,");
1651 print_number(optval
, 0);
1653 case TARGET_SO_REUSEADDR
:
1654 gemu_log("SO_REUSEADDR,");
1656 case TARGET_SO_TYPE
:
1657 gemu_log("SO_TYPE,");
1659 case TARGET_SO_ERROR
:
1660 gemu_log("SO_ERROR,");
1662 case TARGET_SO_DONTROUTE
:
1663 gemu_log("SO_DONTROUTE,");
1665 case TARGET_SO_BROADCAST
:
1666 gemu_log("SO_BROADCAST,");
1668 case TARGET_SO_SNDBUF
:
1669 gemu_log("SO_SNDBUF,");
1671 case TARGET_SO_RCVBUF
:
1672 gemu_log("SO_RCVBUF,");
1674 case TARGET_SO_KEEPALIVE
:
1675 gemu_log("SO_KEEPALIVE,");
1677 case TARGET_SO_OOBINLINE
:
1678 gemu_log("SO_OOBINLINE,");
1680 case TARGET_SO_NO_CHECK
:
1681 gemu_log("SO_NO_CHECK,");
1683 case TARGET_SO_PRIORITY
:
1684 gemu_log("SO_PRIORITY,");
1686 case TARGET_SO_BSDCOMPAT
:
1687 gemu_log("SO_BSDCOMPAT,");
1689 case TARGET_SO_PASSCRED
:
1690 gemu_log("SO_PASSCRED,");
1692 case TARGET_SO_TIMESTAMP
:
1693 gemu_log("SO_TIMESTAMP,");
1695 case TARGET_SO_RCVLOWAT
:
1696 gemu_log("SO_RCVLOWAT,");
1698 case TARGET_SO_RCVTIMEO
:
1699 gemu_log("SO_RCVTIMEO,");
1700 print_timeval(optval
, 0);
1702 case TARGET_SO_SNDTIMEO
:
1703 gemu_log("SO_SNDTIMEO,");
1704 print_timeval(optval
, 0);
1706 case TARGET_SO_ATTACH_FILTER
: {
1707 struct target_sock_fprog
*fprog
;
1709 gemu_log("SO_ATTACH_FILTER,");
1711 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
1712 struct target_sock_filter
*filter
;
1714 if (lock_user_struct(VERIFY_READ
, filter
,
1715 tswapal(fprog
->filter
), 0)) {
1717 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
1718 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1719 i
, tswap16(filter
[i
].code
),
1720 filter
[i
].jt
, filter
[i
].jf
,
1721 tswap32(filter
[i
].k
));
1723 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1724 i
, tswap16(filter
[i
].code
),
1725 filter
[i
].jt
, filter
[i
].jf
,
1726 tswap32(filter
[i
].k
));
1728 gemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
1730 gemu_log(",%d},", tswap16(fprog
->len
));
1731 unlock_user(fprog
, optval
, 0);
1733 print_pointer(optval
, 0);
1738 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1739 print_pointer(optval
, 0);
1744 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
1745 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1746 print_pointer(optval
, 0);
1749 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
1753 #define PRINT_SOCKOP(name, func) \
1754 [TARGET_SYS_##name] = { #name, func }
1758 void (*print
)(const char *, abi_long
);
1760 PRINT_SOCKOP(SOCKET
, do_print_socket
),
1761 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
1762 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
1763 PRINT_SOCKOP(LISTEN
, do_print_listen
),
1764 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
1765 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
1766 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
1767 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
1768 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
1769 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
1770 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
1771 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
1772 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
1773 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
1774 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
1775 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
1776 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
1777 PRINT_SOCKOP(ACCEPT4
, NULL
),
1778 PRINT_SOCKOP(RECVMMSG
, NULL
),
1779 PRINT_SOCKOP(SENDMMSG
, NULL
),
1783 print_socketcall(const struct syscallname
*name
,
1784 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1785 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1787 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
1788 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
1791 print_syscall_prologue(name
);
1792 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
1793 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1794 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1795 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
1796 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
1797 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
1798 print_syscall_epilogue(name
);
1802 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
1803 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
1805 print_stat(const struct syscallname
*name
,
1806 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1807 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1809 print_syscall_prologue(name
);
1810 print_string(arg0
, 0);
1811 print_pointer(arg1
, 1);
1812 print_syscall_epilogue(name
);
1814 #define print_lstat print_stat
1815 #define print_stat64 print_stat
1816 #define print_lstat64 print_stat
1819 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
1821 print_fstat(const struct syscallname
*name
,
1822 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1823 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1825 print_syscall_prologue(name
);
1826 print_raw_param("%d", arg0
, 0);
1827 print_pointer(arg1
, 1);
1828 print_syscall_epilogue(name
);
1830 #define print_fstat64 print_fstat
1833 #ifdef TARGET_NR_mkdir
1835 print_mkdir(const struct syscallname
*name
,
1836 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1837 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1839 print_syscall_prologue(name
);
1840 print_string(arg0
, 0);
1841 print_file_mode(arg1
, 1);
1842 print_syscall_epilogue(name
);
1846 #ifdef TARGET_NR_mkdirat
1848 print_mkdirat(const struct syscallname
*name
,
1849 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1850 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1852 print_syscall_prologue(name
);
1853 print_at_dirfd(arg0
, 0);
1854 print_string(arg1
, 0);
1855 print_file_mode(arg2
, 1);
1856 print_syscall_epilogue(name
);
1860 #ifdef TARGET_NR_rmdir
1862 print_rmdir(const struct syscallname
*name
,
1863 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1864 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1866 print_syscall_prologue(name
);
1867 print_string(arg0
, 0);
1868 print_syscall_epilogue(name
);
1872 #ifdef TARGET_NR_rt_sigaction
1874 print_rt_sigaction(const struct syscallname
*name
,
1875 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1876 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1878 print_syscall_prologue(name
);
1879 print_signal(arg0
, 0);
1880 print_pointer(arg1
, 0);
1881 print_pointer(arg2
, 1);
1882 print_syscall_epilogue(name
);
1886 #ifdef TARGET_NR_rt_sigprocmask
1888 print_rt_sigprocmask(const struct syscallname
*name
,
1889 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1890 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1892 const char *how
= "UNKNOWN";
1893 print_syscall_prologue(name
);
1895 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
1896 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
1897 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
1899 gemu_log("%s,",how
);
1900 print_pointer(arg1
, 0);
1901 print_pointer(arg2
, 1);
1902 print_syscall_epilogue(name
);
1906 #ifdef TARGET_NR_syslog
1908 print_syslog_action(abi_ulong arg
, int last
)
1913 case TARGET_SYSLOG_ACTION_CLOSE
: {
1914 type
= "SYSLOG_ACTION_CLOSE";
1917 case TARGET_SYSLOG_ACTION_OPEN
: {
1918 type
= "SYSLOG_ACTION_OPEN";
1921 case TARGET_SYSLOG_ACTION_READ
: {
1922 type
= "SYSLOG_ACTION_READ";
1925 case TARGET_SYSLOG_ACTION_READ_ALL
: {
1926 type
= "SYSLOG_ACTION_READ_ALL";
1929 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
1930 type
= "SYSLOG_ACTION_READ_CLEAR";
1933 case TARGET_SYSLOG_ACTION_CLEAR
: {
1934 type
= "SYSLOG_ACTION_CLEAR";
1937 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
1938 type
= "SYSLOG_ACTION_CONSOLE_OFF";
1941 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
1942 type
= "SYSLOG_ACTION_CONSOLE_ON";
1945 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
1946 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
1949 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
1950 type
= "SYSLOG_ACTION_SIZE_UNREAD";
1953 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
1954 type
= "SYSLOG_ACTION_SIZE_BUFFER";
1958 print_raw_param("%ld", arg
, last
);
1962 gemu_log("%s%s", type
, get_comma(last
));
1966 print_syslog(const struct syscallname
*name
,
1967 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1968 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1970 print_syscall_prologue(name
);
1971 print_syslog_action(arg0
, 0);
1972 print_pointer(arg1
, 0);
1973 print_raw_param("%d", arg2
, 1);
1974 print_syscall_epilogue(name
);
1978 #ifdef TARGET_NR_mknod
1980 print_mknod(const struct syscallname
*name
,
1981 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1982 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1984 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
1986 print_syscall_prologue(name
);
1987 print_string(arg0
, 0);
1988 print_file_mode(arg1
, (hasdev
== 0));
1990 print_raw_param("makedev(%d", major(arg2
), 0);
1991 print_raw_param("%d)", minor(arg2
), 1);
1993 print_syscall_epilogue(name
);
1997 #ifdef TARGET_NR_mknodat
1999 print_mknodat(const struct syscallname
*name
,
2000 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2001 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2003 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
2005 print_syscall_prologue(name
);
2006 print_at_dirfd(arg0
, 0);
2007 print_string(arg1
, 0);
2008 print_file_mode(arg2
, (hasdev
== 0));
2010 print_raw_param("makedev(%d", major(arg3
), 0);
2011 print_raw_param("%d)", minor(arg3
), 1);
2013 print_syscall_epilogue(name
);
2017 #ifdef TARGET_NR_mq_open
2019 print_mq_open(const struct syscallname
*name
,
2020 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2021 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2023 int is_creat
= (arg1
& TARGET_O_CREAT
);
2025 print_syscall_prologue(name
);
2026 print_string(arg0
, 0);
2027 print_open_flags(arg1
, (is_creat
== 0));
2029 print_file_mode(arg2
, 0);
2030 print_pointer(arg3
, 1);
2032 print_syscall_epilogue(name
);
2036 #ifdef TARGET_NR_open
2038 print_open(const struct syscallname
*name
,
2039 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2040 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2042 int is_creat
= (arg1
& TARGET_O_CREAT
);
2044 print_syscall_prologue(name
);
2045 print_string(arg0
, 0);
2046 print_open_flags(arg1
, (is_creat
== 0));
2048 print_file_mode(arg2
, 1);
2049 print_syscall_epilogue(name
);
2053 #ifdef TARGET_NR_openat
2055 print_openat(const struct syscallname
*name
,
2056 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2057 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2059 int is_creat
= (arg2
& TARGET_O_CREAT
);
2061 print_syscall_prologue(name
);
2062 print_at_dirfd(arg0
, 0);
2063 print_string(arg1
, 0);
2064 print_open_flags(arg2
, (is_creat
== 0));
2066 print_file_mode(arg3
, 1);
2067 print_syscall_epilogue(name
);
2071 #ifdef TARGET_NR_mq_unlink
2073 print_mq_unlink(const struct syscallname
*name
,
2074 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2075 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2077 print_syscall_prologue(name
);
2078 print_string(arg0
, 1);
2079 print_syscall_epilogue(name
);
2083 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2085 print_fstatat64(const struct syscallname
*name
,
2086 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2087 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2089 print_syscall_prologue(name
);
2090 print_at_dirfd(arg0
, 0);
2091 print_string(arg1
, 0);
2092 print_pointer(arg2
, 0);
2093 print_flags(at_file_flags
, arg3
, 1);
2094 print_syscall_epilogue(name
);
2096 #define print_newfstatat print_fstatat64
2099 #ifdef TARGET_NR_readlink
2101 print_readlink(const struct syscallname
*name
,
2102 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2103 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2105 print_syscall_prologue(name
);
2106 print_string(arg0
, 0);
2107 print_pointer(arg1
, 0);
2108 print_raw_param("%u", arg2
, 1);
2109 print_syscall_epilogue(name
);
2113 #ifdef TARGET_NR_readlinkat
2115 print_readlinkat(const struct syscallname
*name
,
2116 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2117 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2119 print_syscall_prologue(name
);
2120 print_at_dirfd(arg0
, 0);
2121 print_string(arg1
, 0);
2122 print_pointer(arg2
, 0);
2123 print_raw_param("%u", arg3
, 1);
2124 print_syscall_epilogue(name
);
2128 #ifdef TARGET_NR_rename
2130 print_rename(const struct syscallname
*name
,
2131 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2132 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2134 print_syscall_prologue(name
);
2135 print_string(arg0
, 0);
2136 print_string(arg1
, 1);
2137 print_syscall_epilogue(name
);
2141 #ifdef TARGET_NR_renameat
2143 print_renameat(const struct syscallname
*name
,
2144 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2145 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2147 print_syscall_prologue(name
);
2148 print_at_dirfd(arg0
, 0);
2149 print_string(arg1
, 0);
2150 print_at_dirfd(arg2
, 0);
2151 print_string(arg3
, 1);
2152 print_syscall_epilogue(name
);
2156 #ifdef TARGET_NR_statfs
2158 print_statfs(const struct syscallname
*name
,
2159 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2160 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2162 print_syscall_prologue(name
);
2163 print_string(arg0
, 0);
2164 print_pointer(arg1
, 1);
2165 print_syscall_epilogue(name
);
2167 #define print_statfs64 print_statfs
2170 #ifdef TARGET_NR_symlink
2172 print_symlink(const struct syscallname
*name
,
2173 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2174 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2176 print_syscall_prologue(name
);
2177 print_string(arg0
, 0);
2178 print_string(arg1
, 1);
2179 print_syscall_epilogue(name
);
2183 #ifdef TARGET_NR_symlinkat
2185 print_symlinkat(const struct syscallname
*name
,
2186 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2187 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2189 print_syscall_prologue(name
);
2190 print_string(arg0
, 0);
2191 print_at_dirfd(arg1
, 0);
2192 print_string(arg2
, 1);
2193 print_syscall_epilogue(name
);
2197 #ifdef TARGET_NR_mount
2199 print_mount(const struct syscallname
*name
,
2200 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2201 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2203 print_syscall_prologue(name
);
2204 print_string(arg0
, 0);
2205 print_string(arg1
, 0);
2206 print_string(arg2
, 0);
2207 print_flags(mount_flags
, arg3
, 0);
2208 print_pointer(arg4
, 1);
2209 print_syscall_epilogue(name
);
2213 #ifdef TARGET_NR_umount
2215 print_umount(const struct syscallname
*name
,
2216 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2217 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2219 print_syscall_prologue(name
);
2220 print_string(arg0
, 1);
2221 print_syscall_epilogue(name
);
2225 #ifdef TARGET_NR_umount2
2227 print_umount2(const struct syscallname
*name
,
2228 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2229 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2231 print_syscall_prologue(name
);
2232 print_string(arg0
, 0);
2233 print_flags(umount2_flags
, arg1
, 1);
2234 print_syscall_epilogue(name
);
2238 #ifdef TARGET_NR_unlink
2240 print_unlink(const struct syscallname
*name
,
2241 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2242 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2244 print_syscall_prologue(name
);
2245 print_string(arg0
, 1);
2246 print_syscall_epilogue(name
);
2250 #ifdef TARGET_NR_unlinkat
2252 print_unlinkat(const struct syscallname
*name
,
2253 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2254 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2256 print_syscall_prologue(name
);
2257 print_at_dirfd(arg0
, 0);
2258 print_string(arg1
, 0);
2259 print_flags(unlinkat_flags
, arg2
, 1);
2260 print_syscall_epilogue(name
);
2264 #ifdef TARGET_NR_utime
2266 print_utime(const struct syscallname
*name
,
2267 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2268 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2270 print_syscall_prologue(name
);
2271 print_string(arg0
, 0);
2272 print_pointer(arg1
, 1);
2273 print_syscall_epilogue(name
);
2277 #ifdef TARGET_NR_utimes
2279 print_utimes(const struct syscallname
*name
,
2280 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2281 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2283 print_syscall_prologue(name
);
2284 print_string(arg0
, 0);
2285 print_pointer(arg1
, 1);
2286 print_syscall_epilogue(name
);
2290 #ifdef TARGET_NR_utimensat
2292 print_utimensat(const struct syscallname
*name
,
2293 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2294 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2296 print_syscall_prologue(name
);
2297 print_at_dirfd(arg0
, 0);
2298 print_string(arg1
, 0);
2299 print_pointer(arg2
, 0);
2300 print_flags(at_file_flags
, arg3
, 1);
2301 print_syscall_epilogue(name
);
2305 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2307 print_mmap(const struct syscallname
*name
,
2308 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2309 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2311 print_syscall_prologue(name
);
2312 print_pointer(arg0
, 0);
2313 print_raw_param("%d", arg1
, 0);
2314 print_flags(mmap_prot_flags
, arg2
, 0);
2315 print_flags(mmap_flags
, arg3
, 0);
2316 print_raw_param("%d", arg4
, 0);
2317 print_raw_param("%#x", arg5
, 1);
2318 print_syscall_epilogue(name
);
2320 #define print_mmap2 print_mmap
2323 #ifdef TARGET_NR_mprotect
2325 print_mprotect(const struct syscallname
*name
,
2326 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2327 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2329 print_syscall_prologue(name
);
2330 print_pointer(arg0
, 0);
2331 print_raw_param("%d", arg1
, 0);
2332 print_flags(mmap_prot_flags
, arg2
, 1);
2333 print_syscall_epilogue(name
);
2337 #ifdef TARGET_NR_munmap
2339 print_munmap(const struct syscallname
*name
,
2340 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2341 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2343 print_syscall_prologue(name
);
2344 print_pointer(arg0
, 0);
2345 print_raw_param("%d", arg1
, 1);
2346 print_syscall_epilogue(name
);
2350 #ifdef TARGET_NR_futex
2351 static void print_futex_op(abi_long tflag
, int last
)
2353 #define print_op(val) \
2354 if( cmd == val ) { \
2359 int cmd
= (int)tflag
;
2360 #ifdef FUTEX_PRIVATE_FLAG
2361 if (cmd
& FUTEX_PRIVATE_FLAG
) {
2362 gemu_log("FUTEX_PRIVATE_FLAG|");
2363 cmd
&= ~FUTEX_PRIVATE_FLAG
;
2366 #ifdef FUTEX_CLOCK_REALTIME
2367 if (cmd
& FUTEX_CLOCK_REALTIME
) {
2368 gemu_log("FUTEX_CLOCK_REALTIME|");
2369 cmd
&= ~FUTEX_CLOCK_REALTIME
;
2372 print_op(FUTEX_WAIT
)
2373 print_op(FUTEX_WAKE
)
2375 print_op(FUTEX_REQUEUE
)
2376 print_op(FUTEX_CMP_REQUEUE
)
2377 print_op(FUTEX_WAKE_OP
)
2378 print_op(FUTEX_LOCK_PI
)
2379 print_op(FUTEX_UNLOCK_PI
)
2380 print_op(FUTEX_TRYLOCK_PI
)
2381 #ifdef FUTEX_WAIT_BITSET
2382 print_op(FUTEX_WAIT_BITSET
)
2384 #ifdef FUTEX_WAKE_BITSET
2385 print_op(FUTEX_WAKE_BITSET
)
2387 /* unknown values */
2392 print_futex(const struct syscallname
*name
,
2393 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2394 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2396 print_syscall_prologue(name
);
2397 print_pointer(arg0
, 0);
2398 print_futex_op(arg1
, 0);
2399 print_raw_param(",%d", arg2
, 0);
2400 print_pointer(arg3
, 0); /* struct timespec */
2401 print_pointer(arg4
, 0);
2402 print_raw_param("%d", arg4
, 1);
2403 print_syscall_epilogue(name
);
2407 #ifdef TARGET_NR_kill
2409 print_kill(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_raw_param("%d", arg0
, 0);
2415 print_signal(arg1
, 1);
2416 print_syscall_epilogue(name
);
2421 * An array of all of the syscalls we know about
2424 static const struct syscallname scnames
[] = {
2425 #include "strace.list"
2428 static int nsyscalls
= ARRAY_SIZE(scnames
);
2431 * The public interface to this module.
2434 print_syscall(int num
,
2435 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2436 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2439 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
")";
2441 gemu_log("%d ", getpid() );
2443 for(i
=0;i
<nsyscalls
;i
++)
2444 if( scnames
[i
].nr
== num
) {
2445 if( scnames
[i
].call
!= NULL
) {
2446 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2448 /* XXX: this format system is broken because it uses
2449 host types and host pointers for strings */
2450 if( scnames
[i
].format
!= NULL
)
2451 format
= scnames
[i
].format
;
2452 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2456 gemu_log("Unknown syscall %d\n", num
);
2461 print_syscall_ret(int num
, abi_long ret
)
2464 const char *errstr
= NULL
;
2466 for(i
=0;i
<nsyscalls
;i
++)
2467 if( scnames
[i
].nr
== num
) {
2468 if( scnames
[i
].result
!= NULL
) {
2469 scnames
[i
].result(&scnames
[i
],ret
);
2472 errstr
= target_strerror(-ret
);
2475 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n",
2478 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);
2485 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
2487 /* Print the strace output for a signal being taken:
2488 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2491 print_signal(target_signum
, 1);
2493 print_siginfo(tinfo
);