3 #include <sys/select.h>
6 #include <sys/syscall.h>
15 void (*call
)(const struct syscallname
*,
16 abi_long
, abi_long
, abi_long
,
17 abi_long
, abi_long
, abi_long
);
18 void (*result
)(const struct syscallname
*, abi_long
);
26 print_execve(const struct syscallname
*name
,
27 abi_long arg1
, abi_long arg2
, abi_long arg3
,
28 abi_long arg4
, abi_long arg5
, abi_long arg6
)
30 abi_ulong arg_ptr_addr
;
33 if (!(s
= lock_user_string(arg1
)))
35 gemu_log("%s(\"%s\",{", name
->name
, s
);
36 unlock_user(s
, arg1
, 0);
38 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
39 abi_ulong
*arg_ptr
, arg_addr
;
41 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
44 arg_addr
= tswapl(*arg_ptr
);
45 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
48 if ((s
= lock_user_string(arg_addr
))) {
49 gemu_log("\"%s\",", s
);
50 unlock_user(s
, arg_addr
, 0);
58 * Variants for the return value output function
62 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
65 gemu_log(" = -1 errno=%d (%s)\n", errno
, strerror(errno
));
67 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
71 #if 0 /* currently unused */
73 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
75 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
80 * An array of all of the syscalls we know about
83 static const struct syscallname freebsd_scnames
[] = {
84 #include "freebsd/strace.list"
86 static const struct syscallname netbsd_scnames
[] = {
87 #include "netbsd/strace.list"
89 static const struct syscallname openbsd_scnames
[] = {
90 #include "openbsd/strace.list"
94 print_syscall(int num
, const struct syscallname
*scnames
, unsigned int nscnames
,
95 abi_long arg1
, abi_long arg2
, abi_long arg3
,
96 abi_long arg4
, abi_long arg5
, abi_long arg6
)
99 const char *format
="%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
","
100 TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
","
101 TARGET_ABI_FMT_ld
")";
103 gemu_log("%d ", getpid() );
105 for (i
= 0; i
< nscnames
; i
++)
106 if (scnames
[i
].nr
== num
) {
107 if (scnames
[i
].call
!= NULL
) {
108 scnames
[i
].call(&scnames
[i
], arg1
, arg2
, arg3
, arg4
, arg5
,
111 /* XXX: this format system is broken because it uses
112 host types and host pointers for strings */
113 if (scnames
[i
].format
!= NULL
)
114 format
= scnames
[i
].format
;
115 gemu_log(format
, scnames
[i
].name
, arg1
, arg2
, arg3
, arg4
,
120 gemu_log("Unknown syscall %d\n", num
);
124 print_syscall_ret(int num
, abi_long ret
, const struct syscallname
*scnames
,
125 unsigned int nscnames
)
129 for (i
= 0; i
< nscnames
; i
++)
130 if (scnames
[i
].nr
== num
) {
131 if (scnames
[i
].result
!= NULL
) {
132 scnames
[i
].result(&scnames
[i
], ret
);
135 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n", -ret
,
138 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);
146 * The public interface to this module.
149 print_freebsd_syscall(int num
,
150 abi_long arg1
, abi_long arg2
, abi_long arg3
,
151 abi_long arg4
, abi_long arg5
, abi_long arg6
)
153 print_syscall(num
, freebsd_scnames
, ARRAY_SIZE(freebsd_scnames
),
154 arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
158 print_freebsd_syscall_ret(int num
, abi_long ret
)
160 print_syscall_ret(num
, ret
, freebsd_scnames
, ARRAY_SIZE(freebsd_scnames
));
164 print_netbsd_syscall(int num
,
165 abi_long arg1
, abi_long arg2
, abi_long arg3
,
166 abi_long arg4
, abi_long arg5
, abi_long arg6
)
168 print_syscall(num
, netbsd_scnames
, ARRAY_SIZE(netbsd_scnames
),
169 arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
173 print_netbsd_syscall_ret(int num
, abi_long ret
)
175 print_syscall_ret(num
, ret
, netbsd_scnames
, ARRAY_SIZE(netbsd_scnames
));
179 print_openbsd_syscall(int num
,
180 abi_long arg1
, abi_long arg2
, abi_long arg3
,
181 abi_long arg4
, abi_long arg5
, abi_long arg6
)
183 print_syscall(num
, openbsd_scnames
, ARRAY_SIZE(openbsd_scnames
),
184 arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
188 print_openbsd_syscall_ret(int num
, abi_long ret
)
190 print_syscall_ret(num
, ret
, openbsd_scnames
, ARRAY_SIZE(openbsd_scnames
));