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
) {
86 target_fds
= lock_user(VERIFY_READ
,
88 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
94 for (i
=n
; i
>=0; i
--) {
95 if ((tswapl(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
98 unlock_user(target_fds
, target_fds_addr
, 0);
104 print_timeval(target_ulong tv_addr
)
107 struct target_timeval
*tv
;
109 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
112 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}",
113 tv
->tv_sec
, tv
->tv_usec
);
114 unlock_user(tv
, tv_addr
, 0);
120 * Sysycall specific output functions
124 static long newselect_arg1
= 0;
125 static long newselect_arg2
= 0;
126 static long newselect_arg3
= 0;
127 static long newselect_arg4
= 0;
128 static long newselect_arg5
= 0;
131 print_newselect(struct syscallname
*name
,
132 target_long arg1
, target_long arg2
, target_long arg3
,
133 target_long arg4
, target_long arg5
, target_long arg6
)
135 gemu_log("%s(" TARGET_FMT_ld
",", name
->name
, arg1
);
136 print_fdset(arg1
, arg2
);
138 print_fdset(arg1
, arg3
);
140 print_fdset(arg1
, arg4
);
145 /* save for use in the return output function below */
154 print_semctl(struct syscallname
*name
,
155 target_long arg1
, target_long arg2
, target_long arg3
,
156 target_long arg4
, target_long arg5
, target_long arg6
)
158 gemu_log("%s(" TARGET_FMT_ld
"," TARGET_FMT_ld
",", name
->name
, arg1
, arg2
);
160 gemu_log(",0x" TARGET_FMT_lx
")", arg4
);
164 print_execve(struct syscallname
*name
,
165 target_long arg1
, target_long arg2
, target_long arg3
,
166 target_long arg4
, target_long arg5
, target_long arg6
)
168 target_ulong arg_ptr_addr
;
171 if (!(s
= lock_user_string(arg1
)))
173 gemu_log("%s(\"%s\",{", name
->name
, s
);
174 unlock_user(s
, arg1
, 0);
176 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(target_ulong
)) {
177 target_ulong
*arg_ptr
, arg_addr
, s_addr
;
179 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(target_ulong
), 1);
182 arg_addr
= tswapl(*arg_ptr
);
183 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
186 if ((s
= lock_user_string(arg_addr
))) {
187 gemu_log("\"%s\",", s
);
188 unlock_user(s
, s_addr
, 0);
196 print_ipc(struct syscallname
*name
,
197 target_long arg1
, target_long arg2
, target_long arg3
,
198 target_long arg4
, target_long arg5
, target_long arg6
)
202 name
->name
= "semctl";
203 print_semctl(name
,arg2
,arg3
,arg4
,arg5
,arg6
,0);
206 gemu_log("%s(" TARGET_FMT_ld
"," TARGET_FMT_ld
"," TARGET_FMT_ld
"," TARGET_FMT_ld
")",
207 name
->name
, arg1
, arg2
, arg3
, arg4
);
212 * Variants for the return value output function
216 print_syscall_ret_addr(struct syscallname
*name
, target_long ret
)
219 gemu_log(" = -1 errno=%d (%s)\n", errno
, target_strerror(errno
));
221 gemu_log(" = " TARGET_FMT_lx
"\n", ret
);
225 #if 0 /* currently unused */
227 print_syscall_ret_raw(struct syscallname
*name
, target_long ret
)
229 gemu_log(" = " TARGET_FMT_lx
"\n", ret
);
233 #ifdef TARGET_NR__newselect
235 print_syscall_ret_newselect(struct syscallname
*name
, target_long ret
)
237 gemu_log(" = " TARGET_FMT_lx
" (", ret
);
238 print_fdset(newselect_arg1
,newselect_arg2
);
240 print_fdset(newselect_arg1
,newselect_arg3
);
242 print_fdset(newselect_arg1
,newselect_arg4
);
244 print_timeval(newselect_arg5
);
250 * An array of all of the syscalls we know about
253 static struct syscallname scnames
[] = {
254 #include "strace.list"
257 static int nsyscalls
= sizeof(scnames
)/sizeof(struct syscallname
);
260 * The public interface to this module.
263 print_syscall(int num
,
264 target_long arg1
, target_long arg2
, target_long arg3
,
265 target_long arg4
, target_long arg5
, target_long arg6
)
268 char *format
="%s(%ld,%ld,%ld,%ld,%ld,%ld)";
270 gemu_log("%d ", getpid() );
272 for(i
=0;i
<nsyscalls
;i
++)
273 if( scnames
[i
].nr
== num
) {
274 if( scnames
[i
].call
!= NULL
) {
275 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
277 if( scnames
[i
].format
!= NULL
)
278 format
= scnames
[i
].format
;
279 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
287 print_syscall_ret(int num
, target_long ret
)
291 for(i
=0;i
<nsyscalls
;i
++)
292 if( scnames
[i
].nr
== num
) {
293 if( scnames
[i
].result
!= NULL
) {
294 scnames
[i
].result(&scnames
[i
],ret
);
297 gemu_log(" = -1 errno=%d (%s)\n", -ret
, target_strerror(-ret
));
299 gemu_log(" = %d\n", ret
);