7 #include <sys/select.h>
18 void (*call
)(struct syscallname
*,
19 abi_long
, abi_long
, abi_long
,
20 abi_long
, abi_long
, abi_long
);
21 void (*result
)(struct syscallname
*, abi_long
);
28 print_ipc_cmd(int cmd
)
30 #define output_cmd(val) \
38 /* General IPC commands */
39 output_cmd( IPC_RMID
);
40 output_cmd( IPC_SET
);
41 output_cmd( IPC_STAT
);
42 output_cmd( IPC_INFO
);
43 /* msgctl() commands */
45 output_cmd( MSG_STAT
);
46 output_cmd( MSG_INFO
);
48 /* shmctl() commands */
49 output_cmd( SHM_LOCK
);
50 output_cmd( SHM_UNLOCK
);
51 output_cmd( SHM_STAT
);
52 output_cmd( SHM_INFO
);
53 /* semctl() commands */
57 output_cmd( GETNCNT
);
58 output_cmd( GETZCNT
);
61 output_cmd( SEM_STAT
);
62 output_cmd( SEM_INFO
);
63 output_cmd( IPC_RMID
);
64 output_cmd( IPC_RMID
);
65 output_cmd( IPC_RMID
);
66 output_cmd( IPC_RMID
);
67 output_cmd( IPC_RMID
);
68 output_cmd( IPC_RMID
);
69 output_cmd( IPC_RMID
);
70 output_cmd( IPC_RMID
);
71 output_cmd( IPC_RMID
);
73 /* Some value we don't recognize */
77 #ifdef TARGET_NR__newselect
79 print_fdset(int n
, abi_ulong target_fds_addr
)
84 if( target_fds_addr
) {
87 target_fds
= lock_user(VERIFY_READ
,
89 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
95 for (i
=n
; i
>=0; i
--) {
96 if ((tswapl(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
99 unlock_user(target_fds
, target_fds_addr
, 0);
105 print_timeval(abi_ulong tv_addr
)
108 struct target_timeval
*tv
;
110 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
113 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}",
114 tv
->tv_sec
, tv
->tv_usec
);
115 unlock_user(tv
, tv_addr
, 0);
122 * Sysycall specific output functions
126 #ifdef TARGET_NR__newselect
127 static long newselect_arg1
= 0;
128 static long newselect_arg2
= 0;
129 static long newselect_arg3
= 0;
130 static long newselect_arg4
= 0;
131 static long newselect_arg5
= 0;
134 print_newselect(struct syscallname
*name
,
135 abi_long arg1
, abi_long arg2
, abi_long arg3
,
136 abi_long arg4
, abi_long arg5
, abi_long arg6
)
138 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
139 print_fdset(arg1
, arg2
);
141 print_fdset(arg1
, arg3
);
143 print_fdset(arg1
, arg4
);
148 /* save for use in the return output function below */
158 print_semctl(struct syscallname
*name
,
159 abi_long arg1
, abi_long arg2
, abi_long arg3
,
160 abi_long arg4
, abi_long arg5
, abi_long arg6
)
162 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
164 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
168 print_execve(struct syscallname
*name
,
169 abi_long arg1
, abi_long arg2
, abi_long arg3
,
170 abi_long arg4
, abi_long arg5
, abi_long arg6
)
172 abi_ulong arg_ptr_addr
;
175 if (!(s
= lock_user_string(arg1
)))
177 gemu_log("%s(\"%s\",{", name
->name
, s
);
178 unlock_user(s
, arg1
, 0);
180 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
181 abi_ulong
*arg_ptr
, arg_addr
, s_addr
;
183 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
186 arg_addr
= tswapl(*arg_ptr
);
187 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
190 if ((s
= lock_user_string(arg_addr
))) {
191 gemu_log("\"%s\",", s
);
192 unlock_user(s
, s_addr
, 0);
201 print_ipc(struct syscallname
*name
,
202 abi_long arg1
, abi_long arg2
, abi_long arg3
,
203 abi_long arg4
, abi_long arg5
, abi_long arg6
)
207 name
->name
= "semctl";
208 print_semctl(name
,arg2
,arg3
,arg4
,arg5
,arg6
,0);
211 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
212 name
->name
, arg1
, arg2
, arg3
, arg4
);
218 * Variants for the return value output function
222 print_syscall_ret_addr(struct syscallname
*name
, abi_long ret
)
225 gemu_log(" = -1 errno=%d (%s)\n", errno
, target_strerror(errno
));
227 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
231 #if 0 /* currently unused */
233 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
235 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
239 #ifdef TARGET_NR__newselect
241 print_syscall_ret_newselect(struct syscallname
*name
, abi_long ret
)
243 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
244 print_fdset(newselect_arg1
,newselect_arg2
);
246 print_fdset(newselect_arg1
,newselect_arg3
);
248 print_fdset(newselect_arg1
,newselect_arg4
);
250 print_timeval(newselect_arg5
);
256 * An array of all of the syscalls we know about
259 static struct syscallname scnames
[] = {
260 #include "strace.list"
263 static int nsyscalls
= sizeof(scnames
)/sizeof(struct syscallname
);
266 * The public interface to this module.
269 print_syscall(int num
,
270 abi_long arg1
, abi_long arg2
, abi_long arg3
,
271 abi_long arg4
, abi_long arg5
, abi_long arg6
)
274 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
")";
276 gemu_log("%d ", getpid() );
278 for(i
=0;i
<nsyscalls
;i
++)
279 if( scnames
[i
].nr
== num
) {
280 if( scnames
[i
].call
!= NULL
) {
281 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
283 /* XXX: this format system is broken because it uses
284 host types and host pointers for strings */
285 if( scnames
[i
].format
!= NULL
)
286 format
= scnames
[i
].format
;
287 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
295 print_syscall_ret(int num
, abi_long ret
)
299 for(i
=0;i
<nsyscalls
;i
++)
300 if( scnames
[i
].nr
== num
) {
301 if( scnames
[i
].result
!= NULL
) {
302 scnames
[i
].result(&scnames
[i
],ret
);
305 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n", -ret
, target_strerror(-ret
));
307 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);