blob: e00275fcb51bd7378b5c02de46f72bd79319df99 [file] [log] [blame]
Peter Maydelld39594e2016-01-26 18:17:02 +00001#include "qemu/osdep.h"
ths33189d32007-11-01 00:13:36 +00002#include <sys/ipc.h>
3#include <sys/msg.h>
4#include <sys/sem.h>
5#include <sys/shm.h>
6#include <sys/select.h>
Mika Westerberg74d753a2009-04-07 16:57:29 +03007#include <sys/mount.h>
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02008#include <arpa/inet.h>
9#include <netinet/tcp.h>
10#include <linux/if_packet.h>
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +020011#include <linux/netlink.h>
Laurent Vivier608e5592011-04-07 00:25:32 +020012#include <sched.h>
ths33189d32007-11-01 00:13:36 +000013#include "qemu.h"
14
ths33189d32007-11-01 00:13:36 +000015struct syscallname {
16 int nr;
blueswir17ccfb2e2008-09-14 06:45:34 +000017 const char *name;
18 const char *format;
Filip Bozutae400e112020-08-11 18:45:49 +020019 void (*call)(void *, const struct syscallname *,
bellardc16f9ed2007-11-11 17:23:29 +000020 abi_long, abi_long, abi_long,
21 abi_long, abi_long, abi_long);
Filip Bozutae400e112020-08-11 18:45:49 +020022 void (*result)(void *, const struct syscallname *, abi_long,
Filip Bozutac84be712020-06-19 14:33:26 +020023 abi_long, abi_long, abi_long,
24 abi_long, abi_long, abi_long);
ths33189d32007-11-01 00:13:36 +000025};
26
Mika Westerberg74d753a2009-04-07 16:57:29 +030027/*
28 * It is possible that target doesn't have syscall that uses
29 * following flags but we don't want the compiler to warn
30 * us about them being unused. Same applies to utility print
31 * functions. It is ok to keep them while not used.
32 */
33#define UNUSED __attribute__ ((unused))
Mika Westerberg74d753a2009-04-07 16:57:29 +030034
35/*
36 * Structure used to translate flag values into strings. This is
37 * similar that is in the actual strace tool.
38 */
39struct flags {
40 abi_long f_value; /* flag */
41 const char *f_string; /* stringified flag */
42};
43
44/* common flags for all architectures */
45#define FLAG_GENERIC(name) { name, #name }
46/* target specific flags (syscall_defs.h has TARGET_<flag>) */
47#define FLAG_TARGET(name) { TARGET_ ## name, #name }
48/* end of flags array */
49#define FLAG_END { 0, NULL }
50
Filip Bozuta45f56792020-08-11 18:45:52 +020051/* Structure used to translate enumerated values into strings */
52struct enums {
53 abi_long e_value; /* enum value */
54 const char *e_string; /* stringified enum */
55};
56
57/* common enums for all architectures */
58#define ENUM_GENERIC(name) { name, #name }
59/* target specific enums */
60#define ENUM_TARGET(name) { TARGET_ ## name, #name }
61/* end of enums array */
62#define ENUM_END { 0, NULL }
63
Mika Westerberg74d753a2009-04-07 16:57:29 +030064UNUSED static const char *get_comma(int);
65UNUSED static void print_pointer(abi_long, int);
66UNUSED static void print_flags(const struct flags *, abi_long, int);
Filip Bozuta45f56792020-08-11 18:45:52 +020067UNUSED static void print_enums(const struct enums *, abi_long, int);
Mika Westerberg74d753a2009-04-07 16:57:29 +030068UNUSED static void print_at_dirfd(abi_long, int);
69UNUSED static void print_file_mode(abi_long, int);
70UNUSED static void print_open_flags(abi_long, int);
71UNUSED static void print_syscall_prologue(const struct syscallname *);
72UNUSED static void print_syscall_epilogue(const struct syscallname *);
73UNUSED static void print_string(abi_long, int);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +020074UNUSED static void print_buf(abi_long addr, abi_long len, int last);
Mika Westerberg74d753a2009-04-07 16:57:29 +030075UNUSED static void print_raw_param(const char *, abi_long, int);
76UNUSED static void print_timeval(abi_ulong, int);
Filip Bozuta1a674ad2020-08-11 18:45:53 +020077UNUSED static void print_timespec(abi_ulong, int);
Philippe Mathieu-Daudé6d33e032019-10-21 13:48:50 +020078UNUSED static void print_timezone(abi_ulong, int);
Filip Bozuta1a674ad2020-08-11 18:45:53 +020079UNUSED static void print_itimerval(abi_ulong, int);
Mika Westerberg74d753a2009-04-07 16:57:29 +030080UNUSED static void print_number(abi_long, int);
Laurent Vivier608e5592011-04-07 00:25:32 +020081UNUSED static void print_signal(abi_ulong, int);
Philippe Mathieu-Daudé42b15d72019-10-21 13:48:56 +020082UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +020083UNUSED static void print_socket_domain(int domain);
84UNUSED static void print_socket_type(int type);
85UNUSED static void print_socket_protocol(int domain, int type, int protocol);
Mika Westerberg74d753a2009-04-07 16:57:29 +030086
ths33189d32007-11-01 00:13:36 +000087/*
88 * Utility functions
89 */
90static void
91print_ipc_cmd(int cmd)
92{
93#define output_cmd(val) \
94if( cmd == val ) { \
Josh Kunz4b25a502020-02-03 18:54:14 -080095 qemu_log(#val); \
ths33189d32007-11-01 00:13:36 +000096 return; \
97}
98
99 cmd &= 0xff;
100
101 /* General IPC commands */
102 output_cmd( IPC_RMID );
103 output_cmd( IPC_SET );
104 output_cmd( IPC_STAT );
105 output_cmd( IPC_INFO );
106 /* msgctl() commands */
ths33189d32007-11-01 00:13:36 +0000107 output_cmd( MSG_STAT );
108 output_cmd( MSG_INFO );
ths33189d32007-11-01 00:13:36 +0000109 /* shmctl() commands */
110 output_cmd( SHM_LOCK );
111 output_cmd( SHM_UNLOCK );
112 output_cmd( SHM_STAT );
113 output_cmd( SHM_INFO );
114 /* semctl() commands */
115 output_cmd( GETPID );
116 output_cmd( GETVAL );
117 output_cmd( GETALL );
118 output_cmd( GETNCNT );
119 output_cmd( GETZCNT );
120 output_cmd( SETVAL );
121 output_cmd( SETALL );
122 output_cmd( SEM_STAT );
123 output_cmd( SEM_INFO );
124 output_cmd( IPC_RMID );
125 output_cmd( IPC_RMID );
126 output_cmd( IPC_RMID );
127 output_cmd( IPC_RMID );
128 output_cmd( IPC_RMID );
129 output_cmd( IPC_RMID );
130 output_cmd( IPC_RMID );
131 output_cmd( IPC_RMID );
132 output_cmd( IPC_RMID );
133
134 /* Some value we don't recognize */
Josh Kunz4b25a502020-02-03 18:54:14 -0800135 qemu_log("%d", cmd);
ths33189d32007-11-01 00:13:36 +0000136}
137
Laurent Vivier608e5592011-04-07 00:25:32 +0200138static void
139print_signal(abi_ulong arg, int last)
140{
141 const char *signal_name = NULL;
142 switch(arg) {
143 case TARGET_SIGHUP: signal_name = "SIGHUP"; break;
144 case TARGET_SIGINT: signal_name = "SIGINT"; break;
145 case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break;
146 case TARGET_SIGILL: signal_name = "SIGILL"; break;
147 case TARGET_SIGABRT: signal_name = "SIGABRT"; break;
148 case TARGET_SIGFPE: signal_name = "SIGFPE"; break;
149 case TARGET_SIGKILL: signal_name = "SIGKILL"; break;
150 case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break;
151 case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break;
152 case TARGET_SIGALRM: signal_name = "SIGALRM"; break;
153 case TARGET_SIGTERM: signal_name = "SIGTERM"; break;
154 case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break;
155 case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break;
156 case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break;
157 case TARGET_SIGCONT: signal_name = "SIGCONT"; break;
158 case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break;
159 case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break;
160 case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break;
161 }
162 if (signal_name == NULL) {
Peter Maydellabe20842013-03-28 14:33:24 +0000163 print_raw_param("%ld", arg, last);
Laurent Vivier608e5592011-04-07 00:25:32 +0200164 return;
165 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800166 qemu_log("%s%s", signal_name, get_comma(last));
Laurent Vivier608e5592011-04-07 00:25:32 +0200167}
168
Peter Maydell0cb581d2016-07-18 18:12:24 +0100169static void print_si_code(int arg)
170{
171 const char *codename = NULL;
172
173 switch (arg) {
174 case SI_USER:
175 codename = "SI_USER";
176 break;
177 case SI_KERNEL:
178 codename = "SI_KERNEL";
179 break;
180 case SI_QUEUE:
181 codename = "SI_QUEUE";
182 break;
183 case SI_TIMER:
184 codename = "SI_TIMER";
185 break;
186 case SI_MESGQ:
187 codename = "SI_MESGQ";
188 break;
189 case SI_ASYNCIO:
190 codename = "SI_ASYNCIO";
191 break;
192 case SI_SIGIO:
193 codename = "SI_SIGIO";
194 break;
195 case SI_TKILL:
196 codename = "SI_TKILL";
197 break;
198 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800199 qemu_log("%d", arg);
Peter Maydell0cb581d2016-07-18 18:12:24 +0100200 return;
201 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800202 qemu_log("%s", codename);
Peter Maydell0cb581d2016-07-18 18:12:24 +0100203}
204
Miloš Stojanovićba9fcea2017-05-15 16:59:49 +0200205static void get_target_siginfo(target_siginfo_t *tinfo,
206 const target_siginfo_t *info)
207{
208 abi_ulong sival_ptr;
209
210 int sig;
211 int si_errno;
212 int si_code;
213 int si_type;
214
215 __get_user(sig, &info->si_signo);
216 __get_user(si_errno, &tinfo->si_errno);
217 __get_user(si_code, &info->si_code);
218
219 tinfo->si_signo = sig;
220 tinfo->si_errno = si_errno;
221 tinfo->si_code = si_code;
222
223 /* Ensure we don't leak random junk to the guest later */
224 memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
225
226 /* This is awkward, because we have to use a combination of
227 * the si_code and si_signo to figure out which of the union's
228 * members are valid. (Within the host kernel it is always possible
229 * to tell, but the kernel carefully avoids giving userspace the
230 * high 16 bits of si_code, so we don't have the information to
231 * do this the easy way...) We therefore make our best guess,
232 * bearing in mind that a guest can spoof most of the si_codes
233 * via rt_sigqueueinfo() if it likes.
234 *
235 * Once we have made our guess, we record it in the top 16 bits of
236 * the si_code, so that print_siginfo() later can use it.
237 * print_siginfo() will strip these top bits out before printing
238 * the si_code.
239 */
240
241 switch (si_code) {
242 case SI_USER:
243 case SI_TKILL:
244 case SI_KERNEL:
245 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
246 * These are the only unspoofable si_code values.
247 */
248 __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
249 __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
250 si_type = QEMU_SI_KILL;
251 break;
252 default:
253 /* Everything else is spoofable. Make best guess based on signal */
254 switch (sig) {
255 case TARGET_SIGCHLD:
256 __get_user(tinfo->_sifields._sigchld._pid,
257 &info->_sifields._sigchld._pid);
258 __get_user(tinfo->_sifields._sigchld._uid,
259 &info->_sifields._sigchld._uid);
260 __get_user(tinfo->_sifields._sigchld._status,
261 &info->_sifields._sigchld._status);
262 __get_user(tinfo->_sifields._sigchld._utime,
263 &info->_sifields._sigchld._utime);
264 __get_user(tinfo->_sifields._sigchld._stime,
265 &info->_sifields._sigchld._stime);
266 si_type = QEMU_SI_CHLD;
267 break;
268 case TARGET_SIGIO:
269 __get_user(tinfo->_sifields._sigpoll._band,
270 &info->_sifields._sigpoll._band);
271 __get_user(tinfo->_sifields._sigpoll._fd,
272 &info->_sifields._sigpoll._fd);
273 si_type = QEMU_SI_POLL;
274 break;
275 default:
276 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
277 __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
278 __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
279 /* XXX: potential problem if 64 bit */
280 __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
281 tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
282
283 si_type = QEMU_SI_RT;
284 break;
285 }
286 break;
287 }
288
289 tinfo->si_code = deposit32(si_code, 16, 16, si_type);
290}
291
Peter Maydell0cb581d2016-07-18 18:12:24 +0100292static void print_siginfo(const target_siginfo_t *tinfo)
293{
294 /* Print a target_siginfo_t in the format desired for printing
295 * signals being taken. We assume the target_siginfo_t is in the
296 * internal form where the top 16 bits of si_code indicate which
297 * part of the union is valid, rather than in the guest-visible
298 * form where the bottom 16 bits are sign-extended into the top 16.
299 */
300 int si_type = extract32(tinfo->si_code, 16, 16);
301 int si_code = sextract32(tinfo->si_code, 0, 16);
302
Josh Kunz4b25a502020-02-03 18:54:14 -0800303 qemu_log("{si_signo=");
Peter Maydell0cb581d2016-07-18 18:12:24 +0100304 print_signal(tinfo->si_signo, 1);
Josh Kunz4b25a502020-02-03 18:54:14 -0800305 qemu_log(", si_code=");
Peter Maydell0cb581d2016-07-18 18:12:24 +0100306 print_si_code(si_code);
307
308 switch (si_type) {
309 case QEMU_SI_KILL:
Josh Kunz4b25a502020-02-03 18:54:14 -0800310 qemu_log(", si_pid=%u, si_uid=%u",
Peter Maydell0cb581d2016-07-18 18:12:24 +0100311 (unsigned int)tinfo->_sifields._kill._pid,
312 (unsigned int)tinfo->_sifields._kill._uid);
313 break;
314 case QEMU_SI_TIMER:
Josh Kunz4b25a502020-02-03 18:54:14 -0800315 qemu_log(", si_timer1=%u, si_timer2=%u",
Peter Maydell0cb581d2016-07-18 18:12:24 +0100316 tinfo->_sifields._timer._timer1,
317 tinfo->_sifields._timer._timer2);
318 break;
319 case QEMU_SI_POLL:
Josh Kunz4b25a502020-02-03 18:54:14 -0800320 qemu_log(", si_band=%d, si_fd=%d",
Peter Maydell0cb581d2016-07-18 18:12:24 +0100321 tinfo->_sifields._sigpoll._band,
322 tinfo->_sifields._sigpoll._fd);
323 break;
324 case QEMU_SI_FAULT:
Josh Kunz4b25a502020-02-03 18:54:14 -0800325 qemu_log(", si_addr=");
Peter Maydell0cb581d2016-07-18 18:12:24 +0100326 print_pointer(tinfo->_sifields._sigfault._addr, 1);
327 break;
328 case QEMU_SI_CHLD:
Josh Kunz4b25a502020-02-03 18:54:14 -0800329 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
Peter Maydell0cb581d2016-07-18 18:12:24 +0100330 ", si_utime=" TARGET_ABI_FMT_ld
331 ", si_stime=" TARGET_ABI_FMT_ld,
332 (unsigned int)(tinfo->_sifields._sigchld._pid),
333 (unsigned int)(tinfo->_sifields._sigchld._uid),
334 tinfo->_sifields._sigchld._status,
335 tinfo->_sifields._sigchld._utime,
336 tinfo->_sifields._sigchld._stime);
337 break;
338 case QEMU_SI_RT:
Josh Kunz4b25a502020-02-03 18:54:14 -0800339 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
Peter Maydell0cb581d2016-07-18 18:12:24 +0100340 (unsigned int)tinfo->_sifields._rt._pid,
341 (unsigned int)tinfo->_sifields._rt._uid,
342 tinfo->_sifields._rt._sigval.sival_ptr);
343 break;
344 default:
345 g_assert_not_reached();
346 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800347 qemu_log("}");
Peter Maydell0cb581d2016-07-18 18:12:24 +0100348}
349
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200350static void
Philippe Mathieu-Daudé42b15d72019-10-21 13:48:56 +0200351print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200352{
353 struct target_sockaddr *sa;
354 int i;
355 int sa_family;
356
357 sa = lock_user(VERIFY_READ, addr, addrlen, 1);
358 if (sa) {
359 sa_family = tswap16(sa->sa_family);
360 switch (sa_family) {
361 case AF_UNIX: {
362 struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
363 int i;
Josh Kunz4b25a502020-02-03 18:54:14 -0800364 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200365 for (i = 0; i < addrlen -
366 offsetof(struct target_sockaddr_un, sun_path) &&
367 un->sun_path[i]; i++) {
Josh Kunz4b25a502020-02-03 18:54:14 -0800368 qemu_log("%c", un->sun_path[i]);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200369 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800370 qemu_log("\"}");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200371 break;
372 }
373 case AF_INET: {
374 struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
375 uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
Josh Kunz4b25a502020-02-03 18:54:14 -0800376 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200377 ntohs(in->sin_port));
Josh Kunz4b25a502020-02-03 18:54:14 -0800378 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200379 c[0], c[1], c[2], c[3]);
Josh Kunz4b25a502020-02-03 18:54:14 -0800380 qemu_log("}");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200381 break;
382 }
383 case AF_PACKET: {
384 struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
385 uint8_t *c = (uint8_t *)&ll->sll_addr;
Josh Kunz4b25a502020-02-03 18:54:14 -0800386 qemu_log("{sll_family=AF_PACKET,"
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200387 "sll_protocol=htons(0x%04x),if%d,pkttype=",
388 ntohs(ll->sll_protocol), ll->sll_ifindex);
389 switch (ll->sll_pkttype) {
390 case PACKET_HOST:
Josh Kunz4b25a502020-02-03 18:54:14 -0800391 qemu_log("PACKET_HOST");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200392 break;
393 case PACKET_BROADCAST:
Josh Kunz4b25a502020-02-03 18:54:14 -0800394 qemu_log("PACKET_BROADCAST");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200395 break;
396 case PACKET_MULTICAST:
Josh Kunz4b25a502020-02-03 18:54:14 -0800397 qemu_log("PACKET_MULTICAST");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200398 break;
399 case PACKET_OTHERHOST:
Josh Kunz4b25a502020-02-03 18:54:14 -0800400 qemu_log("PACKET_OTHERHOST");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200401 break;
402 case PACKET_OUTGOING:
Josh Kunz4b25a502020-02-03 18:54:14 -0800403 qemu_log("PACKET_OUTGOING");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200404 break;
405 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800406 qemu_log("%d", ll->sll_pkttype);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200407 break;
408 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800409 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200410 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
Josh Kunz4b25a502020-02-03 18:54:14 -0800411 qemu_log("}");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200412 break;
413 }
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200414 case AF_NETLINK: {
415 struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
Josh Kunz4b25a502020-02-03 18:54:14 -0800416 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200417 tswap32(nl->nl_pid), tswap32(nl->nl_groups));
418 break;
419 }
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200420 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800421 qemu_log("{sa_family=%d, sa_data={", sa->sa_family);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200422 for (i = 0; i < 13; i++) {
Josh Kunz4b25a502020-02-03 18:54:14 -0800423 qemu_log("%02x, ", sa->sa_data[i]);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200424 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800425 qemu_log("%02x}", sa->sa_data[i]);
426 qemu_log("}");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200427 break;
428 }
429 unlock_user(sa, addr, 0);
430 } else {
431 print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
432 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800433 qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200434}
435
436static void
437print_socket_domain(int domain)
438{
439 switch (domain) {
440 case PF_UNIX:
Josh Kunz4b25a502020-02-03 18:54:14 -0800441 qemu_log("PF_UNIX");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200442 break;
443 case PF_INET:
Josh Kunz4b25a502020-02-03 18:54:14 -0800444 qemu_log("PF_INET");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200445 break;
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200446 case PF_NETLINK:
Josh Kunz4b25a502020-02-03 18:54:14 -0800447 qemu_log("PF_NETLINK");
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200448 break;
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200449 case PF_PACKET:
Josh Kunz4b25a502020-02-03 18:54:14 -0800450 qemu_log("PF_PACKET");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200451 break;
452 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800453 qemu_log("%d", domain);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200454 break;
455 }
456}
457
458static void
459print_socket_type(int type)
460{
Laurent Vivier2039b1b2020-03-12 17:55:30 +0100461 switch (type & TARGET_SOCK_TYPE_MASK) {
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200462 case TARGET_SOCK_DGRAM:
Josh Kunz4b25a502020-02-03 18:54:14 -0800463 qemu_log("SOCK_DGRAM");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200464 break;
465 case TARGET_SOCK_STREAM:
Josh Kunz4b25a502020-02-03 18:54:14 -0800466 qemu_log("SOCK_STREAM");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200467 break;
468 case TARGET_SOCK_RAW:
Josh Kunz4b25a502020-02-03 18:54:14 -0800469 qemu_log("SOCK_RAW");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200470 break;
471 case TARGET_SOCK_RDM:
Josh Kunz4b25a502020-02-03 18:54:14 -0800472 qemu_log("SOCK_RDM");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200473 break;
474 case TARGET_SOCK_SEQPACKET:
Josh Kunz4b25a502020-02-03 18:54:14 -0800475 qemu_log("SOCK_SEQPACKET");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200476 break;
477 case TARGET_SOCK_PACKET:
Josh Kunz4b25a502020-02-03 18:54:14 -0800478 qemu_log("SOCK_PACKET");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200479 break;
480 }
Laurent Vivier2039b1b2020-03-12 17:55:30 +0100481 if (type & TARGET_SOCK_CLOEXEC) {
482 qemu_log("|SOCK_CLOEXEC");
483 }
484 if (type & TARGET_SOCK_NONBLOCK) {
485 qemu_log("|SOCK_NONBLOCK");
486 }
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200487}
488
489static void
490print_socket_protocol(int domain, int type, int protocol)
491{
492 if (domain == AF_PACKET ||
493 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
494 switch (protocol) {
495 case 0x0003:
Josh Kunz4b25a502020-02-03 18:54:14 -0800496 qemu_log("ETH_P_ALL");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200497 break;
498 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800499 qemu_log("%d", protocol);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200500 }
501 return;
502 }
503
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200504 if (domain == PF_NETLINK) {
505 switch (protocol) {
506 case NETLINK_ROUTE:
Josh Kunz4b25a502020-02-03 18:54:14 -0800507 qemu_log("NETLINK_ROUTE");
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200508 break;
509 case NETLINK_AUDIT:
Josh Kunz4b25a502020-02-03 18:54:14 -0800510 qemu_log("NETLINK_AUDIT");
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200511 break;
512 case NETLINK_NETFILTER:
Josh Kunz4b25a502020-02-03 18:54:14 -0800513 qemu_log("NETLINK_NETFILTER");
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200514 break;
515 case NETLINK_KOBJECT_UEVENT:
Josh Kunz4b25a502020-02-03 18:54:14 -0800516 qemu_log("NETLINK_KOBJECT_UEVENT");
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200517 break;
518 case NETLINK_RDMA:
Josh Kunz4b25a502020-02-03 18:54:14 -0800519 qemu_log("NETLINK_RDMA");
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200520 break;
521 case NETLINK_CRYPTO:
Josh Kunz4b25a502020-02-03 18:54:14 -0800522 qemu_log("NETLINK_CRYPTO");
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200523 break;
524 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800525 qemu_log("%d", protocol);
Philippe Mathieu-Daudé814ae702019-10-21 13:48:53 +0200526 break;
527 }
528 return;
529 }
530
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200531 switch (protocol) {
532 case IPPROTO_IP:
Josh Kunz4b25a502020-02-03 18:54:14 -0800533 qemu_log("IPPROTO_IP");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200534 break;
535 case IPPROTO_TCP:
Josh Kunz4b25a502020-02-03 18:54:14 -0800536 qemu_log("IPPROTO_TCP");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200537 break;
538 case IPPROTO_UDP:
Josh Kunz4b25a502020-02-03 18:54:14 -0800539 qemu_log("IPPROTO_UDP");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200540 break;
541 case IPPROTO_RAW:
Josh Kunz4b25a502020-02-03 18:54:14 -0800542 qemu_log("IPPROTO_RAW");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200543 break;
544 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800545 qemu_log("%d", protocol);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +0200546 break;
547 }
548}
549
550
bellardc16f9ed2007-11-11 17:23:29 +0000551#ifdef TARGET_NR__newselect
ths33189d32007-11-01 00:13:36 +0000552static void
bellardc16f9ed2007-11-11 17:23:29 +0000553print_fdset(int n, abi_ulong target_fds_addr)
ths33189d32007-11-01 00:13:36 +0000554{
555 int i;
Filip Bozuta664441e2020-07-02 18:09:15 +0200556 int first = 1;
ths33189d32007-11-01 00:13:36 +0000557
Josh Kunz4b25a502020-02-03 18:54:14 -0800558 qemu_log("[");
ths33189d32007-11-01 00:13:36 +0000559 if( target_fds_addr ) {
bellard579a97f2007-11-11 14:26:47 +0000560 abi_long *target_fds;
ths33189d32007-11-01 00:13:36 +0000561
bellard579a97f2007-11-11 14:26:47 +0000562 target_fds = lock_user(VERIFY_READ,
563 target_fds_addr,
564 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
565 1);
566
567 if (!target_fds)
ths33189d32007-11-01 00:13:36 +0000568 return;
569
ths33189d32007-11-01 00:13:36 +0000570 for (i=n; i>=0; i--) {
Filip Bozuta664441e2020-07-02 18:09:15 +0200571 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
572 (i & (TARGET_ABI_BITS - 1))) & 1) {
573 qemu_log("%s%d", get_comma(first), i);
574 first = 0;
ths33189d32007-11-01 00:13:36 +0000575 }
Filip Bozuta664441e2020-07-02 18:09:15 +0200576 }
ths33189d32007-11-01 00:13:36 +0000577 unlock_user(target_fds, target_fds_addr, 0);
578 }
Josh Kunz4b25a502020-02-03 18:54:14 -0800579 qemu_log("]");
ths33189d32007-11-01 00:13:36 +0000580}
bellardc16f9ed2007-11-11 17:23:29 +0000581#endif
ths33189d32007-11-01 00:13:36 +0000582
583/*
584 * Sysycall specific output functions
585 */
586
587/* select */
bellardc16f9ed2007-11-11 17:23:29 +0000588#ifdef TARGET_NR__newselect
ths33189d32007-11-01 00:13:36 +0000589static void
Filip Bozutae400e112020-08-11 18:45:49 +0200590print_newselect(void *cpu_env, const struct syscallname *name,
bellardc16f9ed2007-11-11 17:23:29 +0000591 abi_long arg1, abi_long arg2, abi_long arg3,
592 abi_long arg4, abi_long arg5, abi_long arg6)
ths33189d32007-11-01 00:13:36 +0000593{
Filip Bozutac84be712020-06-19 14:33:26 +0200594 print_syscall_prologue(name);
ths33189d32007-11-01 00:13:36 +0000595 print_fdset(arg1, arg2);
Josh Kunz4b25a502020-02-03 18:54:14 -0800596 qemu_log(",");
ths33189d32007-11-01 00:13:36 +0000597 print_fdset(arg1, arg3);
Josh Kunz4b25a502020-02-03 18:54:14 -0800598 qemu_log(",");
ths33189d32007-11-01 00:13:36 +0000599 print_fdset(arg1, arg4);
Josh Kunz4b25a502020-02-03 18:54:14 -0800600 qemu_log(",");
Mika Westerberg74d753a2009-04-07 16:57:29 +0300601 print_timeval(arg5, 1);
Filip Bozutac84be712020-06-19 14:33:26 +0200602 print_syscall_epilogue(name);
ths33189d32007-11-01 00:13:36 +0000603}
bellardc16f9ed2007-11-11 17:23:29 +0000604#endif
ths33189d32007-11-01 00:13:36 +0000605
blueswir13e46b2e2008-10-03 19:01:41 +0000606#ifdef TARGET_NR_semctl
ths33189d32007-11-01 00:13:36 +0000607static void
Filip Bozutae400e112020-08-11 18:45:49 +0200608print_semctl(void *cpu_env, const struct syscallname *name,
bellardc16f9ed2007-11-11 17:23:29 +0000609 abi_long arg1, abi_long arg2, abi_long arg3,
610 abi_long arg4, abi_long arg5, abi_long arg6)
ths33189d32007-11-01 00:13:36 +0000611{
Josh Kunz4b25a502020-02-03 18:54:14 -0800612 qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
613 name->name, arg1, arg2);
ths33189d32007-11-01 00:13:36 +0000614 print_ipc_cmd(arg3);
Josh Kunz4b25a502020-02-03 18:54:14 -0800615 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
ths33189d32007-11-01 00:13:36 +0000616}
blueswir13e46b2e2008-10-03 19:01:41 +0000617#endif
ths33189d32007-11-01 00:13:36 +0000618
619static void
Filip Bozutae400e112020-08-11 18:45:49 +0200620print_execve(void *cpu_env, const struct syscallname *name,
bellardc16f9ed2007-11-11 17:23:29 +0000621 abi_long arg1, abi_long arg2, abi_long arg3,
622 abi_long arg4, abi_long arg5, abi_long arg6)
ths33189d32007-11-01 00:13:36 +0000623{
bellardc16f9ed2007-11-11 17:23:29 +0000624 abi_ulong arg_ptr_addr;
ths33189d32007-11-01 00:13:36 +0000625 char *s;
626
bellard579a97f2007-11-11 14:26:47 +0000627 if (!(s = lock_user_string(arg1)))
ths33189d32007-11-01 00:13:36 +0000628 return;
Josh Kunz4b25a502020-02-03 18:54:14 -0800629 qemu_log("%s(\"%s\",{", name->name, s);
ths33189d32007-11-01 00:13:36 +0000630 unlock_user(s, arg1, 0);
631
bellardc16f9ed2007-11-11 17:23:29 +0000632 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
blueswir198448f52008-09-30 18:16:09 +0000633 abi_ulong *arg_ptr, arg_addr;
ths33189d32007-11-01 00:13:36 +0000634
Paolo Bonzini7d374352018-12-13 23:37:37 +0100635 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
bellard579a97f2007-11-11 14:26:47 +0000636 if (!arg_ptr)
ths33189d32007-11-01 00:13:36 +0000637 return;
Matthias Brauncbb21ee2011-08-12 19:57:41 +0200638 arg_addr = tswapal(*arg_ptr);
Paolo Bonzini7d374352018-12-13 23:37:37 +0100639 unlock_user(arg_ptr, arg_ptr_addr, 0);
ths33189d32007-11-01 00:13:36 +0000640 if (!arg_addr)
641 break;
bellard579a97f2007-11-11 14:26:47 +0000642 if ((s = lock_user_string(arg_addr))) {
Josh Kunz4b25a502020-02-03 18:54:14 -0800643 qemu_log("\"%s\",", s);
blueswir198448f52008-09-30 18:16:09 +0000644 unlock_user(s, arg_addr, 0);
bellard579a97f2007-11-11 14:26:47 +0000645 }
ths33189d32007-11-01 00:13:36 +0000646 }
647
Josh Kunz4b25a502020-02-03 18:54:14 -0800648 qemu_log("NULL})");
ths33189d32007-11-01 00:13:36 +0000649}
650
bellardc16f9ed2007-11-11 17:23:29 +0000651#ifdef TARGET_NR_ipc
ths33189d32007-11-01 00:13:36 +0000652static void
Filip Bozutae400e112020-08-11 18:45:49 +0200653print_ipc(void *cpu_env, const struct syscallname *name,
bellardc16f9ed2007-11-11 17:23:29 +0000654 abi_long arg1, abi_long arg2, abi_long arg3,
655 abi_long arg4, abi_long arg5, abi_long arg6)
ths33189d32007-11-01 00:13:36 +0000656{
657 switch(arg1) {
658 case IPCOP_semctl:
Josh Kunz4b25a502020-02-03 18:54:14 -0800659 qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
660 arg1, arg2);
blueswir17ccfb2e2008-09-14 06:45:34 +0000661 print_ipc_cmd(arg3);
Josh Kunz4b25a502020-02-03 18:54:14 -0800662 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
ths33189d32007-11-01 00:13:36 +0000663 break;
664 default:
Josh Kunz4b25a502020-02-03 18:54:14 -0800665 qemu_log(("%s("
666 TARGET_ABI_FMT_ld ","
667 TARGET_ABI_FMT_ld ","
668 TARGET_ABI_FMT_ld ","
669 TARGET_ABI_FMT_ld
670 ")"),
ths33189d32007-11-01 00:13:36 +0000671 name->name, arg1, arg2, arg3, arg4);
672 }
673}
bellardc16f9ed2007-11-11 17:23:29 +0000674#endif
ths33189d32007-11-01 00:13:36 +0000675
676/*
677 * Variants for the return value output function
678 */
679
Laurent Vivier42b16182020-07-08 17:24:35 +0200680static bool
Filip Bozutac84be712020-06-19 14:33:26 +0200681print_syscall_err(abi_long ret)
ths33189d32007-11-01 00:13:36 +0000682{
Laurent Vivier42b16182020-07-08 17:24:35 +0200683 const char *errstr;
Alexander Graf962b2892011-11-21 12:04:07 +0100684
Filip Bozutac84be712020-06-19 14:33:26 +0200685 qemu_log(" = ");
Peter Maydell2a7e1242011-11-21 12:21:19 +0000686 if (ret < 0) {
687 errstr = target_strerror(-ret);
Filip Bozutac84be712020-06-19 14:33:26 +0200688 if (errstr) {
Laurent Vivier42b16182020-07-08 17:24:35 +0200689 qemu_log("-1 errno=%d (%s)", (int)-ret, errstr);
690 return true;
Filip Bozutac84be712020-06-19 14:33:26 +0200691 }
Alexander Graf962b2892011-11-21 12:04:07 +0100692 }
Laurent Vivier42b16182020-07-08 17:24:35 +0200693 return false;
Filip Bozutac84be712020-06-19 14:33:26 +0200694}
695
696static void
Filip Bozutae400e112020-08-11 18:45:49 +0200697print_syscall_ret_addr(void *cpu_env, const struct syscallname *name,
698 abi_long ret, abi_long arg0, abi_long arg1,
699 abi_long arg2, abi_long arg3, abi_long arg4,
700 abi_long arg5)
Filip Bozutac84be712020-06-19 14:33:26 +0200701{
Laurent Vivier42b16182020-07-08 17:24:35 +0200702 if (!print_syscall_err(ret)) {
703 qemu_log("0x" TARGET_ABI_FMT_lx, ret);
ths33189d32007-11-01 00:13:36 +0000704 }
Laurent Vivier42b16182020-07-08 17:24:35 +0200705 qemu_log("\n");
ths33189d32007-11-01 00:13:36 +0000706}
707
thsf3e32852007-11-03 15:12:16 +0000708#if 0 /* currently unused */
ths33189d32007-11-01 00:13:36 +0000709static void
bellardc16f9ed2007-11-11 17:23:29 +0000710print_syscall_ret_raw(struct syscallname *name, abi_long ret)
ths33189d32007-11-01 00:13:36 +0000711{
Josh Kunz4b25a502020-02-03 18:54:14 -0800712 qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
ths33189d32007-11-01 00:13:36 +0000713}
thsf3e32852007-11-03 15:12:16 +0000714#endif
ths33189d32007-11-01 00:13:36 +0000715
thsf3e32852007-11-03 15:12:16 +0000716#ifdef TARGET_NR__newselect
ths33189d32007-11-01 00:13:36 +0000717static void
Filip Bozutae400e112020-08-11 18:45:49 +0200718print_syscall_ret_newselect(void *cpu_env, const struct syscallname *name,
719 abi_long ret, abi_long arg0, abi_long arg1,
720 abi_long arg2, abi_long arg3, abi_long arg4,
721 abi_long arg5)
ths33189d32007-11-01 00:13:36 +0000722{
Laurent Vivier42b16182020-07-08 17:24:35 +0200723 if (!print_syscall_err(ret)) {
Filip Bozutac84be712020-06-19 14:33:26 +0200724 qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
725 print_fdset(arg0, arg1);
726 qemu_log(",");
727 print_fdset(arg0, arg2);
728 qemu_log(",");
729 print_fdset(arg0, arg3);
730 qemu_log(",");
731 print_timeval(arg4, 1);
732 qemu_log(")");
733 }
734
735 qemu_log("\n");
ths33189d32007-11-01 00:13:36 +0000736}
thsf3e32852007-11-03 15:12:16 +0000737#endif
ths33189d32007-11-01 00:13:36 +0000738
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200739/* special meanings of adjtimex()' non-negative return values */
740#define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
741#define TARGET_TIME_INS 1 /* insert leap second */
742#define TARGET_TIME_DEL 2 /* delete leap second */
743#define TARGET_TIME_OOP 3 /* leap second in progress */
744#define TARGET_TIME_WAIT 4 /* leap second has occurred */
745#define TARGET_TIME_ERROR 5 /* clock not synchronized */
Alistair Francis859e8a82020-03-12 15:13:49 -0700746#ifdef TARGET_NR_adjtimex
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200747static void
Filip Bozutae400e112020-08-11 18:45:49 +0200748print_syscall_ret_adjtimex(void *cpu_env, const struct syscallname *name,
749 abi_long ret, abi_long arg0, abi_long arg1,
750 abi_long arg2, abi_long arg3, abi_long arg4,
751 abi_long arg5)
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200752{
Laurent Vivier42b16182020-07-08 17:24:35 +0200753 if (!print_syscall_err(ret)) {
Josh Kunz4b25a502020-02-03 18:54:14 -0800754 qemu_log(TARGET_ABI_FMT_ld, ret);
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200755 switch (ret) {
756 case TARGET_TIME_OK:
Josh Kunz4b25a502020-02-03 18:54:14 -0800757 qemu_log(" TIME_OK (clock synchronized, no leap second)");
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200758 break;
759 case TARGET_TIME_INS:
Josh Kunz4b25a502020-02-03 18:54:14 -0800760 qemu_log(" TIME_INS (insert leap second)");
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200761 break;
762 case TARGET_TIME_DEL:
Josh Kunz4b25a502020-02-03 18:54:14 -0800763 qemu_log(" TIME_DEL (delete leap second)");
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200764 break;
765 case TARGET_TIME_OOP:
Josh Kunz4b25a502020-02-03 18:54:14 -0800766 qemu_log(" TIME_OOP (leap second in progress)");
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200767 break;
768 case TARGET_TIME_WAIT:
Josh Kunz4b25a502020-02-03 18:54:14 -0800769 qemu_log(" TIME_WAIT (leap second has occurred)");
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200770 break;
771 case TARGET_TIME_ERROR:
Josh Kunz4b25a502020-02-03 18:54:14 -0800772 qemu_log(" TIME_ERROR (clock not synchronized)");
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200773 break;
774 }
775 }
776
Josh Kunz4b25a502020-02-03 18:54:14 -0800777 qemu_log("\n");
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200778}
Alistair Francis859e8a82020-03-12 15:13:49 -0700779#endif
Aleksandar Markovic19f59bc2016-09-22 18:56:50 +0200780
Filip Bozuta1a674ad2020-08-11 18:45:53 +0200781#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
782static void
783print_syscall_ret_clock_gettime(void *cpu_env, const struct syscallname *name,
784 abi_long ret, abi_long arg0, abi_long arg1,
785 abi_long arg2, abi_long arg3, abi_long arg4,
786 abi_long arg5)
787{
788 if (!print_syscall_err(ret)) {
789 qemu_log(TARGET_ABI_FMT_ld, ret);
790 qemu_log(" (");
791 print_timespec(arg1, 1);
792 qemu_log(")");
793 }
794
795 qemu_log("\n");
796}
797#define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
798#endif
799
800#ifdef TARGET_NR_gettimeofday
801static void
802print_syscall_ret_gettimeofday(void *cpu_env, const struct syscallname *name,
803 abi_long ret, abi_long arg0, abi_long arg1,
804 abi_long arg2, abi_long arg3, abi_long arg4,
805 abi_long arg5)
806{
807 if (!print_syscall_err(ret)) {
808 qemu_log(TARGET_ABI_FMT_ld, ret);
809 qemu_log(" (");
810 print_timeval(arg0, 0);
811 print_timezone(arg1, 1);
812 qemu_log(")");
813 }
814
815 qemu_log("\n");
816}
817#endif
818
819#ifdef TARGET_NR_getitimer
820static void
821print_syscall_ret_getitimer(void *cpu_env, const struct syscallname *name,
822 abi_long ret, abi_long arg0, abi_long arg1,
823 abi_long arg2, abi_long arg3, abi_long arg4,
824 abi_long arg5)
825{
826 if (!print_syscall_err(ret)) {
827 qemu_log(TARGET_ABI_FMT_ld, ret);
828 qemu_log(" (");
829 print_itimerval(arg1, 1);
830 qemu_log(")");
831 }
832
833 qemu_log("\n");
834}
835#endif
836
837
838#ifdef TARGET_NR_getitimer
839static void
840print_syscall_ret_setitimer(void *cpu_env, const struct syscallname *name,
841 abi_long ret, abi_long arg0, abi_long arg1,
842 abi_long arg2, abi_long arg3, abi_long arg4,
843 abi_long arg5)
844{
845 if (!print_syscall_err(ret)) {
846 qemu_log(TARGET_ABI_FMT_ld, ret);
847 qemu_log(" (old_value = ");
848 print_itimerval(arg2, 1);
849 qemu_log(")");
850 }
851
852 qemu_log("\n");
853}
854#endif
855
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +0200856#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
857 || defined(TARGGET_NR_flistxattr)
858static void
Filip Bozutae400e112020-08-11 18:45:49 +0200859print_syscall_ret_listxattr(void *cpu_env, const struct syscallname *name,
860 abi_long ret, abi_long arg0, abi_long arg1,
861 abi_long arg2, abi_long arg3, abi_long arg4,
862 abi_long arg5)
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +0200863{
Laurent Vivier42b16182020-07-08 17:24:35 +0200864 if (!print_syscall_err(ret)) {
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +0200865 qemu_log(TARGET_ABI_FMT_ld, ret);
866 qemu_log(" (list = ");
867 if (arg1 != 0) {
868 abi_long attr = arg1;
869 while (ret) {
870 if (attr != arg1) {
871 qemu_log(",");
872 }
873 print_string(attr, 1);
874 ret -= target_strlen(attr) + 1;
875 attr += target_strlen(attr) + 1;
876 }
877 } else {
878 qemu_log("NULL");
879 }
880 qemu_log(")");
881 }
882
883 qemu_log("\n");
884}
885#define print_syscall_ret_llistxattr print_syscall_ret_listxattr
886#define print_syscall_ret_flistxattr print_syscall_ret_listxattr
887#endif
888
Filip Bozuta79482e592020-06-19 14:47:27 +0200889#ifdef TARGET_NR_ioctl
890static void
Filip Bozutae400e112020-08-11 18:45:49 +0200891print_syscall_ret_ioctl(void *cpu_env, const struct syscallname *name,
892 abi_long ret, abi_long arg0, abi_long arg1,
893 abi_long arg2, abi_long arg3, abi_long arg4,
894 abi_long arg5)
Filip Bozuta79482e592020-06-19 14:47:27 +0200895{
Laurent Vivier42b16182020-07-08 17:24:35 +0200896 if (!print_syscall_err(ret)) {
Filip Bozuta79482e592020-06-19 14:47:27 +0200897 qemu_log(TARGET_ABI_FMT_ld, ret);
898
899 const IOCTLEntry *ie;
900 const argtype *arg_type;
901 void *argptr;
902 int target_size;
903
904 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
905 if (ie->target_cmd == arg1) {
906 break;
907 }
908 }
909
910 if (ie->target_cmd == arg1 &&
911 (ie->access == IOC_R || ie->access == IOC_RW)) {
912 arg_type = ie->arg_type;
913 qemu_log(" (");
914 arg_type++;
915 target_size = thunk_type_size(arg_type, 0);
916 argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
Laurent Vivier4c1850c2020-07-09 21:22:17 +0200917 if (argptr) {
918 thunk_print(argptr, arg_type);
919 unlock_user(argptr, arg2, target_size);
920 } else {
921 print_pointer(arg2, 1);
922 }
Filip Bozuta79482e592020-06-19 14:47:27 +0200923 qemu_log(")");
924 }
925 }
926 qemu_log("\n");
927}
928#endif
929
Mika Westerberg74d753a2009-04-07 16:57:29 +0300930UNUSED static struct flags access_flags[] = {
931 FLAG_GENERIC(F_OK),
932 FLAG_GENERIC(R_OK),
933 FLAG_GENERIC(W_OK),
934 FLAG_GENERIC(X_OK),
935 FLAG_END,
936};
937
938UNUSED static struct flags at_file_flags[] = {
939#ifdef AT_EACCESS
940 FLAG_GENERIC(AT_EACCESS),
941#endif
942#ifdef AT_SYMLINK_NOFOLLOW
943 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
944#endif
945 FLAG_END,
946};
947
948UNUSED static struct flags unlinkat_flags[] = {
949#ifdef AT_REMOVEDIR
950 FLAG_GENERIC(AT_REMOVEDIR),
951#endif
952 FLAG_END,
953};
954
955UNUSED static struct flags mode_flags[] = {
956 FLAG_GENERIC(S_IFSOCK),
957 FLAG_GENERIC(S_IFLNK),
958 FLAG_GENERIC(S_IFREG),
959 FLAG_GENERIC(S_IFBLK),
960 FLAG_GENERIC(S_IFDIR),
961 FLAG_GENERIC(S_IFCHR),
962 FLAG_GENERIC(S_IFIFO),
963 FLAG_END,
964};
965
966UNUSED static struct flags open_access_flags[] = {
967 FLAG_TARGET(O_RDONLY),
968 FLAG_TARGET(O_WRONLY),
969 FLAG_TARGET(O_RDWR),
970 FLAG_END,
971};
972
973UNUSED static struct flags open_flags[] = {
974 FLAG_TARGET(O_APPEND),
975 FLAG_TARGET(O_CREAT),
976 FLAG_TARGET(O_DIRECTORY),
977 FLAG_TARGET(O_EXCL),
978 FLAG_TARGET(O_LARGEFILE),
979 FLAG_TARGET(O_NOCTTY),
980 FLAG_TARGET(O_NOFOLLOW),
981 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
Richard Hendersonafc87632012-07-25 14:30:34 -0700982 FLAG_TARGET(O_DSYNC),
983 FLAG_TARGET(__O_SYNC),
Mika Westerberg74d753a2009-04-07 16:57:29 +0300984 FLAG_TARGET(O_TRUNC),
985#ifdef O_DIRECT
986 FLAG_TARGET(O_DIRECT),
987#endif
Richard Hendersonafc87632012-07-25 14:30:34 -0700988#ifdef O_NOATIME
989 FLAG_TARGET(O_NOATIME),
990#endif
991#ifdef O_CLOEXEC
992 FLAG_TARGET(O_CLOEXEC),
993#endif
994#ifdef O_PATH
995 FLAG_TARGET(O_PATH),
996#endif
Riku Voipio5f9cee42017-08-08 16:01:19 +0300997#ifdef O_TMPFILE
998 FLAG_TARGET(O_TMPFILE),
999 FLAG_TARGET(__O_TMPFILE),
1000#endif
Mika Westerberg74d753a2009-04-07 16:57:29 +03001001 FLAG_END,
1002};
1003
1004UNUSED static struct flags mount_flags[] = {
1005#ifdef MS_BIND
1006 FLAG_GENERIC(MS_BIND),
1007#endif
1008#ifdef MS_DIRSYNC
1009 FLAG_GENERIC(MS_DIRSYNC),
1010#endif
1011 FLAG_GENERIC(MS_MANDLOCK),
1012#ifdef MS_MOVE
1013 FLAG_GENERIC(MS_MOVE),
1014#endif
1015 FLAG_GENERIC(MS_NOATIME),
1016 FLAG_GENERIC(MS_NODEV),
1017 FLAG_GENERIC(MS_NODIRATIME),
1018 FLAG_GENERIC(MS_NOEXEC),
1019 FLAG_GENERIC(MS_NOSUID),
1020 FLAG_GENERIC(MS_RDONLY),
1021#ifdef MS_RELATIME
1022 FLAG_GENERIC(MS_RELATIME),
1023#endif
1024 FLAG_GENERIC(MS_REMOUNT),
1025 FLAG_GENERIC(MS_SYNCHRONOUS),
1026 FLAG_END,
1027};
1028
1029UNUSED static struct flags umount2_flags[] = {
1030#ifdef MNT_FORCE
1031 FLAG_GENERIC(MNT_FORCE),
1032#endif
1033#ifdef MNT_DETACH
1034 FLAG_GENERIC(MNT_DETACH),
1035#endif
1036#ifdef MNT_EXPIRE
1037 FLAG_GENERIC(MNT_EXPIRE),
1038#endif
1039 FLAG_END,
1040};
1041
1042UNUSED static struct flags mmap_prot_flags[] = {
1043 FLAG_GENERIC(PROT_NONE),
1044 FLAG_GENERIC(PROT_EXEC),
1045 FLAG_GENERIC(PROT_READ),
1046 FLAG_GENERIC(PROT_WRITE),
Paul Brook9e0b74a2010-06-16 13:03:51 +01001047 FLAG_TARGET(PROT_SEM),
1048 FLAG_GENERIC(PROT_GROWSDOWN),
1049 FLAG_GENERIC(PROT_GROWSUP),
Mika Westerberg74d753a2009-04-07 16:57:29 +03001050 FLAG_END,
1051};
1052
1053UNUSED static struct flags mmap_flags[] = {
1054 FLAG_TARGET(MAP_SHARED),
1055 FLAG_TARGET(MAP_PRIVATE),
1056 FLAG_TARGET(MAP_ANONYMOUS),
1057 FLAG_TARGET(MAP_DENYWRITE),
1058 FLAG_TARGET(MAP_FIXED),
1059 FLAG_TARGET(MAP_GROWSDOWN),
Mike Frysinger906c1b82011-02-07 01:05:52 -05001060 FLAG_TARGET(MAP_EXECUTABLE),
Mika Westerberg74d753a2009-04-07 16:57:29 +03001061#ifdef MAP_LOCKED
1062 FLAG_TARGET(MAP_LOCKED),
1063#endif
1064#ifdef MAP_NONBLOCK
1065 FLAG_TARGET(MAP_NONBLOCK),
1066#endif
1067 FLAG_TARGET(MAP_NORESERVE),
1068#ifdef MAP_POPULATE
1069 FLAG_TARGET(MAP_POPULATE),
1070#endif
Mike Frysinger906c1b82011-02-07 01:05:52 -05001071#ifdef TARGET_MAP_UNINITIALIZED
1072 FLAG_TARGET(MAP_UNINITIALIZED),
1073#endif
Mika Westerberg74d753a2009-04-07 16:57:29 +03001074 FLAG_END,
1075};
1076
Laurent Vivier608e5592011-04-07 00:25:32 +02001077UNUSED static struct flags clone_flags[] = {
1078 FLAG_GENERIC(CLONE_VM),
1079 FLAG_GENERIC(CLONE_FS),
1080 FLAG_GENERIC(CLONE_FILES),
1081 FLAG_GENERIC(CLONE_SIGHAND),
1082 FLAG_GENERIC(CLONE_PTRACE),
1083 FLAG_GENERIC(CLONE_VFORK),
1084 FLAG_GENERIC(CLONE_PARENT),
1085 FLAG_GENERIC(CLONE_THREAD),
1086 FLAG_GENERIC(CLONE_NEWNS),
1087 FLAG_GENERIC(CLONE_SYSVSEM),
1088 FLAG_GENERIC(CLONE_SETTLS),
1089 FLAG_GENERIC(CLONE_PARENT_SETTID),
1090 FLAG_GENERIC(CLONE_CHILD_CLEARTID),
1091 FLAG_GENERIC(CLONE_DETACHED),
1092 FLAG_GENERIC(CLONE_UNTRACED),
1093 FLAG_GENERIC(CLONE_CHILD_SETTID),
Stefan Weil6f11f012011-04-27 10:44:38 +02001094#if defined(CLONE_NEWUTS)
Laurent Vivier608e5592011-04-07 00:25:32 +02001095 FLAG_GENERIC(CLONE_NEWUTS),
Stefan Weil6f11f012011-04-27 10:44:38 +02001096#endif
1097#if defined(CLONE_NEWIPC)
Laurent Vivier608e5592011-04-07 00:25:32 +02001098 FLAG_GENERIC(CLONE_NEWIPC),
Stefan Weil6f11f012011-04-27 10:44:38 +02001099#endif
1100#if defined(CLONE_NEWUSER)
Laurent Vivier608e5592011-04-07 00:25:32 +02001101 FLAG_GENERIC(CLONE_NEWUSER),
Stefan Weil6f11f012011-04-27 10:44:38 +02001102#endif
1103#if defined(CLONE_NEWPID)
Laurent Vivier608e5592011-04-07 00:25:32 +02001104 FLAG_GENERIC(CLONE_NEWPID),
Stefan Weil6f11f012011-04-27 10:44:38 +02001105#endif
1106#if defined(CLONE_NEWNET)
Laurent Vivier608e5592011-04-07 00:25:32 +02001107 FLAG_GENERIC(CLONE_NEWNET),
Stefan Weil6f11f012011-04-27 10:44:38 +02001108#endif
1109#if defined(CLONE_IO)
Laurent Vivier608e5592011-04-07 00:25:32 +02001110 FLAG_GENERIC(CLONE_IO),
Stefan Weil6f11f012011-04-27 10:44:38 +02001111#endif
Laurent Vivier608e5592011-04-07 00:25:32 +02001112 FLAG_END,
1113};
1114
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001115UNUSED static struct flags msg_flags[] = {
1116 /* send */
1117 FLAG_GENERIC(MSG_CONFIRM),
1118 FLAG_GENERIC(MSG_DONTROUTE),
1119 FLAG_GENERIC(MSG_DONTWAIT),
1120 FLAG_GENERIC(MSG_EOR),
1121 FLAG_GENERIC(MSG_MORE),
1122 FLAG_GENERIC(MSG_NOSIGNAL),
1123 FLAG_GENERIC(MSG_OOB),
1124 /* recv */
1125 FLAG_GENERIC(MSG_CMSG_CLOEXEC),
1126 FLAG_GENERIC(MSG_ERRQUEUE),
1127 FLAG_GENERIC(MSG_PEEK),
1128 FLAG_GENERIC(MSG_TRUNC),
1129 FLAG_GENERIC(MSG_WAITALL),
1130 /* recvmsg */
1131 FLAG_GENERIC(MSG_CTRUNC),
1132 FLAG_END,
1133};
1134
Jim Wilsond42744f2019-06-28 12:43:35 +02001135UNUSED static struct flags statx_flags[] = {
1136#ifdef AT_EMPTY_PATH
1137 FLAG_GENERIC(AT_EMPTY_PATH),
1138#endif
1139#ifdef AT_NO_AUTOMOUNT
1140 FLAG_GENERIC(AT_NO_AUTOMOUNT),
1141#endif
1142#ifdef AT_SYMLINK_NOFOLLOW
1143 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
1144#endif
1145#ifdef AT_STATX_SYNC_AS_STAT
1146 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT),
1147#endif
1148#ifdef AT_STATX_FORCE_SYNC
1149 FLAG_GENERIC(AT_STATX_FORCE_SYNC),
1150#endif
1151#ifdef AT_STATX_DONT_SYNC
1152 FLAG_GENERIC(AT_STATX_DONT_SYNC),
1153#endif
1154 FLAG_END,
1155};
1156
1157UNUSED static struct flags statx_mask[] = {
1158/* This must come first, because it includes everything. */
1159#ifdef STATX_ALL
1160 FLAG_GENERIC(STATX_ALL),
1161#endif
1162/* This must come second; it includes everything except STATX_BTIME. */
1163#ifdef STATX_BASIC_STATS
1164 FLAG_GENERIC(STATX_BASIC_STATS),
1165#endif
1166#ifdef STATX_TYPE
1167 FLAG_GENERIC(STATX_TYPE),
1168#endif
1169#ifdef STATX_MODE
1170 FLAG_GENERIC(STATX_MODE),
1171#endif
1172#ifdef STATX_NLINK
1173 FLAG_GENERIC(STATX_NLINK),
1174#endif
1175#ifdef STATX_UID
1176 FLAG_GENERIC(STATX_UID),
1177#endif
1178#ifdef STATX_GID
1179 FLAG_GENERIC(STATX_GID),
1180#endif
1181#ifdef STATX_ATIME
1182 FLAG_GENERIC(STATX_ATIME),
1183#endif
1184#ifdef STATX_MTIME
1185 FLAG_GENERIC(STATX_MTIME),
1186#endif
1187#ifdef STATX_CTIME
1188 FLAG_GENERIC(STATX_CTIME),
1189#endif
1190#ifdef STATX_INO
1191 FLAG_GENERIC(STATX_INO),
1192#endif
1193#ifdef STATX_SIZE
1194 FLAG_GENERIC(STATX_SIZE),
1195#endif
1196#ifdef STATX_BLOCKS
1197 FLAG_GENERIC(STATX_BLOCKS),
1198#endif
1199#ifdef STATX_BTIME
1200 FLAG_GENERIC(STATX_BTIME),
1201#endif
1202 FLAG_END,
1203};
1204
Filip Bozutaf4d92c52020-06-19 14:33:31 +02001205UNUSED static struct flags falloc_flags[] = {
1206 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
1207 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE),
1208#ifdef FALLOC_FL_NO_HIDE_STALE
1209 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE),
1210#endif
1211#ifdef FALLOC_FL_COLLAPSE_RANGE
1212 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE),
1213#endif
1214#ifdef FALLOC_FL_ZERO_RANGE
1215 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE),
1216#endif
1217#ifdef FALLOC_FL_INSERT_RANGE
1218 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE),
1219#endif
1220#ifdef FALLOC_FL_UNSHARE_RANGE
1221 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE),
1222#endif
1223};
1224
Filip Bozuta888468d2020-07-23 23:02:33 +02001225UNUSED static struct flags termios_iflags[] = {
1226 FLAG_TARGET(IGNBRK),
1227 FLAG_TARGET(BRKINT),
1228 FLAG_TARGET(IGNPAR),
1229 FLAG_TARGET(PARMRK),
1230 FLAG_TARGET(INPCK),
1231 FLAG_TARGET(ISTRIP),
1232 FLAG_TARGET(INLCR),
1233 FLAG_TARGET(IGNCR),
1234 FLAG_TARGET(ICRNL),
1235 FLAG_TARGET(IUCLC),
1236 FLAG_TARGET(IXON),
1237 FLAG_TARGET(IXANY),
1238 FLAG_TARGET(IXOFF),
1239 FLAG_TARGET(IMAXBEL),
1240 FLAG_TARGET(IUTF8),
1241 FLAG_END,
1242};
1243
1244UNUSED static struct flags termios_oflags[] = {
1245 FLAG_TARGET(OPOST),
1246 FLAG_TARGET(OLCUC),
1247 FLAG_TARGET(ONLCR),
1248 FLAG_TARGET(OCRNL),
1249 FLAG_TARGET(ONOCR),
1250 FLAG_TARGET(ONLRET),
1251 FLAG_TARGET(OFILL),
1252 FLAG_TARGET(OFDEL),
1253 FLAG_END,
1254};
1255
1256UNUSED static struct enums termios_oflags_NLDLY[] = {
1257 ENUM_TARGET(NL0),
1258 ENUM_TARGET(NL1),
1259 ENUM_END,
1260};
1261
1262UNUSED static struct enums termios_oflags_CRDLY[] = {
1263 ENUM_TARGET(CR0),
1264 ENUM_TARGET(CR1),
1265 ENUM_TARGET(CR2),
1266 ENUM_TARGET(CR3),
1267 ENUM_END,
1268};
1269
1270UNUSED static struct enums termios_oflags_TABDLY[] = {
1271 ENUM_TARGET(TAB0),
1272 ENUM_TARGET(TAB1),
1273 ENUM_TARGET(TAB2),
1274 ENUM_TARGET(TAB3),
1275 ENUM_END,
1276};
1277
1278UNUSED static struct enums termios_oflags_VTDLY[] = {
1279 ENUM_TARGET(VT0),
1280 ENUM_TARGET(VT1),
1281 ENUM_END,
1282};
1283
1284UNUSED static struct enums termios_oflags_FFDLY[] = {
1285 ENUM_TARGET(FF0),
1286 ENUM_TARGET(FF1),
1287 ENUM_END,
1288};
1289
1290UNUSED static struct enums termios_oflags_BSDLY[] = {
1291 ENUM_TARGET(BS0),
1292 ENUM_TARGET(BS1),
1293 ENUM_END,
1294};
1295
1296UNUSED static struct enums termios_cflags_CBAUD[] = {
1297 ENUM_TARGET(B0),
1298 ENUM_TARGET(B50),
1299 ENUM_TARGET(B75),
1300 ENUM_TARGET(B110),
1301 ENUM_TARGET(B134),
1302 ENUM_TARGET(B150),
1303 ENUM_TARGET(B200),
1304 ENUM_TARGET(B300),
1305 ENUM_TARGET(B600),
1306 ENUM_TARGET(B1200),
1307 ENUM_TARGET(B1800),
1308 ENUM_TARGET(B2400),
1309 ENUM_TARGET(B4800),
1310 ENUM_TARGET(B9600),
1311 ENUM_TARGET(B19200),
1312 ENUM_TARGET(B38400),
1313 ENUM_TARGET(B57600),
1314 ENUM_TARGET(B115200),
1315 ENUM_TARGET(B230400),
1316 ENUM_TARGET(B460800),
1317 ENUM_END,
1318};
1319
1320UNUSED static struct enums termios_cflags_CSIZE[] = {
1321 ENUM_TARGET(CS5),
1322 ENUM_TARGET(CS6),
1323 ENUM_TARGET(CS7),
1324 ENUM_TARGET(CS8),
1325 ENUM_END,
1326};
1327
1328UNUSED static struct flags termios_cflags[] = {
1329 FLAG_TARGET(CSTOPB),
1330 FLAG_TARGET(CREAD),
1331 FLAG_TARGET(PARENB),
1332 FLAG_TARGET(PARODD),
1333 FLAG_TARGET(HUPCL),
1334 FLAG_TARGET(CLOCAL),
1335 FLAG_TARGET(CRTSCTS),
1336 FLAG_END,
1337};
1338
1339UNUSED static struct flags termios_lflags[] = {
1340 FLAG_TARGET(ISIG),
1341 FLAG_TARGET(ICANON),
1342 FLAG_TARGET(XCASE),
1343 FLAG_TARGET(ECHO),
1344 FLAG_TARGET(ECHOE),
1345 FLAG_TARGET(ECHOK),
1346 FLAG_TARGET(ECHONL),
1347 FLAG_TARGET(NOFLSH),
1348 FLAG_TARGET(TOSTOP),
1349 FLAG_TARGET(ECHOCTL),
1350 FLAG_TARGET(ECHOPRT),
1351 FLAG_TARGET(ECHOKE),
1352 FLAG_TARGET(FLUSHO),
1353 FLAG_TARGET(PENDIN),
1354 FLAG_TARGET(IEXTEN),
1355 FLAG_TARGET(EXTPROC),
1356 FLAG_END,
1357};
1358
Filip Bozuta02e5d7d2020-08-11 18:45:51 +02001359UNUSED static struct flags mlockall_flags[] = {
1360 FLAG_TARGET(MCL_CURRENT),
1361 FLAG_TARGET(MCL_FUTURE),
1362#ifdef MCL_ONFAULT
1363 FLAG_TARGET(MCL_ONFAULT),
1364#endif
1365 FLAG_END,
1366};
1367
Filip Bozuta1a674ad2020-08-11 18:45:53 +02001368/* IDs of the various system clocks */
1369#define TARGET_CLOCK_REALTIME 0
1370#define TARGET_CLOCK_MONOTONIC 1
1371#define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1372#define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1373#define TARGET_CLOCK_MONOTONIC_RAW 4
1374#define TARGET_CLOCK_REALTIME_COARSE 5
1375#define TARGET_CLOCK_MONOTONIC_COARSE 6
1376#define TARGET_CLOCK_BOOTTIME 7
1377#define TARGET_CLOCK_REALTIME_ALARM 8
1378#define TARGET_CLOCK_BOOTTIME_ALARM 9
1379#define TARGET_CLOCK_SGI_CYCLE 10
1380#define TARGET_CLOCK_TAI 11
1381
1382UNUSED static struct enums clockids[] = {
1383 ENUM_TARGET(CLOCK_REALTIME),
1384 ENUM_TARGET(CLOCK_MONOTONIC),
1385 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID),
1386 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID),
1387 ENUM_TARGET(CLOCK_MONOTONIC_RAW),
1388 ENUM_TARGET(CLOCK_REALTIME_COARSE),
1389 ENUM_TARGET(CLOCK_MONOTONIC_COARSE),
1390 ENUM_TARGET(CLOCK_BOOTTIME),
1391 ENUM_TARGET(CLOCK_REALTIME_ALARM),
1392 ENUM_TARGET(CLOCK_BOOTTIME_ALARM),
1393 ENUM_TARGET(CLOCK_SGI_CYCLE),
1394 ENUM_TARGET(CLOCK_TAI),
1395 ENUM_END,
1396};
1397
1398UNUSED static struct enums itimer_types[] = {
1399 ENUM_GENERIC(ITIMER_REAL),
1400 ENUM_GENERIC(ITIMER_VIRTUAL),
1401 ENUM_GENERIC(ITIMER_PROF),
1402 ENUM_END,
1403};
1404
Mika Westerberg74d753a2009-04-07 16:57:29 +03001405/*
1406 * print_xxx utility functions. These are used to print syscall
1407 * parameters in certain format. All of these have parameter
1408 * named 'last'. This parameter is used to add comma to output
1409 * when last == 0.
1410 */
1411
1412static const char *
1413get_comma(int last)
1414{
1415 return ((last) ? "" : ",");
1416}
1417
1418static void
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001419print_flags(const struct flags *f, abi_long flags, int last)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001420{
1421 const char *sep = "";
Mika Westerberg74d753a2009-04-07 16:57:29 +03001422 int n;
1423
Mika Westerberg74d753a2009-04-07 16:57:29 +03001424 if ((flags == 0) && (f->f_value == 0)) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001425 qemu_log("%s%s", f->f_string, get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001426 return;
1427 }
1428 for (n = 0; f->f_string != NULL; f++) {
1429 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001430 qemu_log("%s%s", sep, f->f_string);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001431 flags &= ~f->f_value;
1432 sep = "|";
1433 n++;
1434 }
1435 }
1436
1437 if (n > 0) {
1438 /* print rest of the flags as numeric */
1439 if (flags != 0) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001440 qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001441 } else {
Josh Kunz4b25a502020-02-03 18:54:14 -08001442 qemu_log("%s", get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001443 }
1444 } else {
1445 /* no string version of flags found, print them in hex then */
Josh Kunz4b25a502020-02-03 18:54:14 -08001446 qemu_log("%#x%s", (unsigned int)flags, get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001447 }
1448}
1449
1450static void
Filip Bozuta45f56792020-08-11 18:45:52 +02001451print_enums(const struct enums *e, abi_long enum_arg, int last)
1452{
1453 for (; e->e_string != NULL; e++) {
1454 if (e->e_value == enum_arg) {
1455 qemu_log("%s", e->e_string);
1456 break;
1457 }
1458 }
1459
1460 if (e->e_string == NULL) {
1461 qemu_log("%#x", (unsigned int)enum_arg);
1462 }
1463
1464 qemu_log("%s", get_comma(last));
1465}
1466
1467static void
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001468print_at_dirfd(abi_long dirfd, int last)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001469{
Mika Westerberg74d753a2009-04-07 16:57:29 +03001470#ifdef AT_FDCWD
1471 if (dirfd == AT_FDCWD) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001472 qemu_log("AT_FDCWD%s", get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001473 return;
1474 }
1475#endif
Josh Kunz4b25a502020-02-03 18:54:14 -08001476 qemu_log("%d%s", (int)dirfd, get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001477}
1478
1479static void
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001480print_file_mode(abi_long mode, int last)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001481{
1482 const char *sep = "";
1483 const struct flags *m;
Mika Westerberg74d753a2009-04-07 16:57:29 +03001484
1485 for (m = &mode_flags[0]; m->f_string != NULL; m++) {
1486 if ((m->f_value & mode) == m->f_value) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001487 qemu_log("%s%s", m->f_string, sep);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001488 sep = "|";
1489 mode &= ~m->f_value;
1490 break;
1491 }
1492 }
1493
1494 mode &= ~S_IFMT;
1495 /* print rest of the mode as octal */
1496 if (mode != 0)
Josh Kunz4b25a502020-02-03 18:54:14 -08001497 qemu_log("%s%#o", sep, (unsigned int)mode);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001498
Josh Kunz4b25a502020-02-03 18:54:14 -08001499 qemu_log("%s", get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001500}
1501
1502static void
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001503print_open_flags(abi_long flags, int last)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001504{
Mika Westerberg74d753a2009-04-07 16:57:29 +03001505 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
1506 flags &= ~TARGET_O_ACCMODE;
1507 if (flags == 0) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001508 qemu_log("%s", get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001509 return;
1510 }
Josh Kunz4b25a502020-02-03 18:54:14 -08001511 qemu_log("|");
Mika Westerberg74d753a2009-04-07 16:57:29 +03001512 print_flags(open_flags, flags, last);
1513}
1514
1515static void
1516print_syscall_prologue(const struct syscallname *sc)
1517{
Josh Kunz4b25a502020-02-03 18:54:14 -08001518 qemu_log("%s(", sc->name);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001519}
1520
1521/*ARGSUSED*/
1522static void
1523print_syscall_epilogue(const struct syscallname *sc)
1524{
1525 (void)sc;
Josh Kunz4b25a502020-02-03 18:54:14 -08001526 qemu_log(")");
Mika Westerberg74d753a2009-04-07 16:57:29 +03001527}
1528
1529static void
1530print_string(abi_long addr, int last)
1531{
1532 char *s;
1533
1534 if ((s = lock_user_string(addr)) != NULL) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001535 qemu_log("\"%s\"%s", s, get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001536 unlock_user(s, addr, 0);
1537 } else {
1538 /* can't get string out of it, so print it as pointer */
1539 print_pointer(addr, last);
1540 }
1541}
1542
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001543#define MAX_PRINT_BUF 40
1544static void
1545print_buf(abi_long addr, abi_long len, int last)
1546{
1547 uint8_t *s;
1548 int i;
1549
1550 s = lock_user(VERIFY_READ, addr, len, 1);
1551 if (s) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001552 qemu_log("\"");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001553 for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
1554 if (isprint(s[i])) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001555 qemu_log("%c", s[i]);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001556 } else {
Josh Kunz4b25a502020-02-03 18:54:14 -08001557 qemu_log("\\%o", s[i]);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001558 }
1559 }
Josh Kunz4b25a502020-02-03 18:54:14 -08001560 qemu_log("\"");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001561 if (i != len) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001562 qemu_log("...");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001563 }
1564 if (!last) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001565 qemu_log(",");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02001566 }
1567 unlock_user(s, addr, 0);
1568 } else {
1569 print_pointer(addr, last);
1570 }
1571}
1572
Mika Westerberg74d753a2009-04-07 16:57:29 +03001573/*
1574 * Prints out raw parameter using given format. Caller needs
1575 * to do byte swapping if needed.
1576 */
1577static void
1578print_raw_param(const char *fmt, abi_long param, int last)
1579{
1580 char format[64];
1581
1582 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
Josh Kunz4b25a502020-02-03 18:54:14 -08001583 qemu_log(format, param);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001584}
1585
1586static void
1587print_pointer(abi_long p, int last)
1588{
1589 if (p == 0)
Josh Kunz4b25a502020-02-03 18:54:14 -08001590 qemu_log("NULL%s", get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001591 else
Josh Kunz4b25a502020-02-03 18:54:14 -08001592 qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001593}
1594
1595/*
1596 * Reads 32-bit (int) number from guest address space from
1597 * address 'addr' and prints it.
1598 */
1599static void
1600print_number(abi_long addr, int last)
1601{
1602 if (addr == 0) {
Josh Kunz4b25a502020-02-03 18:54:14 -08001603 qemu_log("NULL%s", get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001604 } else {
1605 int num;
1606
1607 get_user_s32(num, addr);
Josh Kunz4b25a502020-02-03 18:54:14 -08001608 qemu_log("[%d]%s", num, get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001609 }
1610}
1611
1612static void
1613print_timeval(abi_ulong tv_addr, int last)
1614{
1615 if( tv_addr ) {
1616 struct target_timeval *tv;
1617
1618 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
Philippe Mathieu-Daudé8f930892019-10-21 13:48:49 +02001619 if (!tv) {
1620 print_pointer(tv_addr, last);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001621 return;
Philippe Mathieu-Daudé8f930892019-10-21 13:48:49 +02001622 }
Filip Bozuta1a674ad2020-08-11 18:45:53 +02001623 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1624 ",tv_usec = " TARGET_ABI_FMT_ld "}%s",
1625 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001626 unlock_user(tv, tv_addr, 0);
1627 } else
Josh Kunz4b25a502020-02-03 18:54:14 -08001628 qemu_log("NULL%s", get_comma(last));
Mika Westerberg74d753a2009-04-07 16:57:29 +03001629}
1630
Philippe Mathieu-Daudé6d33e032019-10-21 13:48:50 +02001631static void
Filip Bozuta1a674ad2020-08-11 18:45:53 +02001632print_timespec(abi_ulong ts_addr, int last)
1633{
1634 if (ts_addr) {
1635 struct target_timespec *ts;
1636
1637 ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
1638 if (!ts) {
1639 print_pointer(ts_addr, last);
1640 return;
1641 }
1642 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1643 ",tv_nsec = " TARGET_ABI_FMT_ld "}%s",
1644 tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last));
1645 unlock_user(ts, ts_addr, 0);
1646 } else {
1647 qemu_log("NULL%s", get_comma(last));
1648 }
1649}
1650
1651static void
Philippe Mathieu-Daudé6d33e032019-10-21 13:48:50 +02001652print_timezone(abi_ulong tz_addr, int last)
1653{
1654 if (tz_addr) {
1655 struct target_timezone *tz;
1656
1657 tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
1658 if (!tz) {
1659 print_pointer(tz_addr, last);
1660 return;
1661 }
Josh Kunz4b25a502020-02-03 18:54:14 -08001662 qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest),
Philippe Mathieu-Daudé6d33e032019-10-21 13:48:50 +02001663 tswap32(tz->tz_dsttime), get_comma(last));
1664 unlock_user(tz, tz_addr, 0);
1665 } else {
Josh Kunz4b25a502020-02-03 18:54:14 -08001666 qemu_log("NULL%s", get_comma(last));
Philippe Mathieu-Daudé6d33e032019-10-21 13:48:50 +02001667 }
1668}
1669
Filip Bozuta1a674ad2020-08-11 18:45:53 +02001670static void
1671print_itimerval(abi_ulong it_addr, int last)
1672{
1673 if (it_addr) {
1674 qemu_log("{it_interval=");
1675 print_timeval(it_addr +
1676 offsetof(struct target_itimerval, it_interval), 0);
1677 qemu_log("it_value=");
1678 print_timeval(it_addr +
1679 offsetof(struct target_itimerval, it_value), 0);
1680 qemu_log("}%s", get_comma(last));
1681 } else {
1682 qemu_log("NULL%s", get_comma(last));
1683 }
1684}
1685
Filip Bozuta888468d2020-07-23 23:02:33 +02001686void
1687print_termios(void *arg)
1688{
1689 const struct target_termios *target = arg;
1690
1691 target_tcflag_t iflags = tswap32(target->c_iflag);
1692 target_tcflag_t oflags = tswap32(target->c_oflag);
1693 target_tcflag_t cflags = tswap32(target->c_cflag);
1694 target_tcflag_t lflags = tswap32(target->c_lflag);
1695
1696 qemu_log("{");
1697
1698 qemu_log("c_iflag = ");
1699 print_flags(termios_iflags, iflags, 0);
1700
1701 qemu_log("c_oflag = ");
1702 target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY |
1703 TARGET_TABDLY | TARGET_BSDLY |
1704 TARGET_VTDLY | TARGET_FFDLY);
1705 print_flags(termios_oflags, oflags_clean, 0);
1706 if (oflags & TARGET_NLDLY) {
1707 print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0);
1708 }
1709 if (oflags & TARGET_CRDLY) {
1710 print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0);
1711 }
1712 if (oflags & TARGET_TABDLY) {
1713 print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0);
1714 }
1715 if (oflags & TARGET_BSDLY) {
1716 print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0);
1717 }
1718 if (oflags & TARGET_VTDLY) {
1719 print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0);
1720 }
1721 if (oflags & TARGET_FFDLY) {
1722 print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0);
1723 }
1724
1725 qemu_log("c_cflag = ");
1726 if (cflags & TARGET_CBAUD) {
1727 print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0);
1728 }
1729 if (cflags & TARGET_CSIZE) {
1730 print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0);
1731 }
1732 target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE);
1733 print_flags(termios_cflags, cflags_clean, 0);
1734
1735 qemu_log("c_lflag = ");
1736 print_flags(termios_lflags, lflags, 0);
1737
1738 qemu_log("c_cc = ");
1739 qemu_log("\"%s\",", target->c_cc);
1740
1741 qemu_log("c_line = ");
1742 print_raw_param("\'%c\'", target->c_line, 1);
1743
1744 qemu_log("}");
1745}
1746
Mika Westerberg74d753a2009-04-07 16:57:29 +03001747#undef UNUSED
1748
1749#ifdef TARGET_NR_accept
1750static void
Filip Bozutae400e112020-08-11 18:45:49 +02001751print_accept(void *cpu_env, const struct syscallname *name,
1752 abi_long arg0, abi_long arg1, abi_long arg2,
1753 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001754{
1755 print_syscall_prologue(name);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001756 print_raw_param("%d", arg0, 0);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001757 print_pointer(arg1, 0);
1758 print_number(arg2, 1);
1759 print_syscall_epilogue(name);
1760}
1761#endif
1762
1763#ifdef TARGET_NR_access
1764static void
Filip Bozutae400e112020-08-11 18:45:49 +02001765print_access(void *cpu_env, const struct syscallname *name,
1766 abi_long arg0, abi_long arg1, abi_long arg2,
1767 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001768{
1769 print_syscall_prologue(name);
1770 print_string(arg0, 0);
1771 print_flags(access_flags, arg1, 1);
1772 print_syscall_epilogue(name);
1773}
1774#endif
1775
Filip Bozutac42569f2020-06-19 14:33:27 +02001776#ifdef TARGET_NR_acct
1777static void
Filip Bozutae400e112020-08-11 18:45:49 +02001778print_acct(void *cpu_env, const struct syscallname *name,
1779 abi_long arg0, abi_long arg1, abi_long arg2,
1780 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozutac42569f2020-06-19 14:33:27 +02001781{
1782 print_syscall_prologue(name);
1783 print_string(arg0, 1);
1784 print_syscall_epilogue(name);
1785}
1786#endif
1787
Mika Westerberg74d753a2009-04-07 16:57:29 +03001788#ifdef TARGET_NR_brk
1789static void
Filip Bozutae400e112020-08-11 18:45:49 +02001790print_brk(void *cpu_env, const struct syscallname *name,
1791 abi_long arg0, abi_long arg1, abi_long arg2,
1792 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001793{
1794 print_syscall_prologue(name);
1795 print_pointer(arg0, 1);
1796 print_syscall_epilogue(name);
1797}
1798#endif
1799
1800#ifdef TARGET_NR_chdir
1801static void
Filip Bozutae400e112020-08-11 18:45:49 +02001802print_chdir(void *cpu_env, const struct syscallname *name,
1803 abi_long arg0, abi_long arg1, abi_long arg2,
1804 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001805{
1806 print_syscall_prologue(name);
1807 print_string(arg0, 1);
1808 print_syscall_epilogue(name);
1809}
1810#endif
1811
Helge Deller1b7695f2019-02-27 20:11:15 +01001812#ifdef TARGET_NR_chroot
1813static void
Filip Bozutae400e112020-08-11 18:45:49 +02001814print_chroot(void *cpu_env, const struct syscallname *name,
1815 abi_long arg0, abi_long arg1, abi_long arg2,
1816 abi_long arg3, abi_long arg4, abi_long arg5)
Helge Deller1b7695f2019-02-27 20:11:15 +01001817{
1818 print_syscall_prologue(name);
1819 print_string(arg0, 1);
1820 print_syscall_epilogue(name);
1821}
1822#endif
1823
Mika Westerberg74d753a2009-04-07 16:57:29 +03001824#ifdef TARGET_NR_chmod
1825static void
Filip Bozutae400e112020-08-11 18:45:49 +02001826print_chmod(void *cpu_env, const struct syscallname *name,
1827 abi_long arg0, abi_long arg1, abi_long arg2,
1828 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001829{
1830 print_syscall_prologue(name);
1831 print_string(arg0, 0);
1832 print_file_mode(arg1, 1);
1833 print_syscall_epilogue(name);
1834}
1835#endif
1836
Filip Bozuta5844f4b2020-06-19 14:33:30 +02001837#if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1838static void
Filip Bozutae400e112020-08-11 18:45:49 +02001839print_chown(void *cpu_env, const struct syscallname *name,
1840 abi_long arg0, abi_long arg1, abi_long arg2,
1841 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozuta5844f4b2020-06-19 14:33:30 +02001842{
1843 print_syscall_prologue(name);
1844 print_string(arg0, 0);
1845 print_raw_param("%d", arg1, 0);
1846 print_raw_param("%d", arg2, 1);
1847 print_syscall_epilogue(name);
1848}
1849#define print_lchown print_chown
1850#endif
1851
Aleksandar Markovic38860a02016-10-10 13:23:29 +02001852#ifdef TARGET_NR_clock_adjtime
1853static void
Filip Bozutae400e112020-08-11 18:45:49 +02001854print_clock_adjtime(void *cpu_env, const struct syscallname *name,
1855 abi_long arg0, abi_long arg1, abi_long arg2,
1856 abi_long arg3, abi_long arg4, abi_long arg5)
Aleksandar Markovic38860a02016-10-10 13:23:29 +02001857{
1858 print_syscall_prologue(name);
Filip Bozuta1a674ad2020-08-11 18:45:53 +02001859 print_enums(clockids, arg0, 0);
Aleksandar Markovic38860a02016-10-10 13:23:29 +02001860 print_pointer(arg1, 1);
1861 print_syscall_epilogue(name);
1862}
1863#endif
1864
Laurent Vivier608e5592011-04-07 00:25:32 +02001865#ifdef TARGET_NR_clone
Laurent Vivier84bd8282016-06-11 02:19:47 +02001866static void do_print_clone(unsigned int flags, abi_ulong newsp,
1867 abi_ulong parent_tidptr, target_ulong newtls,
1868 abi_ulong child_tidptr)
1869{
1870 print_flags(clone_flags, flags, 0);
1871 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
1872 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
1873 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
1874 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
1875}
1876
Laurent Vivier608e5592011-04-07 00:25:32 +02001877static void
Filip Bozutae400e112020-08-11 18:45:49 +02001878print_clone(void *cpu_env, const struct syscallname *name,
1879 abi_long arg1, abi_long arg2, abi_long arg3,
1880 abi_long arg4, abi_long arg5, abi_long arg6)
Laurent Vivier608e5592011-04-07 00:25:32 +02001881{
1882 print_syscall_prologue(name);
Laurent Vivier84bd8282016-06-11 02:19:47 +02001883#if defined(TARGET_MICROBLAZE)
1884 do_print_clone(arg1, arg2, arg4, arg6, arg5);
1885#elif defined(TARGET_CLONE_BACKWARDS)
1886 do_print_clone(arg1, arg2, arg3, arg4, arg5);
1887#elif defined(TARGET_CLONE_BACKWARDS2)
1888 do_print_clone(arg2, arg1, arg3, arg5, arg4);
Laurent Vivier608e5592011-04-07 00:25:32 +02001889#else
Laurent Vivier84bd8282016-06-11 02:19:47 +02001890 do_print_clone(arg1, arg2, arg3, arg5, arg4);
Laurent Vivier608e5592011-04-07 00:25:32 +02001891#endif
1892 print_syscall_epilogue(name);
1893}
1894#endif
1895
Mika Westerberg74d753a2009-04-07 16:57:29 +03001896#ifdef TARGET_NR_creat
1897static void
Filip Bozutae400e112020-08-11 18:45:49 +02001898print_creat(void *cpu_env, const struct syscallname *name,
1899 abi_long arg0, abi_long arg1, abi_long arg2,
1900 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001901{
1902 print_syscall_prologue(name);
1903 print_string(arg0, 0);
1904 print_file_mode(arg1, 1);
1905 print_syscall_epilogue(name);
1906}
1907#endif
1908
1909#ifdef TARGET_NR_execv
1910static void
Filip Bozutae400e112020-08-11 18:45:49 +02001911print_execv(void *cpu_env, const struct syscallname *name,
1912 abi_long arg0, abi_long arg1, abi_long arg2,
1913 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001914{
1915 print_syscall_prologue(name);
1916 print_string(arg0, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001917 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001918 print_syscall_epilogue(name);
1919}
1920#endif
1921
1922#ifdef TARGET_NR_faccessat
1923static void
Filip Bozutae400e112020-08-11 18:45:49 +02001924print_faccessat(void *cpu_env, const struct syscallname *name,
1925 abi_long arg0, abi_long arg1, abi_long arg2,
1926 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001927{
1928 print_syscall_prologue(name);
1929 print_at_dirfd(arg0, 0);
1930 print_string(arg1, 0);
1931 print_flags(access_flags, arg2, 0);
1932 print_flags(at_file_flags, arg3, 1);
1933 print_syscall_epilogue(name);
1934}
1935#endif
1936
Filip Bozutaf4d92c52020-06-19 14:33:31 +02001937#ifdef TARGET_NR_fallocate
1938static void
Filip Bozutae400e112020-08-11 18:45:49 +02001939print_fallocate(void *cpu_env, const struct syscallname *name,
1940 abi_long arg0, abi_long arg1, abi_long arg2,
1941 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozutaf4d92c52020-06-19 14:33:31 +02001942{
1943 print_syscall_prologue(name);
1944 print_raw_param("%d", arg0, 0);
1945 print_flags(falloc_flags, arg1, 0);
1946#if TARGET_ABI_BITS == 32
1947 print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0);
1948 print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1);
1949#else
1950 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1951 print_raw_param(TARGET_ABI_FMT_ld, arg3, 1);
1952#endif
1953 print_syscall_epilogue(name);
1954}
1955#endif
1956
Mika Westerberg74d753a2009-04-07 16:57:29 +03001957#ifdef TARGET_NR_fchmodat
1958static void
Filip Bozutae400e112020-08-11 18:45:49 +02001959print_fchmodat(void *cpu_env, const struct syscallname *name,
1960 abi_long arg0, abi_long arg1, abi_long arg2,
1961 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001962{
1963 print_syscall_prologue(name);
1964 print_at_dirfd(arg0, 0);
1965 print_string(arg1, 0);
1966 print_file_mode(arg2, 0);
1967 print_flags(at_file_flags, arg3, 1);
1968 print_syscall_epilogue(name);
1969}
1970#endif
1971
1972#ifdef TARGET_NR_fchownat
1973static void
Filip Bozutae400e112020-08-11 18:45:49 +02001974print_fchownat(void *cpu_env, const struct syscallname *name,
1975 abi_long arg0, abi_long arg1, abi_long arg2,
1976 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001977{
1978 print_syscall_prologue(name);
1979 print_at_dirfd(arg0, 0);
1980 print_string(arg1, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001981 print_raw_param("%d", arg2, 0);
1982 print_raw_param("%d", arg3, 0);
Mika Westerberg74d753a2009-04-07 16:57:29 +03001983 print_flags(at_file_flags, arg4, 1);
1984 print_syscall_epilogue(name);
1985}
1986#endif
1987
1988#if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1989static void
Filip Bozutae400e112020-08-11 18:45:49 +02001990print_fcntl(void *cpu_env, const struct syscallname *name,
1991 abi_long arg0, abi_long arg1, abi_long arg2,
1992 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03001993{
1994 print_syscall_prologue(name);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01001995 print_raw_param("%d", arg0, 0);
Laurent Vivierd95ec142012-12-31 21:00:11 +01001996 switch(arg1) {
1997 case TARGET_F_DUPFD:
Josh Kunz4b25a502020-02-03 18:54:14 -08001998 qemu_log("F_DUPFD,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01001999 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2000 break;
2001 case TARGET_F_GETFD:
Josh Kunz4b25a502020-02-03 18:54:14 -08002002 qemu_log("F_GETFD");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002003 break;
2004 case TARGET_F_SETFD:
Josh Kunz4b25a502020-02-03 18:54:14 -08002005 qemu_log("F_SETFD,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002006 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2007 break;
2008 case TARGET_F_GETFL:
Josh Kunz4b25a502020-02-03 18:54:14 -08002009 qemu_log("F_GETFL");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002010 break;
2011 case TARGET_F_SETFL:
Josh Kunz4b25a502020-02-03 18:54:14 -08002012 qemu_log("F_SETFL,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002013 print_open_flags(arg2, 1);
2014 break;
2015 case TARGET_F_GETLK:
Josh Kunz4b25a502020-02-03 18:54:14 -08002016 qemu_log("F_GETLK,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002017 print_pointer(arg2, 1);
2018 break;
2019 case TARGET_F_SETLK:
Josh Kunz4b25a502020-02-03 18:54:14 -08002020 qemu_log("F_SETLK,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002021 print_pointer(arg2, 1);
2022 break;
2023 case TARGET_F_SETLKW:
Josh Kunz4b25a502020-02-03 18:54:14 -08002024 qemu_log("F_SETLKW,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002025 print_pointer(arg2, 1);
2026 break;
2027 case TARGET_F_GETOWN:
Josh Kunz4b25a502020-02-03 18:54:14 -08002028 qemu_log("F_GETOWN");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002029 break;
2030 case TARGET_F_SETOWN:
Josh Kunz4b25a502020-02-03 18:54:14 -08002031 qemu_log("F_SETOWN,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002032 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2033 break;
2034 case TARGET_F_GETSIG:
Josh Kunz4b25a502020-02-03 18:54:14 -08002035 qemu_log("F_GETSIG");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002036 break;
2037 case TARGET_F_SETSIG:
Josh Kunz4b25a502020-02-03 18:54:14 -08002038 qemu_log("F_SETSIG,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002039 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2040 break;
2041#if TARGET_ABI_BITS == 32
2042 case TARGET_F_GETLK64:
Josh Kunz4b25a502020-02-03 18:54:14 -08002043 qemu_log("F_GETLK64,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002044 print_pointer(arg2, 1);
2045 break;
2046 case TARGET_F_SETLK64:
Josh Kunz4b25a502020-02-03 18:54:14 -08002047 qemu_log("F_SETLK64,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002048 print_pointer(arg2, 1);
2049 break;
2050 case TARGET_F_SETLKW64:
Josh Kunz4b25a502020-02-03 18:54:14 -08002051 qemu_log("F_SETLKW64,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002052 print_pointer(arg2, 1);
2053 break;
2054#endif
Mike Gelfand38be8632020-08-30 12:22:42 +03002055 case TARGET_F_OFD_GETLK:
2056 qemu_log("F_OFD_GETLK,");
2057 print_pointer(arg2, 1);
2058 break;
2059 case TARGET_F_OFD_SETLK:
2060 qemu_log("F_OFD_SETLK,");
2061 print_pointer(arg2, 1);
2062 break;
2063 case TARGET_F_OFD_SETLKW:
2064 qemu_log("F_OFD_SETLKW,");
2065 print_pointer(arg2, 1);
2066 break;
Laurent Vivierd95ec142012-12-31 21:00:11 +01002067 case TARGET_F_SETLEASE:
Josh Kunz4b25a502020-02-03 18:54:14 -08002068 qemu_log("F_SETLEASE,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002069 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2070 break;
2071 case TARGET_F_GETLEASE:
Josh Kunz4b25a502020-02-03 18:54:14 -08002072 qemu_log("F_GETLEASE");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002073 break;
Peter Maydell7e3b92e2016-06-20 15:50:37 +01002074 case TARGET_F_SETPIPE_SZ:
Josh Kunz4b25a502020-02-03 18:54:14 -08002075 qemu_log("F_SETPIPE_SZ,");
Peter Maydell7e3b92e2016-06-20 15:50:37 +01002076 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2077 break;
2078 case TARGET_F_GETPIPE_SZ:
Josh Kunz4b25a502020-02-03 18:54:14 -08002079 qemu_log("F_GETPIPE_SZ");
Peter Maydell7e3b92e2016-06-20 15:50:37 +01002080 break;
Laurent Vivierd95ec142012-12-31 21:00:11 +01002081 case TARGET_F_DUPFD_CLOEXEC:
Josh Kunz4b25a502020-02-03 18:54:14 -08002082 qemu_log("F_DUPFD_CLOEXEC,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002083 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2084 break;
2085 case TARGET_F_NOTIFY:
Josh Kunz4b25a502020-02-03 18:54:14 -08002086 qemu_log("F_NOTIFY,");
Laurent Vivierd95ec142012-12-31 21:00:11 +01002087 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2088 break;
2089 default:
2090 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2091 print_pointer(arg2, 1);
2092 break;
2093 }
Mika Westerberg74d753a2009-04-07 16:57:29 +03002094 print_syscall_epilogue(name);
2095}
2096#define print_fcntl64 print_fcntl
2097#endif
2098
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +02002099#ifdef TARGET_NR_fgetxattr
2100static void
Filip Bozutae400e112020-08-11 18:45:49 +02002101print_fgetxattr(void *cpu_env, const struct syscallname *name,
2102 abi_long arg0, abi_long arg1, abi_long arg2,
2103 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +02002104{
2105 print_syscall_prologue(name);
2106 print_raw_param("%d", arg0, 0);
2107 print_string(arg1, 0);
2108 print_pointer(arg2, 0);
2109 print_raw_param(TARGET_FMT_lu, arg3, 1);
2110 print_syscall_epilogue(name);
2111}
2112#endif
2113
2114#ifdef TARGET_NR_flistxattr
2115static void
Filip Bozutae400e112020-08-11 18:45:49 +02002116print_flistxattr(void *cpu_env, const struct syscallname *name,
2117 abi_long arg0, abi_long arg1, abi_long arg2,
2118 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +02002119{
2120 print_syscall_prologue(name);
2121 print_raw_param("%d", arg0, 0);
2122 print_pointer(arg1, 0);
2123 print_raw_param(TARGET_FMT_lu, arg2, 1);
2124 print_syscall_epilogue(name);
2125}
2126#endif
2127
2128#if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2129static void
Filip Bozutae400e112020-08-11 18:45:49 +02002130print_getxattr(void *cpu_env, const struct syscallname *name,
2131 abi_long arg0, abi_long arg1, abi_long arg2,
2132 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +02002133{
2134 print_syscall_prologue(name);
2135 print_string(arg0, 0);
2136 print_string(arg1, 0);
2137 print_pointer(arg2, 0);
2138 print_raw_param(TARGET_FMT_lu, arg3, 1);
2139 print_syscall_epilogue(name);
2140}
2141#define print_lgetxattr print_getxattr
2142#endif
2143
2144#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2145static void
Filip Bozutae400e112020-08-11 18:45:49 +02002146print_listxattr(void *cpu_env, const struct syscallname *name,
2147 abi_long arg0, abi_long arg1, abi_long arg2,
2148 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +02002149{
2150 print_syscall_prologue(name);
2151 print_string(arg0, 0);
2152 print_pointer(arg1, 0);
2153 print_raw_param(TARGET_FMT_lu, arg2, 1);
2154 print_syscall_epilogue(name);
2155}
2156#define print_llistxattr print_listxattr
2157#endif
2158
2159#if defined(TARGET_NR_fremovexattr)
2160static void
Filip Bozutae400e112020-08-11 18:45:49 +02002161print_fremovexattr(void *cpu_env, const struct syscallname *name,
2162 abi_long arg0, abi_long arg1, abi_long arg2,
2163 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +02002164{
2165 print_syscall_prologue(name);
2166 print_raw_param("%d", arg0, 0);
2167 print_string(arg1, 1);
2168 print_syscall_epilogue(name);
2169}
2170#endif
2171
2172#if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2173static void
Filip Bozutae400e112020-08-11 18:45:49 +02002174print_removexattr(void *cpu_env, const struct syscallname *name,
2175 abi_long arg0, abi_long arg1, abi_long arg2,
2176 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozuta4fc3cdd2020-06-19 14:33:28 +02002177{
2178 print_syscall_prologue(name);
2179 print_string(arg0, 0);
2180 print_string(arg1, 1);
2181 print_syscall_epilogue(name);
2182}
2183#define print_lremovexattr print_removexattr
2184#endif
2185
Mika Westerberg74d753a2009-04-07 16:57:29 +03002186#ifdef TARGET_NR_futimesat
2187static void
Filip Bozutae400e112020-08-11 18:45:49 +02002188print_futimesat(void *cpu_env, const struct syscallname *name,
2189 abi_long arg0, abi_long arg1, abi_long arg2,
2190 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03002191{
2192 print_syscall_prologue(name);
2193 print_at_dirfd(arg0, 0);
2194 print_string(arg1, 0);
2195 print_timeval(arg2, 0);
2196 print_timeval(arg2 + sizeof (struct target_timeval), 1);
2197 print_syscall_epilogue(name);
2198}
2199#endif
2200
Filip Bozuta1a674ad2020-08-11 18:45:53 +02002201#ifdef TARGET_NR_gettimeofday
2202static void
2203print_gettimeofday(void *cpu_env, const struct syscallname *name,
2204 abi_long arg0, abi_long arg1, abi_long arg2,
2205 abi_long arg3, abi_long arg4, abi_long arg5)
2206{
2207 print_syscall_prologue(name);
2208 print_pointer(arg0, 0);
2209 print_pointer(arg1, 1);
2210 print_syscall_epilogue(name);
2211}
2212#endif
2213
Philippe Mathieu-Daudé0d2187c2019-10-21 13:48:51 +02002214#ifdef TARGET_NR_settimeofday
2215static void
Filip Bozutae400e112020-08-11 18:45:49 +02002216print_settimeofday(void *cpu_env, const struct syscallname *name,
2217 abi_long arg0, abi_long arg1, abi_long arg2,
2218 abi_long arg3, abi_long arg4, abi_long arg5)
Philippe Mathieu-Daudé0d2187c2019-10-21 13:48:51 +02002219{
2220 print_syscall_prologue(name);
2221 print_timeval(arg0, 0);
2222 print_timezone(arg1, 1);
2223 print_syscall_epilogue(name);
2224}
2225#endif
2226
Filip Bozuta1a674ad2020-08-11 18:45:53 +02002227#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2228static void
2229print_clock_gettime(void *cpu_env, const struct syscallname *name,
2230 abi_long arg0, abi_long arg1, abi_long arg2,
2231 abi_long arg3, abi_long arg4, abi_long arg5)
2232{
2233 print_syscall_prologue(name);
2234 print_enums(clockids, arg0, 0);
2235 print_pointer(arg1, 1);
2236 print_syscall_epilogue(name);
2237}
2238#define print_clock_getres print_clock_gettime
2239#endif
2240
2241#ifdef TARGET_NR_clock_settime
2242static void
2243print_clock_settime(void *cpu_env, const struct syscallname *name,
2244 abi_long arg0, abi_long arg1, abi_long arg2,
2245 abi_long arg3, abi_long arg4, abi_long arg5)
2246{
2247 print_syscall_prologue(name);
2248 print_enums(clockids, arg0, 0);
2249 print_timespec(arg1, 1);
2250 print_syscall_epilogue(name);
2251}
2252#endif
2253
2254#ifdef TARGET_NR_getitimer
2255static void
2256print_getitimer(void *cpu_env, const struct syscallname *name,
2257 abi_long arg0, abi_long arg1, abi_long arg2,
2258 abi_long arg3, abi_long arg4, abi_long arg5)
2259{
2260 print_syscall_prologue(name);
2261 print_enums(itimer_types, arg0, 0);
2262 print_pointer(arg1, 1);
2263 print_syscall_epilogue(name);
2264}
2265#endif
2266
2267#ifdef TARGET_NR_setitimer
2268static void
2269print_setitimer(void *cpu_env, const struct syscallname *name,
2270 abi_long arg0, abi_long arg1, abi_long arg2,
2271 abi_long arg3, abi_long arg4, abi_long arg5)
2272{
2273 print_syscall_prologue(name);
2274 print_enums(itimer_types, arg0, 0);
2275 print_itimerval(arg1, 0);
2276 print_pointer(arg2, 1);
2277 print_syscall_epilogue(name);
2278}
2279#endif
2280
Mika Westerberg74d753a2009-04-07 16:57:29 +03002281#ifdef TARGET_NR_link
2282static void
Filip Bozutae400e112020-08-11 18:45:49 +02002283print_link(void *cpu_env, const struct syscallname *name,
2284 abi_long arg0, abi_long arg1, abi_long arg2,
2285 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03002286{
2287 print_syscall_prologue(name);
2288 print_string(arg0, 0);
2289 print_string(arg1, 1);
2290 print_syscall_epilogue(name);
2291}
2292#endif
2293
2294#ifdef TARGET_NR_linkat
2295static void
Filip Bozutae400e112020-08-11 18:45:49 +02002296print_linkat(void *cpu_env, const struct syscallname *name,
2297 abi_long arg0, abi_long arg1, abi_long arg2,
2298 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03002299{
2300 print_syscall_prologue(name);
2301 print_at_dirfd(arg0, 0);
2302 print_string(arg1, 0);
2303 print_at_dirfd(arg2, 0);
2304 print_string(arg3, 0);
2305 print_flags(at_file_flags, arg4, 1);
2306 print_syscall_epilogue(name);
2307}
2308#endif
2309
Laurent Vivier608e5592011-04-07 00:25:32 +02002310#ifdef TARGET_NR__llseek
2311static void
Filip Bozutae400e112020-08-11 18:45:49 +02002312print__llseek(void *cpu_env, const struct syscallname *name,
2313 abi_long arg0, abi_long arg1, abi_long arg2,
2314 abi_long arg3, abi_long arg4, abi_long arg5)
Laurent Vivier608e5592011-04-07 00:25:32 +02002315{
2316 const char *whence = "UNKNOWN";
2317 print_syscall_prologue(name);
2318 print_raw_param("%d", arg0, 0);
2319 print_raw_param("%ld", arg1, 0);
2320 print_raw_param("%ld", arg2, 0);
2321 print_pointer(arg3, 0);
2322 switch(arg4) {
2323 case SEEK_SET: whence = "SEEK_SET"; break;
2324 case SEEK_CUR: whence = "SEEK_CUR"; break;
2325 case SEEK_END: whence = "SEEK_END"; break;
2326 }
Josh Kunz4b25a502020-02-03 18:54:14 -08002327 qemu_log("%s", whence);
Laurent Vivier608e5592011-04-07 00:25:32 +02002328 print_syscall_epilogue(name);
2329}
2330#endif
2331
Filip Bozutaaf861de2020-06-19 14:33:29 +02002332#ifdef TARGET_NR_lseek
2333static void
Filip Bozutae400e112020-08-11 18:45:49 +02002334print_lseek(void *cpu_env, const struct syscallname *name,
2335 abi_long arg0, abi_long arg1, abi_long arg2,
2336 abi_long arg3, abi_long arg4, abi_long arg5)
Filip Bozutaaf861de2020-06-19 14:33:29 +02002337{
2338 print_syscall_prologue(name);
2339 print_raw_param("%d", arg0, 0);
2340 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2341 switch (arg2) {
2342 case SEEK_SET:
2343 qemu_log("SEEK_SET"); break;
2344 case SEEK_CUR:
2345 qemu_log("SEEK_CUR"); break;
2346 case SEEK_END:
2347 qemu_log("SEEK_END"); break;
2348#ifdef SEEK_DATA
2349 case SEEK_DATA:
2350 qemu_log("SEEK_DATA"); break;
2351#endif
2352#ifdef SEEK_HOLE
2353 case SEEK_HOLE:
2354 qemu_log("SEEK_HOLE"); break;
2355#endif
2356 default:
2357 print_raw_param("%#x", arg2, 1);
2358 }
2359 print_syscall_epilogue(name);
2360}
2361#endif
2362
Filip Bozuta7c89f342020-08-11 18:45:50 +02002363#ifdef TARGET_NR_truncate
2364static void
2365print_truncate(void *cpu_env, const struct syscallname *name,
2366 abi_long arg0, abi_long arg1, abi_long arg2,
2367 abi_long arg3, abi_long arg4, abi_long arg5)
2368{
2369 print_syscall_prologue(name);
2370 print_string(arg0, 0);
2371 print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
2372 print_syscall_epilogue(name);
2373}
2374#endif
2375
2376#ifdef TARGET_NR_truncate64
2377static void
2378print_truncate64(void *cpu_env, const struct syscallname *name,
2379 abi_long arg0, abi_long arg1, abi_long arg2,
2380 abi_long arg3, abi_long arg4, abi_long arg5)
2381{
2382 print_syscall_prologue(name);
2383 print_string(arg0, 0);
2384 if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
2385 arg1 = arg2;
2386 arg2 = arg3;
2387 }
2388 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2389 print_syscall_epilogue(name);
2390}
2391#endif
2392
2393#ifdef TARGET_NR_ftruncate64
2394static void
2395print_ftruncate64(void *cpu_env, const struct syscallname *name,
2396 abi_long arg0, abi_long arg1, abi_long arg2,
2397 abi_long arg3, abi_long arg4, abi_long arg5)
2398{
2399 print_syscall_prologue(name);
2400 print_raw_param("%d", arg0, 0);
2401 if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
2402 arg1 = arg2;
2403 arg2 = arg3;
2404 }
2405 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2406 print_syscall_epilogue(name);
2407}
2408#endif
2409
Filip Bozuta02e5d7d2020-08-11 18:45:51 +02002410#ifdef TARGET_NR_mlockall
2411static void
2412print_mlockall(void *cpu_env, const struct syscallname *name,
2413 abi_long arg0, abi_long arg1, abi_long arg2,
2414 abi_long arg3, abi_long arg4, abi_long arg5)
2415{
2416 print_syscall_prologue(name);
2417 print_flags(mlockall_flags, arg0, 1);
2418 print_syscall_epilogue(name);
2419}
2420#endif
2421
Laurent Vivier8997d1b2016-06-11 02:19:46 +02002422#if defined(TARGET_NR_socket)
2423static void
Filip Bozutae400e112020-08-11 18:45:49 +02002424print_socket(void *cpu_env, const struct syscallname *name,
Laurent Vivier8997d1b2016-06-11 02:19:46 +02002425 abi_long arg0, abi_long arg1, abi_long arg2,
2426 abi_long arg3, abi_long arg4, abi_long arg5)
2427{
2428 abi_ulong domain = arg0, type = arg1, protocol = arg2;
2429
2430 print_syscall_prologue(name);
2431 print_socket_domain(domain);
Josh Kunz4b25a502020-02-03 18:54:14 -08002432 qemu_log(",");
Laurent Vivier8997d1b2016-06-11 02:19:46 +02002433 print_socket_type(type);
Josh Kunz4b25a502020-02-03 18:54:14 -08002434 qemu_log(",");
Laurent Vivier8997d1b2016-06-11 02:19:46 +02002435 if (domain == AF_PACKET ||
2436 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2437 protocol = tswap16(protocol);
2438 }
2439 print_socket_protocol(domain, type, protocol);
2440 print_syscall_epilogue(name);
2441}
2442
2443#endif
2444
Philippe Mathieu-Daudébb105402019-10-21 13:48:55 +02002445#if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002446
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002447static void print_sockfd(abi_long sockfd, int last)
2448{
2449 print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
2450}
2451
2452#endif
2453
2454#if defined(TARGET_NR_socketcall)
2455
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002456#define get_user_ualx(x, gaddr, idx) \
2457 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2458
2459static void do_print_socket(const char *name, abi_long arg1)
2460{
2461 abi_ulong domain, type, protocol;
2462
2463 get_user_ualx(domain, arg1, 0);
2464 get_user_ualx(type, arg1, 1);
2465 get_user_ualx(protocol, arg1, 2);
Josh Kunz4b25a502020-02-03 18:54:14 -08002466 qemu_log("%s(", name);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002467 print_socket_domain(domain);
Josh Kunz4b25a502020-02-03 18:54:14 -08002468 qemu_log(",");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002469 print_socket_type(type);
Josh Kunz4b25a502020-02-03 18:54:14 -08002470 qemu_log(",");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002471 if (domain == AF_PACKET ||
2472 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2473 protocol = tswap16(protocol);
2474 }
2475 print_socket_protocol(domain, type, protocol);
Josh Kunz4b25a502020-02-03 18:54:14 -08002476 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002477}
2478
2479static void do_print_sockaddr(const char *name, abi_long arg1)
2480{
2481 abi_ulong sockfd, addr, addrlen;
2482
2483 get_user_ualx(sockfd, arg1, 0);
2484 get_user_ualx(addr, arg1, 1);
2485 get_user_ualx(addrlen, arg1, 2);
2486
Josh Kunz4b25a502020-02-03 18:54:14 -08002487 qemu_log("%s(", name);
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002488 print_sockfd(sockfd, 0);
Philippe Mathieu-Daudé42b15d72019-10-21 13:48:56 +02002489 print_sockaddr(addr, addrlen, 0);
Josh Kunz4b25a502020-02-03 18:54:14 -08002490 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002491}
2492
2493static void do_print_listen(const char *name, abi_long arg1)
2494{
2495 abi_ulong sockfd, backlog;
2496
2497 get_user_ualx(sockfd, arg1, 0);
2498 get_user_ualx(backlog, arg1, 1);
2499
Josh Kunz4b25a502020-02-03 18:54:14 -08002500 qemu_log("%s(", name);
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002501 print_sockfd(sockfd, 0);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002502 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
Josh Kunz4b25a502020-02-03 18:54:14 -08002503 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002504}
2505
2506static void do_print_socketpair(const char *name, abi_long arg1)
2507{
2508 abi_ulong domain, type, protocol, tab;
2509
2510 get_user_ualx(domain, arg1, 0);
2511 get_user_ualx(type, arg1, 1);
2512 get_user_ualx(protocol, arg1, 2);
2513 get_user_ualx(tab, arg1, 3);
2514
Josh Kunz4b25a502020-02-03 18:54:14 -08002515 qemu_log("%s(", name);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002516 print_socket_domain(domain);
Josh Kunz4b25a502020-02-03 18:54:14 -08002517 qemu_log(",");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002518 print_socket_type(type);
Josh Kunz4b25a502020-02-03 18:54:14 -08002519 qemu_log(",");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002520 print_socket_protocol(domain, type, protocol);
Josh Kunz4b25a502020-02-03 18:54:14 -08002521 qemu_log(",");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002522 print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
Josh Kunz4b25a502020-02-03 18:54:14 -08002523 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002524}
2525
2526static void do_print_sendrecv(const char *name, abi_long arg1)
2527{
2528 abi_ulong sockfd, msg, len, flags;
2529
2530 get_user_ualx(sockfd, arg1, 0);
2531 get_user_ualx(msg, arg1, 1);
2532 get_user_ualx(len, arg1, 2);
2533 get_user_ualx(flags, arg1, 3);
2534
Josh Kunz4b25a502020-02-03 18:54:14 -08002535 qemu_log("%s(", name);
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002536 print_sockfd(sockfd, 0);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002537 print_buf(msg, len, 0);
2538 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2539 print_flags(msg_flags, flags, 1);
Josh Kunz4b25a502020-02-03 18:54:14 -08002540 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002541}
2542
2543static void do_print_msgaddr(const char *name, abi_long arg1)
2544{
2545 abi_ulong sockfd, msg, len, flags, addr, addrlen;
2546
2547 get_user_ualx(sockfd, arg1, 0);
2548 get_user_ualx(msg, arg1, 1);
2549 get_user_ualx(len, arg1, 2);
2550 get_user_ualx(flags, arg1, 3);
2551 get_user_ualx(addr, arg1, 4);
2552 get_user_ualx(addrlen, arg1, 5);
2553
Josh Kunz4b25a502020-02-03 18:54:14 -08002554 qemu_log("%s(", name);
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002555 print_sockfd(sockfd, 0);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002556 print_buf(msg, len, 0);
2557 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2558 print_flags(msg_flags, flags, 0);
Philippe Mathieu-Daudé42b15d72019-10-21 13:48:56 +02002559 print_sockaddr(addr, addrlen, 0);
Josh Kunz4b25a502020-02-03 18:54:14 -08002560 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002561}
2562
2563static void do_print_shutdown(const char *name, abi_long arg1)
2564{
2565 abi_ulong sockfd, how;
2566
2567 get_user_ualx(sockfd, arg1, 0);
2568 get_user_ualx(how, arg1, 1);
2569
Josh Kunz4b25a502020-02-03 18:54:14 -08002570 qemu_log("shutdown(");
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002571 print_sockfd(sockfd, 0);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002572 switch (how) {
2573 case SHUT_RD:
Josh Kunz4b25a502020-02-03 18:54:14 -08002574 qemu_log("SHUT_RD");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002575 break;
2576 case SHUT_WR:
Josh Kunz4b25a502020-02-03 18:54:14 -08002577 qemu_log("SHUT_WR");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002578 break;
2579 case SHUT_RDWR:
Josh Kunz4b25a502020-02-03 18:54:14 -08002580 qemu_log("SHUT_RDWR");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002581 break;
2582 default:
2583 print_raw_param(TARGET_ABI_FMT_ld, how, 1);
2584 break;
2585 }
Josh Kunz4b25a502020-02-03 18:54:14 -08002586 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002587}
2588
2589static void do_print_msg(const char *name, abi_long arg1)
2590{
2591 abi_ulong sockfd, msg, flags;
2592
2593 get_user_ualx(sockfd, arg1, 0);
2594 get_user_ualx(msg, arg1, 1);
2595 get_user_ualx(flags, arg1, 2);
2596
Josh Kunz4b25a502020-02-03 18:54:14 -08002597 qemu_log("%s(", name);
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002598 print_sockfd(sockfd, 0);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002599 print_pointer(msg, 0);
2600 print_flags(msg_flags, flags, 1);
Josh Kunz4b25a502020-02-03 18:54:14 -08002601 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002602}
2603
2604static void do_print_sockopt(const char *name, abi_long arg1)
2605{
2606 abi_ulong sockfd, level, optname, optval, optlen;
2607
2608 get_user_ualx(sockfd, arg1, 0);
2609 get_user_ualx(level, arg1, 1);
2610 get_user_ualx(optname, arg1, 2);
2611 get_user_ualx(optval, arg1, 3);
2612 get_user_ualx(optlen, arg1, 4);
2613
Josh Kunz4b25a502020-02-03 18:54:14 -08002614 qemu_log("%s(", name);
Philippe Mathieu-Daudéd84fe1e2019-10-21 13:48:54 +02002615 print_sockfd(sockfd, 0);
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002616 switch (level) {
2617 case SOL_TCP:
Josh Kunz4b25a502020-02-03 18:54:14 -08002618 qemu_log("SOL_TCP,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002619 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2620 print_pointer(optval, 0);
2621 break;
2622 case SOL_IP:
Josh Kunz4b25a502020-02-03 18:54:14 -08002623 qemu_log("SOL_IP,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002624 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2625 print_pointer(optval, 0);
2626 break;
2627 case SOL_RAW:
Josh Kunz4b25a502020-02-03 18:54:14 -08002628 qemu_log("SOL_RAW,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002629 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2630 print_pointer(optval, 0);
2631 break;
2632 case TARGET_SOL_SOCKET:
Josh Kunz4b25a502020-02-03 18:54:14 -08002633 qemu_log("SOL_SOCKET,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002634 switch (optname) {
2635 case TARGET_SO_DEBUG:
Josh Kunz4b25a502020-02-03 18:54:14 -08002636 qemu_log("SO_DEBUG,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002637print_optint:
2638 print_number(optval, 0);
2639 break;
2640 case TARGET_SO_REUSEADDR:
Josh Kunz4b25a502020-02-03 18:54:14 -08002641 qemu_log("SO_REUSEADDR,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002642 goto print_optint;
Yunqiang Su113a9dd2018-10-30 13:55:08 +01002643 case TARGET_SO_REUSEPORT:
Josh Kunz4b25a502020-02-03 18:54:14 -08002644 qemu_log("SO_REUSEPORT,");
Yunqiang Su113a9dd2018-10-30 13:55:08 +01002645 goto print_optint;
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002646 case TARGET_SO_TYPE:
Josh Kunz4b25a502020-02-03 18:54:14 -08002647 qemu_log("SO_TYPE,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002648 goto print_optint;
2649 case TARGET_SO_ERROR:
Josh Kunz4b25a502020-02-03 18:54:14 -08002650 qemu_log("SO_ERROR,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002651 goto print_optint;
2652 case TARGET_SO_DONTROUTE:
Josh Kunz4b25a502020-02-03 18:54:14 -08002653 qemu_log("SO_DONTROUTE,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002654 goto print_optint;
2655 case TARGET_SO_BROADCAST:
Josh Kunz4b25a502020-02-03 18:54:14 -08002656 qemu_log("SO_BROADCAST,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002657 goto print_optint;
2658 case TARGET_SO_SNDBUF:
Josh Kunz4b25a502020-02-03 18:54:14 -08002659 qemu_log("SO_SNDBUF,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002660 goto print_optint;
2661 case TARGET_SO_RCVBUF:
Josh Kunz4b25a502020-02-03 18:54:14 -08002662 qemu_log("SO_RCVBUF,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002663 goto print_optint;
2664 case TARGET_SO_KEEPALIVE:
Josh Kunz4b25a502020-02-03 18:54:14 -08002665 qemu_log("SO_KEEPALIVE,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002666 goto print_optint;
2667 case TARGET_SO_OOBINLINE:
Josh Kunz4b25a502020-02-03 18:54:14 -08002668 qemu_log("SO_OOBINLINE,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002669 goto print_optint;
2670 case TARGET_SO_NO_CHECK:
Josh Kunz4b25a502020-02-03 18:54:14 -08002671 qemu_log("SO_NO_CHECK,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002672 goto print_optint;
2673 case TARGET_SO_PRIORITY:
Josh Kunz4b25a502020-02-03 18:54:14 -08002674 qemu_log("SO_PRIORITY,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002675 goto print_optint;
2676 case TARGET_SO_BSDCOMPAT:
Josh Kunz4b25a502020-02-03 18:54:14 -08002677 qemu_log("SO_BSDCOMPAT,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002678 goto print_optint;
2679 case TARGET_SO_PASSCRED:
Josh Kunz4b25a502020-02-03 18:54:14 -08002680 qemu_log("SO_PASSCRED,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002681 goto print_optint;
2682 case TARGET_SO_TIMESTAMP:
Josh Kunz4b25a502020-02-03 18:54:14 -08002683 qemu_log("SO_TIMESTAMP,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002684 goto print_optint;
2685 case TARGET_SO_RCVLOWAT:
Josh Kunz4b25a502020-02-03 18:54:14 -08002686 qemu_log("SO_RCVLOWAT,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002687 goto print_optint;
2688 case TARGET_SO_RCVTIMEO:
Josh Kunz4b25a502020-02-03 18:54:14 -08002689 qemu_log("SO_RCVTIMEO,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002690 print_timeval(optval, 0);
2691 break;
2692 case TARGET_SO_SNDTIMEO:
Josh Kunz4b25a502020-02-03 18:54:14 -08002693 qemu_log("SO_SNDTIMEO,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002694 print_timeval(optval, 0);
2695 break;
2696 case TARGET_SO_ATTACH_FILTER: {
2697 struct target_sock_fprog *fprog;
2698
Josh Kunz4b25a502020-02-03 18:54:14 -08002699 qemu_log("SO_ATTACH_FILTER,");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002700
2701 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
2702 struct target_sock_filter *filter;
Josh Kunz4b25a502020-02-03 18:54:14 -08002703 qemu_log("{");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002704 if (lock_user_struct(VERIFY_READ, filter,
2705 tswapal(fprog->filter), 0)) {
2706 int i;
2707 for (i = 0; i < tswap16(fprog->len) - 1; i++) {
Josh Kunz4b25a502020-02-03 18:54:14 -08002708 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002709 i, tswap16(filter[i].code),
2710 filter[i].jt, filter[i].jf,
2711 tswap32(filter[i].k));
2712 }
Josh Kunz4b25a502020-02-03 18:54:14 -08002713 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002714 i, tswap16(filter[i].code),
2715 filter[i].jt, filter[i].jf,
2716 tswap32(filter[i].k));
2717 } else {
Josh Kunz4b25a502020-02-03 18:54:14 -08002718 qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002719 }
Josh Kunz4b25a502020-02-03 18:54:14 -08002720 qemu_log(",%d},", tswap16(fprog->len));
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002721 unlock_user(fprog, optval, 0);
2722 } else {
2723 print_pointer(optval, 0);
2724 }
2725 break;
2726 }
2727 default:
2728 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2729 print_pointer(optval, 0);
2730 break;
2731 }
2732 break;
2733 default:
2734 print_raw_param(TARGET_ABI_FMT_ld, level, 0);
2735 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2736 print_pointer(optval, 0);
2737 break;
2738 }
2739 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
Josh Kunz4b25a502020-02-03 18:54:14 -08002740 qemu_log(")");
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002741}
2742
2743#define PRINT_SOCKOP(name, func) \
Aleksandar Markovicff71a452016-09-22 18:56:57 +02002744 [TARGET_SYS_##name] = { #name, func }
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002745
2746static struct {
2747 const char *name;
2748 void (*print)(const char *, abi_long);
2749} scall[] = {
Aleksandar Markovicff71a452016-09-22 18:56:57 +02002750 PRINT_SOCKOP(SOCKET, do_print_socket),
2751 PRINT_SOCKOP(BIND, do_print_sockaddr),
2752 PRINT_SOCKOP(CONNECT, do_print_sockaddr),
2753 PRINT_SOCKOP(LISTEN, do_print_listen),
2754 PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
2755 PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
2756 PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
2757 PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
2758 PRINT_SOCKOP(SEND, do_print_sendrecv),
2759 PRINT_SOCKOP(RECV, do_print_sendrecv),
2760 PRINT_SOCKOP(SENDTO, do_print_msgaddr),
2761 PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
2762 PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
2763 PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
2764 PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
2765 PRINT_SOCKOP(SENDMSG, do_print_msg),
2766 PRINT_SOCKOP(RECVMSG, do_print_msg),
2767 PRINT_SOCKOP(ACCEPT4, NULL),
2768 PRINT_SOCKOP(RECVMMSG, NULL),
2769 PRINT_SOCKOP(SENDMMSG, NULL),
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002770};
2771
2772static void
Filip Bozutae400e112020-08-11 18:45:49 +02002773print_socketcall(void *cpu_env, const struct syscallname *name,
Laurent Vivierfb3aabf2016-06-11 02:19:45 +02002774 abi_long arg0, abi_long arg1, abi_long arg2,
2775 abi_long arg3, abi_long arg4, abi_long arg5)
2776{
2777 if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
2778 scall[arg0].print(scall[arg0].name, arg1);
2779 return;
2780 }
2781 print_syscall_prologue(name);
2782 print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
2783 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2784 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2785 print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
2786 print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
2787 print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
2788 print_syscall_epilogue(name);
2789}
2790#endif
2791
Philippe Mathieu-Daudébb105402019-10-21 13:48:55 +02002792#if defined(TARGET_NR_bind)
2793static void
Filip Bozutae400e112020-08-11 18:45:49 +02002794print_bind(void *cpu_env, const struct syscallname *name,
Philippe Mathieu-Daudébb105402019-10-21 13:48:55 +02002795 abi_long arg0, abi_long arg1, abi_long arg2,
2796 abi_long arg3, abi_long arg4, abi_long arg5)
2797{
2798 print_syscall_prologue(name);
2799 print_sockfd(arg0, 0);
2800 print_sockaddr(arg1, arg2, 1);
2801 print_syscall_epilogue(name);
2802}
2803#endif
2804
Mika Westerberg74d753a2009-04-07 16:57:29 +03002805#if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2806 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2807static void
Filip Bozutae400e112020-08-11 18:45:49 +02002808print_stat(void *cpu_env, const struct syscallname *name,
2809 abi_long arg0, abi_long arg1, abi_long arg2,
2810 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03002811{
2812 print_syscall_prologue(name);
2813 print_string(arg0, 0);
2814 print_pointer(arg1, 1);
2815 print_syscall_epilogue(name);
2816}
2817#define print_lstat print_stat
2818#define print_stat64 print_stat
2819#define print_lstat64 print_stat
2820#endif
2821
2822#if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2823static void
Filip Bozutae400e112020-08-11 18:45:49 +02002824print_fstat(void *cpu_env, const struct syscallname *name,
2825 abi_long arg0, abi_long arg1, abi_long arg2,
2826 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03002827{
2828 print_syscall_prologue(name);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01002829 print_raw_param("%d", arg0, 0);
Mika Westerberg74d753a2009-04-07 16:57:29 +03002830 print_pointer(arg1, 1);
2831 print_syscall_epilogue(name);
2832}
2833#define print_fstat64 print_fstat
2834#endif
2835
2836#ifdef TARGET_NR_mkdir
2837static void
Filip Bozutae400e112020-08-11 18:45:49 +02002838print_mkdir(void *cpu_env, const struct syscallname *name,
2839 abi_long arg0, abi_long arg1, abi_long arg2,
2840 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03002841{
2842 print_syscall_prologue(name);
2843 print_string(arg0, 0);
2844 print_file_mode(arg1, 1);
2845 print_syscall_epilogue(name);
2846}
2847#endif
2848
2849#ifdef TARGET_NR_mkdirat
2850static void
Filip Bozutae400e112020-08-11 18:45:49 +02002851print_mkdirat(void *cpu_env, const struct syscallname *name,
2852 abi_long arg0, abi_long arg1, abi_long arg2,
2853 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03002854{
2855 print_syscall_prologue(name);
2856 print_at_dirfd(arg0, 0);
2857 print_string(arg1, 0);
2858 print_file_mode(arg2, 1);
2859 print_syscall_epilogue(name);
2860}
2861#endif
2862
Laurent Vivier4de596c2011-02-15 21:10:43 +01002863#ifdef TARGET_NR_rmdir
2864static void
Filip Bozutae400e112020-08-11 18:45:49 +02002865print_rmdir(void *cpu_env, const struct syscallname *name,
2866 abi_long arg0, abi_long arg1, abi_long arg2,
2867 abi_long arg3, abi_long arg4, abi_long arg5)
Laurent Vivier4de596c2011-02-15 21:10:43 +01002868{
2869 print_syscall_prologue(name);
2870 print_string(arg0, 0);
2871 print_syscall_epilogue(name);
2872}
2873#endif
2874
Laurent Vivier608e5592011-04-07 00:25:32 +02002875#ifdef TARGET_NR_rt_sigaction
2876static void
Filip Bozutae400e112020-08-11 18:45:49 +02002877print_rt_sigaction(void *cpu_env, const struct syscallname *name,
2878 abi_long arg0, abi_long arg1, abi_long arg2,
2879 abi_long arg3, abi_long arg4, abi_long arg5)
Laurent Vivier608e5592011-04-07 00:25:32 +02002880{
2881 print_syscall_prologue(name);
2882 print_signal(arg0, 0);
2883 print_pointer(arg1, 0);
2884 print_pointer(arg2, 1);
2885 print_syscall_epilogue(name);
2886}
2887#endif
2888
2889#ifdef TARGET_NR_rt_sigprocmask
2890static void
Filip Bozutae400e112020-08-11 18:45:49 +02002891print_rt_sigprocmask(void *cpu_env, const struct syscallname *name,
2892 abi_long arg0, abi_long arg1, abi_long arg2,
2893 abi_long arg3, abi_long arg4, abi_long arg5)
Laurent Vivier608e5592011-04-07 00:25:32 +02002894{
2895 const char *how = "UNKNOWN";
2896 print_syscall_prologue(name);
2897 switch(arg0) {
2898 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
2899 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
2900 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
2901 }
Josh Kunz4b25a502020-02-03 18:54:14 -08002902 qemu_log("%s,", how);
Laurent Vivier608e5592011-04-07 00:25:32 +02002903 print_pointer(arg1, 0);
2904 print_pointer(arg2, 1);
2905 print_syscall_epilogue(name);
2906}
2907#endif
2908
Miloš Stojanović51622642017-05-15 16:59:42 +02002909#ifdef TARGET_NR_rt_sigqueueinfo
2910static void
Filip Bozutae400e112020-08-11 18:45:49 +02002911print_rt_sigqueueinfo(void *cpu_env, const struct syscallname *name,
2912 abi_long arg0, abi_long arg1, abi_long arg2,
2913 abi_long arg3, abi_long arg4, abi_long arg5)
Miloš Stojanović51622642017-05-15 16:59:42 +02002914{
Miloš Stojanovićba9fcea2017-05-15 16:59:49 +02002915 void *p;
2916 target_siginfo_t uinfo;
2917
Miloš Stojanović51622642017-05-15 16:59:42 +02002918 print_syscall_prologue(name);
2919 print_raw_param("%d", arg0, 0);
2920 print_signal(arg1, 0);
Miloš Stojanovićba9fcea2017-05-15 16:59:49 +02002921 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
2922 if (p) {
2923 get_target_siginfo(&uinfo, p);
2924 print_siginfo(&uinfo);
2925
2926 unlock_user(p, arg2, 0);
2927 } else {
2928 print_pointer(arg2, 1);
2929 }
Miloš Stojanović51622642017-05-15 16:59:42 +02002930 print_syscall_epilogue(name);
2931}
2932#endif
2933
Miloš Stojanović243e0fe2017-05-15 16:59:47 +02002934#ifdef TARGET_NR_rt_tgsigqueueinfo
2935static void
Filip Bozutae400e112020-08-11 18:45:49 +02002936print_rt_tgsigqueueinfo(void *cpu_env, const struct syscallname *name,
2937 abi_long arg0, abi_long arg1, abi_long arg2,
2938 abi_long arg3, abi_long arg4, abi_long arg5)
Miloš Stojanović243e0fe2017-05-15 16:59:47 +02002939{
Miloš Stojanovićba9fcea2017-05-15 16:59:49 +02002940 void *p;
2941 target_siginfo_t uinfo;
2942
Miloš Stojanović243e0fe2017-05-15 16:59:47 +02002943 print_syscall_prologue(name);
2944 print_raw_param("%d", arg0, 0);
2945 print_raw_param("%d", arg1, 0);
2946 print_signal(arg2, 0);
Miloš Stojanovićba9fcea2017-05-15 16:59:49 +02002947 p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
2948 if (p) {
2949 get_target_siginfo(&uinfo, p);
2950 print_siginfo(&uinfo);
2951
2952 unlock_user(p, arg3, 0);
2953 } else {
2954 print_pointer(arg3, 1);
2955 }
Miloš Stojanović243e0fe2017-05-15 16:59:47 +02002956 print_syscall_epilogue(name);
2957}
2958#endif
2959
Aleksandar Markovicda2c8ad2016-09-22 18:56:58 +02002960#ifdef TARGET_NR_syslog
2961static void
2962print_syslog_action(abi_ulong arg, int last)
2963{
2964 const char *type;
2965
2966 switch (arg) {
2967 case TARGET_SYSLOG_ACTION_CLOSE: {
2968 type = "SYSLOG_ACTION_CLOSE";
2969 break;
2970 }
2971 case TARGET_SYSLOG_ACTION_OPEN: {
2972 type = "SYSLOG_ACTION_OPEN";
2973 break;
2974 }
2975 case TARGET_SYSLOG_ACTION_READ: {
2976 type = "SYSLOG_ACTION_READ";
2977 break;
2978 }
2979 case TARGET_SYSLOG_ACTION_READ_ALL: {
2980 type = "SYSLOG_ACTION_READ_ALL";
2981 break;
2982 }
2983 case TARGET_SYSLOG_ACTION_READ_CLEAR: {
2984 type = "SYSLOG_ACTION_READ_CLEAR";
2985 break;
2986 }
2987 case TARGET_SYSLOG_ACTION_CLEAR: {
2988 type = "SYSLOG_ACTION_CLEAR";
2989 break;
2990 }
2991 case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
2992 type = "SYSLOG_ACTION_CONSOLE_OFF";
2993 break;
2994 }
2995 case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
2996 type = "SYSLOG_ACTION_CONSOLE_ON";
2997 break;
2998 }
2999 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
3000 type = "SYSLOG_ACTION_CONSOLE_LEVEL";
3001 break;
3002 }
3003 case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
3004 type = "SYSLOG_ACTION_SIZE_UNREAD";
3005 break;
3006 }
3007 case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
3008 type = "SYSLOG_ACTION_SIZE_BUFFER";
3009 break;
3010 }
3011 default: {
3012 print_raw_param("%ld", arg, last);
3013 return;
3014 }
3015 }
Josh Kunz4b25a502020-02-03 18:54:14 -08003016 qemu_log("%s%s", type, get_comma(last));
Aleksandar Markovicda2c8ad2016-09-22 18:56:58 +02003017}
3018
3019static void
Filip Bozutae400e112020-08-11 18:45:49 +02003020print_syslog(void *cpu_env, const struct syscallname *name,
3021 abi_long arg0, abi_long arg1, abi_long arg2,
3022 abi_long arg3, abi_long arg4, abi_long arg5)
Aleksandar Markovicda2c8ad2016-09-22 18:56:58 +02003023{
3024 print_syscall_prologue(name);
3025 print_syslog_action(arg0, 0);
3026 print_pointer(arg1, 0);
3027 print_raw_param("%d", arg2, 1);
3028 print_syscall_epilogue(name);
3029}
3030#endif
3031
Mika Westerberg74d753a2009-04-07 16:57:29 +03003032#ifdef TARGET_NR_mknod
3033static void
Filip Bozutae400e112020-08-11 18:45:49 +02003034print_mknod(void *cpu_env, const struct syscallname *name,
3035 abi_long arg0, abi_long arg1, abi_long arg2,
3036 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003037{
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003038 int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
Mika Westerberg74d753a2009-04-07 16:57:29 +03003039
3040 print_syscall_prologue(name);
3041 print_string(arg0, 0);
3042 print_file_mode(arg1, (hasdev == 0));
3043 if (hasdev) {
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003044 print_raw_param("makedev(%d", major(arg2), 0);
3045 print_raw_param("%d)", minor(arg2), 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003046 }
3047 print_syscall_epilogue(name);
3048}
3049#endif
3050
3051#ifdef TARGET_NR_mknodat
3052static void
Filip Bozutae400e112020-08-11 18:45:49 +02003053print_mknodat(void *cpu_env, const struct syscallname *name,
3054 abi_long arg0, abi_long arg1, abi_long arg2,
3055 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003056{
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003057 int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
Mika Westerberg74d753a2009-04-07 16:57:29 +03003058
3059 print_syscall_prologue(name);
3060 print_at_dirfd(arg0, 0);
3061 print_string(arg1, 0);
3062 print_file_mode(arg2, (hasdev == 0));
3063 if (hasdev) {
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003064 print_raw_param("makedev(%d", major(arg3), 0);
3065 print_raw_param("%d)", minor(arg3), 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003066 }
3067 print_syscall_epilogue(name);
3068}
3069#endif
3070
3071#ifdef TARGET_NR_mq_open
3072static void
Filip Bozutae400e112020-08-11 18:45:49 +02003073print_mq_open(void *cpu_env, const struct syscallname *name,
3074 abi_long arg0, abi_long arg1, abi_long arg2,
3075 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003076{
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003077 int is_creat = (arg1 & TARGET_O_CREAT);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003078
3079 print_syscall_prologue(name);
3080 print_string(arg0, 0);
3081 print_open_flags(arg1, (is_creat == 0));
3082 if (is_creat) {
3083 print_file_mode(arg2, 0);
3084 print_pointer(arg3, 1);
3085 }
3086 print_syscall_epilogue(name);
3087}
3088#endif
3089
3090#ifdef TARGET_NR_open
3091static void
Filip Bozutae400e112020-08-11 18:45:49 +02003092print_open(void *cpu_env, const struct syscallname *name,
3093 abi_long arg0, abi_long arg1, abi_long arg2,
3094 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003095{
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003096 int is_creat = (arg1 & TARGET_O_CREAT);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003097
3098 print_syscall_prologue(name);
3099 print_string(arg0, 0);
3100 print_open_flags(arg1, (is_creat == 0));
3101 if (is_creat)
3102 print_file_mode(arg2, 1);
3103 print_syscall_epilogue(name);
3104}
3105#endif
3106
3107#ifdef TARGET_NR_openat
3108static void
Filip Bozutae400e112020-08-11 18:45:49 +02003109print_openat(void *cpu_env, const struct syscallname *name,
3110 abi_long arg0, abi_long arg1, abi_long arg2,
3111 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003112{
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003113 int is_creat = (arg2 & TARGET_O_CREAT);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003114
3115 print_syscall_prologue(name);
3116 print_at_dirfd(arg0, 0);
3117 print_string(arg1, 0);
3118 print_open_flags(arg2, (is_creat == 0));
3119 if (is_creat)
3120 print_file_mode(arg3, 1);
3121 print_syscall_epilogue(name);
3122}
3123#endif
3124
3125#ifdef TARGET_NR_mq_unlink
3126static void
Filip Bozutae400e112020-08-11 18:45:49 +02003127print_mq_unlink(void *cpu_env, const struct syscallname *name,
3128 abi_long arg0, abi_long arg1, abi_long arg2,
3129 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003130{
3131 print_syscall_prologue(name);
3132 print_string(arg0, 1);
3133 print_syscall_epilogue(name);
3134}
3135#endif
3136
3137#if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3138static void
Filip Bozutae400e112020-08-11 18:45:49 +02003139print_fstatat64(void *cpu_env, const struct syscallname *name,
3140 abi_long arg0, abi_long arg1, abi_long arg2,
3141 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003142{
3143 print_syscall_prologue(name);
3144 print_at_dirfd(arg0, 0);
3145 print_string(arg1, 0);
3146 print_pointer(arg2, 0);
3147 print_flags(at_file_flags, arg3, 1);
3148 print_syscall_epilogue(name);
3149}
3150#define print_newfstatat print_fstatat64
3151#endif
3152
3153#ifdef TARGET_NR_readlink
3154static void
Filip Bozutae400e112020-08-11 18:45:49 +02003155print_readlink(void *cpu_env, const struct syscallname *name,
3156 abi_long arg0, abi_long arg1, abi_long arg2,
3157 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003158{
3159 print_syscall_prologue(name);
3160 print_string(arg0, 0);
3161 print_pointer(arg1, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003162 print_raw_param("%u", arg2, 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003163 print_syscall_epilogue(name);
3164}
3165#endif
3166
3167#ifdef TARGET_NR_readlinkat
3168static void
Filip Bozutae400e112020-08-11 18:45:49 +02003169print_readlinkat(void *cpu_env, const struct syscallname *name,
3170 abi_long arg0, abi_long arg1, abi_long arg2,
3171 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003172{
3173 print_syscall_prologue(name);
3174 print_at_dirfd(arg0, 0);
3175 print_string(arg1, 0);
3176 print_pointer(arg2, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003177 print_raw_param("%u", arg3, 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003178 print_syscall_epilogue(name);
3179}
3180#endif
3181
3182#ifdef TARGET_NR_rename
3183static void
Filip Bozutae400e112020-08-11 18:45:49 +02003184print_rename(void *cpu_env, const struct syscallname *name,
3185 abi_long arg0, abi_long arg1, abi_long arg2,
3186 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003187{
3188 print_syscall_prologue(name);
3189 print_string(arg0, 0);
3190 print_string(arg1, 1);
3191 print_syscall_epilogue(name);
3192}
3193#endif
3194
3195#ifdef TARGET_NR_renameat
3196static void
Filip Bozutae400e112020-08-11 18:45:49 +02003197print_renameat(void *cpu_env, const struct syscallname *name,
3198 abi_long arg0, abi_long arg1, abi_long arg2,
3199 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003200{
3201 print_syscall_prologue(name);
3202 print_at_dirfd(arg0, 0);
3203 print_string(arg1, 0);
3204 print_at_dirfd(arg2, 0);
3205 print_string(arg3, 1);
3206 print_syscall_epilogue(name);
3207}
3208#endif
3209
3210#ifdef TARGET_NR_statfs
3211static void
Filip Bozutae400e112020-08-11 18:45:49 +02003212print_statfs(void *cpu_env, const struct syscallname *name,
3213 abi_long arg0, abi_long arg1, abi_long arg2,
3214 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003215{
3216 print_syscall_prologue(name);
3217 print_string(arg0, 0);
3218 print_pointer(arg1, 1);
3219 print_syscall_epilogue(name);
3220}
Aleksandar Rikalo4f7f8922018-08-02 16:16:00 +02003221#endif
3222
3223#ifdef TARGET_NR_statfs64
3224static void
Filip Bozutae400e112020-08-11 18:45:49 +02003225print_statfs64(void *cpu_env, const struct syscallname *name,
3226 abi_long arg0, abi_long arg1, abi_long arg2,
3227 abi_long arg3, abi_long arg4, abi_long arg5)
Aleksandar Rikalo4f7f8922018-08-02 16:16:00 +02003228{
3229 print_syscall_prologue(name);
3230 print_string(arg0, 0);
3231 print_pointer(arg1, 1);
3232 print_syscall_epilogue(name);
3233}
Mika Westerberg74d753a2009-04-07 16:57:29 +03003234#endif
3235
3236#ifdef TARGET_NR_symlink
3237static void
Filip Bozutae400e112020-08-11 18:45:49 +02003238print_symlink(void *cpu_env, const struct syscallname *name,
3239 abi_long arg0, abi_long arg1, abi_long arg2,
3240 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003241{
3242 print_syscall_prologue(name);
3243 print_string(arg0, 0);
3244 print_string(arg1, 1);
3245 print_syscall_epilogue(name);
3246}
3247#endif
3248
3249#ifdef TARGET_NR_symlinkat
3250static void
Filip Bozutae400e112020-08-11 18:45:49 +02003251print_symlinkat(void *cpu_env, const struct syscallname *name,
3252 abi_long arg0, abi_long arg1, abi_long arg2,
3253 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003254{
3255 print_syscall_prologue(name);
3256 print_string(arg0, 0);
3257 print_at_dirfd(arg1, 0);
3258 print_string(arg2, 1);
3259 print_syscall_epilogue(name);
3260}
3261#endif
3262
3263#ifdef TARGET_NR_mount
3264static void
Filip Bozutae400e112020-08-11 18:45:49 +02003265print_mount(void *cpu_env, const struct syscallname *name,
3266 abi_long arg0, abi_long arg1, abi_long arg2,
3267 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003268{
3269 print_syscall_prologue(name);
3270 print_string(arg0, 0);
3271 print_string(arg1, 0);
3272 print_string(arg2, 0);
3273 print_flags(mount_flags, arg3, 0);
3274 print_pointer(arg4, 1);
3275 print_syscall_epilogue(name);
3276}
3277#endif
3278
3279#ifdef TARGET_NR_umount
3280static void
Filip Bozutae400e112020-08-11 18:45:49 +02003281print_umount(void *cpu_env, const struct syscallname *name,
3282 abi_long arg0, abi_long arg1, abi_long arg2,
3283 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003284{
3285 print_syscall_prologue(name);
3286 print_string(arg0, 1);
3287 print_syscall_epilogue(name);
3288}
3289#endif
3290
3291#ifdef TARGET_NR_umount2
3292static void
Filip Bozutae400e112020-08-11 18:45:49 +02003293print_umount2(void *cpu_env, const struct syscallname *name,
3294 abi_long arg0, abi_long arg1, abi_long arg2,
3295 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003296{
3297 print_syscall_prologue(name);
3298 print_string(arg0, 0);
3299 print_flags(umount2_flags, arg1, 1);
3300 print_syscall_epilogue(name);
3301}
3302#endif
3303
3304#ifdef TARGET_NR_unlink
3305static void
Filip Bozutae400e112020-08-11 18:45:49 +02003306print_unlink(void *cpu_env, const struct syscallname *name,
3307 abi_long arg0, abi_long arg1, abi_long arg2,
3308 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003309{
3310 print_syscall_prologue(name);
3311 print_string(arg0, 1);
3312 print_syscall_epilogue(name);
3313}
3314#endif
3315
3316#ifdef TARGET_NR_unlinkat
3317static void
Filip Bozutae400e112020-08-11 18:45:49 +02003318print_unlinkat(void *cpu_env, const struct syscallname *name,
3319 abi_long arg0, abi_long arg1, abi_long arg2,
3320 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003321{
3322 print_syscall_prologue(name);
3323 print_at_dirfd(arg0, 0);
3324 print_string(arg1, 0);
3325 print_flags(unlinkat_flags, arg2, 1);
3326 print_syscall_epilogue(name);
3327}
3328#endif
3329
3330#ifdef TARGET_NR_utime
3331static void
Filip Bozutae400e112020-08-11 18:45:49 +02003332print_utime(void *cpu_env, const struct syscallname *name,
3333 abi_long arg0, abi_long arg1, abi_long arg2,
3334 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003335{
3336 print_syscall_prologue(name);
3337 print_string(arg0, 0);
3338 print_pointer(arg1, 1);
3339 print_syscall_epilogue(name);
3340}
3341#endif
3342
3343#ifdef TARGET_NR_utimes
3344static void
Filip Bozutae400e112020-08-11 18:45:49 +02003345print_utimes(void *cpu_env, const struct syscallname *name,
3346 abi_long arg0, abi_long arg1, abi_long arg2,
3347 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003348{
3349 print_syscall_prologue(name);
3350 print_string(arg0, 0);
3351 print_pointer(arg1, 1);
3352 print_syscall_epilogue(name);
3353}
3354#endif
3355
3356#ifdef TARGET_NR_utimensat
3357static void
Filip Bozutae400e112020-08-11 18:45:49 +02003358print_utimensat(void *cpu_env, const struct syscallname *name,
3359 abi_long arg0, abi_long arg1, abi_long arg2,
3360 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003361{
3362 print_syscall_prologue(name);
3363 print_at_dirfd(arg0, 0);
3364 print_string(arg1, 0);
3365 print_pointer(arg2, 0);
3366 print_flags(at_file_flags, arg3, 1);
3367 print_syscall_epilogue(name);
3368}
3369#endif
3370
Mike Frysinger8d9016c2011-02-07 01:05:57 -05003371#if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003372static void
Filip Bozutae400e112020-08-11 18:45:49 +02003373print_mmap(void *cpu_env, const struct syscallname *name,
3374 abi_long arg0, abi_long arg1, abi_long arg2,
3375 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003376{
3377 print_syscall_prologue(name);
3378 print_pointer(arg0, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003379 print_raw_param("%d", arg1, 0);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003380 print_flags(mmap_prot_flags, arg2, 0);
3381 print_flags(mmap_flags, arg3, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003382 print_raw_param("%d", arg4, 0);
3383 print_raw_param("%#x", arg5, 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003384 print_syscall_epilogue(name);
3385}
3386#define print_mmap2 print_mmap
3387#endif
3388
3389#ifdef TARGET_NR_mprotect
3390static void
Filip Bozutae400e112020-08-11 18:45:49 +02003391print_mprotect(void *cpu_env, const struct syscallname *name,
3392 abi_long arg0, abi_long arg1, abi_long arg2,
3393 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003394{
3395 print_syscall_prologue(name);
3396 print_pointer(arg0, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003397 print_raw_param("%d", arg1, 0);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003398 print_flags(mmap_prot_flags, arg2, 1);
3399 print_syscall_epilogue(name);
3400}
3401#endif
3402
3403#ifdef TARGET_NR_munmap
3404static void
Filip Bozutae400e112020-08-11 18:45:49 +02003405print_munmap(void *cpu_env, const struct syscallname *name,
3406 abi_long arg0, abi_long arg1, abi_long arg2,
3407 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003408{
3409 print_syscall_prologue(name);
3410 print_pointer(arg0, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003411 print_raw_param("%d", arg1, 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003412 print_syscall_epilogue(name);
3413}
3414#endif
3415
3416#ifdef TARGET_NR_futex
3417static void print_futex_op(abi_long tflag, int last)
3418{
3419#define print_op(val) \
3420if( cmd == val ) { \
Josh Kunz4b25a502020-02-03 18:54:14 -08003421 qemu_log(#val); \
Mika Westerberg74d753a2009-04-07 16:57:29 +03003422 return; \
3423}
3424
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003425 int cmd = (int)tflag;
Mika Westerberg74d753a2009-04-07 16:57:29 +03003426#ifdef FUTEX_PRIVATE_FLAG
Paul Brook5f2243f2010-02-19 16:04:51 +00003427 if (cmd & FUTEX_PRIVATE_FLAG) {
Josh Kunz4b25a502020-02-03 18:54:14 -08003428 qemu_log("FUTEX_PRIVATE_FLAG|");
Paul Brook5f2243f2010-02-19 16:04:51 +00003429 cmd &= ~FUTEX_PRIVATE_FLAG;
3430 }
Mika Westerberg74d753a2009-04-07 16:57:29 +03003431#endif
John Rigbybfb669f2013-02-23 16:14:08 -07003432#ifdef FUTEX_CLOCK_REALTIME
3433 if (cmd & FUTEX_CLOCK_REALTIME) {
Josh Kunz4b25a502020-02-03 18:54:14 -08003434 qemu_log("FUTEX_CLOCK_REALTIME|");
John Rigbybfb669f2013-02-23 16:14:08 -07003435 cmd &= ~FUTEX_CLOCK_REALTIME;
3436 }
3437#endif
Mika Westerberg74d753a2009-04-07 16:57:29 +03003438 print_op(FUTEX_WAIT)
3439 print_op(FUTEX_WAKE)
3440 print_op(FUTEX_FD)
3441 print_op(FUTEX_REQUEUE)
3442 print_op(FUTEX_CMP_REQUEUE)
3443 print_op(FUTEX_WAKE_OP)
3444 print_op(FUTEX_LOCK_PI)
3445 print_op(FUTEX_UNLOCK_PI)
3446 print_op(FUTEX_TRYLOCK_PI)
3447#ifdef FUTEX_WAIT_BITSET
3448 print_op(FUTEX_WAIT_BITSET)
3449#endif
3450#ifdef FUTEX_WAKE_BITSET
3451 print_op(FUTEX_WAKE_BITSET)
3452#endif
3453 /* unknown values */
Josh Kunz4b25a502020-02-03 18:54:14 -08003454 qemu_log("%d", cmd);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003455}
3456
3457static void
Filip Bozutae400e112020-08-11 18:45:49 +02003458print_futex(void *cpu_env, const struct syscallname *name,
3459 abi_long arg0, abi_long arg1, abi_long arg2,
3460 abi_long arg3, abi_long arg4, abi_long arg5)
Mika Westerberg74d753a2009-04-07 16:57:29 +03003461{
3462 print_syscall_prologue(name);
3463 print_pointer(arg0, 0);
3464 print_futex_op(arg1, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003465 print_raw_param(",%d", arg2, 0);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003466 print_pointer(arg3, 0); /* struct timespec */
3467 print_pointer(arg4, 0);
Laurent Vivierd2ee72a2011-02-15 21:10:44 +01003468 print_raw_param("%d", arg4, 1);
Mika Westerberg74d753a2009-04-07 16:57:29 +03003469 print_syscall_epilogue(name);
3470}
3471#endif
3472
Laurent Vivier608e5592011-04-07 00:25:32 +02003473#ifdef TARGET_NR_kill
3474static void
Filip Bozutae400e112020-08-11 18:45:49 +02003475print_kill(void *cpu_env, const struct syscallname *name,
3476 abi_long arg0, abi_long arg1, abi_long arg2,
3477 abi_long arg3, abi_long arg4, abi_long arg5)
Laurent Vivier608e5592011-04-07 00:25:32 +02003478{
3479 print_syscall_prologue(name);
3480 print_raw_param("%d", arg0, 0);
3481 print_signal(arg1, 1);
3482 print_syscall_epilogue(name);
3483}
3484#endif
3485
Miloš Stojanović51622642017-05-15 16:59:42 +02003486#ifdef TARGET_NR_tkill
3487static void
Filip Bozutae400e112020-08-11 18:45:49 +02003488print_tkill(void *cpu_env, const struct syscallname *name,
3489 abi_long arg0, abi_long arg1, abi_long arg2,
3490 abi_long arg3, abi_long arg4, abi_long arg5)
Miloš Stojanović51622642017-05-15 16:59:42 +02003491{
3492 print_syscall_prologue(name);
3493 print_raw_param("%d", arg0, 0);
3494 print_signal(arg1, 1);
3495 print_syscall_epilogue(name);
3496}
3497#endif
3498
3499#ifdef TARGET_NR_tgkill
3500static void
Filip Bozutae400e112020-08-11 18:45:49 +02003501print_tgkill(void *cpu_env, const struct syscallname *name,
3502 abi_long arg0, abi_long arg1, abi_long arg2,
3503 abi_long arg3, abi_long arg4, abi_long arg5)
Miloš Stojanović51622642017-05-15 16:59:42 +02003504{
3505 print_syscall_prologue(name);
3506 print_raw_param("%d", arg0, 0);
3507 print_raw_param("%d", arg1, 0);
3508 print_signal(arg2, 1);
3509 print_syscall_epilogue(name);
3510}
3511#endif
3512
Jim Wilsond42744f2019-06-28 12:43:35 +02003513#ifdef TARGET_NR_statx
3514static void
Filip Bozutae400e112020-08-11 18:45:49 +02003515print_statx(void *cpu_env, const struct syscallname *name,
Jim Wilsond42744f2019-06-28 12:43:35 +02003516 abi_long arg0, abi_long arg1, abi_long arg2,
3517 abi_long arg3, abi_long arg4, abi_long arg5)
3518{
3519 print_syscall_prologue(name);
3520 print_at_dirfd(arg0, 0);
3521 print_string(arg1, 0);
3522 print_flags(statx_flags, arg2, 0);
3523 print_flags(statx_mask, arg3, 0);
3524 print_pointer(arg4, 1);
3525 print_syscall_epilogue(name);
3526}
3527#endif
3528
Filip Bozuta79482e592020-06-19 14:47:27 +02003529#ifdef TARGET_NR_ioctl
3530static void
Filip Bozutae400e112020-08-11 18:45:49 +02003531print_ioctl(void *cpu_env, const struct syscallname *name,
Filip Bozuta79482e592020-06-19 14:47:27 +02003532 abi_long arg0, abi_long arg1, abi_long arg2,
3533 abi_long arg3, abi_long arg4, abi_long arg5)
3534{
3535 print_syscall_prologue(name);
3536 print_raw_param("%d", arg0, 0);
3537
3538 const IOCTLEntry *ie;
3539 const argtype *arg_type;
3540 void *argptr;
3541 int target_size;
3542
3543 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
3544 if (ie->target_cmd == arg1) {
3545 break;
3546 }
3547 }
3548
3549 if (ie->target_cmd == 0) {
3550 print_raw_param("%#x", arg1, 0);
3551 print_raw_param("%#x", arg2, 1);
3552 } else {
3553 qemu_log("%s", ie->name);
3554 arg_type = ie->arg_type;
3555
3556 if (arg_type[0] != TYPE_NULL) {
3557 qemu_log(",");
3558
3559 switch (arg_type[0]) {
3560 case TYPE_PTRVOID:
3561 print_pointer(arg2, 1);
3562 break;
3563 case TYPE_CHAR:
3564 case TYPE_SHORT:
3565 case TYPE_INT:
3566 print_raw_param("%d", arg2, 1);
3567 break;
3568 case TYPE_LONG:
3569 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
3570 break;
3571 case TYPE_ULONG:
3572 print_raw_param(TARGET_ABI_FMT_lu, arg2, 1);
3573 break;
3574 case TYPE_PTR:
3575 switch (ie->access) {
3576 case IOC_R:
3577 print_pointer(arg2, 1);
3578 break;
3579 case IOC_W:
3580 case IOC_RW:
3581 arg_type++;
3582 target_size = thunk_type_size(arg_type, 0);
3583 argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
Laurent Vivier4c1850c2020-07-09 21:22:17 +02003584 if (argptr) {
3585 thunk_print(argptr, arg_type);
3586 unlock_user(argptr, arg2, target_size);
3587 } else {
3588 print_pointer(arg2, 1);
3589 }
Filip Bozuta79482e592020-06-19 14:47:27 +02003590 break;
3591 }
3592 break;
3593 default:
3594 g_assert_not_reached();
3595 }
3596 }
3597 }
3598 print_syscall_epilogue(name);
3599}
3600#endif
3601
ths33189d32007-11-01 00:13:36 +00003602/*
3603 * An array of all of the syscalls we know about
3604 */
3605
blueswir17ccfb2e2008-09-14 06:45:34 +00003606static const struct syscallname scnames[] = {
ths33189d32007-11-01 00:13:36 +00003607#include "strace.list"
3608};
3609
malcb1503cd2008-12-22 20:33:55 +00003610static int nsyscalls = ARRAY_SIZE(scnames);
ths33189d32007-11-01 00:13:36 +00003611
3612/*
3613 * The public interface to this module.
3614 */
3615void
Filip Bozutae400e112020-08-11 18:45:49 +02003616print_syscall(void *cpu_env, int num,
bellardc16f9ed2007-11-11 17:23:29 +00003617 abi_long arg1, abi_long arg2, abi_long arg3,
3618 abi_long arg4, abi_long arg5, abi_long arg6)
ths33189d32007-11-01 00:13:36 +00003619{
3620 int i;
blueswir17ccfb2e2008-09-14 06:45:34 +00003621 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 ")";
ths33189d32007-11-01 00:13:36 +00003622
Josh Kunz4b25a502020-02-03 18:54:14 -08003623 qemu_log("%d ", getpid());
ths33189d32007-11-01 00:13:36 +00003624
3625 for(i=0;i<nsyscalls;i++)
3626 if( scnames[i].nr == num ) {
3627 if( scnames[i].call != NULL ) {
Josh Kunz4b25a502020-02-03 18:54:14 -08003628 scnames[i].call(
Filip Bozutae400e112020-08-11 18:45:49 +02003629 cpu_env, &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6);
ths33189d32007-11-01 00:13:36 +00003630 } else {
bellard6b23f772007-11-14 18:04:05 +00003631 /* XXX: this format system is broken because it uses
3632 host types and host pointers for strings */
ths33189d32007-11-01 00:13:36 +00003633 if( scnames[i].format != NULL )
3634 format = scnames[i].format;
Josh Kunz4b25a502020-02-03 18:54:14 -08003635 qemu_log(format,
3636 scnames[i].name, arg1, arg2, arg3, arg4, arg5, arg6);
ths33189d32007-11-01 00:13:36 +00003637 }
pbrook74c11e52008-05-29 13:49:09 +00003638 return;
ths33189d32007-11-01 00:13:36 +00003639 }
Josh Kunz4b25a502020-02-03 18:54:14 -08003640 qemu_log("Unknown syscall %d\n", num);
ths33189d32007-11-01 00:13:36 +00003641}
3642
3643
3644void
Filip Bozutae400e112020-08-11 18:45:49 +02003645print_syscall_ret(void *cpu_env, int num, abi_long ret,
Filip Bozutac84be712020-06-19 14:33:26 +02003646 abi_long arg1, abi_long arg2, abi_long arg3,
3647 abi_long arg4, abi_long arg5, abi_long arg6)
ths33189d32007-11-01 00:13:36 +00003648{
3649 int i;
3650
3651 for(i=0;i<nsyscalls;i++)
3652 if( scnames[i].nr == num ) {
3653 if( scnames[i].result != NULL ) {
Filip Bozutae400e112020-08-11 18:45:49 +02003654 scnames[i].result(cpu_env, &scnames[i], ret,
Filip Bozutac84be712020-06-19 14:33:26 +02003655 arg1, arg2, arg3,
3656 arg4, arg5, arg6);
ths33189d32007-11-01 00:13:36 +00003657 } else {
Laurent Vivier42b16182020-07-08 17:24:35 +02003658 if (!print_syscall_err(ret)) {
Filip Bozutac84be712020-06-19 14:33:26 +02003659 qemu_log(TARGET_ABI_FMT_ld, ret);
Alexander Graf962b2892011-11-21 12:04:07 +01003660 }
Filip Bozutac84be712020-06-19 14:33:26 +02003661 qemu_log("\n");
ths33189d32007-11-01 00:13:36 +00003662 }
3663 break;
3664 }
3665}
Peter Maydell0cb581d2016-07-18 18:12:24 +01003666
3667void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
3668{
3669 /* Print the strace output for a signal being taken:
3670 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
3671 */
Josh Kunz4b25a502020-02-03 18:54:14 -08003672 qemu_log("--- ");
Peter Maydell0cb581d2016-07-18 18:12:24 +01003673 print_signal(target_signum, 1);
Josh Kunz4b25a502020-02-03 18:54:14 -08003674 qemu_log(" ");
Peter Maydell0cb581d2016-07-18 18:12:24 +01003675 print_siginfo(tinfo);
Josh Kunz4b25a502020-02-03 18:54:14 -08003676 qemu_log(" ---\n");
Peter Maydell0cb581d2016-07-18 18:12:24 +01003677}