]>
Commit | Line | Data |
---|---|---|
d39594e9 | 1 | #include "qemu/osdep.h" |
33189d31 TS |
2 | #include <sys/ipc.h> |
3 | #include <sys/msg.h> | |
4 | #include <sys/sem.h> | |
5 | #include <sys/shm.h> | |
6 | #include <sys/select.h> | |
74d753ac | 7 | #include <sys/mount.h> |
fb3aabf3 LV |
8 | #include <arpa/inet.h> |
9 | #include <netinet/tcp.h> | |
10 | #include <linux/if_packet.h> | |
814ae70f | 11 | #include <linux/netlink.h> |
608e5592 | 12 | #include <sched.h> |
33189d31 TS |
13 | #include "qemu.h" |
14 | ||
33189d31 TS |
15 | struct syscallname { |
16 | int nr; | |
7ccfb2eb BS |
17 | const char *name; |
18 | const char *format; | |
19 | void (*call)(const struct syscallname *, | |
c16f9ed3 FB |
20 | abi_long, abi_long, abi_long, |
21 | abi_long, abi_long, abi_long); | |
c84be71f FB |
22 | void (*result)(const struct syscallname *, abi_long, |
23 | abi_long, abi_long, abi_long, | |
24 | abi_long, abi_long, abi_long); | |
33189d31 TS |
25 | }; |
26 | ||
74d753ac MW |
27 | #ifdef __GNUC__ |
28 | /* | |
29 | * It is possible that target doesn't have syscall that uses | |
30 | * following flags but we don't want the compiler to warn | |
31 | * us about them being unused. Same applies to utility print | |
32 | * functions. It is ok to keep them while not used. | |
33 | */ | |
34 | #define UNUSED __attribute__ ((unused)) | |
35 | #else | |
36 | #define UNUSED | |
37 | #endif | |
38 | ||
39 | /* | |
40 | * Structure used to translate flag values into strings. This is | |
41 | * similar that is in the actual strace tool. | |
42 | */ | |
43 | struct flags { | |
44 | abi_long f_value; /* flag */ | |
45 | const char *f_string; /* stringified flag */ | |
46 | }; | |
47 | ||
48 | /* common flags for all architectures */ | |
49 | #define FLAG_GENERIC(name) { name, #name } | |
50 | /* target specific flags (syscall_defs.h has TARGET_<flag>) */ | |
51 | #define FLAG_TARGET(name) { TARGET_ ## name, #name } | |
52 | /* end of flags array */ | |
53 | #define FLAG_END { 0, NULL } | |
54 | ||
55 | UNUSED static const char *get_comma(int); | |
56 | UNUSED static void print_pointer(abi_long, int); | |
57 | UNUSED static void print_flags(const struct flags *, abi_long, int); | |
58 | UNUSED static void print_at_dirfd(abi_long, int); | |
59 | UNUSED static void print_file_mode(abi_long, int); | |
60 | UNUSED static void print_open_flags(abi_long, int); | |
61 | UNUSED static void print_syscall_prologue(const struct syscallname *); | |
62 | UNUSED static void print_syscall_epilogue(const struct syscallname *); | |
63 | UNUSED static void print_string(abi_long, int); | |
fb3aabf3 | 64 | UNUSED static void print_buf(abi_long addr, abi_long len, int last); |
74d753ac MW |
65 | UNUSED static void print_raw_param(const char *, abi_long, int); |
66 | UNUSED static void print_timeval(abi_ulong, int); | |
6d33e036 | 67 | UNUSED static void print_timezone(abi_ulong, int); |
74d753ac | 68 | UNUSED static void print_number(abi_long, int); |
608e5592 | 69 | UNUSED static void print_signal(abi_ulong, int); |
42b15d70 | 70 | UNUSED static void print_sockaddr(abi_ulong, abi_long, int); |
fb3aabf3 LV |
71 | UNUSED static void print_socket_domain(int domain); |
72 | UNUSED static void print_socket_type(int type); | |
73 | UNUSED static void print_socket_protocol(int domain, int type, int protocol); | |
74d753ac | 74 | |
33189d31 TS |
75 | /* |
76 | * Utility functions | |
77 | */ | |
78 | static void | |
79 | print_ipc_cmd(int cmd) | |
80 | { | |
81 | #define output_cmd(val) \ | |
82 | if( cmd == val ) { \ | |
4b25a506 | 83 | qemu_log(#val); \ |
33189d31 TS |
84 | return; \ |
85 | } | |
86 | ||
87 | cmd &= 0xff; | |
88 | ||
89 | /* General IPC commands */ | |
90 | output_cmd( IPC_RMID ); | |
91 | output_cmd( IPC_SET ); | |
92 | output_cmd( IPC_STAT ); | |
93 | output_cmd( IPC_INFO ); | |
94 | /* msgctl() commands */ | |
33189d31 TS |
95 | output_cmd( MSG_STAT ); |
96 | output_cmd( MSG_INFO ); | |
33189d31 TS |
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 ); | |
121 | ||
122 | /* Some value we don't recognize */ | |
4b25a506 | 123 | qemu_log("%d", cmd); |
33189d31 TS |
124 | } |
125 | ||
608e5592 LV |
126 | static void |
127 | print_signal(abi_ulong arg, int last) | |
128 | { | |
129 | const char *signal_name = NULL; | |
130 | switch(arg) { | |
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; | |
149 | } | |
150 | if (signal_name == NULL) { | |
abe20840 | 151 | print_raw_param("%ld", arg, last); |
608e5592 LV |
152 | return; |
153 | } | |
4b25a506 | 154 | qemu_log("%s%s", signal_name, get_comma(last)); |
608e5592 LV |
155 | } |
156 | ||
0cb581d6 PM |
157 | static void print_si_code(int arg) |
158 | { | |
159 | const char *codename = NULL; | |
160 | ||
161 | switch (arg) { | |
162 | case SI_USER: | |
163 | codename = "SI_USER"; | |
164 | break; | |
165 | case SI_KERNEL: | |
166 | codename = "SI_KERNEL"; | |
167 | break; | |
168 | case SI_QUEUE: | |
169 | codename = "SI_QUEUE"; | |
170 | break; | |
171 | case SI_TIMER: | |
172 | codename = "SI_TIMER"; | |
173 | break; | |
174 | case SI_MESGQ: | |
175 | codename = "SI_MESGQ"; | |
176 | break; | |
177 | case SI_ASYNCIO: | |
178 | codename = "SI_ASYNCIO"; | |
179 | break; | |
180 | case SI_SIGIO: | |
181 | codename = "SI_SIGIO"; | |
182 | break; | |
183 | case SI_TKILL: | |
184 | codename = "SI_TKILL"; | |
185 | break; | |
186 | default: | |
4b25a506 | 187 | qemu_log("%d", arg); |
0cb581d6 PM |
188 | return; |
189 | } | |
4b25a506 | 190 | qemu_log("%s", codename); |
0cb581d6 PM |
191 | } |
192 | ||
ba9fcea1 MS |
193 | static void get_target_siginfo(target_siginfo_t *tinfo, |
194 | const target_siginfo_t *info) | |
195 | { | |
196 | abi_ulong sival_ptr; | |
197 | ||
198 | int sig; | |
199 | int si_errno; | |
200 | int si_code; | |
201 | int si_type; | |
202 | ||
203 | __get_user(sig, &info->si_signo); | |
204 | __get_user(si_errno, &tinfo->si_errno); | |
205 | __get_user(si_code, &info->si_code); | |
206 | ||
207 | tinfo->si_signo = sig; | |
208 | tinfo->si_errno = si_errno; | |
209 | tinfo->si_code = si_code; | |
210 | ||
211 | /* Ensure we don't leak random junk to the guest later */ | |
212 | memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad)); | |
213 | ||
214 | /* This is awkward, because we have to use a combination of | |
215 | * the si_code and si_signo to figure out which of the union's | |
216 | * members are valid. (Within the host kernel it is always possible | |
217 | * to tell, but the kernel carefully avoids giving userspace the | |
218 | * high 16 bits of si_code, so we don't have the information to | |
219 | * do this the easy way...) We therefore make our best guess, | |
220 | * bearing in mind that a guest can spoof most of the si_codes | |
221 | * via rt_sigqueueinfo() if it likes. | |
222 | * | |
223 | * Once we have made our guess, we record it in the top 16 bits of | |
224 | * the si_code, so that print_siginfo() later can use it. | |
225 | * print_siginfo() will strip these top bits out before printing | |
226 | * the si_code. | |
227 | */ | |
228 | ||
229 | switch (si_code) { | |
230 | case SI_USER: | |
231 | case SI_TKILL: | |
232 | case SI_KERNEL: | |
233 | /* Sent via kill(), tkill() or tgkill(), or direct from the kernel. | |
234 | * These are the only unspoofable si_code values. | |
235 | */ | |
236 | __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid); | |
237 | __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid); | |
238 | si_type = QEMU_SI_KILL; | |
239 | break; | |
240 | default: | |
241 | /* Everything else is spoofable. Make best guess based on signal */ | |
242 | switch (sig) { | |
243 | case TARGET_SIGCHLD: | |
244 | __get_user(tinfo->_sifields._sigchld._pid, | |
245 | &info->_sifields._sigchld._pid); | |
246 | __get_user(tinfo->_sifields._sigchld._uid, | |
247 | &info->_sifields._sigchld._uid); | |
248 | __get_user(tinfo->_sifields._sigchld._status, | |
249 | &info->_sifields._sigchld._status); | |
250 | __get_user(tinfo->_sifields._sigchld._utime, | |
251 | &info->_sifields._sigchld._utime); | |
252 | __get_user(tinfo->_sifields._sigchld._stime, | |
253 | &info->_sifields._sigchld._stime); | |
254 | si_type = QEMU_SI_CHLD; | |
255 | break; | |
256 | case TARGET_SIGIO: | |
257 | __get_user(tinfo->_sifields._sigpoll._band, | |
258 | &info->_sifields._sigpoll._band); | |
259 | __get_user(tinfo->_sifields._sigpoll._fd, | |
260 | &info->_sifields._sigpoll._fd); | |
261 | si_type = QEMU_SI_POLL; | |
262 | break; | |
263 | default: | |
264 | /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */ | |
265 | __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid); | |
266 | __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid); | |
267 | /* XXX: potential problem if 64 bit */ | |
268 | __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr); | |
269 | tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr; | |
270 | ||
271 | si_type = QEMU_SI_RT; | |
272 | break; | |
273 | } | |
274 | break; | |
275 | } | |
276 | ||
277 | tinfo->si_code = deposit32(si_code, 16, 16, si_type); | |
278 | } | |
279 | ||
0cb581d6 PM |
280 | static void print_siginfo(const target_siginfo_t *tinfo) |
281 | { | |
282 | /* Print a target_siginfo_t in the format desired for printing | |
283 | * signals being taken. We assume the target_siginfo_t is in the | |
284 | * internal form where the top 16 bits of si_code indicate which | |
285 | * part of the union is valid, rather than in the guest-visible | |
286 | * form where the bottom 16 bits are sign-extended into the top 16. | |
287 | */ | |
288 | int si_type = extract32(tinfo->si_code, 16, 16); | |
289 | int si_code = sextract32(tinfo->si_code, 0, 16); | |
290 | ||
4b25a506 | 291 | qemu_log("{si_signo="); |
0cb581d6 | 292 | print_signal(tinfo->si_signo, 1); |
4b25a506 | 293 | qemu_log(", si_code="); |
0cb581d6 PM |
294 | print_si_code(si_code); |
295 | ||
296 | switch (si_type) { | |
297 | case QEMU_SI_KILL: | |
4b25a506 | 298 | qemu_log(", si_pid=%u, si_uid=%u", |
0cb581d6 PM |
299 | (unsigned int)tinfo->_sifields._kill._pid, |
300 | (unsigned int)tinfo->_sifields._kill._uid); | |
301 | break; | |
302 | case QEMU_SI_TIMER: | |
4b25a506 | 303 | qemu_log(", si_timer1=%u, si_timer2=%u", |
0cb581d6 PM |
304 | tinfo->_sifields._timer._timer1, |
305 | tinfo->_sifields._timer._timer2); | |
306 | break; | |
307 | case QEMU_SI_POLL: | |
4b25a506 | 308 | qemu_log(", si_band=%d, si_fd=%d", |
0cb581d6 PM |
309 | tinfo->_sifields._sigpoll._band, |
310 | tinfo->_sifields._sigpoll._fd); | |
311 | break; | |
312 | case QEMU_SI_FAULT: | |
4b25a506 | 313 | qemu_log(", si_addr="); |
0cb581d6 PM |
314 | print_pointer(tinfo->_sifields._sigfault._addr, 1); |
315 | break; | |
316 | case QEMU_SI_CHLD: | |
4b25a506 | 317 | qemu_log(", si_pid=%u, si_uid=%u, si_status=%d" |
0cb581d6 PM |
318 | ", si_utime=" TARGET_ABI_FMT_ld |
319 | ", si_stime=" TARGET_ABI_FMT_ld, | |
320 | (unsigned int)(tinfo->_sifields._sigchld._pid), | |
321 | (unsigned int)(tinfo->_sifields._sigchld._uid), | |
322 | tinfo->_sifields._sigchld._status, | |
323 | tinfo->_sifields._sigchld._utime, | |
324 | tinfo->_sifields._sigchld._stime); | |
325 | break; | |
326 | case QEMU_SI_RT: | |
4b25a506 | 327 | qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld, |
0cb581d6 PM |
328 | (unsigned int)tinfo->_sifields._rt._pid, |
329 | (unsigned int)tinfo->_sifields._rt._uid, | |
330 | tinfo->_sifields._rt._sigval.sival_ptr); | |
331 | break; | |
332 | default: | |
333 | g_assert_not_reached(); | |
334 | } | |
4b25a506 | 335 | qemu_log("}"); |
0cb581d6 PM |
336 | } |
337 | ||
fb3aabf3 | 338 | static void |
42b15d70 | 339 | print_sockaddr(abi_ulong addr, abi_long addrlen, int last) |
fb3aabf3 LV |
340 | { |
341 | struct target_sockaddr *sa; | |
342 | int i; | |
343 | int sa_family; | |
344 | ||
345 | sa = lock_user(VERIFY_READ, addr, addrlen, 1); | |
346 | if (sa) { | |
347 | sa_family = tswap16(sa->sa_family); | |
348 | switch (sa_family) { | |
349 | case AF_UNIX: { | |
350 | struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa; | |
351 | int i; | |
4b25a506 | 352 | qemu_log("{sun_family=AF_UNIX,sun_path=\""); |
fb3aabf3 LV |
353 | for (i = 0; i < addrlen - |
354 | offsetof(struct target_sockaddr_un, sun_path) && | |
355 | un->sun_path[i]; i++) { | |
4b25a506 | 356 | qemu_log("%c", un->sun_path[i]); |
fb3aabf3 | 357 | } |
4b25a506 | 358 | qemu_log("\"}"); |
fb3aabf3 LV |
359 | break; |
360 | } | |
361 | case AF_INET: { | |
362 | struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa; | |
363 | uint8_t *c = (uint8_t *)&in->sin_addr.s_addr; | |
4b25a506 | 364 | qemu_log("{sin_family=AF_INET,sin_port=htons(%d),", |
fb3aabf3 | 365 | ntohs(in->sin_port)); |
4b25a506 | 366 | qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", |
fb3aabf3 | 367 | c[0], c[1], c[2], c[3]); |
4b25a506 | 368 | qemu_log("}"); |
fb3aabf3 LV |
369 | break; |
370 | } | |
371 | case AF_PACKET: { | |
372 | struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa; | |
373 | uint8_t *c = (uint8_t *)&ll->sll_addr; | |
4b25a506 | 374 | qemu_log("{sll_family=AF_PACKET," |
fb3aabf3 LV |
375 | "sll_protocol=htons(0x%04x),if%d,pkttype=", |
376 | ntohs(ll->sll_protocol), ll->sll_ifindex); | |
377 | switch (ll->sll_pkttype) { | |
378 | case PACKET_HOST: | |
4b25a506 | 379 | qemu_log("PACKET_HOST"); |
fb3aabf3 LV |
380 | break; |
381 | case PACKET_BROADCAST: | |
4b25a506 | 382 | qemu_log("PACKET_BROADCAST"); |
fb3aabf3 LV |
383 | break; |
384 | case PACKET_MULTICAST: | |
4b25a506 | 385 | qemu_log("PACKET_MULTICAST"); |
fb3aabf3 LV |
386 | break; |
387 | case PACKET_OTHERHOST: | |
4b25a506 | 388 | qemu_log("PACKET_OTHERHOST"); |
fb3aabf3 LV |
389 | break; |
390 | case PACKET_OUTGOING: | |
4b25a506 | 391 | qemu_log("PACKET_OUTGOING"); |
fb3aabf3 LV |
392 | break; |
393 | default: | |
4b25a506 | 394 | qemu_log("%d", ll->sll_pkttype); |
fb3aabf3 LV |
395 | break; |
396 | } | |
4b25a506 | 397 | qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", |
fb3aabf3 | 398 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); |
4b25a506 | 399 | qemu_log("}"); |
fb3aabf3 LV |
400 | break; |
401 | } | |
814ae70f PMD |
402 | case AF_NETLINK: { |
403 | struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa; | |
4b25a506 | 404 | qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}", |
814ae70f PMD |
405 | tswap32(nl->nl_pid), tswap32(nl->nl_groups)); |
406 | break; | |
407 | } | |
fb3aabf3 | 408 | default: |
4b25a506 | 409 | qemu_log("{sa_family=%d, sa_data={", sa->sa_family); |
fb3aabf3 | 410 | for (i = 0; i < 13; i++) { |
4b25a506 | 411 | qemu_log("%02x, ", sa->sa_data[i]); |
fb3aabf3 | 412 | } |
4b25a506 JK |
413 | qemu_log("%02x}", sa->sa_data[i]); |
414 | qemu_log("}"); | |
fb3aabf3 LV |
415 | break; |
416 | } | |
417 | unlock_user(sa, addr, 0); | |
418 | } else { | |
419 | print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); | |
420 | } | |
4b25a506 | 421 | qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); |
fb3aabf3 LV |
422 | } |
423 | ||
424 | static void | |
425 | print_socket_domain(int domain) | |
426 | { | |
427 | switch (domain) { | |
428 | case PF_UNIX: | |
4b25a506 | 429 | qemu_log("PF_UNIX"); |
fb3aabf3 LV |
430 | break; |
431 | case PF_INET: | |
4b25a506 | 432 | qemu_log("PF_INET"); |
fb3aabf3 | 433 | break; |
814ae70f | 434 | case PF_NETLINK: |
4b25a506 | 435 | qemu_log("PF_NETLINK"); |
814ae70f | 436 | break; |
fb3aabf3 | 437 | case PF_PACKET: |
4b25a506 | 438 | qemu_log("PF_PACKET"); |
fb3aabf3 LV |
439 | break; |
440 | default: | |
4b25a506 | 441 | qemu_log("%d", domain); |
fb3aabf3 LV |
442 | break; |
443 | } | |
444 | } | |
445 | ||
446 | static void | |
447 | print_socket_type(int type) | |
448 | { | |
2039b1b0 | 449 | switch (type & TARGET_SOCK_TYPE_MASK) { |
fb3aabf3 | 450 | case TARGET_SOCK_DGRAM: |
4b25a506 | 451 | qemu_log("SOCK_DGRAM"); |
fb3aabf3 LV |
452 | break; |
453 | case TARGET_SOCK_STREAM: | |
4b25a506 | 454 | qemu_log("SOCK_STREAM"); |
fb3aabf3 LV |
455 | break; |
456 | case TARGET_SOCK_RAW: | |
4b25a506 | 457 | qemu_log("SOCK_RAW"); |
fb3aabf3 LV |
458 | break; |
459 | case TARGET_SOCK_RDM: | |
4b25a506 | 460 | qemu_log("SOCK_RDM"); |
fb3aabf3 LV |
461 | break; |
462 | case TARGET_SOCK_SEQPACKET: | |
4b25a506 | 463 | qemu_log("SOCK_SEQPACKET"); |
fb3aabf3 LV |
464 | break; |
465 | case TARGET_SOCK_PACKET: | |
4b25a506 | 466 | qemu_log("SOCK_PACKET"); |
fb3aabf3 LV |
467 | break; |
468 | } | |
2039b1b0 LV |
469 | if (type & TARGET_SOCK_CLOEXEC) { |
470 | qemu_log("|SOCK_CLOEXEC"); | |
471 | } | |
472 | if (type & TARGET_SOCK_NONBLOCK) { | |
473 | qemu_log("|SOCK_NONBLOCK"); | |
474 | } | |
fb3aabf3 LV |
475 | } |
476 | ||
477 | static void | |
478 | print_socket_protocol(int domain, int type, int protocol) | |
479 | { | |
480 | if (domain == AF_PACKET || | |
481 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
482 | switch (protocol) { | |
483 | case 0x0003: | |
4b25a506 | 484 | qemu_log("ETH_P_ALL"); |
fb3aabf3 LV |
485 | break; |
486 | default: | |
4b25a506 | 487 | qemu_log("%d", protocol); |
fb3aabf3 LV |
488 | } |
489 | return; | |
490 | } | |
491 | ||
814ae70f PMD |
492 | if (domain == PF_NETLINK) { |
493 | switch (protocol) { | |
494 | case NETLINK_ROUTE: | |
4b25a506 | 495 | qemu_log("NETLINK_ROUTE"); |
814ae70f PMD |
496 | break; |
497 | case NETLINK_AUDIT: | |
4b25a506 | 498 | qemu_log("NETLINK_AUDIT"); |
814ae70f PMD |
499 | break; |
500 | case NETLINK_NETFILTER: | |
4b25a506 | 501 | qemu_log("NETLINK_NETFILTER"); |
814ae70f PMD |
502 | break; |
503 | case NETLINK_KOBJECT_UEVENT: | |
4b25a506 | 504 | qemu_log("NETLINK_KOBJECT_UEVENT"); |
814ae70f PMD |
505 | break; |
506 | case NETLINK_RDMA: | |
4b25a506 | 507 | qemu_log("NETLINK_RDMA"); |
814ae70f PMD |
508 | break; |
509 | case NETLINK_CRYPTO: | |
4b25a506 | 510 | qemu_log("NETLINK_CRYPTO"); |
814ae70f PMD |
511 | break; |
512 | default: | |
4b25a506 | 513 | qemu_log("%d", protocol); |
814ae70f PMD |
514 | break; |
515 | } | |
516 | return; | |
517 | } | |
518 | ||
fb3aabf3 LV |
519 | switch (protocol) { |
520 | case IPPROTO_IP: | |
4b25a506 | 521 | qemu_log("IPPROTO_IP"); |
fb3aabf3 LV |
522 | break; |
523 | case IPPROTO_TCP: | |
4b25a506 | 524 | qemu_log("IPPROTO_TCP"); |
fb3aabf3 LV |
525 | break; |
526 | case IPPROTO_UDP: | |
4b25a506 | 527 | qemu_log("IPPROTO_UDP"); |
fb3aabf3 LV |
528 | break; |
529 | case IPPROTO_RAW: | |
4b25a506 | 530 | qemu_log("IPPROTO_RAW"); |
fb3aabf3 LV |
531 | break; |
532 | default: | |
4b25a506 | 533 | qemu_log("%d", protocol); |
fb3aabf3 LV |
534 | break; |
535 | } | |
536 | } | |
537 | ||
538 | ||
c16f9ed3 | 539 | #ifdef TARGET_NR__newselect |
33189d31 | 540 | static void |
c16f9ed3 | 541 | print_fdset(int n, abi_ulong target_fds_addr) |
33189d31 TS |
542 | { |
543 | int i; | |
544 | ||
4b25a506 | 545 | qemu_log("["); |
33189d31 | 546 | if( target_fds_addr ) { |
579a97f7 | 547 | abi_long *target_fds; |
33189d31 | 548 | |
579a97f7 FB |
549 | target_fds = lock_user(VERIFY_READ, |
550 | target_fds_addr, | |
551 | sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), | |
552 | 1); | |
553 | ||
554 | if (!target_fds) | |
33189d31 TS |
555 | return; |
556 | ||
33189d31 | 557 | for (i=n; i>=0; i--) { |
cbb21eed | 558 | if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) |
4b25a506 | 559 | qemu_log("%d,", i); |
33189d31 TS |
560 | } |
561 | unlock_user(target_fds, target_fds_addr, 0); | |
562 | } | |
4b25a506 | 563 | qemu_log("]"); |
33189d31 | 564 | } |
c16f9ed3 | 565 | #endif |
33189d31 | 566 | |
38860a03 AM |
567 | #ifdef TARGET_NR_clock_adjtime |
568 | /* IDs of the various system clocks */ | |
569 | #define TARGET_CLOCK_REALTIME 0 | |
570 | #define TARGET_CLOCK_MONOTONIC 1 | |
571 | #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 | |
572 | #define TARGET_CLOCK_THREAD_CPUTIME_ID 3 | |
573 | #define TARGET_CLOCK_MONOTONIC_RAW 4 | |
574 | #define TARGET_CLOCK_REALTIME_COARSE 5 | |
575 | #define TARGET_CLOCK_MONOTONIC_COARSE 6 | |
576 | #define TARGET_CLOCK_BOOTTIME 7 | |
577 | #define TARGET_CLOCK_REALTIME_ALARM 8 | |
578 | #define TARGET_CLOCK_BOOTTIME_ALARM 9 | |
579 | #define TARGET_CLOCK_SGI_CYCLE 10 | |
580 | #define TARGET_CLOCK_TAI 11 | |
581 | ||
582 | static void | |
583 | print_clockid(int clockid, int last) | |
584 | { | |
585 | switch (clockid) { | |
586 | case TARGET_CLOCK_REALTIME: | |
4b25a506 | 587 | qemu_log("CLOCK_REALTIME"); |
38860a03 AM |
588 | break; |
589 | case TARGET_CLOCK_MONOTONIC: | |
4b25a506 | 590 | qemu_log("CLOCK_MONOTONIC"); |
38860a03 AM |
591 | break; |
592 | case TARGET_CLOCK_PROCESS_CPUTIME_ID: | |
4b25a506 | 593 | qemu_log("CLOCK_PROCESS_CPUTIME_ID"); |
38860a03 AM |
594 | break; |
595 | case TARGET_CLOCK_THREAD_CPUTIME_ID: | |
4b25a506 | 596 | qemu_log("CLOCK_THREAD_CPUTIME_ID"); |
38860a03 AM |
597 | break; |
598 | case TARGET_CLOCK_MONOTONIC_RAW: | |
4b25a506 | 599 | qemu_log("CLOCK_MONOTONIC_RAW"); |
38860a03 AM |
600 | break; |
601 | case TARGET_CLOCK_REALTIME_COARSE: | |
4b25a506 | 602 | qemu_log("CLOCK_REALTIME_COARSE"); |
38860a03 AM |
603 | break; |
604 | case TARGET_CLOCK_MONOTONIC_COARSE: | |
4b25a506 | 605 | qemu_log("CLOCK_MONOTONIC_COARSE"); |
38860a03 AM |
606 | break; |
607 | case TARGET_CLOCK_BOOTTIME: | |
4b25a506 | 608 | qemu_log("CLOCK_BOOTTIME"); |
38860a03 AM |
609 | break; |
610 | case TARGET_CLOCK_REALTIME_ALARM: | |
4b25a506 | 611 | qemu_log("CLOCK_REALTIME_ALARM"); |
38860a03 AM |
612 | break; |
613 | case TARGET_CLOCK_BOOTTIME_ALARM: | |
4b25a506 | 614 | qemu_log("CLOCK_BOOTTIME_ALARM"); |
38860a03 AM |
615 | break; |
616 | case TARGET_CLOCK_SGI_CYCLE: | |
4b25a506 | 617 | qemu_log("CLOCK_SGI_CYCLE"); |
38860a03 AM |
618 | break; |
619 | case TARGET_CLOCK_TAI: | |
4b25a506 | 620 | qemu_log("CLOCK_TAI"); |
38860a03 AM |
621 | break; |
622 | default: | |
4b25a506 | 623 | qemu_log("%d", clockid); |
38860a03 AM |
624 | break; |
625 | } | |
4b25a506 | 626 | qemu_log("%s", get_comma(last)); |
38860a03 AM |
627 | } |
628 | #endif | |
629 | ||
33189d31 TS |
630 | /* |
631 | * Sysycall specific output functions | |
632 | */ | |
633 | ||
634 | /* select */ | |
c16f9ed3 | 635 | #ifdef TARGET_NR__newselect |
33189d31 | 636 | static void |
7ccfb2eb | 637 | print_newselect(const struct syscallname *name, |
c16f9ed3 FB |
638 | abi_long arg1, abi_long arg2, abi_long arg3, |
639 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 640 | { |
c84be71f | 641 | print_syscall_prologue(name); |
33189d31 | 642 | print_fdset(arg1, arg2); |
4b25a506 | 643 | qemu_log(","); |
33189d31 | 644 | print_fdset(arg1, arg3); |
4b25a506 | 645 | qemu_log(","); |
33189d31 | 646 | print_fdset(arg1, arg4); |
4b25a506 | 647 | qemu_log(","); |
74d753ac | 648 | print_timeval(arg5, 1); |
c84be71f | 649 | print_syscall_epilogue(name); |
33189d31 | 650 | } |
c16f9ed3 | 651 | #endif |
33189d31 | 652 | |
3e46b2ef | 653 | #ifdef TARGET_NR_semctl |
33189d31 | 654 | static void |
7ccfb2eb | 655 | print_semctl(const struct syscallname *name, |
c16f9ed3 FB |
656 | abi_long arg1, abi_long arg2, abi_long arg3, |
657 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 658 | { |
4b25a506 JK |
659 | qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", |
660 | name->name, arg1, arg2); | |
33189d31 | 661 | print_ipc_cmd(arg3); |
4b25a506 | 662 | qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
33189d31 | 663 | } |
3e46b2ef | 664 | #endif |
33189d31 TS |
665 | |
666 | static void | |
7ccfb2eb | 667 | print_execve(const struct syscallname *name, |
c16f9ed3 FB |
668 | abi_long arg1, abi_long arg2, abi_long arg3, |
669 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 670 | { |
c16f9ed3 | 671 | abi_ulong arg_ptr_addr; |
33189d31 TS |
672 | char *s; |
673 | ||
579a97f7 | 674 | if (!(s = lock_user_string(arg1))) |
33189d31 | 675 | return; |
4b25a506 | 676 | qemu_log("%s(\"%s\",{", name->name, s); |
33189d31 TS |
677 | unlock_user(s, arg1, 0); |
678 | ||
c16f9ed3 | 679 | for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { |
98448f58 | 680 | abi_ulong *arg_ptr, arg_addr; |
33189d31 | 681 | |
7d37435b | 682 | arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); |
579a97f7 | 683 | if (!arg_ptr) |
33189d31 | 684 | return; |
cbb21eed | 685 | arg_addr = tswapal(*arg_ptr); |
7d37435b | 686 | unlock_user(arg_ptr, arg_ptr_addr, 0); |
33189d31 TS |
687 | if (!arg_addr) |
688 | break; | |
579a97f7 | 689 | if ((s = lock_user_string(arg_addr))) { |
4b25a506 | 690 | qemu_log("\"%s\",", s); |
98448f58 | 691 | unlock_user(s, arg_addr, 0); |
579a97f7 | 692 | } |
33189d31 TS |
693 | } |
694 | ||
4b25a506 | 695 | qemu_log("NULL})"); |
33189d31 TS |
696 | } |
697 | ||
c16f9ed3 | 698 | #ifdef TARGET_NR_ipc |
33189d31 | 699 | static void |
7ccfb2eb | 700 | print_ipc(const struct syscallname *name, |
c16f9ed3 FB |
701 | abi_long arg1, abi_long arg2, abi_long arg3, |
702 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
703 | { |
704 | switch(arg1) { | |
705 | case IPCOP_semctl: | |
4b25a506 JK |
706 | qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", |
707 | arg1, arg2); | |
7ccfb2eb | 708 | print_ipc_cmd(arg3); |
4b25a506 | 709 | qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
33189d31 TS |
710 | break; |
711 | default: | |
4b25a506 JK |
712 | qemu_log(("%s(" |
713 | TARGET_ABI_FMT_ld "," | |
714 | TARGET_ABI_FMT_ld "," | |
715 | TARGET_ABI_FMT_ld "," | |
716 | TARGET_ABI_FMT_ld | |
717 | ")"), | |
33189d31 TS |
718 | name->name, arg1, arg2, arg3, arg4); |
719 | } | |
720 | } | |
c16f9ed3 | 721 | #endif |
33189d31 TS |
722 | |
723 | /* | |
724 | * Variants for the return value output function | |
725 | */ | |
726 | ||
727 | static void | |
c84be71f | 728 | print_syscall_err(abi_long ret) |
33189d31 | 729 | { |
7dcdaeaf | 730 | const char *errstr = NULL; |
962b289e | 731 | |
c84be71f | 732 | qemu_log(" = "); |
2a7e1245 | 733 | if (ret < 0) { |
c84be71f | 734 | qemu_log("-1 errno=%d", errno); |
2a7e1245 | 735 | errstr = target_strerror(-ret); |
c84be71f FB |
736 | if (errstr) { |
737 | qemu_log(" (%s)", errstr); | |
738 | } | |
962b289e | 739 | } |
c84be71f FB |
740 | } |
741 | ||
742 | static void | |
743 | print_syscall_ret_addr(const struct syscallname *name, abi_long ret, | |
744 | abi_long arg0, abi_long arg1, abi_long arg2, | |
745 | abi_long arg3, abi_long arg4, abi_long arg5) | |
746 | { | |
747 | print_syscall_err(ret); | |
748 | ||
749 | if (ret >= 0) { | |
750 | qemu_log("0x" TARGET_ABI_FMT_lx "\n", ret); | |
33189d31 TS |
751 | } |
752 | } | |
753 | ||
f3e3285d | 754 | #if 0 /* currently unused */ |
33189d31 | 755 | static void |
c16f9ed3 | 756 | print_syscall_ret_raw(struct syscallname *name, abi_long ret) |
33189d31 | 757 | { |
4b25a506 | 758 | qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
33189d31 | 759 | } |
f3e3285d | 760 | #endif |
33189d31 | 761 | |
f3e3285d | 762 | #ifdef TARGET_NR__newselect |
33189d31 | 763 | static void |
c84be71f FB |
764 | print_syscall_ret_newselect(const struct syscallname *name, abi_long ret, |
765 | abi_long arg0, abi_long arg1, abi_long arg2, | |
766 | abi_long arg3, abi_long arg4, abi_long arg5) | |
767 | { | |
768 | print_syscall_err(ret); | |
769 | ||
770 | if (ret >= 0) { | |
771 | qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); | |
772 | print_fdset(arg0, arg1); | |
773 | qemu_log(","); | |
774 | print_fdset(arg0, arg2); | |
775 | qemu_log(","); | |
776 | print_fdset(arg0, arg3); | |
777 | qemu_log(","); | |
778 | print_timeval(arg4, 1); | |
779 | qemu_log(")"); | |
780 | } | |
781 | ||
782 | qemu_log("\n"); | |
33189d31 | 783 | } |
f3e3285d | 784 | #endif |
33189d31 | 785 | |
19f59bce AM |
786 | /* special meanings of adjtimex()' non-negative return values */ |
787 | #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */ | |
788 | #define TARGET_TIME_INS 1 /* insert leap second */ | |
789 | #define TARGET_TIME_DEL 2 /* delete leap second */ | |
790 | #define TARGET_TIME_OOP 3 /* leap second in progress */ | |
791 | #define TARGET_TIME_WAIT 4 /* leap second has occurred */ | |
792 | #define TARGET_TIME_ERROR 5 /* clock not synchronized */ | |
859e8a89 | 793 | #ifdef TARGET_NR_adjtimex |
19f59bce | 794 | static void |
c84be71f FB |
795 | print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret, |
796 | abi_long arg0, abi_long arg1, abi_long arg2, | |
797 | abi_long arg3, abi_long arg4, abi_long arg5) | |
19f59bce | 798 | { |
c84be71f | 799 | print_syscall_err(ret); |
19f59bce | 800 | |
c84be71f | 801 | if (ret >= 0) { |
4b25a506 | 802 | qemu_log(TARGET_ABI_FMT_ld, ret); |
19f59bce AM |
803 | switch (ret) { |
804 | case TARGET_TIME_OK: | |
4b25a506 | 805 | qemu_log(" TIME_OK (clock synchronized, no leap second)"); |
19f59bce AM |
806 | break; |
807 | case TARGET_TIME_INS: | |
4b25a506 | 808 | qemu_log(" TIME_INS (insert leap second)"); |
19f59bce AM |
809 | break; |
810 | case TARGET_TIME_DEL: | |
4b25a506 | 811 | qemu_log(" TIME_DEL (delete leap second)"); |
19f59bce AM |
812 | break; |
813 | case TARGET_TIME_OOP: | |
4b25a506 | 814 | qemu_log(" TIME_OOP (leap second in progress)"); |
19f59bce AM |
815 | break; |
816 | case TARGET_TIME_WAIT: | |
4b25a506 | 817 | qemu_log(" TIME_WAIT (leap second has occurred)"); |
19f59bce AM |
818 | break; |
819 | case TARGET_TIME_ERROR: | |
4b25a506 | 820 | qemu_log(" TIME_ERROR (clock not synchronized)"); |
19f59bce AM |
821 | break; |
822 | } | |
823 | } | |
824 | ||
4b25a506 | 825 | qemu_log("\n"); |
19f59bce | 826 | } |
859e8a89 | 827 | #endif |
19f59bce | 828 | |
4fc3cdde FB |
829 | #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ |
830 | || defined(TARGGET_NR_flistxattr) | |
831 | static void | |
832 | print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret, | |
833 | abi_long arg0, abi_long arg1, abi_long arg2, | |
834 | abi_long arg3, abi_long arg4, abi_long arg5) | |
835 | { | |
836 | print_syscall_err(ret); | |
837 | ||
838 | if (ret >= 0) { | |
839 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
840 | qemu_log(" (list = "); | |
841 | if (arg1 != 0) { | |
842 | abi_long attr = arg1; | |
843 | while (ret) { | |
844 | if (attr != arg1) { | |
845 | qemu_log(","); | |
846 | } | |
847 | print_string(attr, 1); | |
848 | ret -= target_strlen(attr) + 1; | |
849 | attr += target_strlen(attr) + 1; | |
850 | } | |
851 | } else { | |
852 | qemu_log("NULL"); | |
853 | } | |
854 | qemu_log(")"); | |
855 | } | |
856 | ||
857 | qemu_log("\n"); | |
858 | } | |
859 | #define print_syscall_ret_llistxattr print_syscall_ret_listxattr | |
860 | #define print_syscall_ret_flistxattr print_syscall_ret_listxattr | |
861 | #endif | |
862 | ||
79482e59 FB |
863 | #ifdef TARGET_NR_ioctl |
864 | static void | |
865 | print_syscall_ret_ioctl(const struct syscallname *name, abi_long ret, | |
866 | abi_long arg0, abi_long arg1, abi_long arg2, | |
867 | abi_long arg3, abi_long arg4, abi_long arg5) | |
868 | { | |
869 | print_syscall_err(ret); | |
870 | ||
871 | if (ret >= 0) { | |
872 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
873 | ||
874 | const IOCTLEntry *ie; | |
875 | const argtype *arg_type; | |
876 | void *argptr; | |
877 | int target_size; | |
878 | ||
879 | for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { | |
880 | if (ie->target_cmd == arg1) { | |
881 | break; | |
882 | } | |
883 | } | |
884 | ||
885 | if (ie->target_cmd == arg1 && | |
886 | (ie->access == IOC_R || ie->access == IOC_RW)) { | |
887 | arg_type = ie->arg_type; | |
888 | qemu_log(" ("); | |
889 | arg_type++; | |
890 | target_size = thunk_type_size(arg_type, 0); | |
891 | argptr = lock_user(VERIFY_READ, arg2, target_size, 1); | |
892 | thunk_print(argptr, arg_type); | |
893 | unlock_user(argptr, arg2, target_size); | |
894 | qemu_log(")"); | |
895 | } | |
896 | } | |
897 | qemu_log("\n"); | |
898 | } | |
899 | #endif | |
900 | ||
74d753ac MW |
901 | UNUSED static struct flags access_flags[] = { |
902 | FLAG_GENERIC(F_OK), | |
903 | FLAG_GENERIC(R_OK), | |
904 | FLAG_GENERIC(W_OK), | |
905 | FLAG_GENERIC(X_OK), | |
906 | FLAG_END, | |
907 | }; | |
908 | ||
909 | UNUSED static struct flags at_file_flags[] = { | |
910 | #ifdef AT_EACCESS | |
911 | FLAG_GENERIC(AT_EACCESS), | |
912 | #endif | |
913 | #ifdef AT_SYMLINK_NOFOLLOW | |
914 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), | |
915 | #endif | |
916 | FLAG_END, | |
917 | }; | |
918 | ||
919 | UNUSED static struct flags unlinkat_flags[] = { | |
920 | #ifdef AT_REMOVEDIR | |
921 | FLAG_GENERIC(AT_REMOVEDIR), | |
922 | #endif | |
923 | FLAG_END, | |
924 | }; | |
925 | ||
926 | UNUSED static struct flags mode_flags[] = { | |
927 | FLAG_GENERIC(S_IFSOCK), | |
928 | FLAG_GENERIC(S_IFLNK), | |
929 | FLAG_GENERIC(S_IFREG), | |
930 | FLAG_GENERIC(S_IFBLK), | |
931 | FLAG_GENERIC(S_IFDIR), | |
932 | FLAG_GENERIC(S_IFCHR), | |
933 | FLAG_GENERIC(S_IFIFO), | |
934 | FLAG_END, | |
935 | }; | |
936 | ||
937 | UNUSED static struct flags open_access_flags[] = { | |
938 | FLAG_TARGET(O_RDONLY), | |
939 | FLAG_TARGET(O_WRONLY), | |
940 | FLAG_TARGET(O_RDWR), | |
941 | FLAG_END, | |
942 | }; | |
943 | ||
944 | UNUSED static struct flags open_flags[] = { | |
945 | FLAG_TARGET(O_APPEND), | |
946 | FLAG_TARGET(O_CREAT), | |
947 | FLAG_TARGET(O_DIRECTORY), | |
948 | FLAG_TARGET(O_EXCL), | |
949 | FLAG_TARGET(O_LARGEFILE), | |
950 | FLAG_TARGET(O_NOCTTY), | |
951 | FLAG_TARGET(O_NOFOLLOW), | |
952 | FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ | |
afc8763f RH |
953 | FLAG_TARGET(O_DSYNC), |
954 | FLAG_TARGET(__O_SYNC), | |
74d753ac MW |
955 | FLAG_TARGET(O_TRUNC), |
956 | #ifdef O_DIRECT | |
957 | FLAG_TARGET(O_DIRECT), | |
afc8763f RH |
958 | #endif |
959 | #ifdef O_NOATIME | |
960 | FLAG_TARGET(O_NOATIME), | |
961 | #endif | |
962 | #ifdef O_CLOEXEC | |
963 | FLAG_TARGET(O_CLOEXEC), | |
964 | #endif | |
965 | #ifdef O_PATH | |
966 | FLAG_TARGET(O_PATH), | |
5f9cee46 RV |
967 | #endif |
968 | #ifdef O_TMPFILE | |
969 | FLAG_TARGET(O_TMPFILE), | |
970 | FLAG_TARGET(__O_TMPFILE), | |
74d753ac MW |
971 | #endif |
972 | FLAG_END, | |
973 | }; | |
974 | ||
975 | UNUSED static struct flags mount_flags[] = { | |
976 | #ifdef MS_BIND | |
977 | FLAG_GENERIC(MS_BIND), | |
978 | #endif | |
979 | #ifdef MS_DIRSYNC | |
980 | FLAG_GENERIC(MS_DIRSYNC), | |
981 | #endif | |
982 | FLAG_GENERIC(MS_MANDLOCK), | |
983 | #ifdef MS_MOVE | |
984 | FLAG_GENERIC(MS_MOVE), | |
985 | #endif | |
986 | FLAG_GENERIC(MS_NOATIME), | |
987 | FLAG_GENERIC(MS_NODEV), | |
988 | FLAG_GENERIC(MS_NODIRATIME), | |
989 | FLAG_GENERIC(MS_NOEXEC), | |
990 | FLAG_GENERIC(MS_NOSUID), | |
991 | FLAG_GENERIC(MS_RDONLY), | |
992 | #ifdef MS_RELATIME | |
993 | FLAG_GENERIC(MS_RELATIME), | |
994 | #endif | |
995 | FLAG_GENERIC(MS_REMOUNT), | |
996 | FLAG_GENERIC(MS_SYNCHRONOUS), | |
997 | FLAG_END, | |
998 | }; | |
999 | ||
1000 | UNUSED static struct flags umount2_flags[] = { | |
1001 | #ifdef MNT_FORCE | |
1002 | FLAG_GENERIC(MNT_FORCE), | |
1003 | #endif | |
1004 | #ifdef MNT_DETACH | |
1005 | FLAG_GENERIC(MNT_DETACH), | |
1006 | #endif | |
1007 | #ifdef MNT_EXPIRE | |
1008 | FLAG_GENERIC(MNT_EXPIRE), | |
1009 | #endif | |
1010 | FLAG_END, | |
1011 | }; | |
1012 | ||
1013 | UNUSED static struct flags mmap_prot_flags[] = { | |
1014 | FLAG_GENERIC(PROT_NONE), | |
1015 | FLAG_GENERIC(PROT_EXEC), | |
1016 | FLAG_GENERIC(PROT_READ), | |
1017 | FLAG_GENERIC(PROT_WRITE), | |
9e0b74a4 PB |
1018 | FLAG_TARGET(PROT_SEM), |
1019 | FLAG_GENERIC(PROT_GROWSDOWN), | |
1020 | FLAG_GENERIC(PROT_GROWSUP), | |
74d753ac MW |
1021 | FLAG_END, |
1022 | }; | |
1023 | ||
1024 | UNUSED static struct flags mmap_flags[] = { | |
1025 | FLAG_TARGET(MAP_SHARED), | |
1026 | FLAG_TARGET(MAP_PRIVATE), | |
1027 | FLAG_TARGET(MAP_ANONYMOUS), | |
1028 | FLAG_TARGET(MAP_DENYWRITE), | |
1029 | FLAG_TARGET(MAP_FIXED), | |
1030 | FLAG_TARGET(MAP_GROWSDOWN), | |
906c1b8e | 1031 | FLAG_TARGET(MAP_EXECUTABLE), |
74d753ac MW |
1032 | #ifdef MAP_LOCKED |
1033 | FLAG_TARGET(MAP_LOCKED), | |
1034 | #endif | |
1035 | #ifdef MAP_NONBLOCK | |
1036 | FLAG_TARGET(MAP_NONBLOCK), | |
1037 | #endif | |
1038 | FLAG_TARGET(MAP_NORESERVE), | |
1039 | #ifdef MAP_POPULATE | |
1040 | FLAG_TARGET(MAP_POPULATE), | |
906c1b8e MF |
1041 | #endif |
1042 | #ifdef TARGET_MAP_UNINITIALIZED | |
1043 | FLAG_TARGET(MAP_UNINITIALIZED), | |
74d753ac MW |
1044 | #endif |
1045 | FLAG_END, | |
1046 | }; | |
1047 | ||
608e5592 LV |
1048 | UNUSED static struct flags clone_flags[] = { |
1049 | FLAG_GENERIC(CLONE_VM), | |
1050 | FLAG_GENERIC(CLONE_FS), | |
1051 | FLAG_GENERIC(CLONE_FILES), | |
1052 | FLAG_GENERIC(CLONE_SIGHAND), | |
1053 | FLAG_GENERIC(CLONE_PTRACE), | |
1054 | FLAG_GENERIC(CLONE_VFORK), | |
1055 | FLAG_GENERIC(CLONE_PARENT), | |
1056 | FLAG_GENERIC(CLONE_THREAD), | |
1057 | FLAG_GENERIC(CLONE_NEWNS), | |
1058 | FLAG_GENERIC(CLONE_SYSVSEM), | |
1059 | FLAG_GENERIC(CLONE_SETTLS), | |
1060 | FLAG_GENERIC(CLONE_PARENT_SETTID), | |
1061 | FLAG_GENERIC(CLONE_CHILD_CLEARTID), | |
1062 | FLAG_GENERIC(CLONE_DETACHED), | |
1063 | FLAG_GENERIC(CLONE_UNTRACED), | |
1064 | FLAG_GENERIC(CLONE_CHILD_SETTID), | |
6f11f013 | 1065 | #if defined(CLONE_NEWUTS) |
608e5592 | 1066 | FLAG_GENERIC(CLONE_NEWUTS), |
6f11f013 SW |
1067 | #endif |
1068 | #if defined(CLONE_NEWIPC) | |
608e5592 | 1069 | FLAG_GENERIC(CLONE_NEWIPC), |
6f11f013 SW |
1070 | #endif |
1071 | #if defined(CLONE_NEWUSER) | |
608e5592 | 1072 | FLAG_GENERIC(CLONE_NEWUSER), |
6f11f013 SW |
1073 | #endif |
1074 | #if defined(CLONE_NEWPID) | |
608e5592 | 1075 | FLAG_GENERIC(CLONE_NEWPID), |
6f11f013 SW |
1076 | #endif |
1077 | #if defined(CLONE_NEWNET) | |
608e5592 | 1078 | FLAG_GENERIC(CLONE_NEWNET), |
6f11f013 SW |
1079 | #endif |
1080 | #if defined(CLONE_IO) | |
608e5592 | 1081 | FLAG_GENERIC(CLONE_IO), |
6f11f013 | 1082 | #endif |
608e5592 LV |
1083 | FLAG_END, |
1084 | }; | |
1085 | ||
fb3aabf3 LV |
1086 | UNUSED static struct flags msg_flags[] = { |
1087 | /* send */ | |
1088 | FLAG_GENERIC(MSG_CONFIRM), | |
1089 | FLAG_GENERIC(MSG_DONTROUTE), | |
1090 | FLAG_GENERIC(MSG_DONTWAIT), | |
1091 | FLAG_GENERIC(MSG_EOR), | |
1092 | FLAG_GENERIC(MSG_MORE), | |
1093 | FLAG_GENERIC(MSG_NOSIGNAL), | |
1094 | FLAG_GENERIC(MSG_OOB), | |
1095 | /* recv */ | |
1096 | FLAG_GENERIC(MSG_CMSG_CLOEXEC), | |
1097 | FLAG_GENERIC(MSG_ERRQUEUE), | |
1098 | FLAG_GENERIC(MSG_PEEK), | |
1099 | FLAG_GENERIC(MSG_TRUNC), | |
1100 | FLAG_GENERIC(MSG_WAITALL), | |
1101 | /* recvmsg */ | |
1102 | FLAG_GENERIC(MSG_CTRUNC), | |
1103 | FLAG_END, | |
1104 | }; | |
1105 | ||
d42744fe JW |
1106 | UNUSED static struct flags statx_flags[] = { |
1107 | #ifdef AT_EMPTY_PATH | |
1108 | FLAG_GENERIC(AT_EMPTY_PATH), | |
1109 | #endif | |
1110 | #ifdef AT_NO_AUTOMOUNT | |
1111 | FLAG_GENERIC(AT_NO_AUTOMOUNT), | |
1112 | #endif | |
1113 | #ifdef AT_SYMLINK_NOFOLLOW | |
1114 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), | |
1115 | #endif | |
1116 | #ifdef AT_STATX_SYNC_AS_STAT | |
1117 | FLAG_GENERIC(AT_STATX_SYNC_AS_STAT), | |
1118 | #endif | |
1119 | #ifdef AT_STATX_FORCE_SYNC | |
1120 | FLAG_GENERIC(AT_STATX_FORCE_SYNC), | |
1121 | #endif | |
1122 | #ifdef AT_STATX_DONT_SYNC | |
1123 | FLAG_GENERIC(AT_STATX_DONT_SYNC), | |
1124 | #endif | |
1125 | FLAG_END, | |
1126 | }; | |
1127 | ||
1128 | UNUSED static struct flags statx_mask[] = { | |
1129 | /* This must come first, because it includes everything. */ | |
1130 | #ifdef STATX_ALL | |
1131 | FLAG_GENERIC(STATX_ALL), | |
1132 | #endif | |
1133 | /* This must come second; it includes everything except STATX_BTIME. */ | |
1134 | #ifdef STATX_BASIC_STATS | |
1135 | FLAG_GENERIC(STATX_BASIC_STATS), | |
1136 | #endif | |
1137 | #ifdef STATX_TYPE | |
1138 | FLAG_GENERIC(STATX_TYPE), | |
1139 | #endif | |
1140 | #ifdef STATX_MODE | |
1141 | FLAG_GENERIC(STATX_MODE), | |
1142 | #endif | |
1143 | #ifdef STATX_NLINK | |
1144 | FLAG_GENERIC(STATX_NLINK), | |
1145 | #endif | |
1146 | #ifdef STATX_UID | |
1147 | FLAG_GENERIC(STATX_UID), | |
1148 | #endif | |
1149 | #ifdef STATX_GID | |
1150 | FLAG_GENERIC(STATX_GID), | |
1151 | #endif | |
1152 | #ifdef STATX_ATIME | |
1153 | FLAG_GENERIC(STATX_ATIME), | |
1154 | #endif | |
1155 | #ifdef STATX_MTIME | |
1156 | FLAG_GENERIC(STATX_MTIME), | |
1157 | #endif | |
1158 | #ifdef STATX_CTIME | |
1159 | FLAG_GENERIC(STATX_CTIME), | |
1160 | #endif | |
1161 | #ifdef STATX_INO | |
1162 | FLAG_GENERIC(STATX_INO), | |
1163 | #endif | |
1164 | #ifdef STATX_SIZE | |
1165 | FLAG_GENERIC(STATX_SIZE), | |
1166 | #endif | |
1167 | #ifdef STATX_BLOCKS | |
1168 | FLAG_GENERIC(STATX_BLOCKS), | |
1169 | #endif | |
1170 | #ifdef STATX_BTIME | |
1171 | FLAG_GENERIC(STATX_BTIME), | |
1172 | #endif | |
1173 | FLAG_END, | |
1174 | }; | |
1175 | ||
f4d92c5e FB |
1176 | UNUSED static struct flags falloc_flags[] = { |
1177 | FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), | |
1178 | FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), | |
1179 | #ifdef FALLOC_FL_NO_HIDE_STALE | |
1180 | FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), | |
1181 | #endif | |
1182 | #ifdef FALLOC_FL_COLLAPSE_RANGE | |
1183 | FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), | |
1184 | #endif | |
1185 | #ifdef FALLOC_FL_ZERO_RANGE | |
1186 | FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), | |
1187 | #endif | |
1188 | #ifdef FALLOC_FL_INSERT_RANGE | |
1189 | FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), | |
1190 | #endif | |
1191 | #ifdef FALLOC_FL_UNSHARE_RANGE | |
1192 | FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), | |
1193 | #endif | |
1194 | }; | |
1195 | ||
74d753ac MW |
1196 | /* |
1197 | * print_xxx utility functions. These are used to print syscall | |
1198 | * parameters in certain format. All of these have parameter | |
1199 | * named 'last'. This parameter is used to add comma to output | |
1200 | * when last == 0. | |
1201 | */ | |
1202 | ||
1203 | static const char * | |
1204 | get_comma(int last) | |
1205 | { | |
1206 | return ((last) ? "" : ","); | |
1207 | } | |
1208 | ||
1209 | static void | |
d2ee72a5 | 1210 | print_flags(const struct flags *f, abi_long flags, int last) |
74d753ac MW |
1211 | { |
1212 | const char *sep = ""; | |
74d753ac MW |
1213 | int n; |
1214 | ||
74d753ac | 1215 | if ((flags == 0) && (f->f_value == 0)) { |
4b25a506 | 1216 | qemu_log("%s%s", f->f_string, get_comma(last)); |
74d753ac MW |
1217 | return; |
1218 | } | |
1219 | for (n = 0; f->f_string != NULL; f++) { | |
1220 | if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { | |
4b25a506 | 1221 | qemu_log("%s%s", sep, f->f_string); |
74d753ac MW |
1222 | flags &= ~f->f_value; |
1223 | sep = "|"; | |
1224 | n++; | |
1225 | } | |
1226 | } | |
1227 | ||
1228 | if (n > 0) { | |
1229 | /* print rest of the flags as numeric */ | |
1230 | if (flags != 0) { | |
4b25a506 | 1231 | qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); |
74d753ac | 1232 | } else { |
4b25a506 | 1233 | qemu_log("%s", get_comma(last)); |
74d753ac MW |
1234 | } |
1235 | } else { | |
1236 | /* no string version of flags found, print them in hex then */ | |
4b25a506 | 1237 | qemu_log("%#x%s", (unsigned int)flags, get_comma(last)); |
74d753ac MW |
1238 | } |
1239 | } | |
1240 | ||
1241 | static void | |
d2ee72a5 | 1242 | print_at_dirfd(abi_long dirfd, int last) |
74d753ac | 1243 | { |
74d753ac MW |
1244 | #ifdef AT_FDCWD |
1245 | if (dirfd == AT_FDCWD) { | |
4b25a506 | 1246 | qemu_log("AT_FDCWD%s", get_comma(last)); |
74d753ac MW |
1247 | return; |
1248 | } | |
1249 | #endif | |
4b25a506 | 1250 | qemu_log("%d%s", (int)dirfd, get_comma(last)); |
74d753ac MW |
1251 | } |
1252 | ||
1253 | static void | |
d2ee72a5 | 1254 | print_file_mode(abi_long mode, int last) |
74d753ac MW |
1255 | { |
1256 | const char *sep = ""; | |
1257 | const struct flags *m; | |
74d753ac MW |
1258 | |
1259 | for (m = &mode_flags[0]; m->f_string != NULL; m++) { | |
1260 | if ((m->f_value & mode) == m->f_value) { | |
4b25a506 | 1261 | qemu_log("%s%s", m->f_string, sep); |
74d753ac MW |
1262 | sep = "|"; |
1263 | mode &= ~m->f_value; | |
1264 | break; | |
1265 | } | |
1266 | } | |
1267 | ||
1268 | mode &= ~S_IFMT; | |
1269 | /* print rest of the mode as octal */ | |
1270 | if (mode != 0) | |
4b25a506 | 1271 | qemu_log("%s%#o", sep, (unsigned int)mode); |
74d753ac | 1272 | |
4b25a506 | 1273 | qemu_log("%s", get_comma(last)); |
74d753ac MW |
1274 | } |
1275 | ||
1276 | static void | |
d2ee72a5 | 1277 | print_open_flags(abi_long flags, int last) |
74d753ac | 1278 | { |
74d753ac MW |
1279 | print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); |
1280 | flags &= ~TARGET_O_ACCMODE; | |
1281 | if (flags == 0) { | |
4b25a506 | 1282 | qemu_log("%s", get_comma(last)); |
74d753ac MW |
1283 | return; |
1284 | } | |
4b25a506 | 1285 | qemu_log("|"); |
74d753ac MW |
1286 | print_flags(open_flags, flags, last); |
1287 | } | |
1288 | ||
1289 | static void | |
1290 | print_syscall_prologue(const struct syscallname *sc) | |
1291 | { | |
4b25a506 | 1292 | qemu_log("%s(", sc->name); |
74d753ac MW |
1293 | } |
1294 | ||
1295 | /*ARGSUSED*/ | |
1296 | static void | |
1297 | print_syscall_epilogue(const struct syscallname *sc) | |
1298 | { | |
1299 | (void)sc; | |
4b25a506 | 1300 | qemu_log(")"); |
74d753ac MW |
1301 | } |
1302 | ||
1303 | static void | |
1304 | print_string(abi_long addr, int last) | |
1305 | { | |
1306 | char *s; | |
1307 | ||
1308 | if ((s = lock_user_string(addr)) != NULL) { | |
4b25a506 | 1309 | qemu_log("\"%s\"%s", s, get_comma(last)); |
74d753ac MW |
1310 | unlock_user(s, addr, 0); |
1311 | } else { | |
1312 | /* can't get string out of it, so print it as pointer */ | |
1313 | print_pointer(addr, last); | |
1314 | } | |
1315 | } | |
1316 | ||
fb3aabf3 LV |
1317 | #define MAX_PRINT_BUF 40 |
1318 | static void | |
1319 | print_buf(abi_long addr, abi_long len, int last) | |
1320 | { | |
1321 | uint8_t *s; | |
1322 | int i; | |
1323 | ||
1324 | s = lock_user(VERIFY_READ, addr, len, 1); | |
1325 | if (s) { | |
4b25a506 | 1326 | qemu_log("\""); |
fb3aabf3 LV |
1327 | for (i = 0; i < MAX_PRINT_BUF && i < len; i++) { |
1328 | if (isprint(s[i])) { | |
4b25a506 | 1329 | qemu_log("%c", s[i]); |
fb3aabf3 | 1330 | } else { |
4b25a506 | 1331 | qemu_log("\\%o", s[i]); |
fb3aabf3 LV |
1332 | } |
1333 | } | |
4b25a506 | 1334 | qemu_log("\""); |
fb3aabf3 | 1335 | if (i != len) { |
4b25a506 | 1336 | qemu_log("..."); |
fb3aabf3 LV |
1337 | } |
1338 | if (!last) { | |
4b25a506 | 1339 | qemu_log(","); |
fb3aabf3 LV |
1340 | } |
1341 | unlock_user(s, addr, 0); | |
1342 | } else { | |
1343 | print_pointer(addr, last); | |
1344 | } | |
1345 | } | |
1346 | ||
74d753ac MW |
1347 | /* |
1348 | * Prints out raw parameter using given format. Caller needs | |
1349 | * to do byte swapping if needed. | |
1350 | */ | |
1351 | static void | |
1352 | print_raw_param(const char *fmt, abi_long param, int last) | |
1353 | { | |
1354 | char format[64]; | |
1355 | ||
1356 | (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); | |
4b25a506 | 1357 | qemu_log(format, param); |
74d753ac MW |
1358 | } |
1359 | ||
1360 | static void | |
1361 | print_pointer(abi_long p, int last) | |
1362 | { | |
1363 | if (p == 0) | |
4b25a506 | 1364 | qemu_log("NULL%s", get_comma(last)); |
74d753ac | 1365 | else |
4b25a506 | 1366 | qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); |
74d753ac MW |
1367 | } |
1368 | ||
1369 | /* | |
1370 | * Reads 32-bit (int) number from guest address space from | |
1371 | * address 'addr' and prints it. | |
1372 | */ | |
1373 | static void | |
1374 | print_number(abi_long addr, int last) | |
1375 | { | |
1376 | if (addr == 0) { | |
4b25a506 | 1377 | qemu_log("NULL%s", get_comma(last)); |
74d753ac MW |
1378 | } else { |
1379 | int num; | |
1380 | ||
1381 | get_user_s32(num, addr); | |
4b25a506 | 1382 | qemu_log("[%d]%s", num, get_comma(last)); |
74d753ac MW |
1383 | } |
1384 | } | |
1385 | ||
1386 | static void | |
1387 | print_timeval(abi_ulong tv_addr, int last) | |
1388 | { | |
1389 | if( tv_addr ) { | |
1390 | struct target_timeval *tv; | |
1391 | ||
1392 | tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); | |
8f93089d PMD |
1393 | if (!tv) { |
1394 | print_pointer(tv_addr, last); | |
74d753ac | 1395 | return; |
8f93089d | 1396 | } |
4b25a506 | 1397 | qemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", |
910ee4e5 | 1398 | tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); |
74d753ac MW |
1399 | unlock_user(tv, tv_addr, 0); |
1400 | } else | |
4b25a506 | 1401 | qemu_log("NULL%s", get_comma(last)); |
74d753ac MW |
1402 | } |
1403 | ||
6d33e036 PMD |
1404 | static void |
1405 | print_timezone(abi_ulong tz_addr, int last) | |
1406 | { | |
1407 | if (tz_addr) { | |
1408 | struct target_timezone *tz; | |
1409 | ||
1410 | tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1); | |
1411 | if (!tz) { | |
1412 | print_pointer(tz_addr, last); | |
1413 | return; | |
1414 | } | |
4b25a506 | 1415 | qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest), |
6d33e036 PMD |
1416 | tswap32(tz->tz_dsttime), get_comma(last)); |
1417 | unlock_user(tz, tz_addr, 0); | |
1418 | } else { | |
4b25a506 | 1419 | qemu_log("NULL%s", get_comma(last)); |
6d33e036 PMD |
1420 | } |
1421 | } | |
1422 | ||
74d753ac MW |
1423 | #undef UNUSED |
1424 | ||
1425 | #ifdef TARGET_NR_accept | |
1426 | static void | |
1427 | print_accept(const struct syscallname *name, | |
1428 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1429 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1430 | { | |
1431 | print_syscall_prologue(name); | |
d2ee72a5 | 1432 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
1433 | print_pointer(arg1, 0); |
1434 | print_number(arg2, 1); | |
1435 | print_syscall_epilogue(name); | |
1436 | } | |
1437 | #endif | |
1438 | ||
1439 | #ifdef TARGET_NR_access | |
1440 | static void | |
1441 | print_access(const struct syscallname *name, | |
1442 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1443 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1444 | { | |
1445 | print_syscall_prologue(name); | |
1446 | print_string(arg0, 0); | |
1447 | print_flags(access_flags, arg1, 1); | |
1448 | print_syscall_epilogue(name); | |
1449 | } | |
1450 | #endif | |
1451 | ||
c42569f6 FB |
1452 | #ifdef TARGET_NR_acct |
1453 | static void | |
1454 | print_acct(const struct syscallname *name, | |
1455 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1456 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1457 | { | |
1458 | print_syscall_prologue(name); | |
1459 | print_string(arg0, 1); | |
1460 | print_syscall_epilogue(name); | |
1461 | } | |
1462 | #endif | |
1463 | ||
74d753ac MW |
1464 | #ifdef TARGET_NR_brk |
1465 | static void | |
1466 | print_brk(const struct syscallname *name, | |
1467 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1468 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1469 | { | |
1470 | print_syscall_prologue(name); | |
1471 | print_pointer(arg0, 1); | |
1472 | print_syscall_epilogue(name); | |
1473 | } | |
1474 | #endif | |
1475 | ||
1476 | #ifdef TARGET_NR_chdir | |
1477 | static void | |
1478 | print_chdir(const struct syscallname *name, | |
1479 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1480 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1481 | { | |
1482 | print_syscall_prologue(name); | |
1483 | print_string(arg0, 1); | |
1484 | print_syscall_epilogue(name); | |
1485 | } | |
1486 | #endif | |
1487 | ||
1b7695fe HD |
1488 | #ifdef TARGET_NR_chroot |
1489 | static void | |
1490 | print_chroot(const struct syscallname *name, | |
1491 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1492 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1493 | { | |
1494 | print_syscall_prologue(name); | |
1495 | print_string(arg0, 1); | |
1496 | print_syscall_epilogue(name); | |
1497 | } | |
1498 | #endif | |
1499 | ||
74d753ac MW |
1500 | #ifdef TARGET_NR_chmod |
1501 | static void | |
1502 | print_chmod(const struct syscallname *name, | |
1503 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1504 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1505 | { | |
1506 | print_syscall_prologue(name); | |
1507 | print_string(arg0, 0); | |
1508 | print_file_mode(arg1, 1); | |
1509 | print_syscall_epilogue(name); | |
1510 | } | |
1511 | #endif | |
1512 | ||
5844f4bc FB |
1513 | #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) |
1514 | static void | |
1515 | print_chown(const struct syscallname *name, | |
1516 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1517 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1518 | { | |
1519 | print_syscall_prologue(name); | |
1520 | print_string(arg0, 0); | |
1521 | print_raw_param("%d", arg1, 0); | |
1522 | print_raw_param("%d", arg2, 1); | |
1523 | print_syscall_epilogue(name); | |
1524 | } | |
1525 | #define print_lchown print_chown | |
1526 | #endif | |
1527 | ||
38860a03 AM |
1528 | #ifdef TARGET_NR_clock_adjtime |
1529 | static void | |
1530 | print_clock_adjtime(const struct syscallname *name, | |
1531 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1532 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1533 | { | |
1534 | print_syscall_prologue(name); | |
1535 | print_clockid(arg0, 0); | |
1536 | print_pointer(arg1, 1); | |
1537 | print_syscall_epilogue(name); | |
1538 | } | |
1539 | #endif | |
1540 | ||
608e5592 | 1541 | #ifdef TARGET_NR_clone |
84bd8284 LV |
1542 | static void do_print_clone(unsigned int flags, abi_ulong newsp, |
1543 | abi_ulong parent_tidptr, target_ulong newtls, | |
1544 | abi_ulong child_tidptr) | |
1545 | { | |
1546 | print_flags(clone_flags, flags, 0); | |
1547 | print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0); | |
1548 | print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0); | |
1549 | print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0); | |
1550 | print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1); | |
1551 | } | |
1552 | ||
608e5592 LV |
1553 | static void |
1554 | print_clone(const struct syscallname *name, | |
84bd8284 LV |
1555 | abi_long arg1, abi_long arg2, abi_long arg3, |
1556 | abi_long arg4, abi_long arg5, abi_long arg6) | |
608e5592 LV |
1557 | { |
1558 | print_syscall_prologue(name); | |
84bd8284 LV |
1559 | #if defined(TARGET_MICROBLAZE) |
1560 | do_print_clone(arg1, arg2, arg4, arg6, arg5); | |
1561 | #elif defined(TARGET_CLONE_BACKWARDS) | |
1562 | do_print_clone(arg1, arg2, arg3, arg4, arg5); | |
1563 | #elif defined(TARGET_CLONE_BACKWARDS2) | |
1564 | do_print_clone(arg2, arg1, arg3, arg5, arg4); | |
608e5592 | 1565 | #else |
84bd8284 | 1566 | do_print_clone(arg1, arg2, arg3, arg5, arg4); |
608e5592 LV |
1567 | #endif |
1568 | print_syscall_epilogue(name); | |
1569 | } | |
1570 | #endif | |
1571 | ||
74d753ac MW |
1572 | #ifdef TARGET_NR_creat |
1573 | static void | |
1574 | print_creat(const struct syscallname *name, | |
1575 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1576 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1577 | { | |
1578 | print_syscall_prologue(name); | |
1579 | print_string(arg0, 0); | |
1580 | print_file_mode(arg1, 1); | |
1581 | print_syscall_epilogue(name); | |
1582 | } | |
1583 | #endif | |
1584 | ||
1585 | #ifdef TARGET_NR_execv | |
1586 | static void | |
1587 | print_execv(const struct syscallname *name, | |
1588 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1589 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1590 | { | |
1591 | print_syscall_prologue(name); | |
1592 | print_string(arg0, 0); | |
d2ee72a5 | 1593 | print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1); |
74d753ac MW |
1594 | print_syscall_epilogue(name); |
1595 | } | |
1596 | #endif | |
1597 | ||
1598 | #ifdef TARGET_NR_faccessat | |
1599 | static void | |
1600 | print_faccessat(const struct syscallname *name, | |
1601 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1602 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1603 | { | |
1604 | print_syscall_prologue(name); | |
1605 | print_at_dirfd(arg0, 0); | |
1606 | print_string(arg1, 0); | |
1607 | print_flags(access_flags, arg2, 0); | |
1608 | print_flags(at_file_flags, arg3, 1); | |
1609 | print_syscall_epilogue(name); | |
1610 | } | |
1611 | #endif | |
1612 | ||
f4d92c5e FB |
1613 | #ifdef TARGET_NR_fallocate |
1614 | static void | |
1615 | print_fallocate(const struct syscallname *name, | |
1616 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1617 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1618 | { | |
1619 | print_syscall_prologue(name); | |
1620 | print_raw_param("%d", arg0, 0); | |
1621 | print_flags(falloc_flags, arg1, 0); | |
1622 | #if TARGET_ABI_BITS == 32 | |
1623 | print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); | |
1624 | print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); | |
1625 | #else | |
1626 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
1627 | print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); | |
1628 | #endif | |
1629 | print_syscall_epilogue(name); | |
1630 | } | |
1631 | #endif | |
1632 | ||
74d753ac MW |
1633 | #ifdef TARGET_NR_fchmodat |
1634 | static void | |
1635 | print_fchmodat(const struct syscallname *name, | |
1636 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1637 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1638 | { | |
1639 | print_syscall_prologue(name); | |
1640 | print_at_dirfd(arg0, 0); | |
1641 | print_string(arg1, 0); | |
1642 | print_file_mode(arg2, 0); | |
1643 | print_flags(at_file_flags, arg3, 1); | |
1644 | print_syscall_epilogue(name); | |
1645 | } | |
1646 | #endif | |
1647 | ||
1648 | #ifdef TARGET_NR_fchownat | |
1649 | static void | |
1650 | print_fchownat(const struct syscallname *name, | |
1651 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1652 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1653 | { | |
1654 | print_syscall_prologue(name); | |
1655 | print_at_dirfd(arg0, 0); | |
1656 | print_string(arg1, 0); | |
d2ee72a5 LV |
1657 | print_raw_param("%d", arg2, 0); |
1658 | print_raw_param("%d", arg3, 0); | |
74d753ac MW |
1659 | print_flags(at_file_flags, arg4, 1); |
1660 | print_syscall_epilogue(name); | |
1661 | } | |
1662 | #endif | |
1663 | ||
1664 | #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) | |
1665 | static void | |
1666 | print_fcntl(const struct syscallname *name, | |
1667 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1668 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1669 | { | |
1670 | print_syscall_prologue(name); | |
d2ee72a5 | 1671 | print_raw_param("%d", arg0, 0); |
d95ec14f LV |
1672 | switch(arg1) { |
1673 | case TARGET_F_DUPFD: | |
4b25a506 | 1674 | qemu_log("F_DUPFD,"); |
d95ec14f LV |
1675 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
1676 | break; | |
1677 | case TARGET_F_GETFD: | |
4b25a506 | 1678 | qemu_log("F_GETFD"); |
d95ec14f LV |
1679 | break; |
1680 | case TARGET_F_SETFD: | |
4b25a506 | 1681 | qemu_log("F_SETFD,"); |
d95ec14f LV |
1682 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
1683 | break; | |
1684 | case TARGET_F_GETFL: | |
4b25a506 | 1685 | qemu_log("F_GETFL"); |
d95ec14f LV |
1686 | break; |
1687 | case TARGET_F_SETFL: | |
4b25a506 | 1688 | qemu_log("F_SETFL,"); |
d95ec14f LV |
1689 | print_open_flags(arg2, 1); |
1690 | break; | |
1691 | case TARGET_F_GETLK: | |
4b25a506 | 1692 | qemu_log("F_GETLK,"); |
d95ec14f LV |
1693 | print_pointer(arg2, 1); |
1694 | break; | |
1695 | case TARGET_F_SETLK: | |
4b25a506 | 1696 | qemu_log("F_SETLK,"); |
d95ec14f LV |
1697 | print_pointer(arg2, 1); |
1698 | break; | |
1699 | case TARGET_F_SETLKW: | |
4b25a506 | 1700 | qemu_log("F_SETLKW,"); |
d95ec14f LV |
1701 | print_pointer(arg2, 1); |
1702 | break; | |
1703 | case TARGET_F_GETOWN: | |
4b25a506 | 1704 | qemu_log("F_GETOWN"); |
d95ec14f LV |
1705 | break; |
1706 | case TARGET_F_SETOWN: | |
4b25a506 | 1707 | qemu_log("F_SETOWN,"); |
d95ec14f LV |
1708 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
1709 | break; | |
1710 | case TARGET_F_GETSIG: | |
4b25a506 | 1711 | qemu_log("F_GETSIG"); |
d95ec14f LV |
1712 | break; |
1713 | case TARGET_F_SETSIG: | |
4b25a506 | 1714 | qemu_log("F_SETSIG,"); |
d95ec14f LV |
1715 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
1716 | break; | |
1717 | #if TARGET_ABI_BITS == 32 | |
1718 | case TARGET_F_GETLK64: | |
4b25a506 | 1719 | qemu_log("F_GETLK64,"); |
d95ec14f LV |
1720 | print_pointer(arg2, 1); |
1721 | break; | |
1722 | case TARGET_F_SETLK64: | |
4b25a506 | 1723 | qemu_log("F_SETLK64,"); |
d95ec14f LV |
1724 | print_pointer(arg2, 1); |
1725 | break; | |
1726 | case TARGET_F_SETLKW64: | |
4b25a506 | 1727 | qemu_log("F_SETLKW64,"); |
d95ec14f LV |
1728 | print_pointer(arg2, 1); |
1729 | break; | |
1730 | #endif | |
1731 | case TARGET_F_SETLEASE: | |
4b25a506 | 1732 | qemu_log("F_SETLEASE,"); |
d95ec14f LV |
1733 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
1734 | break; | |
1735 | case TARGET_F_GETLEASE: | |
4b25a506 | 1736 | qemu_log("F_GETLEASE"); |
d95ec14f | 1737 | break; |
7e3b92ec | 1738 | case TARGET_F_SETPIPE_SZ: |
4b25a506 | 1739 | qemu_log("F_SETPIPE_SZ,"); |
7e3b92ec PM |
1740 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
1741 | break; | |
1742 | case TARGET_F_GETPIPE_SZ: | |
4b25a506 | 1743 | qemu_log("F_GETPIPE_SZ"); |
7e3b92ec | 1744 | break; |
d95ec14f | 1745 | case TARGET_F_DUPFD_CLOEXEC: |
4b25a506 | 1746 | qemu_log("F_DUPFD_CLOEXEC,"); |
d95ec14f LV |
1747 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
1748 | break; | |
1749 | case TARGET_F_NOTIFY: | |
4b25a506 | 1750 | qemu_log("F_NOTIFY,"); |
d95ec14f LV |
1751 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
1752 | break; | |
1753 | default: | |
1754 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
1755 | print_pointer(arg2, 1); | |
1756 | break; | |
1757 | } | |
74d753ac MW |
1758 | print_syscall_epilogue(name); |
1759 | } | |
1760 | #define print_fcntl64 print_fcntl | |
1761 | #endif | |
1762 | ||
4fc3cdde FB |
1763 | #ifdef TARGET_NR_fgetxattr |
1764 | static void | |
1765 | print_fgetxattr(const struct syscallname *name, | |
1766 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1767 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1768 | { | |
1769 | print_syscall_prologue(name); | |
1770 | print_raw_param("%d", arg0, 0); | |
1771 | print_string(arg1, 0); | |
1772 | print_pointer(arg2, 0); | |
1773 | print_raw_param(TARGET_FMT_lu, arg3, 1); | |
1774 | print_syscall_epilogue(name); | |
1775 | } | |
1776 | #endif | |
1777 | ||
1778 | #ifdef TARGET_NR_flistxattr | |
1779 | static void | |
1780 | print_flistxattr(const struct syscallname *name, | |
1781 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1782 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1783 | { | |
1784 | print_syscall_prologue(name); | |
1785 | print_raw_param("%d", arg0, 0); | |
1786 | print_pointer(arg1, 0); | |
1787 | print_raw_param(TARGET_FMT_lu, arg2, 1); | |
1788 | print_syscall_epilogue(name); | |
1789 | } | |
1790 | #endif | |
1791 | ||
1792 | #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) | |
1793 | static void | |
1794 | print_getxattr(const struct syscallname *name, | |
1795 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1796 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1797 | { | |
1798 | print_syscall_prologue(name); | |
1799 | print_string(arg0, 0); | |
1800 | print_string(arg1, 0); | |
1801 | print_pointer(arg2, 0); | |
1802 | print_raw_param(TARGET_FMT_lu, arg3, 1); | |
1803 | print_syscall_epilogue(name); | |
1804 | } | |
1805 | #define print_lgetxattr print_getxattr | |
1806 | #endif | |
1807 | ||
1808 | #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) | |
1809 | static void | |
1810 | print_listxattr(const struct syscallname *name, | |
1811 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1812 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1813 | { | |
1814 | print_syscall_prologue(name); | |
1815 | print_string(arg0, 0); | |
1816 | print_pointer(arg1, 0); | |
1817 | print_raw_param(TARGET_FMT_lu, arg2, 1); | |
1818 | print_syscall_epilogue(name); | |
1819 | } | |
1820 | #define print_llistxattr print_listxattr | |
1821 | #endif | |
1822 | ||
1823 | #if defined(TARGET_NR_fremovexattr) | |
1824 | static void | |
1825 | print_fremovexattr(const struct syscallname *name, | |
1826 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1827 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1828 | { | |
1829 | print_syscall_prologue(name); | |
1830 | print_raw_param("%d", arg0, 0); | |
1831 | print_string(arg1, 1); | |
1832 | print_syscall_epilogue(name); | |
1833 | } | |
1834 | #endif | |
1835 | ||
1836 | #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr) | |
1837 | static void | |
1838 | print_removexattr(const struct syscallname *name, | |
1839 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1840 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1841 | { | |
1842 | print_syscall_prologue(name); | |
1843 | print_string(arg0, 0); | |
1844 | print_string(arg1, 1); | |
1845 | print_syscall_epilogue(name); | |
1846 | } | |
1847 | #define print_lremovexattr print_removexattr | |
1848 | #endif | |
1849 | ||
74d753ac MW |
1850 | #ifdef TARGET_NR_futimesat |
1851 | static void | |
1852 | print_futimesat(const struct syscallname *name, | |
1853 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1854 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1855 | { | |
1856 | print_syscall_prologue(name); | |
1857 | print_at_dirfd(arg0, 0); | |
1858 | print_string(arg1, 0); | |
1859 | print_timeval(arg2, 0); | |
1860 | print_timeval(arg2 + sizeof (struct target_timeval), 1); | |
1861 | print_syscall_epilogue(name); | |
1862 | } | |
1863 | #endif | |
1864 | ||
0d2187c4 PMD |
1865 | #ifdef TARGET_NR_settimeofday |
1866 | static void | |
1867 | print_settimeofday(const struct syscallname *name, | |
1868 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1869 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1870 | { | |
1871 | print_syscall_prologue(name); | |
1872 | print_timeval(arg0, 0); | |
1873 | print_timezone(arg1, 1); | |
1874 | print_syscall_epilogue(name); | |
1875 | } | |
1876 | #endif | |
1877 | ||
74d753ac MW |
1878 | #ifdef TARGET_NR_link |
1879 | static void | |
1880 | print_link(const struct syscallname *name, | |
1881 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1882 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1883 | { | |
1884 | print_syscall_prologue(name); | |
1885 | print_string(arg0, 0); | |
1886 | print_string(arg1, 1); | |
1887 | print_syscall_epilogue(name); | |
1888 | } | |
1889 | #endif | |
1890 | ||
1891 | #ifdef TARGET_NR_linkat | |
1892 | static void | |
1893 | print_linkat(const struct syscallname *name, | |
1894 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1895 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1896 | { | |
1897 | print_syscall_prologue(name); | |
1898 | print_at_dirfd(arg0, 0); | |
1899 | print_string(arg1, 0); | |
1900 | print_at_dirfd(arg2, 0); | |
1901 | print_string(arg3, 0); | |
1902 | print_flags(at_file_flags, arg4, 1); | |
1903 | print_syscall_epilogue(name); | |
1904 | } | |
1905 | #endif | |
1906 | ||
608e5592 LV |
1907 | #ifdef TARGET_NR__llseek |
1908 | static void | |
1909 | print__llseek(const struct syscallname *name, | |
1910 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1911 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1912 | { | |
1913 | const char *whence = "UNKNOWN"; | |
1914 | print_syscall_prologue(name); | |
1915 | print_raw_param("%d", arg0, 0); | |
1916 | print_raw_param("%ld", arg1, 0); | |
1917 | print_raw_param("%ld", arg2, 0); | |
1918 | print_pointer(arg3, 0); | |
1919 | switch(arg4) { | |
1920 | case SEEK_SET: whence = "SEEK_SET"; break; | |
1921 | case SEEK_CUR: whence = "SEEK_CUR"; break; | |
1922 | case SEEK_END: whence = "SEEK_END"; break; | |
1923 | } | |
4b25a506 | 1924 | qemu_log("%s", whence); |
608e5592 LV |
1925 | print_syscall_epilogue(name); |
1926 | } | |
1927 | #endif | |
1928 | ||
af861dea FB |
1929 | #ifdef TARGET_NR_lseek |
1930 | static void | |
1931 | print_lseek(const struct syscallname *name, | |
1932 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1933 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1934 | { | |
1935 | print_syscall_prologue(name); | |
1936 | print_raw_param("%d", arg0, 0); | |
1937 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
1938 | switch (arg2) { | |
1939 | case SEEK_SET: | |
1940 | qemu_log("SEEK_SET"); break; | |
1941 | case SEEK_CUR: | |
1942 | qemu_log("SEEK_CUR"); break; | |
1943 | case SEEK_END: | |
1944 | qemu_log("SEEK_END"); break; | |
1945 | #ifdef SEEK_DATA | |
1946 | case SEEK_DATA: | |
1947 | qemu_log("SEEK_DATA"); break; | |
1948 | #endif | |
1949 | #ifdef SEEK_HOLE | |
1950 | case SEEK_HOLE: | |
1951 | qemu_log("SEEK_HOLE"); break; | |
1952 | #endif | |
1953 | default: | |
1954 | print_raw_param("%#x", arg2, 1); | |
1955 | } | |
1956 | print_syscall_epilogue(name); | |
1957 | } | |
1958 | #endif | |
1959 | ||
8997d1bd LV |
1960 | #if defined(TARGET_NR_socket) |
1961 | static void | |
1962 | print_socket(const struct syscallname *name, | |
1963 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1964 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1965 | { | |
1966 | abi_ulong domain = arg0, type = arg1, protocol = arg2; | |
1967 | ||
1968 | print_syscall_prologue(name); | |
1969 | print_socket_domain(domain); | |
4b25a506 | 1970 | qemu_log(","); |
8997d1bd | 1971 | print_socket_type(type); |
4b25a506 | 1972 | qemu_log(","); |
8997d1bd LV |
1973 | if (domain == AF_PACKET || |
1974 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
1975 | protocol = tswap16(protocol); | |
1976 | } | |
1977 | print_socket_protocol(domain, type, protocol); | |
1978 | print_syscall_epilogue(name); | |
1979 | } | |
1980 | ||
1981 | #endif | |
1982 | ||
bb10540e | 1983 | #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind) |
fb3aabf3 | 1984 | |
d84fe1ed PMD |
1985 | static void print_sockfd(abi_long sockfd, int last) |
1986 | { | |
1987 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, last); | |
1988 | } | |
1989 | ||
1990 | #endif | |
1991 | ||
1992 | #if defined(TARGET_NR_socketcall) | |
1993 | ||
fb3aabf3 LV |
1994 | #define get_user_ualx(x, gaddr, idx) \ |
1995 | get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long)) | |
1996 | ||
1997 | static void do_print_socket(const char *name, abi_long arg1) | |
1998 | { | |
1999 | abi_ulong domain, type, protocol; | |
2000 | ||
2001 | get_user_ualx(domain, arg1, 0); | |
2002 | get_user_ualx(type, arg1, 1); | |
2003 | get_user_ualx(protocol, arg1, 2); | |
4b25a506 | 2004 | qemu_log("%s(", name); |
fb3aabf3 | 2005 | print_socket_domain(domain); |
4b25a506 | 2006 | qemu_log(","); |
fb3aabf3 | 2007 | print_socket_type(type); |
4b25a506 | 2008 | qemu_log(","); |
fb3aabf3 LV |
2009 | if (domain == AF_PACKET || |
2010 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { | |
2011 | protocol = tswap16(protocol); | |
2012 | } | |
2013 | print_socket_protocol(domain, type, protocol); | |
4b25a506 | 2014 | qemu_log(")"); |
fb3aabf3 LV |
2015 | } |
2016 | ||
2017 | static void do_print_sockaddr(const char *name, abi_long arg1) | |
2018 | { | |
2019 | abi_ulong sockfd, addr, addrlen; | |
2020 | ||
2021 | get_user_ualx(sockfd, arg1, 0); | |
2022 | get_user_ualx(addr, arg1, 1); | |
2023 | get_user_ualx(addrlen, arg1, 2); | |
2024 | ||
4b25a506 | 2025 | qemu_log("%s(", name); |
d84fe1ed | 2026 | print_sockfd(sockfd, 0); |
42b15d70 | 2027 | print_sockaddr(addr, addrlen, 0); |
4b25a506 | 2028 | qemu_log(")"); |
fb3aabf3 LV |
2029 | } |
2030 | ||
2031 | static void do_print_listen(const char *name, abi_long arg1) | |
2032 | { | |
2033 | abi_ulong sockfd, backlog; | |
2034 | ||
2035 | get_user_ualx(sockfd, arg1, 0); | |
2036 | get_user_ualx(backlog, arg1, 1); | |
2037 | ||
4b25a506 | 2038 | qemu_log("%s(", name); |
d84fe1ed | 2039 | print_sockfd(sockfd, 0); |
fb3aabf3 | 2040 | print_raw_param(TARGET_ABI_FMT_ld, backlog, 1); |
4b25a506 | 2041 | qemu_log(")"); |
fb3aabf3 LV |
2042 | } |
2043 | ||
2044 | static void do_print_socketpair(const char *name, abi_long arg1) | |
2045 | { | |
2046 | abi_ulong domain, type, protocol, tab; | |
2047 | ||
2048 | get_user_ualx(domain, arg1, 0); | |
2049 | get_user_ualx(type, arg1, 1); | |
2050 | get_user_ualx(protocol, arg1, 2); | |
2051 | get_user_ualx(tab, arg1, 3); | |
2052 | ||
4b25a506 | 2053 | qemu_log("%s(", name); |
fb3aabf3 | 2054 | print_socket_domain(domain); |
4b25a506 | 2055 | qemu_log(","); |
fb3aabf3 | 2056 | print_socket_type(type); |
4b25a506 | 2057 | qemu_log(","); |
fb3aabf3 | 2058 | print_socket_protocol(domain, type, protocol); |
4b25a506 | 2059 | qemu_log(","); |
fb3aabf3 | 2060 | print_raw_param(TARGET_ABI_FMT_lx, tab, 1); |
4b25a506 | 2061 | qemu_log(")"); |
fb3aabf3 LV |
2062 | } |
2063 | ||
2064 | static void do_print_sendrecv(const char *name, abi_long arg1) | |
2065 | { | |
2066 | abi_ulong sockfd, msg, len, flags; | |
2067 | ||
2068 | get_user_ualx(sockfd, arg1, 0); | |
2069 | get_user_ualx(msg, arg1, 1); | |
2070 | get_user_ualx(len, arg1, 2); | |
2071 | get_user_ualx(flags, arg1, 3); | |
2072 | ||
4b25a506 | 2073 | qemu_log("%s(", name); |
d84fe1ed | 2074 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2075 | print_buf(msg, len, 0); |
2076 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); | |
2077 | print_flags(msg_flags, flags, 1); | |
4b25a506 | 2078 | qemu_log(")"); |
fb3aabf3 LV |
2079 | } |
2080 | ||
2081 | static void do_print_msgaddr(const char *name, abi_long arg1) | |
2082 | { | |
2083 | abi_ulong sockfd, msg, len, flags, addr, addrlen; | |
2084 | ||
2085 | get_user_ualx(sockfd, arg1, 0); | |
2086 | get_user_ualx(msg, arg1, 1); | |
2087 | get_user_ualx(len, arg1, 2); | |
2088 | get_user_ualx(flags, arg1, 3); | |
2089 | get_user_ualx(addr, arg1, 4); | |
2090 | get_user_ualx(addrlen, arg1, 5); | |
2091 | ||
4b25a506 | 2092 | qemu_log("%s(", name); |
d84fe1ed | 2093 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2094 | print_buf(msg, len, 0); |
2095 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); | |
2096 | print_flags(msg_flags, flags, 0); | |
42b15d70 | 2097 | print_sockaddr(addr, addrlen, 0); |
4b25a506 | 2098 | qemu_log(")"); |
fb3aabf3 LV |
2099 | } |
2100 | ||
2101 | static void do_print_shutdown(const char *name, abi_long arg1) | |
2102 | { | |
2103 | abi_ulong sockfd, how; | |
2104 | ||
2105 | get_user_ualx(sockfd, arg1, 0); | |
2106 | get_user_ualx(how, arg1, 1); | |
2107 | ||
4b25a506 | 2108 | qemu_log("shutdown("); |
d84fe1ed | 2109 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2110 | switch (how) { |
2111 | case SHUT_RD: | |
4b25a506 | 2112 | qemu_log("SHUT_RD"); |
fb3aabf3 LV |
2113 | break; |
2114 | case SHUT_WR: | |
4b25a506 | 2115 | qemu_log("SHUT_WR"); |
fb3aabf3 LV |
2116 | break; |
2117 | case SHUT_RDWR: | |
4b25a506 | 2118 | qemu_log("SHUT_RDWR"); |
fb3aabf3 LV |
2119 | break; |
2120 | default: | |
2121 | print_raw_param(TARGET_ABI_FMT_ld, how, 1); | |
2122 | break; | |
2123 | } | |
4b25a506 | 2124 | qemu_log(")"); |
fb3aabf3 LV |
2125 | } |
2126 | ||
2127 | static void do_print_msg(const char *name, abi_long arg1) | |
2128 | { | |
2129 | abi_ulong sockfd, msg, flags; | |
2130 | ||
2131 | get_user_ualx(sockfd, arg1, 0); | |
2132 | get_user_ualx(msg, arg1, 1); | |
2133 | get_user_ualx(flags, arg1, 2); | |
2134 | ||
4b25a506 | 2135 | qemu_log("%s(", name); |
d84fe1ed | 2136 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2137 | print_pointer(msg, 0); |
2138 | print_flags(msg_flags, flags, 1); | |
4b25a506 | 2139 | qemu_log(")"); |
fb3aabf3 LV |
2140 | } |
2141 | ||
2142 | static void do_print_sockopt(const char *name, abi_long arg1) | |
2143 | { | |
2144 | abi_ulong sockfd, level, optname, optval, optlen; | |
2145 | ||
2146 | get_user_ualx(sockfd, arg1, 0); | |
2147 | get_user_ualx(level, arg1, 1); | |
2148 | get_user_ualx(optname, arg1, 2); | |
2149 | get_user_ualx(optval, arg1, 3); | |
2150 | get_user_ualx(optlen, arg1, 4); | |
2151 | ||
4b25a506 | 2152 | qemu_log("%s(", name); |
d84fe1ed | 2153 | print_sockfd(sockfd, 0); |
fb3aabf3 LV |
2154 | switch (level) { |
2155 | case SOL_TCP: | |
4b25a506 | 2156 | qemu_log("SOL_TCP,"); |
fb3aabf3 LV |
2157 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
2158 | print_pointer(optval, 0); | |
2159 | break; | |
2160 | case SOL_IP: | |
4b25a506 | 2161 | qemu_log("SOL_IP,"); |
fb3aabf3 LV |
2162 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
2163 | print_pointer(optval, 0); | |
2164 | break; | |
2165 | case SOL_RAW: | |
4b25a506 | 2166 | qemu_log("SOL_RAW,"); |
fb3aabf3 LV |
2167 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
2168 | print_pointer(optval, 0); | |
2169 | break; | |
2170 | case TARGET_SOL_SOCKET: | |
4b25a506 | 2171 | qemu_log("SOL_SOCKET,"); |
fb3aabf3 LV |
2172 | switch (optname) { |
2173 | case TARGET_SO_DEBUG: | |
4b25a506 | 2174 | qemu_log("SO_DEBUG,"); |
fb3aabf3 LV |
2175 | print_optint: |
2176 | print_number(optval, 0); | |
2177 | break; | |
2178 | case TARGET_SO_REUSEADDR: | |
4b25a506 | 2179 | qemu_log("SO_REUSEADDR,"); |
fb3aabf3 | 2180 | goto print_optint; |
113a9dd7 | 2181 | case TARGET_SO_REUSEPORT: |
4b25a506 | 2182 | qemu_log("SO_REUSEPORT,"); |
113a9dd7 | 2183 | goto print_optint; |
fb3aabf3 | 2184 | case TARGET_SO_TYPE: |
4b25a506 | 2185 | qemu_log("SO_TYPE,"); |
fb3aabf3 LV |
2186 | goto print_optint; |
2187 | case TARGET_SO_ERROR: | |
4b25a506 | 2188 | qemu_log("SO_ERROR,"); |
fb3aabf3 LV |
2189 | goto print_optint; |
2190 | case TARGET_SO_DONTROUTE: | |
4b25a506 | 2191 | qemu_log("SO_DONTROUTE,"); |
fb3aabf3 LV |
2192 | goto print_optint; |
2193 | case TARGET_SO_BROADCAST: | |
4b25a506 | 2194 | qemu_log("SO_BROADCAST,"); |
fb3aabf3 LV |
2195 | goto print_optint; |
2196 | case TARGET_SO_SNDBUF: | |
4b25a506 | 2197 | qemu_log("SO_SNDBUF,"); |
fb3aabf3 LV |
2198 | goto print_optint; |
2199 | case TARGET_SO_RCVBUF: | |
4b25a506 | 2200 | qemu_log("SO_RCVBUF,"); |
fb3aabf3 LV |
2201 | goto print_optint; |
2202 | case TARGET_SO_KEEPALIVE: | |
4b25a506 | 2203 | qemu_log("SO_KEEPALIVE,"); |
fb3aabf3 LV |
2204 | goto print_optint; |
2205 | case TARGET_SO_OOBINLINE: | |
4b25a506 | 2206 | qemu_log("SO_OOBINLINE,"); |
fb3aabf3 LV |
2207 | goto print_optint; |
2208 | case TARGET_SO_NO_CHECK: | |
4b25a506 | 2209 | qemu_log("SO_NO_CHECK,"); |
fb3aabf3 LV |
2210 | goto print_optint; |
2211 | case TARGET_SO_PRIORITY: | |
4b25a506 | 2212 | qemu_log("SO_PRIORITY,"); |
fb3aabf3 LV |
2213 | goto print_optint; |
2214 | case TARGET_SO_BSDCOMPAT: | |
4b25a506 | 2215 | qemu_log("SO_BSDCOMPAT,"); |
fb3aabf3 LV |
2216 | goto print_optint; |
2217 | case TARGET_SO_PASSCRED: | |
4b25a506 | 2218 | qemu_log("SO_PASSCRED,"); |
fb3aabf3 LV |
2219 | goto print_optint; |
2220 | case TARGET_SO_TIMESTAMP: | |
4b25a506 | 2221 | qemu_log("SO_TIMESTAMP,"); |
fb3aabf3 LV |
2222 | goto print_optint; |
2223 | case TARGET_SO_RCVLOWAT: | |
4b25a506 | 2224 | qemu_log("SO_RCVLOWAT,"); |
fb3aabf3 LV |
2225 | goto print_optint; |
2226 | case TARGET_SO_RCVTIMEO: | |
4b25a506 | 2227 | qemu_log("SO_RCVTIMEO,"); |
fb3aabf3 LV |
2228 | print_timeval(optval, 0); |
2229 | break; | |
2230 | case TARGET_SO_SNDTIMEO: | |
4b25a506 | 2231 | qemu_log("SO_SNDTIMEO,"); |
fb3aabf3 LV |
2232 | print_timeval(optval, 0); |
2233 | break; | |
2234 | case TARGET_SO_ATTACH_FILTER: { | |
2235 | struct target_sock_fprog *fprog; | |
2236 | ||
4b25a506 | 2237 | qemu_log("SO_ATTACH_FILTER,"); |
fb3aabf3 LV |
2238 | |
2239 | if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) { | |
2240 | struct target_sock_filter *filter; | |
4b25a506 | 2241 | qemu_log("{"); |
fb3aabf3 LV |
2242 | if (lock_user_struct(VERIFY_READ, filter, |
2243 | tswapal(fprog->filter), 0)) { | |
2244 | int i; | |
2245 | for (i = 0; i < tswap16(fprog->len) - 1; i++) { | |
4b25a506 | 2246 | qemu_log("[%d]{0x%x,%d,%d,0x%x},", |
fb3aabf3 LV |
2247 | i, tswap16(filter[i].code), |
2248 | filter[i].jt, filter[i].jf, | |
2249 | tswap32(filter[i].k)); | |
2250 | } | |
4b25a506 | 2251 | qemu_log("[%d]{0x%x,%d,%d,0x%x}", |
fb3aabf3 LV |
2252 | i, tswap16(filter[i].code), |
2253 | filter[i].jt, filter[i].jf, | |
2254 | tswap32(filter[i].k)); | |
2255 | } else { | |
4b25a506 | 2256 | qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter)); |
fb3aabf3 | 2257 | } |
4b25a506 | 2258 | qemu_log(",%d},", tswap16(fprog->len)); |
fb3aabf3 LV |
2259 | unlock_user(fprog, optval, 0); |
2260 | } else { | |
2261 | print_pointer(optval, 0); | |
2262 | } | |
2263 | break; | |
2264 | } | |
2265 | default: | |
2266 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
2267 | print_pointer(optval, 0); | |
2268 | break; | |
2269 | } | |
2270 | break; | |
2271 | default: | |
2272 | print_raw_param(TARGET_ABI_FMT_ld, level, 0); | |
2273 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); | |
2274 | print_pointer(optval, 0); | |
2275 | break; | |
2276 | } | |
2277 | print_raw_param(TARGET_ABI_FMT_ld, optlen, 1); | |
4b25a506 | 2278 | qemu_log(")"); |
fb3aabf3 LV |
2279 | } |
2280 | ||
2281 | #define PRINT_SOCKOP(name, func) \ | |
ff71a454 | 2282 | [TARGET_SYS_##name] = { #name, func } |
fb3aabf3 LV |
2283 | |
2284 | static struct { | |
2285 | const char *name; | |
2286 | void (*print)(const char *, abi_long); | |
2287 | } scall[] = { | |
ff71a454 AM |
2288 | PRINT_SOCKOP(SOCKET, do_print_socket), |
2289 | PRINT_SOCKOP(BIND, do_print_sockaddr), | |
2290 | PRINT_SOCKOP(CONNECT, do_print_sockaddr), | |
2291 | PRINT_SOCKOP(LISTEN, do_print_listen), | |
2292 | PRINT_SOCKOP(ACCEPT, do_print_sockaddr), | |
2293 | PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr), | |
2294 | PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr), | |
2295 | PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair), | |
2296 | PRINT_SOCKOP(SEND, do_print_sendrecv), | |
2297 | PRINT_SOCKOP(RECV, do_print_sendrecv), | |
2298 | PRINT_SOCKOP(SENDTO, do_print_msgaddr), | |
2299 | PRINT_SOCKOP(RECVFROM, do_print_msgaddr), | |
2300 | PRINT_SOCKOP(SHUTDOWN, do_print_shutdown), | |
2301 | PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt), | |
2302 | PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt), | |
2303 | PRINT_SOCKOP(SENDMSG, do_print_msg), | |
2304 | PRINT_SOCKOP(RECVMSG, do_print_msg), | |
2305 | PRINT_SOCKOP(ACCEPT4, NULL), | |
2306 | PRINT_SOCKOP(RECVMMSG, NULL), | |
2307 | PRINT_SOCKOP(SENDMMSG, NULL), | |
fb3aabf3 LV |
2308 | }; |
2309 | ||
2310 | static void | |
2311 | print_socketcall(const struct syscallname *name, | |
2312 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2313 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2314 | { | |
2315 | if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) { | |
2316 | scall[arg0].print(scall[arg0].name, arg1); | |
2317 | return; | |
2318 | } | |
2319 | print_syscall_prologue(name); | |
2320 | print_raw_param(TARGET_ABI_FMT_ld, arg0, 0); | |
2321 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
2322 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
2323 | print_raw_param(TARGET_ABI_FMT_ld, arg3, 0); | |
2324 | print_raw_param(TARGET_ABI_FMT_ld, arg4, 0); | |
2325 | print_raw_param(TARGET_ABI_FMT_ld, arg5, 0); | |
2326 | print_syscall_epilogue(name); | |
2327 | } | |
2328 | #endif | |
2329 | ||
bb10540e PMD |
2330 | #if defined(TARGET_NR_bind) |
2331 | static void | |
2332 | print_bind(const struct syscallname *name, | |
2333 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2334 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2335 | { | |
2336 | print_syscall_prologue(name); | |
2337 | print_sockfd(arg0, 0); | |
2338 | print_sockaddr(arg1, arg2, 1); | |
2339 | print_syscall_epilogue(name); | |
2340 | } | |
2341 | #endif | |
2342 | ||
74d753ac MW |
2343 | #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ |
2344 | defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) | |
2345 | static void | |
2346 | print_stat(const struct syscallname *name, | |
2347 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2348 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2349 | { | |
2350 | print_syscall_prologue(name); | |
2351 | print_string(arg0, 0); | |
2352 | print_pointer(arg1, 1); | |
2353 | print_syscall_epilogue(name); | |
2354 | } | |
2355 | #define print_lstat print_stat | |
2356 | #define print_stat64 print_stat | |
2357 | #define print_lstat64 print_stat | |
2358 | #endif | |
2359 | ||
2360 | #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) | |
2361 | static void | |
2362 | print_fstat(const struct syscallname *name, | |
2363 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2364 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2365 | { | |
2366 | print_syscall_prologue(name); | |
d2ee72a5 | 2367 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
2368 | print_pointer(arg1, 1); |
2369 | print_syscall_epilogue(name); | |
2370 | } | |
2371 | #define print_fstat64 print_fstat | |
2372 | #endif | |
2373 | ||
2374 | #ifdef TARGET_NR_mkdir | |
2375 | static void | |
2376 | print_mkdir(const struct syscallname *name, | |
2377 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2378 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2379 | { | |
2380 | print_syscall_prologue(name); | |
2381 | print_string(arg0, 0); | |
2382 | print_file_mode(arg1, 1); | |
2383 | print_syscall_epilogue(name); | |
2384 | } | |
2385 | #endif | |
2386 | ||
2387 | #ifdef TARGET_NR_mkdirat | |
2388 | static void | |
2389 | print_mkdirat(const struct syscallname *name, | |
2390 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2391 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2392 | { | |
2393 | print_syscall_prologue(name); | |
2394 | print_at_dirfd(arg0, 0); | |
2395 | print_string(arg1, 0); | |
2396 | print_file_mode(arg2, 1); | |
2397 | print_syscall_epilogue(name); | |
2398 | } | |
2399 | #endif | |
2400 | ||
4de596cb LV |
2401 | #ifdef TARGET_NR_rmdir |
2402 | static void | |
2403 | print_rmdir(const struct syscallname *name, | |
2404 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2405 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2406 | { | |
2407 | print_syscall_prologue(name); | |
2408 | print_string(arg0, 0); | |
2409 | print_syscall_epilogue(name); | |
2410 | } | |
2411 | #endif | |
2412 | ||
608e5592 LV |
2413 | #ifdef TARGET_NR_rt_sigaction |
2414 | static void | |
2415 | print_rt_sigaction(const struct syscallname *name, | |
2416 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2417 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2418 | { | |
2419 | print_syscall_prologue(name); | |
2420 | print_signal(arg0, 0); | |
2421 | print_pointer(arg1, 0); | |
2422 | print_pointer(arg2, 1); | |
2423 | print_syscall_epilogue(name); | |
2424 | } | |
2425 | #endif | |
2426 | ||
2427 | #ifdef TARGET_NR_rt_sigprocmask | |
2428 | static void | |
2429 | print_rt_sigprocmask(const struct syscallname *name, | |
2430 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2431 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2432 | { | |
2433 | const char *how = "UNKNOWN"; | |
2434 | print_syscall_prologue(name); | |
2435 | switch(arg0) { | |
2436 | case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; | |
2437 | case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; | |
2438 | case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; | |
2439 | } | |
4b25a506 | 2440 | qemu_log("%s,", how); |
608e5592 LV |
2441 | print_pointer(arg1, 0); |
2442 | print_pointer(arg2, 1); | |
2443 | print_syscall_epilogue(name); | |
2444 | } | |
2445 | #endif | |
2446 | ||
5162264e MS |
2447 | #ifdef TARGET_NR_rt_sigqueueinfo |
2448 | static void | |
2449 | print_rt_sigqueueinfo(const struct syscallname *name, | |
2450 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2451 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2452 | { | |
ba9fcea1 MS |
2453 | void *p; |
2454 | target_siginfo_t uinfo; | |
2455 | ||
5162264e MS |
2456 | print_syscall_prologue(name); |
2457 | print_raw_param("%d", arg0, 0); | |
2458 | print_signal(arg1, 0); | |
ba9fcea1 MS |
2459 | p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); |
2460 | if (p) { | |
2461 | get_target_siginfo(&uinfo, p); | |
2462 | print_siginfo(&uinfo); | |
2463 | ||
2464 | unlock_user(p, arg2, 0); | |
2465 | } else { | |
2466 | print_pointer(arg2, 1); | |
2467 | } | |
5162264e MS |
2468 | print_syscall_epilogue(name); |
2469 | } | |
2470 | #endif | |
2471 | ||
243e0fe5 MS |
2472 | #ifdef TARGET_NR_rt_tgsigqueueinfo |
2473 | static void | |
2474 | print_rt_tgsigqueueinfo(const struct syscallname *name, | |
2475 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2476 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2477 | { | |
ba9fcea1 MS |
2478 | void *p; |
2479 | target_siginfo_t uinfo; | |
2480 | ||
243e0fe5 MS |
2481 | print_syscall_prologue(name); |
2482 | print_raw_param("%d", arg0, 0); | |
2483 | print_raw_param("%d", arg1, 0); | |
2484 | print_signal(arg2, 0); | |
ba9fcea1 MS |
2485 | p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); |
2486 | if (p) { | |
2487 | get_target_siginfo(&uinfo, p); | |
2488 | print_siginfo(&uinfo); | |
2489 | ||
2490 | unlock_user(p, arg3, 0); | |
2491 | } else { | |
2492 | print_pointer(arg3, 1); | |
2493 | } | |
243e0fe5 MS |
2494 | print_syscall_epilogue(name); |
2495 | } | |
2496 | #endif | |
2497 | ||
da2c8ad7 AM |
2498 | #ifdef TARGET_NR_syslog |
2499 | static void | |
2500 | print_syslog_action(abi_ulong arg, int last) | |
2501 | { | |
2502 | const char *type; | |
2503 | ||
2504 | switch (arg) { | |
2505 | case TARGET_SYSLOG_ACTION_CLOSE: { | |
2506 | type = "SYSLOG_ACTION_CLOSE"; | |
2507 | break; | |
2508 | } | |
2509 | case TARGET_SYSLOG_ACTION_OPEN: { | |
2510 | type = "SYSLOG_ACTION_OPEN"; | |
2511 | break; | |
2512 | } | |
2513 | case TARGET_SYSLOG_ACTION_READ: { | |
2514 | type = "SYSLOG_ACTION_READ"; | |
2515 | break; | |
2516 | } | |
2517 | case TARGET_SYSLOG_ACTION_READ_ALL: { | |
2518 | type = "SYSLOG_ACTION_READ_ALL"; | |
2519 | break; | |
2520 | } | |
2521 | case TARGET_SYSLOG_ACTION_READ_CLEAR: { | |
2522 | type = "SYSLOG_ACTION_READ_CLEAR"; | |
2523 | break; | |
2524 | } | |
2525 | case TARGET_SYSLOG_ACTION_CLEAR: { | |
2526 | type = "SYSLOG_ACTION_CLEAR"; | |
2527 | break; | |
2528 | } | |
2529 | case TARGET_SYSLOG_ACTION_CONSOLE_OFF: { | |
2530 | type = "SYSLOG_ACTION_CONSOLE_OFF"; | |
2531 | break; | |
2532 | } | |
2533 | case TARGET_SYSLOG_ACTION_CONSOLE_ON: { | |
2534 | type = "SYSLOG_ACTION_CONSOLE_ON"; | |
2535 | break; | |
2536 | } | |
2537 | case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: { | |
2538 | type = "SYSLOG_ACTION_CONSOLE_LEVEL"; | |
2539 | break; | |
2540 | } | |
2541 | case TARGET_SYSLOG_ACTION_SIZE_UNREAD: { | |
2542 | type = "SYSLOG_ACTION_SIZE_UNREAD"; | |
2543 | break; | |
2544 | } | |
2545 | case TARGET_SYSLOG_ACTION_SIZE_BUFFER: { | |
2546 | type = "SYSLOG_ACTION_SIZE_BUFFER"; | |
2547 | break; | |
2548 | } | |
2549 | default: { | |
2550 | print_raw_param("%ld", arg, last); | |
2551 | return; | |
2552 | } | |
2553 | } | |
4b25a506 | 2554 | qemu_log("%s%s", type, get_comma(last)); |
da2c8ad7 AM |
2555 | } |
2556 | ||
2557 | static void | |
2558 | print_syslog(const struct syscallname *name, | |
2559 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2560 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2561 | { | |
2562 | print_syscall_prologue(name); | |
2563 | print_syslog_action(arg0, 0); | |
2564 | print_pointer(arg1, 0); | |
2565 | print_raw_param("%d", arg2, 1); | |
2566 | print_syscall_epilogue(name); | |
2567 | } | |
2568 | #endif | |
2569 | ||
74d753ac MW |
2570 | #ifdef TARGET_NR_mknod |
2571 | static void | |
2572 | print_mknod(const struct syscallname *name, | |
2573 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2574 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2575 | { | |
d2ee72a5 | 2576 | int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
2577 | |
2578 | print_syscall_prologue(name); | |
2579 | print_string(arg0, 0); | |
2580 | print_file_mode(arg1, (hasdev == 0)); | |
2581 | if (hasdev) { | |
d2ee72a5 LV |
2582 | print_raw_param("makedev(%d", major(arg2), 0); |
2583 | print_raw_param("%d)", minor(arg2), 1); | |
74d753ac MW |
2584 | } |
2585 | print_syscall_epilogue(name); | |
2586 | } | |
2587 | #endif | |
2588 | ||
2589 | #ifdef TARGET_NR_mknodat | |
2590 | static void | |
2591 | print_mknodat(const struct syscallname *name, | |
2592 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2593 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2594 | { | |
d2ee72a5 | 2595 | int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
2596 | |
2597 | print_syscall_prologue(name); | |
2598 | print_at_dirfd(arg0, 0); | |
2599 | print_string(arg1, 0); | |
2600 | print_file_mode(arg2, (hasdev == 0)); | |
2601 | if (hasdev) { | |
d2ee72a5 LV |
2602 | print_raw_param("makedev(%d", major(arg3), 0); |
2603 | print_raw_param("%d)", minor(arg3), 1); | |
74d753ac MW |
2604 | } |
2605 | print_syscall_epilogue(name); | |
2606 | } | |
2607 | #endif | |
2608 | ||
2609 | #ifdef TARGET_NR_mq_open | |
2610 | static void | |
2611 | print_mq_open(const struct syscallname *name, | |
2612 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2613 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2614 | { | |
d2ee72a5 | 2615 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
2616 | |
2617 | print_syscall_prologue(name); | |
2618 | print_string(arg0, 0); | |
2619 | print_open_flags(arg1, (is_creat == 0)); | |
2620 | if (is_creat) { | |
2621 | print_file_mode(arg2, 0); | |
2622 | print_pointer(arg3, 1); | |
2623 | } | |
2624 | print_syscall_epilogue(name); | |
2625 | } | |
2626 | #endif | |
2627 | ||
2628 | #ifdef TARGET_NR_open | |
2629 | static void | |
2630 | print_open(const struct syscallname *name, | |
2631 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2632 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2633 | { | |
d2ee72a5 | 2634 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
2635 | |
2636 | print_syscall_prologue(name); | |
2637 | print_string(arg0, 0); | |
2638 | print_open_flags(arg1, (is_creat == 0)); | |
2639 | if (is_creat) | |
2640 | print_file_mode(arg2, 1); | |
2641 | print_syscall_epilogue(name); | |
2642 | } | |
2643 | #endif | |
2644 | ||
2645 | #ifdef TARGET_NR_openat | |
2646 | static void | |
2647 | print_openat(const struct syscallname *name, | |
2648 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2649 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2650 | { | |
d2ee72a5 | 2651 | int is_creat = (arg2 & TARGET_O_CREAT); |
74d753ac MW |
2652 | |
2653 | print_syscall_prologue(name); | |
2654 | print_at_dirfd(arg0, 0); | |
2655 | print_string(arg1, 0); | |
2656 | print_open_flags(arg2, (is_creat == 0)); | |
2657 | if (is_creat) | |
2658 | print_file_mode(arg3, 1); | |
2659 | print_syscall_epilogue(name); | |
2660 | } | |
2661 | #endif | |
2662 | ||
2663 | #ifdef TARGET_NR_mq_unlink | |
2664 | static void | |
2665 | print_mq_unlink(const struct syscallname *name, | |
2666 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2667 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2668 | { | |
2669 | print_syscall_prologue(name); | |
2670 | print_string(arg0, 1); | |
2671 | print_syscall_epilogue(name); | |
2672 | } | |
2673 | #endif | |
2674 | ||
2675 | #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) | |
2676 | static void | |
2677 | print_fstatat64(const struct syscallname *name, | |
2678 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2679 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2680 | { | |
2681 | print_syscall_prologue(name); | |
2682 | print_at_dirfd(arg0, 0); | |
2683 | print_string(arg1, 0); | |
2684 | print_pointer(arg2, 0); | |
2685 | print_flags(at_file_flags, arg3, 1); | |
2686 | print_syscall_epilogue(name); | |
2687 | } | |
2688 | #define print_newfstatat print_fstatat64 | |
2689 | #endif | |
2690 | ||
2691 | #ifdef TARGET_NR_readlink | |
2692 | static void | |
2693 | print_readlink(const struct syscallname *name, | |
2694 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2695 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2696 | { | |
2697 | print_syscall_prologue(name); | |
2698 | print_string(arg0, 0); | |
2699 | print_pointer(arg1, 0); | |
d2ee72a5 | 2700 | print_raw_param("%u", arg2, 1); |
74d753ac MW |
2701 | print_syscall_epilogue(name); |
2702 | } | |
2703 | #endif | |
2704 | ||
2705 | #ifdef TARGET_NR_readlinkat | |
2706 | static void | |
2707 | print_readlinkat(const struct syscallname *name, | |
2708 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2709 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2710 | { | |
2711 | print_syscall_prologue(name); | |
2712 | print_at_dirfd(arg0, 0); | |
2713 | print_string(arg1, 0); | |
2714 | print_pointer(arg2, 0); | |
d2ee72a5 | 2715 | print_raw_param("%u", arg3, 1); |
74d753ac MW |
2716 | print_syscall_epilogue(name); |
2717 | } | |
2718 | #endif | |
2719 | ||
2720 | #ifdef TARGET_NR_rename | |
2721 | static void | |
2722 | print_rename(const struct syscallname *name, | |
2723 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2724 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2725 | { | |
2726 | print_syscall_prologue(name); | |
2727 | print_string(arg0, 0); | |
2728 | print_string(arg1, 1); | |
2729 | print_syscall_epilogue(name); | |
2730 | } | |
2731 | #endif | |
2732 | ||
2733 | #ifdef TARGET_NR_renameat | |
2734 | static void | |
2735 | print_renameat(const struct syscallname *name, | |
2736 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2737 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2738 | { | |
2739 | print_syscall_prologue(name); | |
2740 | print_at_dirfd(arg0, 0); | |
2741 | print_string(arg1, 0); | |
2742 | print_at_dirfd(arg2, 0); | |
2743 | print_string(arg3, 1); | |
2744 | print_syscall_epilogue(name); | |
2745 | } | |
2746 | #endif | |
2747 | ||
2748 | #ifdef TARGET_NR_statfs | |
2749 | static void | |
2750 | print_statfs(const struct syscallname *name, | |
2751 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2752 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2753 | { | |
2754 | print_syscall_prologue(name); | |
2755 | print_string(arg0, 0); | |
2756 | print_pointer(arg1, 1); | |
2757 | print_syscall_epilogue(name); | |
2758 | } | |
4f7f8924 AR |
2759 | #endif |
2760 | ||
2761 | #ifdef TARGET_NR_statfs64 | |
2762 | static void | |
2763 | print_statfs64(const struct syscallname *name, | |
2764 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2765 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2766 | { | |
2767 | print_syscall_prologue(name); | |
2768 | print_string(arg0, 0); | |
2769 | print_pointer(arg1, 1); | |
2770 | print_syscall_epilogue(name); | |
2771 | } | |
74d753ac MW |
2772 | #endif |
2773 | ||
2774 | #ifdef TARGET_NR_symlink | |
2775 | static void | |
2776 | print_symlink(const struct syscallname *name, | |
2777 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2778 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2779 | { | |
2780 | print_syscall_prologue(name); | |
2781 | print_string(arg0, 0); | |
2782 | print_string(arg1, 1); | |
2783 | print_syscall_epilogue(name); | |
2784 | } | |
2785 | #endif | |
2786 | ||
2787 | #ifdef TARGET_NR_symlinkat | |
2788 | static void | |
2789 | print_symlinkat(const struct syscallname *name, | |
2790 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2791 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2792 | { | |
2793 | print_syscall_prologue(name); | |
2794 | print_string(arg0, 0); | |
2795 | print_at_dirfd(arg1, 0); | |
2796 | print_string(arg2, 1); | |
2797 | print_syscall_epilogue(name); | |
2798 | } | |
2799 | #endif | |
2800 | ||
2801 | #ifdef TARGET_NR_mount | |
2802 | static void | |
2803 | print_mount(const struct syscallname *name, | |
2804 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2805 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2806 | { | |
2807 | print_syscall_prologue(name); | |
2808 | print_string(arg0, 0); | |
2809 | print_string(arg1, 0); | |
2810 | print_string(arg2, 0); | |
2811 | print_flags(mount_flags, arg3, 0); | |
2812 | print_pointer(arg4, 1); | |
2813 | print_syscall_epilogue(name); | |
2814 | } | |
2815 | #endif | |
2816 | ||
2817 | #ifdef TARGET_NR_umount | |
2818 | static void | |
2819 | print_umount(const struct syscallname *name, | |
2820 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2821 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2822 | { | |
2823 | print_syscall_prologue(name); | |
2824 | print_string(arg0, 1); | |
2825 | print_syscall_epilogue(name); | |
2826 | } | |
2827 | #endif | |
2828 | ||
2829 | #ifdef TARGET_NR_umount2 | |
2830 | static void | |
2831 | print_umount2(const struct syscallname *name, | |
2832 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2833 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2834 | { | |
2835 | print_syscall_prologue(name); | |
2836 | print_string(arg0, 0); | |
2837 | print_flags(umount2_flags, arg1, 1); | |
2838 | print_syscall_epilogue(name); | |
2839 | } | |
2840 | #endif | |
2841 | ||
2842 | #ifdef TARGET_NR_unlink | |
2843 | static void | |
2844 | print_unlink(const struct syscallname *name, | |
2845 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2846 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2847 | { | |
2848 | print_syscall_prologue(name); | |
2849 | print_string(arg0, 1); | |
2850 | print_syscall_epilogue(name); | |
2851 | } | |
2852 | #endif | |
2853 | ||
2854 | #ifdef TARGET_NR_unlinkat | |
2855 | static void | |
2856 | print_unlinkat(const struct syscallname *name, | |
2857 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2858 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2859 | { | |
2860 | print_syscall_prologue(name); | |
2861 | print_at_dirfd(arg0, 0); | |
2862 | print_string(arg1, 0); | |
2863 | print_flags(unlinkat_flags, arg2, 1); | |
2864 | print_syscall_epilogue(name); | |
2865 | } | |
2866 | #endif | |
2867 | ||
2868 | #ifdef TARGET_NR_utime | |
2869 | static void | |
2870 | print_utime(const struct syscallname *name, | |
2871 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2872 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2873 | { | |
2874 | print_syscall_prologue(name); | |
2875 | print_string(arg0, 0); | |
2876 | print_pointer(arg1, 1); | |
2877 | print_syscall_epilogue(name); | |
2878 | } | |
2879 | #endif | |
2880 | ||
2881 | #ifdef TARGET_NR_utimes | |
2882 | static void | |
2883 | print_utimes(const struct syscallname *name, | |
2884 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2885 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2886 | { | |
2887 | print_syscall_prologue(name); | |
2888 | print_string(arg0, 0); | |
2889 | print_pointer(arg1, 1); | |
2890 | print_syscall_epilogue(name); | |
2891 | } | |
2892 | #endif | |
2893 | ||
2894 | #ifdef TARGET_NR_utimensat | |
2895 | static void | |
2896 | print_utimensat(const struct syscallname *name, | |
2897 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2898 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2899 | { | |
2900 | print_syscall_prologue(name); | |
2901 | print_at_dirfd(arg0, 0); | |
2902 | print_string(arg1, 0); | |
2903 | print_pointer(arg2, 0); | |
2904 | print_flags(at_file_flags, arg3, 1); | |
2905 | print_syscall_epilogue(name); | |
2906 | } | |
2907 | #endif | |
2908 | ||
8d9016c0 | 2909 | #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) |
74d753ac MW |
2910 | static void |
2911 | print_mmap(const struct syscallname *name, | |
2912 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2913 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2914 | { | |
2915 | print_syscall_prologue(name); | |
2916 | print_pointer(arg0, 0); | |
d2ee72a5 | 2917 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
2918 | print_flags(mmap_prot_flags, arg2, 0); |
2919 | print_flags(mmap_flags, arg3, 0); | |
d2ee72a5 LV |
2920 | print_raw_param("%d", arg4, 0); |
2921 | print_raw_param("%#x", arg5, 1); | |
74d753ac MW |
2922 | print_syscall_epilogue(name); |
2923 | } | |
2924 | #define print_mmap2 print_mmap | |
2925 | #endif | |
2926 | ||
2927 | #ifdef TARGET_NR_mprotect | |
2928 | static void | |
2929 | print_mprotect(const struct syscallname *name, | |
2930 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2931 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2932 | { | |
2933 | print_syscall_prologue(name); | |
2934 | print_pointer(arg0, 0); | |
d2ee72a5 | 2935 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
2936 | print_flags(mmap_prot_flags, arg2, 1); |
2937 | print_syscall_epilogue(name); | |
2938 | } | |
2939 | #endif | |
2940 | ||
2941 | #ifdef TARGET_NR_munmap | |
2942 | static void | |
2943 | print_munmap(const struct syscallname *name, | |
2944 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2945 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2946 | { | |
2947 | print_syscall_prologue(name); | |
2948 | print_pointer(arg0, 0); | |
d2ee72a5 | 2949 | print_raw_param("%d", arg1, 1); |
74d753ac MW |
2950 | print_syscall_epilogue(name); |
2951 | } | |
2952 | #endif | |
2953 | ||
2954 | #ifdef TARGET_NR_futex | |
2955 | static void print_futex_op(abi_long tflag, int last) | |
2956 | { | |
2957 | #define print_op(val) \ | |
2958 | if( cmd == val ) { \ | |
4b25a506 | 2959 | qemu_log(#val); \ |
74d753ac MW |
2960 | return; \ |
2961 | } | |
2962 | ||
d2ee72a5 | 2963 | int cmd = (int)tflag; |
74d753ac | 2964 | #ifdef FUTEX_PRIVATE_FLAG |
5f2243f3 | 2965 | if (cmd & FUTEX_PRIVATE_FLAG) { |
4b25a506 | 2966 | qemu_log("FUTEX_PRIVATE_FLAG|"); |
5f2243f3 PB |
2967 | cmd &= ~FUTEX_PRIVATE_FLAG; |
2968 | } | |
bfb669f3 JR |
2969 | #endif |
2970 | #ifdef FUTEX_CLOCK_REALTIME | |
2971 | if (cmd & FUTEX_CLOCK_REALTIME) { | |
4b25a506 | 2972 | qemu_log("FUTEX_CLOCK_REALTIME|"); |
bfb669f3 JR |
2973 | cmd &= ~FUTEX_CLOCK_REALTIME; |
2974 | } | |
74d753ac MW |
2975 | #endif |
2976 | print_op(FUTEX_WAIT) | |
2977 | print_op(FUTEX_WAKE) | |
2978 | print_op(FUTEX_FD) | |
2979 | print_op(FUTEX_REQUEUE) | |
2980 | print_op(FUTEX_CMP_REQUEUE) | |
2981 | print_op(FUTEX_WAKE_OP) | |
2982 | print_op(FUTEX_LOCK_PI) | |
2983 | print_op(FUTEX_UNLOCK_PI) | |
2984 | print_op(FUTEX_TRYLOCK_PI) | |
2985 | #ifdef FUTEX_WAIT_BITSET | |
2986 | print_op(FUTEX_WAIT_BITSET) | |
2987 | #endif | |
2988 | #ifdef FUTEX_WAKE_BITSET | |
2989 | print_op(FUTEX_WAKE_BITSET) | |
2990 | #endif | |
2991 | /* unknown values */ | |
4b25a506 | 2992 | qemu_log("%d", cmd); |
74d753ac MW |
2993 | } |
2994 | ||
2995 | static void | |
2996 | print_futex(const struct syscallname *name, | |
2997 | abi_long arg0, abi_long arg1, abi_long arg2, | |
2998 | abi_long arg3, abi_long arg4, abi_long arg5) | |
2999 | { | |
3000 | print_syscall_prologue(name); | |
3001 | print_pointer(arg0, 0); | |
3002 | print_futex_op(arg1, 0); | |
d2ee72a5 | 3003 | print_raw_param(",%d", arg2, 0); |
74d753ac MW |
3004 | print_pointer(arg3, 0); /* struct timespec */ |
3005 | print_pointer(arg4, 0); | |
d2ee72a5 | 3006 | print_raw_param("%d", arg4, 1); |
74d753ac MW |
3007 | print_syscall_epilogue(name); |
3008 | } | |
3009 | #endif | |
3010 | ||
608e5592 LV |
3011 | #ifdef TARGET_NR_kill |
3012 | static void | |
3013 | print_kill(const struct syscallname *name, | |
3014 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3015 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3016 | { | |
3017 | print_syscall_prologue(name); | |
3018 | print_raw_param("%d", arg0, 0); | |
3019 | print_signal(arg1, 1); | |
3020 | print_syscall_epilogue(name); | |
3021 | } | |
3022 | #endif | |
3023 | ||
5162264e MS |
3024 | #ifdef TARGET_NR_tkill |
3025 | static void | |
3026 | print_tkill(const struct syscallname *name, | |
3027 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3028 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3029 | { | |
3030 | print_syscall_prologue(name); | |
3031 | print_raw_param("%d", arg0, 0); | |
3032 | print_signal(arg1, 1); | |
3033 | print_syscall_epilogue(name); | |
3034 | } | |
3035 | #endif | |
3036 | ||
3037 | #ifdef TARGET_NR_tgkill | |
3038 | static void | |
3039 | print_tgkill(const struct syscallname *name, | |
3040 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3041 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3042 | { | |
3043 | print_syscall_prologue(name); | |
3044 | print_raw_param("%d", arg0, 0); | |
3045 | print_raw_param("%d", arg1, 0); | |
3046 | print_signal(arg2, 1); | |
3047 | print_syscall_epilogue(name); | |
3048 | } | |
3049 | #endif | |
3050 | ||
d42744fe JW |
3051 | #ifdef TARGET_NR_statx |
3052 | static void | |
3053 | print_statx(const struct syscallname *name, | |
3054 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3055 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3056 | { | |
3057 | print_syscall_prologue(name); | |
3058 | print_at_dirfd(arg0, 0); | |
3059 | print_string(arg1, 0); | |
3060 | print_flags(statx_flags, arg2, 0); | |
3061 | print_flags(statx_mask, arg3, 0); | |
3062 | print_pointer(arg4, 1); | |
3063 | print_syscall_epilogue(name); | |
3064 | } | |
3065 | #endif | |
3066 | ||
79482e59 FB |
3067 | #ifdef TARGET_NR_ioctl |
3068 | static void | |
3069 | print_ioctl(const struct syscallname *name, | |
3070 | abi_long arg0, abi_long arg1, abi_long arg2, | |
3071 | abi_long arg3, abi_long arg4, abi_long arg5) | |
3072 | { | |
3073 | print_syscall_prologue(name); | |
3074 | print_raw_param("%d", arg0, 0); | |
3075 | ||
3076 | const IOCTLEntry *ie; | |
3077 | const argtype *arg_type; | |
3078 | void *argptr; | |
3079 | int target_size; | |
3080 | ||
3081 | for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { | |
3082 | if (ie->target_cmd == arg1) { | |
3083 | break; | |
3084 | } | |
3085 | } | |
3086 | ||
3087 | if (ie->target_cmd == 0) { | |
3088 | print_raw_param("%#x", arg1, 0); | |
3089 | print_raw_param("%#x", arg2, 1); | |
3090 | } else { | |
3091 | qemu_log("%s", ie->name); | |
3092 | arg_type = ie->arg_type; | |
3093 | ||
3094 | if (arg_type[0] != TYPE_NULL) { | |
3095 | qemu_log(","); | |
3096 | ||
3097 | switch (arg_type[0]) { | |
3098 | case TYPE_PTRVOID: | |
3099 | print_pointer(arg2, 1); | |
3100 | break; | |
3101 | case TYPE_CHAR: | |
3102 | case TYPE_SHORT: | |
3103 | case TYPE_INT: | |
3104 | print_raw_param("%d", arg2, 1); | |
3105 | break; | |
3106 | case TYPE_LONG: | |
3107 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
3108 | break; | |
3109 | case TYPE_ULONG: | |
3110 | print_raw_param(TARGET_ABI_FMT_lu, arg2, 1); | |
3111 | break; | |
3112 | case TYPE_PTR: | |
3113 | switch (ie->access) { | |
3114 | case IOC_R: | |
3115 | print_pointer(arg2, 1); | |
3116 | break; | |
3117 | case IOC_W: | |
3118 | case IOC_RW: | |
3119 | arg_type++; | |
3120 | target_size = thunk_type_size(arg_type, 0); | |
3121 | argptr = lock_user(VERIFY_READ, arg2, target_size, 1); | |
3122 | thunk_print(argptr, arg_type); | |
3123 | unlock_user(argptr, arg2, target_size); | |
3124 | break; | |
3125 | } | |
3126 | break; | |
3127 | default: | |
3128 | g_assert_not_reached(); | |
3129 | } | |
3130 | } | |
3131 | } | |
3132 | print_syscall_epilogue(name); | |
3133 | } | |
3134 | #endif | |
3135 | ||
33189d31 TS |
3136 | /* |
3137 | * An array of all of the syscalls we know about | |
3138 | */ | |
3139 | ||
7ccfb2eb | 3140 | static const struct syscallname scnames[] = { |
33189d31 TS |
3141 | #include "strace.list" |
3142 | }; | |
3143 | ||
b1503cda | 3144 | static int nsyscalls = ARRAY_SIZE(scnames); |
33189d31 TS |
3145 | |
3146 | /* | |
3147 | * The public interface to this module. | |
3148 | */ | |
3149 | void | |
3150 | print_syscall(int num, | |
c16f9ed3 FB |
3151 | abi_long arg1, abi_long arg2, abi_long arg3, |
3152 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
3153 | { |
3154 | int i; | |
7ccfb2eb | 3155 | 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 ")"; |
33189d31 | 3156 | |
4b25a506 | 3157 | qemu_log("%d ", getpid()); |
33189d31 TS |
3158 | |
3159 | for(i=0;i<nsyscalls;i++) | |
3160 | if( scnames[i].nr == num ) { | |
3161 | if( scnames[i].call != NULL ) { | |
4b25a506 JK |
3162 | scnames[i].call( |
3163 | &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6); | |
33189d31 | 3164 | } else { |
6b23f777 FB |
3165 | /* XXX: this format system is broken because it uses |
3166 | host types and host pointers for strings */ | |
33189d31 TS |
3167 | if( scnames[i].format != NULL ) |
3168 | format = scnames[i].format; | |
4b25a506 JK |
3169 | qemu_log(format, |
3170 | scnames[i].name, arg1, arg2, arg3, arg4, arg5, arg6); | |
33189d31 | 3171 | } |
74c11e55 | 3172 | return; |
33189d31 | 3173 | } |
4b25a506 | 3174 | qemu_log("Unknown syscall %d\n", num); |
33189d31 TS |
3175 | } |
3176 | ||
3177 | ||
3178 | void | |
c84be71f FB |
3179 | print_syscall_ret(int num, abi_long ret, |
3180 | abi_long arg1, abi_long arg2, abi_long arg3, | |
3181 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
3182 | { |
3183 | int i; | |
3184 | ||
3185 | for(i=0;i<nsyscalls;i++) | |
3186 | if( scnames[i].nr == num ) { | |
3187 | if( scnames[i].result != NULL ) { | |
c84be71f FB |
3188 | scnames[i].result(&scnames[i], ret, |
3189 | arg1, arg2, arg3, | |
3190 | arg4, arg5, arg6); | |
33189d31 | 3191 | } else { |
c84be71f FB |
3192 | print_syscall_err(ret); |
3193 | ||
3194 | if (ret >= 0) { | |
3195 | qemu_log(TARGET_ABI_FMT_ld, ret); | |
33189d31 | 3196 | } |
c84be71f | 3197 | qemu_log("\n"); |
33189d31 TS |
3198 | } |
3199 | break; | |
3200 | } | |
3201 | } | |
0cb581d6 PM |
3202 | |
3203 | void print_taken_signal(int target_signum, const target_siginfo_t *tinfo) | |
3204 | { | |
3205 | /* Print the strace output for a signal being taken: | |
3206 | * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} --- | |
3207 | */ | |
4b25a506 | 3208 | qemu_log("--- "); |
0cb581d6 | 3209 | print_signal(target_signum, 1); |
4b25a506 | 3210 | qemu_log(" "); |
0cb581d6 | 3211 | print_siginfo(tinfo); |
4b25a506 | 3212 | qemu_log(" ---\n"); |
0cb581d6 | 3213 | } |