7 #include <sys/select.h>
18 void (*call
)(struct syscallname
*,
19 target_long
, target_long
, target_long
,
20 target_long
, target_long
, target_long
);
21 void (*result
)(struct syscallname
*, target_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 */
78 print_fdset(int n
, target_ulong target_fds_addr
)
83 if( target_fds_addr
) {
84 target_long
*target_fds
;
86 if (!access_ok(VERIFY_READ
, target_fds_addr
, sizeof(*target_fds
)*(n
/ TARGET_LONG_BITS
+ 1)))
89 target_fds
= lock_user(target_fds_addr
, sizeof(*target_fds
)*(n
/ TARGET_LONG_BITS
+ 1), 1);
90 for (i
=n
; i
>=0; i
--) {
91 if ((tswapl(target_fds
[i
/ TARGET_LONG_BITS
]) >> (i
& (TARGET_LONG_BITS
- 1))) & 1)
94 unlock_user(target_fds
, target_fds_addr
, 0);
100 print_timeval(target_ulong tv_addr
)
103 struct target_timeval
*tv
;
105 if (!access_ok(VERIFY_READ
, tv_addr
, sizeof(*tv
)))
108 tv
= lock_user(tv_addr
, sizeof(*tv
), 1);
109 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}",
110 tv
->tv_sec
, tv
->tv_usec
);
111 unlock_user(tv
, tv_addr
, 0);
117 * Sysycall specific output functions
121 static long newselect_arg1
= 0;
122 static long newselect_arg2
= 0;
123 static long newselect_arg3
= 0;
124 static long newselect_arg4
= 0;
125 static long newselect_arg5
= 0;
128 print_newselect(struct syscallname
*name
,
129 target_long arg1
, target_long arg2
, target_long arg3
,
130 target_long arg4
, target_long arg5
, target_long arg6
)
132 gemu_log("%s(" TARGET_FMT_ld
",", name
->name
, arg1
);
133 print_fdset(arg1
, arg2
);
135 print_fdset(arg1
, arg3
);
137 print_fdset(arg1
, arg4
);
142 /* save for use in the return output function below */
151 print_semctl(struct syscallname
*name
,
152 target_long arg1
, target_long arg2
, target_long arg3
,
153 target_long arg4
, target_long arg5
, target_long arg6
)
155 gemu_log("%s(" TARGET_FMT_ld
"," TARGET_FMT_ld
",", name
->name
, arg1
, arg2
);
157 gemu_log(",0x" TARGET_FMT_lx
")", arg4
);
161 print_execve(struct syscallname
*name
,
162 target_long arg1
, target_long arg2
, target_long arg3
,
163 target_long arg4
, target_long arg5
, target_long arg6
)
165 target_ulong arg_ptr_addr
;
168 if (!access_ok(VERIFY_READ
, arg1
, 1))
171 s
= lock_user_string(arg1
);
172 gemu_log("%s(\"%s\",{", name
->name
, s
);
173 unlock_user(s
, arg1
, 0);
175 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(target_ulong
)) {
176 target_ulong
*arg_ptr
, arg_addr
, s_addr
;
178 if (!access_ok(VERIFY_READ
, arg_ptr_addr
, sizeof(target_ulong
)))
181 arg_ptr
= lock_user(arg_ptr_addr
, sizeof(target_ulong
), 1);
182 arg_addr
= tswapl(*arg_ptr
);
183 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
186 s
= lock_user_string(arg_addr
);
187 gemu_log("\"%s\",", s
);
188 unlock_user(s
, s_addr
, 0);
195 print_ipc(struct syscallname
*name
,
196 target_long arg1
, target_long arg2
, target_long arg3
,
197 target_long arg4
, target_long arg5
, target_long arg6
)
201 name
->name
= "semctl";
202 print_semctl(name
,arg2
,arg3
,arg4
,arg5
,arg6
,0);
205 gemu_log("%s(" TARGET_FMT_ld
"," TARGET_FMT_ld
"," TARGET_FMT_ld
"," TARGET_FMT_ld
")",
206 name
->name
, arg1
, arg2
, arg3
, arg4
);
211 * Variants for the return value output function
215 print_syscall_ret_addr(struct syscallname
*name
, target_long ret
)
218 gemu_log(" = -1 errno=%d (%s)\n", errno
, target_strerror(errno
));
220 gemu_log(" = " TARGET_FMT_lx
"\n", ret
);
224 #if 0 /* currently unused */
226 print_syscall_ret_raw(struct syscallname
*name
, target_long ret
)
228 gemu_log(" = " TARGET_FMT_lx
"\n", ret
);
232 #ifdef TARGET_NR__newselect
234 print_syscall_ret_newselect(struct syscallname
*name
, target_long ret
)
236 gemu_log(" = " TARGET_FMT_lx
" (", ret
);
237 print_fdset(newselect_arg1
,newselect_arg2
);
239 print_fdset(newselect_arg1
,newselect_arg3
);
241 print_fdset(newselect_arg1
,newselect_arg4
);
243 print_timeval(newselect_arg5
);
249 * An array of all of the syscalls we know about
252 static struct syscallname scnames
[] = {
253 #include "strace.list"
256 static int nsyscalls
= sizeof(scnames
)/sizeof(struct syscallname
);
259 * The public interface to this module.
262 print_syscall(int num
,
263 target_long arg1
, target_long arg2
, target_long arg3
,
264 target_long arg4
, target_long arg5
, target_long arg6
)
267 char *format
="%s(%ld,%ld,%ld,%ld,%ld,%ld)";
269 gemu_log("%d ", getpid() );
271 for(i
=0;i
<nsyscalls
;i
++)
272 if( scnames
[i
].nr
== num
) {
273 if( scnames
[i
].call
!= NULL
) {
274 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
276 if( scnames
[i
].format
!= NULL
)
277 format
= scnames
[i
].format
;
278 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
286 print_syscall_ret(int num
, target_long ret
)
290 for(i
=0;i
<nsyscalls
;i
++)
291 if( scnames
[i
].nr
== num
) {
292 if( scnames
[i
].result
!= NULL
) {
293 scnames
[i
].result(&scnames
[i
],ret
);
296 gemu_log(" = -1 errno=%d (%s)\n", -ret
, target_strerror(-ret
));
298 gemu_log(" = %d\n", ret
);