2016-01-26 21:17:02 +03:00
|
|
|
#include "qemu/osdep.h"
|
2021-09-08 18:43:58 +03:00
|
|
|
|
2007-11-01 03:13:36 +03:00
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/msg.h>
|
|
|
|
#include <sys/sem.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <sys/select.h>
|
2009-04-07 17:57:29 +04:00
|
|
|
#include <sys/mount.h>
|
2016-06-11 03:19:45 +03:00
|
|
|
#include <arpa/inet.h>
|
2020-12-18 22:32:13 +03:00
|
|
|
#include <netinet/in.h>
|
2016-06-11 03:19:45 +03:00
|
|
|
#include <netinet/tcp.h>
|
2020-12-18 22:32:11 +03:00
|
|
|
#include <netinet/udp.h>
|
2016-06-11 03:19:45 +03:00
|
|
|
#include <linux/if_packet.h>
|
2020-12-18 22:32:13 +03:00
|
|
|
#include <linux/in6.h>
|
2019-10-21 14:48:53 +03:00
|
|
|
#include <linux/netlink.h>
|
2024-10-01 18:14:54 +03:00
|
|
|
#ifdef HAVE_OPENAT2_H
|
|
|
|
#include <linux/openat2.h>
|
|
|
|
#endif
|
2011-04-07 02:25:32 +04:00
|
|
|
#include <sched.h>
|
2007-11-01 03:13:36 +03:00
|
|
|
#include "qemu.h"
|
2021-09-08 18:44:03 +03:00
|
|
|
#include "user-internals.h"
|
2021-09-08 18:43:58 +03:00
|
|
|
#include "strace.h"
|
2022-09-18 22:45:44 +03:00
|
|
|
#include "signal-common.h"
|
2022-09-06 03:08:37 +03:00
|
|
|
#include "target_mman.h"
|
2007-11-01 03:13:36 +03:00
|
|
|
|
|
|
|
struct syscallname {
|
|
|
|
int nr;
|
2008-09-14 10:45:34 +04:00
|
|
|
const char *name;
|
|
|
|
const char *format;
|
2022-05-09 23:57:27 +03:00
|
|
|
void (*call)(CPUArchState *, const struct syscallname *,
|
2007-11-11 20:23:29 +03:00
|
|
|
abi_long, abi_long, abi_long,
|
|
|
|
abi_long, abi_long, abi_long);
|
2022-05-09 23:57:27 +03:00
|
|
|
void (*result)(CPUArchState *, const struct syscallname *, abi_long,
|
2020-06-19 15:33:26 +03:00
|
|
|
abi_long, abi_long, abi_long,
|
|
|
|
abi_long, abi_long, abi_long);
|
2007-11-01 03:13:36 +03:00
|
|
|
};
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
/*
|
|
|
|
* It is possible that target doesn't have syscall that uses
|
|
|
|
* following flags but we don't want the compiler to warn
|
|
|
|
* us about them being unused. Same applies to utility print
|
|
|
|
* functions. It is ok to keep them while not used.
|
|
|
|
*/
|
|
|
|
#define UNUSED __attribute__ ((unused))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure used to translate flag values into strings. This is
|
|
|
|
* similar that is in the actual strace tool.
|
|
|
|
*/
|
|
|
|
struct flags {
|
|
|
|
abi_long f_value; /* flag */
|
2023-07-07 23:40:33 +03:00
|
|
|
abi_long f_mask; /* mask */
|
2009-04-07 17:57:29 +04:00
|
|
|
const char *f_string; /* stringified flag */
|
|
|
|
};
|
|
|
|
|
2023-07-07 23:40:33 +03:00
|
|
|
/* No 'struct flags' element should have a zero mask. */
|
|
|
|
#define FLAG_BASIC(V, M, N) { V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
/* common flags for all architectures */
|
2023-07-07 23:40:33 +03:00
|
|
|
#define FLAG_GENERIC_MASK(V, M) FLAG_BASIC(V, M, #V)
|
|
|
|
#define FLAG_GENERIC(V) FLAG_BASIC(V, V, #V)
|
2009-04-07 17:57:29 +04:00
|
|
|
/* target specific flags (syscall_defs.h has TARGET_<flag>) */
|
2023-07-07 23:40:33 +03:00
|
|
|
#define FLAG_TARGET_MASK(V, M) FLAG_BASIC(TARGET_##V, TARGET_##M, #V)
|
|
|
|
#define FLAG_TARGET(V) FLAG_BASIC(TARGET_##V, TARGET_##V, #V)
|
2009-04-07 17:57:29 +04:00
|
|
|
/* end of flags array */
|
2023-07-07 23:40:33 +03:00
|
|
|
#define FLAG_END { 0, 0, NULL }
|
2009-04-07 17:57:29 +04:00
|
|
|
|
2020-08-11 19:45:52 +03:00
|
|
|
/* Structure used to translate enumerated values into strings */
|
|
|
|
struct enums {
|
|
|
|
abi_long e_value; /* enum value */
|
|
|
|
const char *e_string; /* stringified enum */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* common enums for all architectures */
|
|
|
|
#define ENUM_GENERIC(name) { name, #name }
|
|
|
|
/* target specific enums */
|
|
|
|
#define ENUM_TARGET(name) { TARGET_ ## name, #name }
|
|
|
|
/* end of enums array */
|
|
|
|
#define ENUM_END { 0, NULL }
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
UNUSED static const char *get_comma(int);
|
|
|
|
UNUSED static void print_pointer(abi_long, int);
|
|
|
|
UNUSED static void print_flags(const struct flags *, abi_long, int);
|
2020-08-11 19:45:52 +03:00
|
|
|
UNUSED static void print_enums(const struct enums *, abi_long, int);
|
2009-04-07 17:57:29 +04:00
|
|
|
UNUSED static void print_at_dirfd(abi_long, int);
|
|
|
|
UNUSED static void print_file_mode(abi_long, int);
|
|
|
|
UNUSED static void print_open_flags(abi_long, int);
|
|
|
|
UNUSED static void print_syscall_prologue(const struct syscallname *);
|
|
|
|
UNUSED static void print_syscall_epilogue(const struct syscallname *);
|
|
|
|
UNUSED static void print_string(abi_long, int);
|
2016-06-11 03:19:45 +03:00
|
|
|
UNUSED static void print_buf(abi_long addr, abi_long len, int last);
|
2009-04-07 17:57:29 +04:00
|
|
|
UNUSED static void print_raw_param(const char *, abi_long, int);
|
2023-01-31 20:18:36 +03:00
|
|
|
UNUSED static void print_raw_param64(const char *, long long, int last);
|
2009-04-07 17:57:29 +04:00
|
|
|
UNUSED static void print_timeval(abi_ulong, int);
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
UNUSED static void print_timespec(abi_ulong, int);
|
2022-09-18 22:45:45 +03:00
|
|
|
UNUSED static void print_timespec64(abi_ulong, int);
|
2019-10-21 14:48:50 +03:00
|
|
|
UNUSED static void print_timezone(abi_ulong, int);
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
UNUSED static void print_itimerval(abi_ulong, int);
|
2009-04-07 17:57:29 +04:00
|
|
|
UNUSED static void print_number(abi_long, int);
|
2011-04-07 02:25:32 +04:00
|
|
|
UNUSED static void print_signal(abi_ulong, int);
|
2019-10-21 14:48:56 +03:00
|
|
|
UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
|
2016-06-11 03:19:45 +03:00
|
|
|
UNUSED static void print_socket_domain(int domain);
|
|
|
|
UNUSED static void print_socket_type(int type);
|
|
|
|
UNUSED static void print_socket_protocol(int domain, int type, int protocol);
|
2009-04-07 17:57:29 +04:00
|
|
|
|
2007-11-01 03:13:36 +03:00
|
|
|
/*
|
|
|
|
* Utility functions
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
print_ipc_cmd(int cmd)
|
|
|
|
{
|
|
|
|
#define output_cmd(val) \
|
|
|
|
if( cmd == val ) { \
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(#val); \
|
2007-11-01 03:13:36 +03:00
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd &= 0xff;
|
|
|
|
|
|
|
|
/* General IPC commands */
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_SET );
|
|
|
|
output_cmd( IPC_STAT );
|
|
|
|
output_cmd( IPC_INFO );
|
|
|
|
/* msgctl() commands */
|
|
|
|
output_cmd( MSG_STAT );
|
|
|
|
output_cmd( MSG_INFO );
|
|
|
|
/* shmctl() commands */
|
|
|
|
output_cmd( SHM_LOCK );
|
|
|
|
output_cmd( SHM_UNLOCK );
|
|
|
|
output_cmd( SHM_STAT );
|
|
|
|
output_cmd( SHM_INFO );
|
|
|
|
/* semctl() commands */
|
|
|
|
output_cmd( GETPID );
|
|
|
|
output_cmd( GETVAL );
|
|
|
|
output_cmd( GETALL );
|
|
|
|
output_cmd( GETNCNT );
|
|
|
|
output_cmd( GETZCNT );
|
|
|
|
output_cmd( SETVAL );
|
|
|
|
output_cmd( SETALL );
|
|
|
|
output_cmd( SEM_STAT );
|
|
|
|
output_cmd( SEM_INFO );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
output_cmd( IPC_RMID );
|
|
|
|
|
|
|
|
/* Some value we don't recognize */
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d", cmd);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
|
|
|
|
2022-09-18 22:45:44 +03:00
|
|
|
static const char * const target_signal_name[] = {
|
|
|
|
#define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig,
|
|
|
|
MAKE_SIGNAL_LIST
|
|
|
|
#undef MAKE_SIG_ENTRY
|
|
|
|
};
|
|
|
|
|
2011-04-07 02:25:32 +04:00
|
|
|
static void
|
linux-user: Trace rt_sigprocmask's sigsets
Add a function for formatting target sigsets. It can be useful for
other syscalls in the future, so put it into the beginning of strace.c.
For simplicity, do not implement the strace's ~[] output syntax.
Add a rt_sigprocmask return handler.
Example outputs:
753914 rt_sigprocmask(SIG_BLOCK,[SIGCHLD SIGTSTP SIGTTIN SIGTTOU],0x00007f80fddfe380,8) = 0 (oldset=[SIGTTOU])
753914 rt_sigprocmask(SIG_SETMASK,[SIGCHLD],NULL,8) = 0
753914 rt_sigprocmask(SIG_BLOCK,NULL,0x00007f80fddff3c0,8) = 0 (oldset=[])
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241022102726.18520-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 13:26:16 +03:00
|
|
|
print_signal_1(abi_ulong arg)
|
2011-04-07 02:25:32 +04:00
|
|
|
{
|
2022-09-18 22:45:44 +03:00
|
|
|
if (arg < ARRAY_SIZE(target_signal_name)) {
|
linux-user: Trace rt_sigprocmask's sigsets
Add a function for formatting target sigsets. It can be useful for
other syscalls in the future, so put it into the beginning of strace.c.
For simplicity, do not implement the strace's ~[] output syntax.
Add a rt_sigprocmask return handler.
Example outputs:
753914 rt_sigprocmask(SIG_BLOCK,[SIGCHLD SIGTSTP SIGTTIN SIGTTOU],0x00007f80fddfe380,8) = 0 (oldset=[SIGTTOU])
753914 rt_sigprocmask(SIG_SETMASK,[SIGCHLD],NULL,8) = 0
753914 rt_sigprocmask(SIG_BLOCK,NULL,0x00007f80fddff3c0,8) = 0 (oldset=[])
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241022102726.18520-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 13:26:16 +03:00
|
|
|
qemu_log("%s", target_signal_name[arg]);
|
|
|
|
} else {
|
|
|
|
qemu_log(TARGET_ABI_FMT_lu, arg);
|
2011-04-07 02:25:32 +04:00
|
|
|
}
|
linux-user: Trace rt_sigprocmask's sigsets
Add a function for formatting target sigsets. It can be useful for
other syscalls in the future, so put it into the beginning of strace.c.
For simplicity, do not implement the strace's ~[] output syntax.
Add a rt_sigprocmask return handler.
Example outputs:
753914 rt_sigprocmask(SIG_BLOCK,[SIGCHLD SIGTSTP SIGTTIN SIGTTOU],0x00007f80fddfe380,8) = 0 (oldset=[SIGTTOU])
753914 rt_sigprocmask(SIG_SETMASK,[SIGCHLD],NULL,8) = 0
753914 rt_sigprocmask(SIG_BLOCK,NULL,0x00007f80fddff3c0,8) = 0 (oldset=[])
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241022102726.18520-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 13:26:16 +03:00
|
|
|
}
|
2022-09-18 22:45:44 +03:00
|
|
|
|
linux-user: Trace rt_sigprocmask's sigsets
Add a function for formatting target sigsets. It can be useful for
other syscalls in the future, so put it into the beginning of strace.c.
For simplicity, do not implement the strace's ~[] output syntax.
Add a rt_sigprocmask return handler.
Example outputs:
753914 rt_sigprocmask(SIG_BLOCK,[SIGCHLD SIGTSTP SIGTTIN SIGTTOU],0x00007f80fddfe380,8) = 0 (oldset=[SIGTTOU])
753914 rt_sigprocmask(SIG_SETMASK,[SIGCHLD],NULL,8) = 0
753914 rt_sigprocmask(SIG_BLOCK,NULL,0x00007f80fddff3c0,8) = 0 (oldset=[])
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241022102726.18520-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 13:26:16 +03:00
|
|
|
static void
|
|
|
|
print_signal(abi_ulong arg, int last)
|
|
|
|
{
|
|
|
|
print_signal_1(arg);
|
|
|
|
qemu_log("%s", get_comma(last));
|
2011-04-07 02:25:32 +04:00
|
|
|
}
|
|
|
|
|
2016-07-18 20:12:24 +03:00
|
|
|
static void print_si_code(int arg)
|
|
|
|
{
|
|
|
|
const char *codename = NULL;
|
|
|
|
|
|
|
|
switch (arg) {
|
|
|
|
case SI_USER:
|
|
|
|
codename = "SI_USER";
|
|
|
|
break;
|
|
|
|
case SI_KERNEL:
|
|
|
|
codename = "SI_KERNEL";
|
|
|
|
break;
|
|
|
|
case SI_QUEUE:
|
|
|
|
codename = "SI_QUEUE";
|
|
|
|
break;
|
|
|
|
case SI_TIMER:
|
|
|
|
codename = "SI_TIMER";
|
|
|
|
break;
|
|
|
|
case SI_MESGQ:
|
|
|
|
codename = "SI_MESGQ";
|
|
|
|
break;
|
|
|
|
case SI_ASYNCIO:
|
|
|
|
codename = "SI_ASYNCIO";
|
|
|
|
break;
|
|
|
|
case SI_SIGIO:
|
|
|
|
codename = "SI_SIGIO";
|
|
|
|
break;
|
|
|
|
case SI_TKILL:
|
|
|
|
codename = "SI_TKILL";
|
|
|
|
break;
|
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d", arg);
|
2016-07-18 20:12:24 +03:00
|
|
|
return;
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s", codename);
|
2016-07-18 20:12:24 +03:00
|
|
|
}
|
|
|
|
|
linux-user: add strace support for uinfo structure of rt_sigqueueinfo() and rt_tgsigqueueinfo()
This commit adds support for printing the content of the target_siginfo_t
structure in a similar way to how it is printed by the host strace. The
pointer to this structure is sent as the last argument of the
rt_sigqueueinfo() and rt_tgsigqueueinfo() system calls.
For this purpose, print_siginfo() is used and the get_target_siginfo()
function is implemented in order to get the information obtained from
the pointer into the form that print_siginfo() expects.
The get_target_siginfo() function is based on
host_to_target_siginfo_noswap() in linux-user mode, but here both
arguments are pointers to target_siginfo_t, so instead of converting
the information to siginfo_t it just extracts and copies it to a
target_siginfo_t structure.
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,{si_signo=50, si_code=SI_QUEUE, si_pid=8307,
si_uid=1000, si_sigval=17716762128}) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:49 +03:00
|
|
|
static void get_target_siginfo(target_siginfo_t *tinfo,
|
|
|
|
const target_siginfo_t *info)
|
|
|
|
{
|
|
|
|
abi_ulong sival_ptr;
|
|
|
|
|
|
|
|
int sig;
|
|
|
|
int si_errno;
|
|
|
|
int si_code;
|
|
|
|
int si_type;
|
|
|
|
|
|
|
|
__get_user(sig, &info->si_signo);
|
|
|
|
__get_user(si_errno, &tinfo->si_errno);
|
|
|
|
__get_user(si_code, &info->si_code);
|
|
|
|
|
|
|
|
tinfo->si_signo = sig;
|
|
|
|
tinfo->si_errno = si_errno;
|
|
|
|
tinfo->si_code = si_code;
|
|
|
|
|
|
|
|
/* Ensure we don't leak random junk to the guest later */
|
|
|
|
memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
|
|
|
|
|
|
|
|
/* This is awkward, because we have to use a combination of
|
|
|
|
* the si_code and si_signo to figure out which of the union's
|
|
|
|
* members are valid. (Within the host kernel it is always possible
|
|
|
|
* to tell, but the kernel carefully avoids giving userspace the
|
|
|
|
* high 16 bits of si_code, so we don't have the information to
|
|
|
|
* do this the easy way...) We therefore make our best guess,
|
|
|
|
* bearing in mind that a guest can spoof most of the si_codes
|
|
|
|
* via rt_sigqueueinfo() if it likes.
|
|
|
|
*
|
|
|
|
* Once we have made our guess, we record it in the top 16 bits of
|
|
|
|
* the si_code, so that print_siginfo() later can use it.
|
|
|
|
* print_siginfo() will strip these top bits out before printing
|
|
|
|
* the si_code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (si_code) {
|
|
|
|
case SI_USER:
|
|
|
|
case SI_TKILL:
|
|
|
|
case SI_KERNEL:
|
|
|
|
/* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
|
|
|
|
* These are the only unspoofable si_code values.
|
|
|
|
*/
|
|
|
|
__get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
|
|
|
|
__get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
|
|
|
|
si_type = QEMU_SI_KILL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Everything else is spoofable. Make best guess based on signal */
|
|
|
|
switch (sig) {
|
|
|
|
case TARGET_SIGCHLD:
|
|
|
|
__get_user(tinfo->_sifields._sigchld._pid,
|
|
|
|
&info->_sifields._sigchld._pid);
|
|
|
|
__get_user(tinfo->_sifields._sigchld._uid,
|
|
|
|
&info->_sifields._sigchld._uid);
|
|
|
|
__get_user(tinfo->_sifields._sigchld._status,
|
|
|
|
&info->_sifields._sigchld._status);
|
|
|
|
__get_user(tinfo->_sifields._sigchld._utime,
|
|
|
|
&info->_sifields._sigchld._utime);
|
|
|
|
__get_user(tinfo->_sifields._sigchld._stime,
|
|
|
|
&info->_sifields._sigchld._stime);
|
|
|
|
si_type = QEMU_SI_CHLD;
|
|
|
|
break;
|
|
|
|
case TARGET_SIGIO:
|
|
|
|
__get_user(tinfo->_sifields._sigpoll._band,
|
|
|
|
&info->_sifields._sigpoll._band);
|
|
|
|
__get_user(tinfo->_sifields._sigpoll._fd,
|
|
|
|
&info->_sifields._sigpoll._fd);
|
|
|
|
si_type = QEMU_SI_POLL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
|
|
|
|
__get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
|
|
|
|
__get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
|
|
|
|
/* XXX: potential problem if 64 bit */
|
|
|
|
__get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
|
|
|
|
tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
|
|
|
|
|
|
|
|
si_type = QEMU_SI_RT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tinfo->si_code = deposit32(si_code, 16, 16, si_type);
|
|
|
|
}
|
|
|
|
|
2016-07-18 20:12:24 +03:00
|
|
|
static void print_siginfo(const target_siginfo_t *tinfo)
|
|
|
|
{
|
|
|
|
/* Print a target_siginfo_t in the format desired for printing
|
|
|
|
* signals being taken. We assume the target_siginfo_t is in the
|
|
|
|
* internal form where the top 16 bits of si_code indicate which
|
|
|
|
* part of the union is valid, rather than in the guest-visible
|
|
|
|
* form where the bottom 16 bits are sign-extended into the top 16.
|
|
|
|
*/
|
|
|
|
int si_type = extract32(tinfo->si_code, 16, 16);
|
|
|
|
int si_code = sextract32(tinfo->si_code, 0, 16);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("{si_signo=");
|
2016-07-18 20:12:24 +03:00
|
|
|
print_signal(tinfo->si_signo, 1);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(", si_code=");
|
2016-07-18 20:12:24 +03:00
|
|
|
print_si_code(si_code);
|
|
|
|
|
|
|
|
switch (si_type) {
|
|
|
|
case QEMU_SI_KILL:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(", si_pid=%u, si_uid=%u",
|
2016-07-18 20:12:24 +03:00
|
|
|
(unsigned int)tinfo->_sifields._kill._pid,
|
|
|
|
(unsigned int)tinfo->_sifields._kill._uid);
|
|
|
|
break;
|
|
|
|
case QEMU_SI_TIMER:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(", si_timer1=%u, si_timer2=%u",
|
2016-07-18 20:12:24 +03:00
|
|
|
tinfo->_sifields._timer._timer1,
|
|
|
|
tinfo->_sifields._timer._timer2);
|
|
|
|
break;
|
|
|
|
case QEMU_SI_POLL:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(", si_band=%d, si_fd=%d",
|
2016-07-18 20:12:24 +03:00
|
|
|
tinfo->_sifields._sigpoll._band,
|
|
|
|
tinfo->_sifields._sigpoll._fd);
|
|
|
|
break;
|
|
|
|
case QEMU_SI_FAULT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(", si_addr=");
|
2016-07-18 20:12:24 +03:00
|
|
|
print_pointer(tinfo->_sifields._sigfault._addr, 1);
|
|
|
|
break;
|
|
|
|
case QEMU_SI_CHLD:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
|
2016-07-18 20:12:24 +03:00
|
|
|
", si_utime=" TARGET_ABI_FMT_ld
|
|
|
|
", si_stime=" TARGET_ABI_FMT_ld,
|
|
|
|
(unsigned int)(tinfo->_sifields._sigchld._pid),
|
|
|
|
(unsigned int)(tinfo->_sifields._sigchld._uid),
|
|
|
|
tinfo->_sifields._sigchld._status,
|
|
|
|
tinfo->_sifields._sigchld._utime,
|
|
|
|
tinfo->_sifields._sigchld._stime);
|
|
|
|
break;
|
|
|
|
case QEMU_SI_RT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
|
2016-07-18 20:12:24 +03:00
|
|
|
(unsigned int)tinfo->_sifields._rt._pid,
|
|
|
|
(unsigned int)tinfo->_sifields._rt._uid,
|
|
|
|
tinfo->_sifields._rt._sigval.sival_ptr);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("}");
|
2016-07-18 20:12:24 +03:00
|
|
|
}
|
|
|
|
|
2016-06-11 03:19:45 +03:00
|
|
|
static void
|
2019-10-21 14:48:56 +03:00
|
|
|
print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
|
2016-06-11 03:19:45 +03:00
|
|
|
{
|
|
|
|
struct target_sockaddr *sa;
|
|
|
|
int i;
|
|
|
|
int sa_family;
|
|
|
|
|
|
|
|
sa = lock_user(VERIFY_READ, addr, addrlen, 1);
|
|
|
|
if (sa) {
|
|
|
|
sa_family = tswap16(sa->sa_family);
|
|
|
|
switch (sa_family) {
|
|
|
|
case AF_UNIX: {
|
|
|
|
struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("{sun_family=AF_UNIX,sun_path=\"");
|
2016-06-11 03:19:45 +03:00
|
|
|
for (i = 0; i < addrlen -
|
|
|
|
offsetof(struct target_sockaddr_un, sun_path) &&
|
|
|
|
un->sun_path[i]; i++) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%c", un->sun_path[i]);
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
2024-10-05 21:09:13 +03:00
|
|
|
qemu_log("\"},");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AF_INET: {
|
|
|
|
struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
|
|
|
|
uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
|
2016-06-11 03:19:45 +03:00
|
|
|
ntohs(in->sin_port));
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
|
2016-06-11 03:19:45 +03:00
|
|
|
c[0], c[1], c[2], c[3]);
|
2024-10-05 21:09:13 +03:00
|
|
|
qemu_log("},");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AF_PACKET: {
|
|
|
|
struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
|
|
|
|
uint8_t *c = (uint8_t *)&ll->sll_addr;
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("{sll_family=AF_PACKET,"
|
2016-06-11 03:19:45 +03:00
|
|
|
"sll_protocol=htons(0x%04x),if%d,pkttype=",
|
|
|
|
ntohs(ll->sll_protocol), ll->sll_ifindex);
|
|
|
|
switch (ll->sll_pkttype) {
|
|
|
|
case PACKET_HOST:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PACKET_HOST");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case PACKET_BROADCAST:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PACKET_BROADCAST");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case PACKET_MULTICAST:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PACKET_MULTICAST");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case PACKET_OTHERHOST:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PACKET_OTHERHOST");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case PACKET_OUTGOING:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PACKET_OUTGOING");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d", ll->sll_pkttype);
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
2016-06-11 03:19:45 +03:00
|
|
|
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
|
2024-10-05 21:09:13 +03:00
|
|
|
qemu_log("},");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
2019-10-21 14:48:53 +03:00
|
|
|
case AF_NETLINK: {
|
|
|
|
struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
|
2024-10-05 21:09:13 +03:00
|
|
|
qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u},",
|
2019-10-21 14:48:53 +03:00
|
|
|
tswap32(nl->nl_pid), tswap32(nl->nl_groups));
|
|
|
|
break;
|
|
|
|
}
|
2016-06-11 03:19:45 +03:00
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("{sa_family=%d, sa_data={", sa->sa_family);
|
2016-06-11 03:19:45 +03:00
|
|
|
for (i = 0; i < 13; i++) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%02x, ", sa->sa_data[i]);
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%02x}", sa->sa_data[i]);
|
2024-10-05 21:09:13 +03:00
|
|
|
qemu_log("},");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
unlock_user(sa, addr, 0);
|
|
|
|
} else {
|
2024-08-07 15:43:03 +03:00
|
|
|
print_pointer(addr, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
2024-10-05 21:09:13 +03:00
|
|
|
qemu_log(TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_socket_domain(int domain)
|
|
|
|
{
|
|
|
|
switch (domain) {
|
|
|
|
case PF_UNIX:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PF_UNIX");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case PF_INET:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PF_INET");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
2019-10-21 14:48:53 +03:00
|
|
|
case PF_NETLINK:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PF_NETLINK");
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
2016-06-11 03:19:45 +03:00
|
|
|
case PF_PACKET:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("PF_PACKET");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d", domain);
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_socket_type(int type)
|
|
|
|
{
|
2020-03-12 19:55:30 +03:00
|
|
|
switch (type & TARGET_SOCK_TYPE_MASK) {
|
2016-06-11 03:19:45 +03:00
|
|
|
case TARGET_SOCK_DGRAM:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOCK_DGRAM");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case TARGET_SOCK_STREAM:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOCK_STREAM");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case TARGET_SOCK_RAW:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOCK_RAW");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case TARGET_SOCK_RDM:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOCK_RDM");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case TARGET_SOCK_SEQPACKET:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOCK_SEQPACKET");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case TARGET_SOCK_PACKET:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOCK_PACKET");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
2020-03-12 19:55:30 +03:00
|
|
|
if (type & TARGET_SOCK_CLOEXEC) {
|
|
|
|
qemu_log("|SOCK_CLOEXEC");
|
|
|
|
}
|
|
|
|
if (type & TARGET_SOCK_NONBLOCK) {
|
|
|
|
qemu_log("|SOCK_NONBLOCK");
|
|
|
|
}
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_socket_protocol(int domain, int type, int protocol)
|
|
|
|
{
|
|
|
|
if (domain == AF_PACKET ||
|
|
|
|
(domain == AF_INET && type == TARGET_SOCK_PACKET)) {
|
|
|
|
switch (protocol) {
|
|
|
|
case 0x0003:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("ETH_P_ALL");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d", protocol);
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-21 14:48:53 +03:00
|
|
|
if (domain == PF_NETLINK) {
|
|
|
|
switch (protocol) {
|
|
|
|
case NETLINK_ROUTE:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NETLINK_ROUTE");
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
2023-01-01 17:11:05 +03:00
|
|
|
case NETLINK_UNUSED:
|
|
|
|
qemu_log("NETLINK_UNUSED");
|
|
|
|
break;
|
|
|
|
case NETLINK_USERSOCK:
|
|
|
|
qemu_log("NETLINK_USERSOCK");
|
|
|
|
break;
|
|
|
|
case NETLINK_FIREWALL:
|
|
|
|
qemu_log("NETLINK_FIREWALL");
|
|
|
|
break;
|
|
|
|
case NETLINK_SOCK_DIAG:
|
|
|
|
qemu_log("NETLINK_SOCK_DIAG");
|
|
|
|
break;
|
|
|
|
case NETLINK_NFLOG:
|
|
|
|
qemu_log("NETLINK_NFLOG");
|
|
|
|
break;
|
|
|
|
case NETLINK_XFRM:
|
|
|
|
qemu_log("NETLINK_XFRM");
|
|
|
|
break;
|
|
|
|
case NETLINK_SELINUX:
|
|
|
|
qemu_log("NETLINK_SELINUX");
|
|
|
|
break;
|
|
|
|
case NETLINK_ISCSI:
|
|
|
|
qemu_log("NETLINK_ISCSI");
|
|
|
|
break;
|
2019-10-21 14:48:53 +03:00
|
|
|
case NETLINK_AUDIT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NETLINK_AUDIT");
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
2023-01-01 17:11:05 +03:00
|
|
|
case NETLINK_FIB_LOOKUP:
|
|
|
|
qemu_log("NETLINK_FIB_LOOKUP");
|
|
|
|
break;
|
|
|
|
case NETLINK_CONNECTOR:
|
|
|
|
qemu_log("NETLINK_CONNECTOR");
|
|
|
|
break;
|
2019-10-21 14:48:53 +03:00
|
|
|
case NETLINK_NETFILTER:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NETLINK_NETFILTER");
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
2023-01-01 17:11:05 +03:00
|
|
|
case NETLINK_IP6_FW:
|
|
|
|
qemu_log("NETLINK_IP6_FW");
|
|
|
|
break;
|
|
|
|
case NETLINK_DNRTMSG:
|
|
|
|
qemu_log("NETLINK_DNRTMSG");
|
|
|
|
break;
|
2019-10-21 14:48:53 +03:00
|
|
|
case NETLINK_KOBJECT_UEVENT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NETLINK_KOBJECT_UEVENT");
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
2023-01-01 17:11:05 +03:00
|
|
|
case NETLINK_GENERIC:
|
|
|
|
qemu_log("NETLINK_GENERIC");
|
|
|
|
break;
|
|
|
|
case NETLINK_SCSITRANSPORT:
|
|
|
|
qemu_log("NETLINK_SCSITRANSPORT");
|
|
|
|
break;
|
|
|
|
case NETLINK_ECRYPTFS:
|
|
|
|
qemu_log("NETLINK_ECRYPTFS");
|
|
|
|
break;
|
2019-10-21 14:48:53 +03:00
|
|
|
case NETLINK_RDMA:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NETLINK_RDMA");
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
|
|
|
case NETLINK_CRYPTO:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NETLINK_CRYPTO");
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
2023-01-01 17:11:05 +03:00
|
|
|
case NETLINK_SMC:
|
|
|
|
qemu_log("NETLINK_SMC");
|
|
|
|
break;
|
2019-10-21 14:48:53 +03:00
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d", protocol);
|
2019-10-21 14:48:53 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-11 03:19:45 +03:00
|
|
|
switch (protocol) {
|
|
|
|
case IPPROTO_IP:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("IPPROTO_IP");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case IPPROTO_TCP:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("IPPROTO_TCP");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case IPPROTO_UDP:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("IPPROTO_UDP");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case IPPROTO_RAW:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("IPPROTO_RAW");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d", protocol);
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-11 20:23:29 +03:00
|
|
|
#ifdef TARGET_NR__newselect
|
2007-11-01 03:13:36 +03:00
|
|
|
static void
|
2007-11-11 20:23:29 +03:00
|
|
|
print_fdset(int n, abi_ulong target_fds_addr)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
|
|
|
int i;
|
2020-07-02 19:09:15 +03:00
|
|
|
int first = 1;
|
2007-11-01 03:13:36 +03:00
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("[");
|
2007-11-01 03:13:36 +03:00
|
|
|
if( target_fds_addr ) {
|
2007-11-11 17:26:47 +03:00
|
|
|
abi_long *target_fds;
|
2007-11-01 03:13:36 +03:00
|
|
|
|
2007-11-11 17:26:47 +03:00
|
|
|
target_fds = lock_user(VERIFY_READ,
|
|
|
|
target_fds_addr,
|
|
|
|
sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
|
|
|
|
1);
|
|
|
|
|
|
|
|
if (!target_fds)
|
2007-11-01 03:13:36 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i=n; i>=0; i--) {
|
2020-07-02 19:09:15 +03:00
|
|
|
if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
|
|
|
|
(i & (TARGET_ABI_BITS - 1))) & 1) {
|
|
|
|
qemu_log("%s%d", get_comma(first), i);
|
|
|
|
first = 0;
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2020-07-02 19:09:15 +03:00
|
|
|
}
|
2007-11-01 03:13:36 +03:00
|
|
|
unlock_user(target_fds, target_fds_addr, 0);
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("]");
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2007-11-11 20:23:29 +03:00
|
|
|
#endif
|
2007-11-01 03:13:36 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sysycall specific output functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* select */
|
2007-11-11 20:23:29 +03:00
|
|
|
#ifdef TARGET_NR__newselect
|
2007-11-01 03:13:36 +03:00
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_newselect(CPUArchState *cpu_env, const struct syscallname *name,
|
2007-11-11 20:23:29 +03:00
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
2020-06-19 15:33:26 +03:00
|
|
|
print_syscall_prologue(name);
|
2007-11-01 03:13:36 +03:00
|
|
|
print_fdset(arg1, arg2);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2007-11-01 03:13:36 +03:00
|
|
|
print_fdset(arg1, arg3);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2007-11-01 03:13:36 +03:00
|
|
|
print_fdset(arg1, arg4);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2009-04-07 17:57:29 +04:00
|
|
|
print_timeval(arg5, 1);
|
2020-06-19 15:33:26 +03:00
|
|
|
print_syscall_epilogue(name);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2007-11-11 20:23:29 +03:00
|
|
|
#endif
|
2007-11-01 03:13:36 +03:00
|
|
|
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_semctl(CPUArchState *cpu_env, const struct syscallname *name,
|
2007-11-11 20:23:29 +03:00
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
|
|
|
|
name->name, arg1, arg2);
|
2007-11-01 03:13:36 +03:00
|
|
|
print_ipc_cmd(arg3);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
|
|
|
|
2024-02-23 04:46:43 +03:00
|
|
|
static void
|
|
|
|
print_shmat(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
static const struct flags shmat_flags[] = {
|
|
|
|
FLAG_GENERIC(SHM_RND),
|
|
|
|
FLAG_GENERIC(SHM_REMAP),
|
|
|
|
FLAG_GENERIC(SHM_RDONLY),
|
|
|
|
FLAG_GENERIC(SHM_EXEC),
|
|
|
|
FLAG_END
|
|
|
|
};
|
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
|
|
|
|
print_pointer(arg1, 0);
|
|
|
|
print_flags(shmat_flags, arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
|
2007-11-11 20:23:29 +03:00
|
|
|
#ifdef TARGET_NR_ipc
|
2007-11-01 03:13:36 +03:00
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_ipc(CPUArchState *cpu_env, const struct syscallname *name,
|
2007-11-11 20:23:29 +03:00
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
|
|
|
switch(arg1) {
|
|
|
|
case IPCOP_semctl:
|
2024-03-25 22:22:59 +03:00
|
|
|
print_semctl(cpu_env, &(const struct syscallname){ .name = "semctl" },
|
|
|
|
arg2, arg3, arg4, arg5, 0, 0);
|
2007-11-01 03:13:36 +03:00
|
|
|
break;
|
2024-02-23 04:46:43 +03:00
|
|
|
case IPCOP_shmat:
|
|
|
|
print_shmat(cpu_env, &(const struct syscallname){ .name = "shmat" },
|
2024-03-25 22:23:00 +03:00
|
|
|
arg2, arg5, arg3, 0, 0, 0);
|
2024-02-23 04:46:43 +03:00
|
|
|
break;
|
2007-11-01 03:13:36 +03:00
|
|
|
default:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(("%s("
|
|
|
|
TARGET_ABI_FMT_ld ","
|
|
|
|
TARGET_ABI_FMT_ld ","
|
|
|
|
TARGET_ABI_FMT_ld ","
|
|
|
|
TARGET_ABI_FMT_ld
|
|
|
|
")"),
|
2007-11-01 03:13:36 +03:00
|
|
|
name->name, arg1, arg2, arg3, arg4);
|
|
|
|
}
|
|
|
|
}
|
2007-11-11 20:23:29 +03:00
|
|
|
#endif
|
2007-11-01 03:13:36 +03:00
|
|
|
|
linux-user: Trace rt_sigprocmask's sigsets
Add a function for formatting target sigsets. It can be useful for
other syscalls in the future, so put it into the beginning of strace.c.
For simplicity, do not implement the strace's ~[] output syntax.
Add a rt_sigprocmask return handler.
Example outputs:
753914 rt_sigprocmask(SIG_BLOCK,[SIGCHLD SIGTSTP SIGTTIN SIGTTOU],0x00007f80fddfe380,8) = 0 (oldset=[SIGTTOU])
753914 rt_sigprocmask(SIG_SETMASK,[SIGCHLD],NULL,8) = 0
753914 rt_sigprocmask(SIG_BLOCK,NULL,0x00007f80fddff3c0,8) = 0 (oldset=[])
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241022102726.18520-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 13:26:16 +03:00
|
|
|
#ifdef TARGET_NR_rt_sigprocmask
|
|
|
|
static void print_target_sigset_t_1(target_sigset_t *set, int last)
|
|
|
|
{
|
|
|
|
bool first = true;
|
|
|
|
int i, sig = 1;
|
|
|
|
|
|
|
|
qemu_log("[");
|
|
|
|
for (i = 0; i < TARGET_NSIG_WORDS; i++) {
|
|
|
|
abi_ulong bits = 0;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
__get_user(bits, &set->sig[i]);
|
|
|
|
for (j = 0; j < sizeof(bits) * 8; j++) {
|
|
|
|
if (bits & ((abi_ulong)1 << j)) {
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
} else {
|
|
|
|
qemu_log(" ");
|
|
|
|
}
|
|
|
|
print_signal_1(sig);
|
|
|
|
}
|
|
|
|
sig++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qemu_log("]%s", get_comma(last));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_target_sigset_t(abi_ulong addr, abi_ulong size, int last)
|
|
|
|
{
|
|
|
|
if (addr && size == sizeof(target_sigset_t)) {
|
|
|
|
target_sigset_t *set;
|
|
|
|
|
|
|
|
set = lock_user(VERIFY_READ, addr, sizeof(target_sigset_t), 1);
|
|
|
|
if (set) {
|
|
|
|
print_target_sigset_t_1(set, last);
|
|
|
|
unlock_user(set, addr, 0);
|
|
|
|
} else {
|
|
|
|
print_pointer(addr, last);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print_pointer(addr, last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-11-01 03:13:36 +03:00
|
|
|
/*
|
|
|
|
* Variants for the return value output function
|
|
|
|
*/
|
|
|
|
|
2020-07-08 18:24:35 +03:00
|
|
|
static bool
|
2020-06-19 15:33:26 +03:00
|
|
|
print_syscall_err(abi_long ret)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
2020-07-08 18:24:35 +03:00
|
|
|
const char *errstr;
|
2011-11-21 15:04:07 +04:00
|
|
|
|
2020-06-19 15:33:26 +03:00
|
|
|
qemu_log(" = ");
|
2022-06-02 04:33:59 +03:00
|
|
|
if (is_error(ret)) {
|
2011-11-21 16:21:19 +04:00
|
|
|
errstr = target_strerror(-ret);
|
2020-06-19 15:33:26 +03:00
|
|
|
if (errstr) {
|
2020-07-08 18:24:35 +03:00
|
|
|
qemu_log("-1 errno=%d (%s)", (int)-ret, errstr);
|
|
|
|
return true;
|
2020-06-19 15:33:26 +03:00
|
|
|
}
|
2011-11-21 15:04:07 +04:00
|
|
|
}
|
2020-07-08 18:24:35 +03:00
|
|
|
return false;
|
2020-06-19 15:33:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_addr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
2020-06-19 15:33:26 +03:00
|
|
|
{
|
2020-07-08 18:24:35 +03:00
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log("0x" TARGET_ABI_FMT_lx, ret);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2020-07-08 18:24:35 +03:00
|
|
|
qemu_log("\n");
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
|
|
|
|
2007-11-03 18:12:16 +03:00
|
|
|
#if 0 /* currently unused */
|
2007-11-01 03:13:36 +03:00
|
|
|
static void
|
2007-11-11 20:23:29 +03:00
|
|
|
print_syscall_ret_raw(struct syscallname *name, abi_long ret)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2007-11-03 18:12:16 +03:00
|
|
|
#endif
|
2007-11-01 03:13:36 +03:00
|
|
|
|
2007-11-03 18:12:16 +03:00
|
|
|
#ifdef TARGET_NR__newselect
|
2007-11-01 03:13:36 +03:00
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_newselect(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
2020-06-19 15:33:26 +03:00
|
|
|
{
|
2020-07-08 18:24:35 +03:00
|
|
|
if (!print_syscall_err(ret)) {
|
2020-06-19 15:33:26 +03:00
|
|
|
qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
|
|
|
|
print_fdset(arg0, arg1);
|
|
|
|
qemu_log(",");
|
|
|
|
print_fdset(arg0, arg2);
|
|
|
|
qemu_log(",");
|
|
|
|
print_fdset(arg0, arg3);
|
|
|
|
qemu_log(",");
|
|
|
|
print_timeval(arg4, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2007-11-03 18:12:16 +03:00
|
|
|
#endif
|
2007-11-01 03:13:36 +03:00
|
|
|
|
2016-09-22 19:56:50 +03:00
|
|
|
/* special meanings of adjtimex()' non-negative return values */
|
|
|
|
#define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
|
|
|
|
#define TARGET_TIME_INS 1 /* insert leap second */
|
|
|
|
#define TARGET_TIME_DEL 2 /* delete leap second */
|
|
|
|
#define TARGET_TIME_OOP 3 /* leap second in progress */
|
|
|
|
#define TARGET_TIME_WAIT 4 /* leap second has occurred */
|
|
|
|
#define TARGET_TIME_ERROR 5 /* clock not synchronized */
|
2020-03-13 01:13:49 +03:00
|
|
|
#ifdef TARGET_NR_adjtimex
|
2016-09-22 19:56:50 +03:00
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_adjtimex(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
2016-09-22 19:56:50 +03:00
|
|
|
{
|
2020-07-08 18:24:35 +03:00
|
|
|
if (!print_syscall_err(ret)) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
2016-09-22 19:56:50 +03:00
|
|
|
switch (ret) {
|
|
|
|
case TARGET_TIME_OK:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(" TIME_OK (clock synchronized, no leap second)");
|
2016-09-22 19:56:50 +03:00
|
|
|
break;
|
|
|
|
case TARGET_TIME_INS:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(" TIME_INS (insert leap second)");
|
2016-09-22 19:56:50 +03:00
|
|
|
break;
|
|
|
|
case TARGET_TIME_DEL:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(" TIME_DEL (delete leap second)");
|
2016-09-22 19:56:50 +03:00
|
|
|
break;
|
|
|
|
case TARGET_TIME_OOP:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(" TIME_OOP (leap second in progress)");
|
2016-09-22 19:56:50 +03:00
|
|
|
break;
|
|
|
|
case TARGET_TIME_WAIT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(" TIME_WAIT (leap second has occurred)");
|
2016-09-22 19:56:50 +03:00
|
|
|
break;
|
|
|
|
case TARGET_TIME_ERROR:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(" TIME_ERROR (clock not synchronized)");
|
2016-09-22 19:56:50 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("\n");
|
2016-09-22 19:56:50 +03:00
|
|
|
}
|
2020-03-13 01:13:49 +03:00
|
|
|
#endif
|
2016-09-22 19:56:50 +03:00
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
qemu_log(" (");
|
|
|
|
print_timespec(arg1, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
|
|
|
|
#endif
|
|
|
|
|
2022-09-18 22:45:45 +03:00
|
|
|
#if defined(TARGET_NR_clock_gettime64)
|
|
|
|
static void
|
|
|
|
print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
qemu_log(" (");
|
|
|
|
print_timespec64(arg1, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
#ifdef TARGET_NR_gettimeofday
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
qemu_log(" (");
|
|
|
|
print_timeval(arg0, 0);
|
|
|
|
print_timezone(arg1, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_getitimer
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
qemu_log(" (");
|
|
|
|
print_itimerval(arg1, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_getitimer
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
qemu_log(" (old_value = ");
|
|
|
|
print_itimerval(arg2, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
|
|
|
|
|| defined(TARGGET_NR_flistxattr)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
{
|
2020-07-08 18:24:35 +03:00
|
|
|
if (!print_syscall_err(ret)) {
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
qemu_log(" (list = ");
|
|
|
|
if (arg1 != 0) {
|
|
|
|
abi_long attr = arg1;
|
|
|
|
while (ret) {
|
|
|
|
if (attr != arg1) {
|
|
|
|
qemu_log(",");
|
|
|
|
}
|
|
|
|
print_string(attr, 1);
|
|
|
|
ret -= target_strlen(attr) + 1;
|
|
|
|
attr += target_strlen(attr) + 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
qemu_log("NULL");
|
|
|
|
}
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#define print_syscall_ret_llistxattr print_syscall_ret_listxattr
|
|
|
|
#define print_syscall_ret_flistxattr print_syscall_ret_listxattr
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing arguments of ioctl()
This patch implements functionality for strace argument printing for ioctls.
When running ioctls through qemu with "-strace", they get printed in format:
"ioctl(fd_num,0x*,0x*) = ret_value"
where the request code an the ioctl's third argument get printed in a hexadicemal
format. This patch changes that by enabling strace to print both the request code
name and the contents of the third argument. For example, when running ioctl
RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
this way:
"ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
In case of IOC_R type ioctls, the contents of the third argument get printed
after the return value, and the argument inside the ioctl call gets printed
as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
"-strace", with changes from this patch, it gets printed in this way:
"ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
In case of IOC_RW type ioctls, the contents of the third argument get printed
both inside the ioctl call and after the return value.
Implementation notes:
Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
in "strace.c", are listed in file "strace.list" as "call" and "result"
value for ioctl. Structure definition "IOCTLEntry" as well as predefined
values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
to file "qemu.h" so that they can be used by these functions to print the
contents of the third ioctl argument. Also, the "static" identifier for array
"ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
so that it can also be used by these functions. To decode the structure type
of the ioctl third argument, function "thunk_print()" was defined in file
"thunk.c" and its definition is somewhat simillar to that of function
"thunk_convert()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
[lv: fix close-bracket]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:47:27 +03:00
|
|
|
#ifdef TARGET_NR_ioctl
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
linux-user: Add strace support for printing arguments of ioctl()
This patch implements functionality for strace argument printing for ioctls.
When running ioctls through qemu with "-strace", they get printed in format:
"ioctl(fd_num,0x*,0x*) = ret_value"
where the request code an the ioctl's third argument get printed in a hexadicemal
format. This patch changes that by enabling strace to print both the request code
name and the contents of the third argument. For example, when running ioctl
RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
this way:
"ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
In case of IOC_R type ioctls, the contents of the third argument get printed
after the return value, and the argument inside the ioctl call gets printed
as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
"-strace", with changes from this patch, it gets printed in this way:
"ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
In case of IOC_RW type ioctls, the contents of the third argument get printed
both inside the ioctl call and after the return value.
Implementation notes:
Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
in "strace.c", are listed in file "strace.list" as "call" and "result"
value for ioctl. Structure definition "IOCTLEntry" as well as predefined
values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
to file "qemu.h" so that they can be used by these functions to print the
contents of the third ioctl argument. Also, the "static" identifier for array
"ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
so that it can also be used by these functions. To decode the structure type
of the ioctl third argument, function "thunk_print()" was defined in file
"thunk.c" and its definition is somewhat simillar to that of function
"thunk_convert()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
[lv: fix close-bracket]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:47:27 +03:00
|
|
|
{
|
2020-07-08 18:24:35 +03:00
|
|
|
if (!print_syscall_err(ret)) {
|
linux-user: Add strace support for printing arguments of ioctl()
This patch implements functionality for strace argument printing for ioctls.
When running ioctls through qemu with "-strace", they get printed in format:
"ioctl(fd_num,0x*,0x*) = ret_value"
where the request code an the ioctl's third argument get printed in a hexadicemal
format. This patch changes that by enabling strace to print both the request code
name and the contents of the third argument. For example, when running ioctl
RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
this way:
"ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
In case of IOC_R type ioctls, the contents of the third argument get printed
after the return value, and the argument inside the ioctl call gets printed
as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
"-strace", with changes from this patch, it gets printed in this way:
"ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
In case of IOC_RW type ioctls, the contents of the third argument get printed
both inside the ioctl call and after the return value.
Implementation notes:
Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
in "strace.c", are listed in file "strace.list" as "call" and "result"
value for ioctl. Structure definition "IOCTLEntry" as well as predefined
values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
to file "qemu.h" so that they can be used by these functions to print the
contents of the third ioctl argument. Also, the "static" identifier for array
"ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
so that it can also be used by these functions. To decode the structure type
of the ioctl third argument, function "thunk_print()" was defined in file
"thunk.c" and its definition is somewhat simillar to that of function
"thunk_convert()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
[lv: fix close-bracket]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:47:27 +03:00
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
|
|
|
|
const IOCTLEntry *ie;
|
|
|
|
const argtype *arg_type;
|
|
|
|
void *argptr;
|
|
|
|
int target_size;
|
|
|
|
|
|
|
|
for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
|
|
|
|
if (ie->target_cmd == arg1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ie->target_cmd == arg1 &&
|
|
|
|
(ie->access == IOC_R || ie->access == IOC_RW)) {
|
|
|
|
arg_type = ie->arg_type;
|
|
|
|
qemu_log(" (");
|
|
|
|
arg_type++;
|
|
|
|
target_size = thunk_type_size(arg_type, 0);
|
|
|
|
argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
|
linux-user: Fix Coverity CID 1430271 / CID 1430272
In new functions print_ioctl() and print_syscall_ret_ioctl(), we don't
check if lock_user() returns NULL and this would cause a segfault in
thunk_print().
If lock_user() returns NULL don't call thunk_print() but prints only the
value of the (invalid) pointer.
Tested with:
# cat ioctl.c
#include <unistd.h>
#include <sys/ioctl.h>
int main(void)
{
int ret;
ret = ioctl(STDOUT_FILENO, TCGETS, 0xdeadbeef);
ret = ioctl(STDOUT_FILENO, TCSETSF, 0xdeadbeef);
return 0;
}
# QEMU_STRACE= ./ioctl
...
578 ioctl(1,TCGETS,0xdeadbeef) = -1 errno=2 (Bad address)
578 ioctl(1,TCSETSF,0xdeadbeef) = -1 errno=2 (Bad address)
...
# QEMU_STRACE= passwd
...
623 ioctl(0,TCGETS,0x3fffed04) = 0 ({})
623 ioctl(0,TCSETSF,{}) = 0
...
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: 79482e5987c8 ("linux-user: Add strace support for printing arguments of ioctl()")
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-09 22:22:17 +03:00
|
|
|
if (argptr) {
|
|
|
|
thunk_print(argptr, arg_type);
|
|
|
|
unlock_user(argptr, arg2, target_size);
|
|
|
|
} else {
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
}
|
linux-user: Add strace support for printing arguments of ioctl()
This patch implements functionality for strace argument printing for ioctls.
When running ioctls through qemu with "-strace", they get printed in format:
"ioctl(fd_num,0x*,0x*) = ret_value"
where the request code an the ioctl's third argument get printed in a hexadicemal
format. This patch changes that by enabling strace to print both the request code
name and the contents of the third argument. For example, when running ioctl
RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
this way:
"ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
In case of IOC_R type ioctls, the contents of the third argument get printed
after the return value, and the argument inside the ioctl call gets printed
as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
"-strace", with changes from this patch, it gets printed in this way:
"ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
In case of IOC_RW type ioctls, the contents of the third argument get printed
both inside the ioctl call and after the return value.
Implementation notes:
Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
in "strace.c", are listed in file "strace.list" as "call" and "result"
value for ioctl. Structure definition "IOCTLEntry" as well as predefined
values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
to file "qemu.h" so that they can be used by these functions to print the
contents of the third ioctl argument. Also, the "static" identifier for array
"ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
so that it can also be used by these functions. To decode the structure type
of the ioctl third argument, function "thunk_print()" was defined in file
"thunk.c" and its definition is somewhat simillar to that of function
"thunk_convert()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
[lv: fix close-bracket]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:47:27 +03:00
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags access_flags[] = {
|
2023-07-07 23:40:33 +03:00
|
|
|
FLAG_GENERIC_MASK(F_OK, R_OK | W_OK | X_OK),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_GENERIC(R_OK),
|
|
|
|
FLAG_GENERIC(W_OK),
|
|
|
|
FLAG_GENERIC(X_OK),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags at_file_flags[] = {
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef AT_EACCESS
|
|
|
|
FLAG_GENERIC(AT_EACCESS),
|
|
|
|
#endif
|
|
|
|
#ifdef AT_SYMLINK_NOFOLLOW
|
|
|
|
FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
|
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags unlinkat_flags[] = {
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef AT_REMOVEDIR
|
|
|
|
FLAG_GENERIC(AT_REMOVEDIR),
|
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags mode_flags[] = {
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_GENERIC(S_IFSOCK),
|
|
|
|
FLAG_GENERIC(S_IFLNK),
|
|
|
|
FLAG_GENERIC(S_IFREG),
|
|
|
|
FLAG_GENERIC(S_IFBLK),
|
|
|
|
FLAG_GENERIC(S_IFDIR),
|
|
|
|
FLAG_GENERIC(S_IFCHR),
|
|
|
|
FLAG_GENERIC(S_IFIFO),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags open_access_flags[] = {
|
2023-07-07 23:40:33 +03:00
|
|
|
FLAG_TARGET_MASK(O_RDONLY, O_ACCMODE),
|
|
|
|
FLAG_TARGET_MASK(O_WRONLY, O_ACCMODE),
|
|
|
|
FLAG_TARGET_MASK(O_RDWR, O_ACCMODE),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags open_flags[] = {
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(O_APPEND),
|
|
|
|
FLAG_TARGET(O_CREAT),
|
|
|
|
FLAG_TARGET(O_DIRECTORY),
|
|
|
|
FLAG_TARGET(O_EXCL),
|
2023-07-07 23:40:33 +03:00
|
|
|
#if TARGET_O_LARGEFILE != 0
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(O_LARGEFILE),
|
2023-07-07 23:40:33 +03:00
|
|
|
#endif
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(O_NOCTTY),
|
|
|
|
FLAG_TARGET(O_NOFOLLOW),
|
|
|
|
FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
|
2012-07-26 01:30:34 +04:00
|
|
|
FLAG_TARGET(O_DSYNC),
|
|
|
|
FLAG_TARGET(__O_SYNC),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(O_TRUNC),
|
|
|
|
#ifdef O_DIRECT
|
|
|
|
FLAG_TARGET(O_DIRECT),
|
2012-07-26 01:30:34 +04:00
|
|
|
#endif
|
|
|
|
#ifdef O_NOATIME
|
|
|
|
FLAG_TARGET(O_NOATIME),
|
|
|
|
#endif
|
|
|
|
#ifdef O_CLOEXEC
|
|
|
|
FLAG_TARGET(O_CLOEXEC),
|
|
|
|
#endif
|
|
|
|
#ifdef O_PATH
|
|
|
|
FLAG_TARGET(O_PATH),
|
2017-08-08 16:01:19 +03:00
|
|
|
#endif
|
|
|
|
#ifdef O_TMPFILE
|
|
|
|
FLAG_TARGET(O_TMPFILE),
|
|
|
|
FLAG_TARGET(__O_TMPFILE),
|
2009-04-07 17:57:29 +04:00
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2024-10-01 18:14:54 +03:00
|
|
|
UNUSED static const struct flags openat2_resolve_flags[] = {
|
|
|
|
#ifdef HAVE_OPENAT2_H
|
|
|
|
FLAG_GENERIC(RESOLVE_NO_XDEV),
|
|
|
|
FLAG_GENERIC(RESOLVE_NO_MAGICLINKS),
|
|
|
|
FLAG_GENERIC(RESOLVE_NO_SYMLINKS),
|
|
|
|
FLAG_GENERIC(RESOLVE_BENEATH),
|
|
|
|
FLAG_GENERIC(RESOLVE_IN_ROOT),
|
|
|
|
FLAG_GENERIC(RESOLVE_CACHED),
|
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags mount_flags[] = {
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef MS_BIND
|
|
|
|
FLAG_GENERIC(MS_BIND),
|
|
|
|
#endif
|
|
|
|
#ifdef MS_DIRSYNC
|
|
|
|
FLAG_GENERIC(MS_DIRSYNC),
|
|
|
|
#endif
|
|
|
|
FLAG_GENERIC(MS_MANDLOCK),
|
|
|
|
#ifdef MS_MOVE
|
|
|
|
FLAG_GENERIC(MS_MOVE),
|
|
|
|
#endif
|
|
|
|
FLAG_GENERIC(MS_NOATIME),
|
|
|
|
FLAG_GENERIC(MS_NODEV),
|
|
|
|
FLAG_GENERIC(MS_NODIRATIME),
|
|
|
|
FLAG_GENERIC(MS_NOEXEC),
|
|
|
|
FLAG_GENERIC(MS_NOSUID),
|
|
|
|
FLAG_GENERIC(MS_RDONLY),
|
|
|
|
#ifdef MS_RELATIME
|
|
|
|
FLAG_GENERIC(MS_RELATIME),
|
|
|
|
#endif
|
|
|
|
FLAG_GENERIC(MS_REMOUNT),
|
|
|
|
FLAG_GENERIC(MS_SYNCHRONOUS),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags umount2_flags[] = {
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef MNT_FORCE
|
|
|
|
FLAG_GENERIC(MNT_FORCE),
|
|
|
|
#endif
|
|
|
|
#ifdef MNT_DETACH
|
|
|
|
FLAG_GENERIC(MNT_DETACH),
|
|
|
|
#endif
|
|
|
|
#ifdef MNT_EXPIRE
|
|
|
|
FLAG_GENERIC(MNT_EXPIRE),
|
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags mmap_prot_flags[] = {
|
2023-07-07 23:40:33 +03:00
|
|
|
FLAG_GENERIC_MASK(PROT_NONE, PROT_READ | PROT_WRITE | PROT_EXEC),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_GENERIC(PROT_EXEC),
|
|
|
|
FLAG_GENERIC(PROT_READ),
|
|
|
|
FLAG_GENERIC(PROT_WRITE),
|
2010-06-16 16:03:51 +04:00
|
|
|
FLAG_TARGET(PROT_SEM),
|
|
|
|
FLAG_GENERIC(PROT_GROWSDOWN),
|
|
|
|
FLAG_GENERIC(PROT_GROWSUP),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags mmap_flags[] = {
|
2023-07-07 23:40:36 +03:00
|
|
|
FLAG_TARGET_MASK(MAP_SHARED, MAP_TYPE),
|
|
|
|
FLAG_TARGET_MASK(MAP_PRIVATE, MAP_TYPE),
|
|
|
|
FLAG_TARGET_MASK(MAP_SHARED_VALIDATE, MAP_TYPE),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(MAP_ANONYMOUS),
|
|
|
|
FLAG_TARGET(MAP_DENYWRITE),
|
2023-07-07 23:40:36 +03:00
|
|
|
FLAG_TARGET(MAP_EXECUTABLE),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(MAP_FIXED),
|
2023-07-07 23:40:36 +03:00
|
|
|
FLAG_TARGET(MAP_FIXED_NOREPLACE),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(MAP_GROWSDOWN),
|
2023-07-07 23:40:36 +03:00
|
|
|
FLAG_TARGET(MAP_HUGETLB),
|
2009-04-07 17:57:29 +04:00
|
|
|
FLAG_TARGET(MAP_LOCKED),
|
|
|
|
FLAG_TARGET(MAP_NONBLOCK),
|
|
|
|
FLAG_TARGET(MAP_NORESERVE),
|
|
|
|
FLAG_TARGET(MAP_POPULATE),
|
2023-07-07 23:40:36 +03:00
|
|
|
FLAG_TARGET(MAP_STACK),
|
|
|
|
FLAG_TARGET(MAP_SYNC),
|
|
|
|
#if TARGET_MAP_UNINITIALIZED != 0
|
2011-02-07 09:05:52 +03:00
|
|
|
FLAG_TARGET(MAP_UNINITIALIZED),
|
2009-04-07 17:57:29 +04:00
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-29 14:08:20 +03:00
|
|
|
#ifndef CLONE_PIDFD
|
|
|
|
# define CLONE_PIDFD 0x00001000
|
|
|
|
#endif
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags clone_flags[] = {
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_VM),
|
|
|
|
FLAG_GENERIC(CLONE_FS),
|
|
|
|
FLAG_GENERIC(CLONE_FILES),
|
|
|
|
FLAG_GENERIC(CLONE_SIGHAND),
|
2022-11-29 14:08:20 +03:00
|
|
|
FLAG_GENERIC(CLONE_PIDFD),
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_PTRACE),
|
|
|
|
FLAG_GENERIC(CLONE_VFORK),
|
|
|
|
FLAG_GENERIC(CLONE_PARENT),
|
|
|
|
FLAG_GENERIC(CLONE_THREAD),
|
|
|
|
FLAG_GENERIC(CLONE_NEWNS),
|
|
|
|
FLAG_GENERIC(CLONE_SYSVSEM),
|
|
|
|
FLAG_GENERIC(CLONE_SETTLS),
|
|
|
|
FLAG_GENERIC(CLONE_PARENT_SETTID),
|
|
|
|
FLAG_GENERIC(CLONE_CHILD_CLEARTID),
|
|
|
|
FLAG_GENERIC(CLONE_DETACHED),
|
|
|
|
FLAG_GENERIC(CLONE_UNTRACED),
|
|
|
|
FLAG_GENERIC(CLONE_CHILD_SETTID),
|
2011-04-27 12:44:38 +04:00
|
|
|
#if defined(CLONE_NEWUTS)
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_NEWUTS),
|
2011-04-27 12:44:38 +04:00
|
|
|
#endif
|
|
|
|
#if defined(CLONE_NEWIPC)
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_NEWIPC),
|
2011-04-27 12:44:38 +04:00
|
|
|
#endif
|
|
|
|
#if defined(CLONE_NEWUSER)
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_NEWUSER),
|
2011-04-27 12:44:38 +04:00
|
|
|
#endif
|
|
|
|
#if defined(CLONE_NEWPID)
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_NEWPID),
|
2011-04-27 12:44:38 +04:00
|
|
|
#endif
|
|
|
|
#if defined(CLONE_NEWNET)
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_NEWNET),
|
2011-04-27 12:44:38 +04:00
|
|
|
#endif
|
2021-04-06 17:42:03 +03:00
|
|
|
#if defined(CLONE_NEWCGROUP)
|
|
|
|
FLAG_GENERIC(CLONE_NEWCGROUP),
|
|
|
|
#endif
|
|
|
|
#if defined(CLONE_NEWTIME)
|
|
|
|
FLAG_GENERIC(CLONE_NEWTIME),
|
|
|
|
#endif
|
2011-04-27 12:44:38 +04:00
|
|
|
#if defined(CLONE_IO)
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_GENERIC(CLONE_IO),
|
2011-04-27 12:44:38 +04:00
|
|
|
#endif
|
2011-04-07 02:25:32 +04:00
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:30 +03:00
|
|
|
UNUSED static const struct flags execveat_flags[] = {
|
|
|
|
#ifdef AT_EMPTY_PATH
|
|
|
|
FLAG_GENERIC(AT_EMPTY_PATH),
|
|
|
|
#endif
|
|
|
|
#ifdef AT_SYMLINK_NOFOLLOW
|
|
|
|
FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
|
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags msg_flags[] = {
|
2016-06-11 03:19:45 +03:00
|
|
|
/* send */
|
|
|
|
FLAG_GENERIC(MSG_CONFIRM),
|
|
|
|
FLAG_GENERIC(MSG_DONTROUTE),
|
|
|
|
FLAG_GENERIC(MSG_DONTWAIT),
|
|
|
|
FLAG_GENERIC(MSG_EOR),
|
|
|
|
FLAG_GENERIC(MSG_MORE),
|
|
|
|
FLAG_GENERIC(MSG_NOSIGNAL),
|
|
|
|
FLAG_GENERIC(MSG_OOB),
|
|
|
|
/* recv */
|
|
|
|
FLAG_GENERIC(MSG_CMSG_CLOEXEC),
|
|
|
|
FLAG_GENERIC(MSG_ERRQUEUE),
|
|
|
|
FLAG_GENERIC(MSG_PEEK),
|
|
|
|
FLAG_GENERIC(MSG_TRUNC),
|
|
|
|
FLAG_GENERIC(MSG_WAITALL),
|
|
|
|
/* recvmsg */
|
|
|
|
FLAG_GENERIC(MSG_CTRUNC),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags statx_flags[] = {
|
2019-06-28 13:43:35 +03:00
|
|
|
#ifdef AT_EMPTY_PATH
|
|
|
|
FLAG_GENERIC(AT_EMPTY_PATH),
|
|
|
|
#endif
|
|
|
|
#ifdef AT_NO_AUTOMOUNT
|
|
|
|
FLAG_GENERIC(AT_NO_AUTOMOUNT),
|
|
|
|
#endif
|
|
|
|
#ifdef AT_SYMLINK_NOFOLLOW
|
|
|
|
FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
|
|
|
|
#endif
|
|
|
|
#ifdef AT_STATX_SYNC_AS_STAT
|
2023-07-07 23:40:33 +03:00
|
|
|
FLAG_GENERIC_MASK(AT_STATX_SYNC_AS_STAT, AT_STATX_SYNC_TYPE),
|
2019-06-28 13:43:35 +03:00
|
|
|
#endif
|
|
|
|
#ifdef AT_STATX_FORCE_SYNC
|
2023-07-07 23:40:33 +03:00
|
|
|
FLAG_GENERIC_MASK(AT_STATX_FORCE_SYNC, AT_STATX_SYNC_TYPE),
|
2019-06-28 13:43:35 +03:00
|
|
|
#endif
|
|
|
|
#ifdef AT_STATX_DONT_SYNC
|
2023-07-07 23:40:33 +03:00
|
|
|
FLAG_GENERIC_MASK(AT_STATX_DONT_SYNC, AT_STATX_SYNC_TYPE),
|
2019-06-28 13:43:35 +03:00
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags statx_mask[] = {
|
2019-06-28 13:43:35 +03:00
|
|
|
/* This must come first, because it includes everything. */
|
|
|
|
#ifdef STATX_ALL
|
|
|
|
FLAG_GENERIC(STATX_ALL),
|
|
|
|
#endif
|
|
|
|
/* This must come second; it includes everything except STATX_BTIME. */
|
|
|
|
#ifdef STATX_BASIC_STATS
|
|
|
|
FLAG_GENERIC(STATX_BASIC_STATS),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_TYPE
|
|
|
|
FLAG_GENERIC(STATX_TYPE),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_MODE
|
|
|
|
FLAG_GENERIC(STATX_MODE),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_NLINK
|
|
|
|
FLAG_GENERIC(STATX_NLINK),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_UID
|
|
|
|
FLAG_GENERIC(STATX_UID),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_GID
|
|
|
|
FLAG_GENERIC(STATX_GID),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_ATIME
|
|
|
|
FLAG_GENERIC(STATX_ATIME),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_MTIME
|
|
|
|
FLAG_GENERIC(STATX_MTIME),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_CTIME
|
|
|
|
FLAG_GENERIC(STATX_CTIME),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_INO
|
|
|
|
FLAG_GENERIC(STATX_INO),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_SIZE
|
|
|
|
FLAG_GENERIC(STATX_SIZE),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_BLOCKS
|
|
|
|
FLAG_GENERIC(STATX_BLOCKS),
|
|
|
|
#endif
|
|
|
|
#ifdef STATX_BTIME
|
|
|
|
FLAG_GENERIC(STATX_BTIME),
|
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags falloc_flags[] = {
|
2020-06-19 15:33:31 +03:00
|
|
|
FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
|
|
|
|
FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE),
|
|
|
|
#ifdef FALLOC_FL_NO_HIDE_STALE
|
|
|
|
FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE),
|
|
|
|
#endif
|
|
|
|
#ifdef FALLOC_FL_COLLAPSE_RANGE
|
|
|
|
FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE),
|
|
|
|
#endif
|
|
|
|
#ifdef FALLOC_FL_ZERO_RANGE
|
|
|
|
FLAG_GENERIC(FALLOC_FL_ZERO_RANGE),
|
|
|
|
#endif
|
|
|
|
#ifdef FALLOC_FL_INSERT_RANGE
|
|
|
|
FLAG_GENERIC(FALLOC_FL_INSERT_RANGE),
|
|
|
|
#endif
|
|
|
|
#ifdef FALLOC_FL_UNSHARE_RANGE
|
|
|
|
FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE),
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags termios_iflags[] = {
|
2020-07-24 00:02:33 +03:00
|
|
|
FLAG_TARGET(IGNBRK),
|
|
|
|
FLAG_TARGET(BRKINT),
|
|
|
|
FLAG_TARGET(IGNPAR),
|
|
|
|
FLAG_TARGET(PARMRK),
|
|
|
|
FLAG_TARGET(INPCK),
|
|
|
|
FLAG_TARGET(ISTRIP),
|
|
|
|
FLAG_TARGET(INLCR),
|
|
|
|
FLAG_TARGET(IGNCR),
|
|
|
|
FLAG_TARGET(ICRNL),
|
|
|
|
FLAG_TARGET(IUCLC),
|
|
|
|
FLAG_TARGET(IXON),
|
|
|
|
FLAG_TARGET(IXANY),
|
|
|
|
FLAG_TARGET(IXOFF),
|
|
|
|
FLAG_TARGET(IMAXBEL),
|
|
|
|
FLAG_TARGET(IUTF8),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags termios_oflags[] = {
|
2020-07-24 00:02:33 +03:00
|
|
|
FLAG_TARGET(OPOST),
|
|
|
|
FLAG_TARGET(OLCUC),
|
|
|
|
FLAG_TARGET(ONLCR),
|
|
|
|
FLAG_TARGET(OCRNL),
|
|
|
|
FLAG_TARGET(ONOCR),
|
|
|
|
FLAG_TARGET(ONLRET),
|
|
|
|
FLAG_TARGET(OFILL),
|
|
|
|
FLAG_TARGET(OFDEL),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_oflags_NLDLY[] = {
|
|
|
|
ENUM_TARGET(NL0),
|
|
|
|
ENUM_TARGET(NL1),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_oflags_CRDLY[] = {
|
|
|
|
ENUM_TARGET(CR0),
|
|
|
|
ENUM_TARGET(CR1),
|
|
|
|
ENUM_TARGET(CR2),
|
|
|
|
ENUM_TARGET(CR3),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_oflags_TABDLY[] = {
|
|
|
|
ENUM_TARGET(TAB0),
|
|
|
|
ENUM_TARGET(TAB1),
|
|
|
|
ENUM_TARGET(TAB2),
|
|
|
|
ENUM_TARGET(TAB3),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_oflags_VTDLY[] = {
|
|
|
|
ENUM_TARGET(VT0),
|
|
|
|
ENUM_TARGET(VT1),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_oflags_FFDLY[] = {
|
|
|
|
ENUM_TARGET(FF0),
|
|
|
|
ENUM_TARGET(FF1),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_oflags_BSDLY[] = {
|
|
|
|
ENUM_TARGET(BS0),
|
|
|
|
ENUM_TARGET(BS1),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_cflags_CBAUD[] = {
|
|
|
|
ENUM_TARGET(B0),
|
|
|
|
ENUM_TARGET(B50),
|
|
|
|
ENUM_TARGET(B75),
|
|
|
|
ENUM_TARGET(B110),
|
|
|
|
ENUM_TARGET(B134),
|
|
|
|
ENUM_TARGET(B150),
|
|
|
|
ENUM_TARGET(B200),
|
|
|
|
ENUM_TARGET(B300),
|
|
|
|
ENUM_TARGET(B600),
|
|
|
|
ENUM_TARGET(B1200),
|
|
|
|
ENUM_TARGET(B1800),
|
|
|
|
ENUM_TARGET(B2400),
|
|
|
|
ENUM_TARGET(B4800),
|
|
|
|
ENUM_TARGET(B9600),
|
|
|
|
ENUM_TARGET(B19200),
|
|
|
|
ENUM_TARGET(B38400),
|
|
|
|
ENUM_TARGET(B57600),
|
|
|
|
ENUM_TARGET(B115200),
|
|
|
|
ENUM_TARGET(B230400),
|
|
|
|
ENUM_TARGET(B460800),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums termios_cflags_CSIZE[] = {
|
|
|
|
ENUM_TARGET(CS5),
|
|
|
|
ENUM_TARGET(CS6),
|
|
|
|
ENUM_TARGET(CS7),
|
|
|
|
ENUM_TARGET(CS8),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags termios_cflags[] = {
|
2020-07-24 00:02:33 +03:00
|
|
|
FLAG_TARGET(CSTOPB),
|
|
|
|
FLAG_TARGET(CREAD),
|
|
|
|
FLAG_TARGET(PARENB),
|
|
|
|
FLAG_TARGET(PARODD),
|
|
|
|
FLAG_TARGET(HUPCL),
|
|
|
|
FLAG_TARGET(CLOCAL),
|
|
|
|
FLAG_TARGET(CRTSCTS),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2022-11-04 20:36:28 +03:00
|
|
|
UNUSED static const struct flags termios_lflags[] = {
|
2020-07-24 00:02:33 +03:00
|
|
|
FLAG_TARGET(ISIG),
|
|
|
|
FLAG_TARGET(ICANON),
|
|
|
|
FLAG_TARGET(XCASE),
|
|
|
|
FLAG_TARGET(ECHO),
|
|
|
|
FLAG_TARGET(ECHOE),
|
|
|
|
FLAG_TARGET(ECHOK),
|
|
|
|
FLAG_TARGET(ECHONL),
|
|
|
|
FLAG_TARGET(NOFLSH),
|
|
|
|
FLAG_TARGET(TOSTOP),
|
|
|
|
FLAG_TARGET(ECHOCTL),
|
|
|
|
FLAG_TARGET(ECHOPRT),
|
|
|
|
FLAG_TARGET(ECHOKE),
|
|
|
|
FLAG_TARGET(FLUSHO),
|
|
|
|
FLAG_TARGET(PENDIN),
|
|
|
|
FLAG_TARGET(IEXTEN),
|
|
|
|
FLAG_TARGET(EXTPROC),
|
|
|
|
FLAG_END,
|
|
|
|
};
|
|
|
|
|
2023-01-18 12:01:44 +03:00
|
|
|
#ifdef TARGET_NR_mlockall
|
|
|
|
static const struct flags mlockall_flags[] = {
|
2020-08-11 19:45:51 +03:00
|
|
|
FLAG_TARGET(MCL_CURRENT),
|
|
|
|
FLAG_TARGET(MCL_FUTURE),
|
|
|
|
#ifdef MCL_ONFAULT
|
|
|
|
FLAG_TARGET(MCL_ONFAULT),
|
|
|
|
#endif
|
|
|
|
FLAG_END,
|
|
|
|
};
|
2023-01-18 12:01:44 +03:00
|
|
|
#endif
|
2020-08-11 19:45:51 +03:00
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
/* IDs of the various system clocks */
|
|
|
|
#define TARGET_CLOCK_REALTIME 0
|
|
|
|
#define TARGET_CLOCK_MONOTONIC 1
|
|
|
|
#define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
|
|
|
|
#define TARGET_CLOCK_THREAD_CPUTIME_ID 3
|
|
|
|
#define TARGET_CLOCK_MONOTONIC_RAW 4
|
|
|
|
#define TARGET_CLOCK_REALTIME_COARSE 5
|
|
|
|
#define TARGET_CLOCK_MONOTONIC_COARSE 6
|
|
|
|
#define TARGET_CLOCK_BOOTTIME 7
|
|
|
|
#define TARGET_CLOCK_REALTIME_ALARM 8
|
|
|
|
#define TARGET_CLOCK_BOOTTIME_ALARM 9
|
|
|
|
#define TARGET_CLOCK_SGI_CYCLE 10
|
|
|
|
#define TARGET_CLOCK_TAI 11
|
|
|
|
|
|
|
|
UNUSED static struct enums clockids[] = {
|
|
|
|
ENUM_TARGET(CLOCK_REALTIME),
|
|
|
|
ENUM_TARGET(CLOCK_MONOTONIC),
|
|
|
|
ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID),
|
|
|
|
ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID),
|
|
|
|
ENUM_TARGET(CLOCK_MONOTONIC_RAW),
|
|
|
|
ENUM_TARGET(CLOCK_REALTIME_COARSE),
|
|
|
|
ENUM_TARGET(CLOCK_MONOTONIC_COARSE),
|
|
|
|
ENUM_TARGET(CLOCK_BOOTTIME),
|
|
|
|
ENUM_TARGET(CLOCK_REALTIME_ALARM),
|
|
|
|
ENUM_TARGET(CLOCK_BOOTTIME_ALARM),
|
|
|
|
ENUM_TARGET(CLOCK_SGI_CYCLE),
|
|
|
|
ENUM_TARGET(CLOCK_TAI),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
UNUSED static struct enums itimer_types[] = {
|
|
|
|
ENUM_GENERIC(ITIMER_REAL),
|
|
|
|
ENUM_GENERIC(ITIMER_VIRTUAL),
|
|
|
|
ENUM_GENERIC(ITIMER_PROF),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
/*
|
|
|
|
* print_xxx utility functions. These are used to print syscall
|
|
|
|
* parameters in certain format. All of these have parameter
|
|
|
|
* named 'last'. This parameter is used to add comma to output
|
|
|
|
* when last == 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
get_comma(int last)
|
|
|
|
{
|
|
|
|
return ((last) ? "" : ",");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_flags(const struct flags *f, abi_long flags, int last)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
const char *sep = "";
|
|
|
|
int n;
|
|
|
|
|
|
|
|
for (n = 0; f->f_string != NULL; f++) {
|
2023-07-07 23:40:33 +03:00
|
|
|
if ((flags & f->f_mask) == f->f_value) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s%s", sep, f->f_string);
|
2023-07-07 23:40:33 +03:00
|
|
|
flags &= ~f->f_mask;
|
2009-04-07 17:57:29 +04:00
|
|
|
sep = "|";
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n > 0) {
|
|
|
|
/* print rest of the flags as numeric */
|
|
|
|
if (flags != 0) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
} else {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s", get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* no string version of flags found, print them in hex then */
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%#x%s", (unsigned int)flags, get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 19:45:52 +03:00
|
|
|
static void
|
|
|
|
print_enums(const struct enums *e, abi_long enum_arg, int last)
|
|
|
|
{
|
|
|
|
for (; e->e_string != NULL; e++) {
|
|
|
|
if (e->e_value == enum_arg) {
|
|
|
|
qemu_log("%s", e->e_string);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e->e_string == NULL) {
|
|
|
|
qemu_log("%#x", (unsigned int)enum_arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("%s", get_comma(last));
|
|
|
|
}
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
static void
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_at_dirfd(abi_long dirfd, int last)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
#ifdef AT_FDCWD
|
|
|
|
if (dirfd == AT_FDCWD) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("AT_FDCWD%s", get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%d%s", (int)dirfd, get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_file_mode(abi_long mode, int last)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
const char *sep = "";
|
|
|
|
const struct flags *m;
|
|
|
|
|
2022-09-18 22:45:50 +03:00
|
|
|
if (mode == 0) {
|
|
|
|
qemu_log("000%s", get_comma(last));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
for (m = &mode_flags[0]; m->f_string != NULL; m++) {
|
|
|
|
if ((m->f_value & mode) == m->f_value) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s%s", m->f_string, sep);
|
2009-04-07 17:57:29 +04:00
|
|
|
sep = "|";
|
|
|
|
mode &= ~m->f_value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mode &= ~S_IFMT;
|
|
|
|
/* print rest of the mode as octal */
|
|
|
|
if (mode != 0)
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s%#o", sep, (unsigned int)mode);
|
2009-04-07 17:57:29 +04:00
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s", get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_open_flags(abi_long flags, int last)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
|
|
|
|
flags &= ~TARGET_O_ACCMODE;
|
|
|
|
if (flags == 0) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s", get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
return;
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("|");
|
2009-04-07 17:57:29 +04:00
|
|
|
print_flags(open_flags, flags, last);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_syscall_prologue(const struct syscallname *sc)
|
|
|
|
{
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", sc->name);
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
static void
|
|
|
|
print_syscall_epilogue(const struct syscallname *sc)
|
|
|
|
{
|
|
|
|
(void)sc;
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_string(abi_long addr, int last)
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
if ((s = lock_user_string(addr)) != NULL) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("\"%s\"%s", s, get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
unlock_user(s, addr, 0);
|
|
|
|
} else {
|
|
|
|
/* can't get string out of it, so print it as pointer */
|
|
|
|
print_pointer(addr, last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-11 03:19:45 +03:00
|
|
|
#define MAX_PRINT_BUF 40
|
|
|
|
static void
|
|
|
|
print_buf(abi_long addr, abi_long len, int last)
|
|
|
|
{
|
|
|
|
uint8_t *s;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
s = lock_user(VERIFY_READ, addr, len, 1);
|
|
|
|
if (s) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("\"");
|
2016-06-11 03:19:45 +03:00
|
|
|
for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
|
|
|
|
if (isprint(s[i])) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%c", s[i]);
|
2016-06-11 03:19:45 +03:00
|
|
|
} else {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("\\%o", s[i]);
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("\"");
|
2016-06-11 03:19:45 +03:00
|
|
|
if (i != len) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("...");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
if (!last) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
unlock_user(s, addr, 0);
|
|
|
|
} else {
|
|
|
|
print_pointer(addr, last);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 15:43:04 +03:00
|
|
|
static void
|
|
|
|
print_buf_len(abi_long addr, abi_long len, int last)
|
|
|
|
{
|
|
|
|
print_buf(addr, len, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, len, last);
|
|
|
|
}
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
/*
|
|
|
|
* Prints out raw parameter using given format. Caller needs
|
|
|
|
* to do byte swapping if needed.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
print_raw_param(const char *fmt, abi_long param, int last)
|
|
|
|
{
|
|
|
|
char format[64];
|
|
|
|
|
|
|
|
(void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(format, param);
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
2023-01-31 20:18:36 +03:00
|
|
|
/*
|
|
|
|
* Same as print_raw_param() but prints out raw 64-bit parameter.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
print_raw_param64(const char *fmt, long long param, int last)
|
|
|
|
{
|
|
|
|
char format[64];
|
|
|
|
|
|
|
|
(void)snprintf(format, sizeof(format), "%s%s", fmt, get_comma(last));
|
|
|
|
qemu_log(format, param);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
static void
|
|
|
|
print_pointer(abi_long p, int last)
|
|
|
|
{
|
|
|
|
if (p == 0)
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NULL%s", get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
else
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reads 32-bit (int) number from guest address space from
|
|
|
|
* address 'addr' and prints it.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
print_number(abi_long addr, int last)
|
|
|
|
{
|
|
|
|
if (addr == 0) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NULL%s", get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
} else {
|
|
|
|
int num;
|
|
|
|
|
|
|
|
get_user_s32(num, addr);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("[%d]%s", num, get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_timeval(abi_ulong tv_addr, int last)
|
|
|
|
{
|
|
|
|
if( tv_addr ) {
|
|
|
|
struct target_timeval *tv;
|
|
|
|
|
|
|
|
tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
|
2019-10-21 14:48:49 +03:00
|
|
|
if (!tv) {
|
|
|
|
print_pointer(tv_addr, last);
|
2009-04-07 17:57:29 +04:00
|
|
|
return;
|
2019-10-21 14:48:49 +03:00
|
|
|
}
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
|
|
|
|
",tv_usec = " TARGET_ABI_FMT_ld "}%s",
|
|
|
|
tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
unlock_user(tv, tv_addr, 0);
|
|
|
|
} else
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NULL%s", get_comma(last));
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
static void
|
|
|
|
print_timespec(abi_ulong ts_addr, int last)
|
|
|
|
{
|
|
|
|
if (ts_addr) {
|
|
|
|
struct target_timespec *ts;
|
|
|
|
|
|
|
|
ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
|
|
|
|
if (!ts) {
|
|
|
|
print_pointer(ts_addr, last);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
|
|
|
|
",tv_nsec = " TARGET_ABI_FMT_ld "}%s",
|
|
|
|
tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last));
|
|
|
|
unlock_user(ts, ts_addr, 0);
|
|
|
|
} else {
|
|
|
|
qemu_log("NULL%s", get_comma(last));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-18 22:45:45 +03:00
|
|
|
static void
|
|
|
|
print_timespec64(abi_ulong ts_addr, int last)
|
|
|
|
{
|
|
|
|
if (ts_addr) {
|
|
|
|
struct target__kernel_timespec *ts;
|
|
|
|
|
|
|
|
ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
|
|
|
|
if (!ts) {
|
|
|
|
print_pointer(ts_addr, last);
|
|
|
|
return;
|
|
|
|
}
|
2023-01-31 20:18:36 +03:00
|
|
|
print_raw_param64("{tv_sec=%" PRId64, tswap64(ts->tv_sec), 0);
|
|
|
|
print_raw_param64("tv_nsec=%" PRId64 "}", tswap64(ts->tv_nsec), last);
|
2022-09-18 22:45:45 +03:00
|
|
|
unlock_user(ts, ts_addr, 0);
|
|
|
|
} else {
|
|
|
|
qemu_log("NULL%s", get_comma(last));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-21 14:48:50 +03:00
|
|
|
static void
|
|
|
|
print_timezone(abi_ulong tz_addr, int last)
|
|
|
|
{
|
|
|
|
if (tz_addr) {
|
|
|
|
struct target_timezone *tz;
|
|
|
|
|
|
|
|
tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
|
|
|
|
if (!tz) {
|
|
|
|
print_pointer(tz_addr, last);
|
|
|
|
return;
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest),
|
2019-10-21 14:48:50 +03:00
|
|
|
tswap32(tz->tz_dsttime), get_comma(last));
|
|
|
|
unlock_user(tz, tz_addr, 0);
|
|
|
|
} else {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("NULL%s", get_comma(last));
|
2019-10-21 14:48:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
static void
|
|
|
|
print_itimerval(abi_ulong it_addr, int last)
|
|
|
|
{
|
|
|
|
if (it_addr) {
|
|
|
|
qemu_log("{it_interval=");
|
|
|
|
print_timeval(it_addr +
|
|
|
|
offsetof(struct target_itimerval, it_interval), 0);
|
|
|
|
qemu_log("it_value=");
|
|
|
|
print_timeval(it_addr +
|
|
|
|
offsetof(struct target_itimerval, it_value), 0);
|
|
|
|
qemu_log("}%s", get_comma(last));
|
|
|
|
} else {
|
|
|
|
qemu_log("NULL%s", get_comma(last));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-24 00:02:33 +03:00
|
|
|
void
|
|
|
|
print_termios(void *arg)
|
|
|
|
{
|
|
|
|
const struct target_termios *target = arg;
|
|
|
|
|
|
|
|
target_tcflag_t iflags = tswap32(target->c_iflag);
|
|
|
|
target_tcflag_t oflags = tswap32(target->c_oflag);
|
|
|
|
target_tcflag_t cflags = tswap32(target->c_cflag);
|
|
|
|
target_tcflag_t lflags = tswap32(target->c_lflag);
|
|
|
|
|
|
|
|
qemu_log("{");
|
|
|
|
|
|
|
|
qemu_log("c_iflag = ");
|
|
|
|
print_flags(termios_iflags, iflags, 0);
|
|
|
|
|
|
|
|
qemu_log("c_oflag = ");
|
|
|
|
target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY |
|
|
|
|
TARGET_TABDLY | TARGET_BSDLY |
|
|
|
|
TARGET_VTDLY | TARGET_FFDLY);
|
|
|
|
print_flags(termios_oflags, oflags_clean, 0);
|
|
|
|
if (oflags & TARGET_NLDLY) {
|
|
|
|
print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0);
|
|
|
|
}
|
|
|
|
if (oflags & TARGET_CRDLY) {
|
|
|
|
print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0);
|
|
|
|
}
|
|
|
|
if (oflags & TARGET_TABDLY) {
|
|
|
|
print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0);
|
|
|
|
}
|
|
|
|
if (oflags & TARGET_BSDLY) {
|
|
|
|
print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0);
|
|
|
|
}
|
|
|
|
if (oflags & TARGET_VTDLY) {
|
|
|
|
print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0);
|
|
|
|
}
|
|
|
|
if (oflags & TARGET_FFDLY) {
|
|
|
|
print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("c_cflag = ");
|
|
|
|
if (cflags & TARGET_CBAUD) {
|
|
|
|
print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0);
|
|
|
|
}
|
|
|
|
if (cflags & TARGET_CSIZE) {
|
|
|
|
print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0);
|
|
|
|
}
|
|
|
|
target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE);
|
|
|
|
print_flags(termios_cflags, cflags_clean, 0);
|
|
|
|
|
|
|
|
qemu_log("c_lflag = ");
|
|
|
|
print_flags(termios_lflags, lflags, 0);
|
|
|
|
|
|
|
|
qemu_log("c_cc = ");
|
|
|
|
qemu_log("\"%s\",", target->c_cc);
|
|
|
|
|
|
|
|
qemu_log("c_line = ");
|
|
|
|
print_raw_param("\'%c\'", target->c_line, 1);
|
|
|
|
|
|
|
|
qemu_log("}");
|
|
|
|
}
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#undef UNUSED
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_accept
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_accept(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg0, 0);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_pointer(arg1, 0);
|
|
|
|
print_number(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_access
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_access(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_flags(access_flags, arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-06-19 15:33:27 +03:00
|
|
|
#ifdef TARGET_NR_acct
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_acct(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2020-06-19 15:33:27 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_brk
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_brk(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_pointer(arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_chdir
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_chdir(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-27 22:11:15 +03:00
|
|
|
#ifdef TARGET_NR_chroot
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_chroot(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2019-02-27 22:11:15 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_chmod
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_chmod(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_file_mode(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-06-19 15:33:30 +03:00
|
|
|
#if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_chown(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2020-06-19 15:33:30 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_raw_param("%d", arg1, 0);
|
|
|
|
print_raw_param("%d", arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_lchown print_chown
|
|
|
|
#endif
|
|
|
|
|
2016-10-10 14:23:29 +03:00
|
|
|
#ifdef TARGET_NR_clock_adjtime
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_clock_adjtime(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2016-10-10 14:23:29 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
print_enums(clockids, arg0, 0);
|
2016-10-10 14:23:29 +03:00
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-07 02:25:32 +04:00
|
|
|
#ifdef TARGET_NR_clone
|
2016-06-11 03:19:47 +03:00
|
|
|
static void do_print_clone(unsigned int flags, abi_ulong newsp,
|
|
|
|
abi_ulong parent_tidptr, target_ulong newtls,
|
|
|
|
abi_ulong child_tidptr)
|
|
|
|
{
|
|
|
|
print_flags(clone_flags, flags, 0);
|
|
|
|
print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
|
|
|
|
print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
|
|
|
|
print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
|
|
|
|
print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
|
|
|
|
}
|
|
|
|
|
2011-04-07 02:25:32 +04:00
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_clone(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
2011-04-07 02:25:32 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
2016-06-11 03:19:47 +03:00
|
|
|
#if defined(TARGET_MICROBLAZE)
|
|
|
|
do_print_clone(arg1, arg2, arg4, arg6, arg5);
|
|
|
|
#elif defined(TARGET_CLONE_BACKWARDS)
|
|
|
|
do_print_clone(arg1, arg2, arg3, arg4, arg5);
|
|
|
|
#elif defined(TARGET_CLONE_BACKWARDS2)
|
|
|
|
do_print_clone(arg2, arg1, arg3, arg5, arg4);
|
2011-04-07 02:25:32 +04:00
|
|
|
#else
|
2016-06-11 03:19:47 +03:00
|
|
|
do_print_clone(arg1, arg2, arg3, arg5, arg4);
|
2011-04-07 02:25:32 +04:00
|
|
|
#endif
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_creat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_creat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_file_mode(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_execv
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_execv(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-11-04 20:36:29 +03:00
|
|
|
static void
|
|
|
|
print_execve_argv(abi_long argv, int last)
|
|
|
|
{
|
|
|
|
abi_ulong arg_ptr_addr;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
qemu_log("{");
|
|
|
|
for (arg_ptr_addr = argv; ; arg_ptr_addr += sizeof(abi_ulong)) {
|
|
|
|
abi_ulong *arg_ptr, arg_addr;
|
|
|
|
|
|
|
|
arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
|
|
|
|
if (!arg_ptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
arg_addr = tswapal(*arg_ptr);
|
|
|
|
unlock_user(arg_ptr, arg_ptr_addr, 0);
|
|
|
|
if (!arg_addr) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
s = lock_user_string(arg_addr);
|
|
|
|
if (s) {
|
|
|
|
qemu_log("\"%s\",", s);
|
|
|
|
unlock_user(s, arg_addr, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qemu_log("NULL}%s", get_comma(last));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_execve(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_execve_argv(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
|
2022-11-04 20:36:30 +03:00
|
|
|
static void
|
|
|
|
print_execveat(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg1, 0);
|
|
|
|
print_string(arg2, 0);
|
|
|
|
print_execve_argv(arg3, 0);
|
|
|
|
print_flags(execveat_flags, arg5, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
|
2022-10-09 09:08:13 +03:00
|
|
|
#if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2)
|
2009-04-07 17:57:29 +04:00
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_faccessat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_flags(access_flags, arg2, 0);
|
|
|
|
print_flags(at_file_flags, arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-06-19 15:33:31 +03:00
|
|
|
#ifdef TARGET_NR_fallocate
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fallocate(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2020-06-19 15:33:31 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_flags(falloc_flags, arg1, 0);
|
|
|
|
#if TARGET_ABI_BITS == 32
|
|
|
|
print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0);
|
|
|
|
print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1);
|
|
|
|
#else
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg3, 1);
|
|
|
|
#endif
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_fchmodat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fchmodat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_file_mode(arg2, 0);
|
|
|
|
print_flags(at_file_flags, arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_fchownat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fchownat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg2, 0);
|
|
|
|
print_raw_param("%d", arg3, 0);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_flags(at_file_flags, arg4, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fcntl(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg0, 0);
|
2013-01-01 00:00:11 +04:00
|
|
|
switch(arg1) {
|
|
|
|
case TARGET_F_DUPFD:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_DUPFD,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_GETFD:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETFD");
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
|
|
|
case TARGET_F_SETFD:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETFD,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_GETFL:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETFL");
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
|
|
|
case TARGET_F_SETFL:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETFL,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_open_flags(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_GETLK:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETLK,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_SETLK:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETLK,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_SETLKW:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETLKW,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_GETOWN:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETOWN");
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
|
|
|
case TARGET_F_SETOWN:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETOWN,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
|
|
|
|
break;
|
|
|
|
case TARGET_F_GETSIG:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETSIG");
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
|
|
|
case TARGET_F_SETSIG:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETSIG,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
|
|
|
|
break;
|
|
|
|
#if TARGET_ABI_BITS == 32
|
|
|
|
case TARGET_F_GETLK64:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETLK64,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_SETLK64:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETLK64,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_SETLKW64:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETLKW64,");
|
2013-01-01 00:00:11 +04:00
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
#endif
|
2020-08-30 12:22:42 +03:00
|
|
|
case TARGET_F_OFD_GETLK:
|
|
|
|
qemu_log("F_OFD_GETLK,");
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_OFD_SETLK:
|
|
|
|
qemu_log("F_OFD_SETLK,");
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_OFD_SETLKW:
|
|
|
|
qemu_log("F_OFD_SETLKW,");
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
2013-01-01 00:00:11 +04:00
|
|
|
case TARGET_F_SETLEASE:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETLEASE,");
|
2020-12-18 22:32:10 +03:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
|
|
|
case TARGET_F_GETLEASE:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETLEASE");
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
2020-12-18 22:32:10 +03:00
|
|
|
#ifdef F_DUPFD_CLOEXEC
|
|
|
|
case TARGET_F_DUPFD_CLOEXEC:
|
|
|
|
qemu_log("F_DUPFD_CLOEXEC,");
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case TARGET_F_NOTIFY:
|
|
|
|
qemu_log("F_NOTIFY,");
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
|
|
|
|
break;
|
|
|
|
#ifdef F_GETOWN_EX
|
|
|
|
case TARGET_F_GETOWN_EX:
|
|
|
|
qemu_log("F_GETOWN_EX,");
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef F_SETOWN_EX
|
|
|
|
case TARGET_F_SETOWN_EX:
|
|
|
|
qemu_log("F_SETOWN_EX,");
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef F_SETPIPE_SZ
|
2016-06-20 17:50:37 +03:00
|
|
|
case TARGET_F_SETPIPE_SZ:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_SETPIPE_SZ,");
|
2016-06-20 17:50:37 +03:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
|
|
|
|
break;
|
|
|
|
case TARGET_F_GETPIPE_SZ:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("F_GETPIPE_SZ");
|
2016-06-20 17:50:37 +03:00
|
|
|
break;
|
2020-12-18 22:32:10 +03:00
|
|
|
#endif
|
|
|
|
#ifdef F_ADD_SEALS
|
|
|
|
case TARGET_F_ADD_SEALS:
|
|
|
|
qemu_log("F_ADD_SEALS,");
|
|
|
|
print_raw_param("0x"TARGET_ABI_FMT_lx, arg2, 1);
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
2020-12-18 22:32:10 +03:00
|
|
|
case TARGET_F_GET_SEALS:
|
|
|
|
qemu_log("F_GET_SEALS");
|
2013-01-01 00:00:11 +04:00
|
|
|
break;
|
2020-12-18 22:32:10 +03:00
|
|
|
#endif
|
2013-01-01 00:00:11 +04:00
|
|
|
default:
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
}
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_fcntl64 print_fcntl
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
#ifdef TARGET_NR_fgetxattr
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fgetxattr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_pointer(arg2, 0);
|
|
|
|
print_raw_param(TARGET_FMT_lu, arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_flistxattr
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_flistxattr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_pointer(arg1, 0);
|
|
|
|
print_raw_param(TARGET_FMT_lu, arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_getxattr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_pointer(arg2, 0);
|
|
|
|
print_raw_param(TARGET_FMT_lu, arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_lgetxattr print_getxattr
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_pointer(arg1, 0);
|
|
|
|
print_raw_param(TARGET_FMT_lu, arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_llistxattr print_listxattr
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_fremovexattr)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fremovexattr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_string(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_removexattr(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: Add strace support for printing argument of syscalls used for extended attributes
This patch implements strace argument printing functionality for following syscalls:
*getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
*listxattr, llistxattr, flistxattr - list extended attribute names
ssize_t listxattr(const char *path, char *list, size_t size)
ssize_t llistxattr(const char *path, char *list, size_t size)
ssize_t flistxattr(int fd, char *list, size_t size)
man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
*removexattr, lremovexattr, fremovexattr - remove an extended attribute
int removexattr(const char *path, const char *name)
int lremovexattr(const char *path, const char *name)
int fremovexattr(int fd, const char *name)
man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html
Implementation notes:
All of the syscalls have strings as argument types and thus a separate
printing function was stated in file "strace.list" for every one of them.
All of these printing functions were defined in "strace.c" using existing
printing functions for appropriate argument types:
"print_string()" - for (const char*) type
"print_pointer()" - for (char*) and (void *) type
"print_raw_param()" for (int) and (size_t) type
Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
share a same definition. The same statement applies to syscalls "listxattr()"
and "llistxattr()".
Function "print_syscall_ret_listxattr()" was added to print the returned list
of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
print_flistxattr()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619123331.17387-4-filip.bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:33:28 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_string(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_lremovexattr print_removexattr
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_futimesat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_futimesat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_timeval(arg2, 0);
|
|
|
|
print_timeval(arg2 + sizeof (struct target_timeval), 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
#ifdef TARGET_NR_gettimeofday
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_pointer(arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-10-21 14:48:51 +03:00
|
|
|
#ifdef TARGET_NR_settimeofday
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_settimeofday(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2019-10-21 14:48:51 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_timeval(arg0, 0);
|
|
|
|
print_timezone(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
#if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_enums(clockids, arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_clock_getres print_clock_gettime
|
|
|
|
#endif
|
|
|
|
|
2022-09-18 22:45:45 +03:00
|
|
|
#if defined(TARGET_NR_clock_gettime64)
|
|
|
|
static void
|
|
|
|
print_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_enums(clockids, arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
#ifdef TARGET_NR_clock_settime
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_enums(clockids, arg0, 0);
|
|
|
|
print_timespec(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_getitimer
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_enums(itimer_types, arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_setitimer
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of some clock and time functions
This patch implements strace argument printing functionality for following syscalls:
* clock_getres, clock_gettime, clock_settime - clock and time functions
int clock_getres(clockid_t clockid, struct timespec *res)
int clock_gettime(clockid_t clockid, struct timespec *tp)
int clock_settime(clockid_t clockid, const struct timespec *tp)
man page: https://man7.org/linux/man-pages/man2/clock_getres.2.html
* gettimeofday - get time
int gettimeofday(struct timeval *tv, struct timezone *tz)
man page: https://man7.org/linux/man-pages/man2/gettimeofday.2.html
* getitimer, setitimer - get or set value of an interval timer
int getitimer(int which, struct itimerval *curr_value)
int setitimer(int which, const struct itimerval *new_value,
struct itimerval *old_value)
man page: https://man7.org/linux/man-pages/man2/getitimer.2.html
Implementation notes:
All of the syscalls have some structue types as argument types and thus
a separate printing function was stated in file "strace.list" for each
of them. All of these functions use existing functions for their
appropriate structure types ("print_timeval()" and "print_timezone()").
Functions "print_timespec()" and "print_itimerval()" were added in this
patch so that they can be used to print types "struct timespec" and
"struct itimerval" used by some of the syscalls. Function "print_itimerval()"
uses the existing function "print_timeval()" to print fields of the
structure "struct itimerval" that are of type "struct timeval".
Function "print_enums()", which was introduced in the previous patch, is used
to print the interval timer type which is the first argument of "getitimer()"
and "setitimer()". Also, this function is used to print the clock id which
is the first argument of "clock_getres()" and "clock_gettime()". For that
reason, the existing function "print_clockid()" was removed in this patch.
Existing function "print_clock_adjtime()" was also changed for this reason
to use "print_enums()".
The existing function "print_timeval()" was changed a little so that it
prints the field names beside the values.
Syscalls "clock_getres()" and "clock_gettime()" have the same number
and types of arguments and thus their print functions "print_clock_getres"
and "print_clock_gettime" share a common definition in file "strace.c".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200811164553.27713-6-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-11 19:45:53 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_enums(itimer_types, arg0, 0);
|
|
|
|
print_itimerval(arg1, 0);
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_link
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_link(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_string(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_linkat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_linkat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_at_dirfd(arg2, 0);
|
|
|
|
print_string(arg3, 0);
|
|
|
|
print_flags(at_file_flags, arg4, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-05-12 13:13:58 +03:00
|
|
|
#if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
|
2011-04-07 02:25:32 +04:00
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print__llseek(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2011-04-07 02:25:32 +04:00
|
|
|
{
|
|
|
|
const char *whence = "UNKNOWN";
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_raw_param("%ld", arg1, 0);
|
|
|
|
print_raw_param("%ld", arg2, 0);
|
|
|
|
print_pointer(arg3, 0);
|
|
|
|
switch(arg4) {
|
|
|
|
case SEEK_SET: whence = "SEEK_SET"; break;
|
|
|
|
case SEEK_CUR: whence = "SEEK_CUR"; break;
|
|
|
|
case SEEK_END: whence = "SEEK_END"; break;
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s", whence);
|
2011-04-07 02:25:32 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
2021-05-12 13:13:58 +03:00
|
|
|
#define print_llseek print__llseek
|
2011-04-07 02:25:32 +04:00
|
|
|
#endif
|
|
|
|
|
2020-06-19 15:33:29 +03:00
|
|
|
#ifdef TARGET_NR_lseek
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_lseek(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2020-06-19 15:33:29 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
|
|
|
|
switch (arg2) {
|
|
|
|
case SEEK_SET:
|
|
|
|
qemu_log("SEEK_SET"); break;
|
|
|
|
case SEEK_CUR:
|
|
|
|
qemu_log("SEEK_CUR"); break;
|
|
|
|
case SEEK_END:
|
|
|
|
qemu_log("SEEK_END"); break;
|
|
|
|
#ifdef SEEK_DATA
|
|
|
|
case SEEK_DATA:
|
|
|
|
qemu_log("SEEK_DATA"); break;
|
|
|
|
#endif
|
|
|
|
#ifdef SEEK_HOLE
|
|
|
|
case SEEK_HOLE:
|
|
|
|
qemu_log("SEEK_HOLE"); break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
print_raw_param("%#x", arg2, 1);
|
|
|
|
}
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-08-11 19:45:50 +03:00
|
|
|
#ifdef TARGET_NR_truncate
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_truncate(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:50 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_truncate64
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_truncate64(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:50 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
|
|
|
|
arg1 = arg2;
|
|
|
|
arg2 = arg3;
|
|
|
|
}
|
|
|
|
print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_ftruncate64
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_ftruncate64(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:50 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
|
|
|
|
arg1 = arg2;
|
|
|
|
arg2 = arg3;
|
|
|
|
}
|
|
|
|
print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-08-11 19:45:51 +03:00
|
|
|
#ifdef TARGET_NR_mlockall
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mlockall(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:51 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_flags(mlockall_flags, arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-11 03:19:46 +03:00
|
|
|
#if defined(TARGET_NR_socket)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_socket(CPUArchState *cpu_env, const struct syscallname *name,
|
2016-06-11 03:19:46 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
abi_ulong domain = arg0, type = arg1, protocol = arg2;
|
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_socket_domain(domain);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:46 +03:00
|
|
|
print_socket_type(type);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:46 +03:00
|
|
|
if (domain == AF_PACKET ||
|
|
|
|
(domain == AF_INET && type == TARGET_SOCK_PACKET)) {
|
|
|
|
protocol = tswap16(protocol);
|
|
|
|
}
|
|
|
|
print_socket_protocol(domain, type, protocol);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-10-21 14:48:55 +03:00
|
|
|
#if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
|
2016-06-11 03:19:45 +03:00
|
|
|
|
2019-10-21 14:48:54 +03:00
|
|
|
static void print_sockfd(abi_long sockfd, int last)
|
|
|
|
{
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_socketcall)
|
|
|
|
|
2016-06-11 03:19:45 +03:00
|
|
|
#define get_user_ualx(x, gaddr, idx) \
|
|
|
|
get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
|
|
|
|
|
|
|
|
static void do_print_socket(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong domain, type, protocol;
|
|
|
|
|
|
|
|
get_user_ualx(domain, arg1, 0);
|
|
|
|
get_user_ualx(type, arg1, 1);
|
|
|
|
get_user_ualx(protocol, arg1, 2);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2016-06-11 03:19:45 +03:00
|
|
|
print_socket_domain(domain);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_socket_type(type);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:45 +03:00
|
|
|
if (domain == AF_PACKET ||
|
|
|
|
(domain == AF_INET && type == TARGET_SOCK_PACKET)) {
|
|
|
|
protocol = tswap16(protocol);
|
|
|
|
}
|
|
|
|
print_socket_protocol(domain, type, protocol);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_sockaddr(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong sockfd, addr, addrlen;
|
|
|
|
|
|
|
|
get_user_ualx(sockfd, arg1, 0);
|
|
|
|
get_user_ualx(addr, arg1, 1);
|
|
|
|
get_user_ualx(addrlen, arg1, 2);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2019-10-21 14:48:54 +03:00
|
|
|
print_sockfd(sockfd, 0);
|
2019-10-21 14:48:56 +03:00
|
|
|
print_sockaddr(addr, addrlen, 0);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_listen(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong sockfd, backlog;
|
|
|
|
|
|
|
|
get_user_ualx(sockfd, arg1, 0);
|
|
|
|
get_user_ualx(backlog, arg1, 1);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2019-10-21 14:48:54 +03:00
|
|
|
print_sockfd(sockfd, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_socketpair(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong domain, type, protocol, tab;
|
|
|
|
|
|
|
|
get_user_ualx(domain, arg1, 0);
|
|
|
|
get_user_ualx(type, arg1, 1);
|
|
|
|
get_user_ualx(protocol, arg1, 2);
|
|
|
|
get_user_ualx(tab, arg1, 3);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2016-06-11 03:19:45 +03:00
|
|
|
print_socket_domain(domain);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_socket_type(type);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_socket_protocol(domain, type, protocol);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_sendrecv(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong sockfd, msg, len, flags;
|
|
|
|
|
|
|
|
get_user_ualx(sockfd, arg1, 0);
|
|
|
|
get_user_ualx(msg, arg1, 1);
|
|
|
|
get_user_ualx(len, arg1, 2);
|
|
|
|
get_user_ualx(flags, arg1, 3);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2019-10-21 14:48:54 +03:00
|
|
|
print_sockfd(sockfd, 0);
|
2024-08-07 15:43:04 +03:00
|
|
|
print_buf_len(msg, len, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
print_flags(msg_flags, flags, 1);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_msgaddr(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong sockfd, msg, len, flags, addr, addrlen;
|
|
|
|
|
|
|
|
get_user_ualx(sockfd, arg1, 0);
|
|
|
|
get_user_ualx(msg, arg1, 1);
|
|
|
|
get_user_ualx(len, arg1, 2);
|
|
|
|
get_user_ualx(flags, arg1, 3);
|
|
|
|
get_user_ualx(addr, arg1, 4);
|
|
|
|
get_user_ualx(addrlen, arg1, 5);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2019-10-21 14:48:54 +03:00
|
|
|
print_sockfd(sockfd, 0);
|
2024-08-07 15:43:04 +03:00
|
|
|
print_buf_len(msg, len, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
print_flags(msg_flags, flags, 0);
|
2019-10-21 14:48:56 +03:00
|
|
|
print_sockaddr(addr, addrlen, 0);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_shutdown(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong sockfd, how;
|
|
|
|
|
|
|
|
get_user_ualx(sockfd, arg1, 0);
|
|
|
|
get_user_ualx(how, arg1, 1);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("shutdown(");
|
2019-10-21 14:48:54 +03:00
|
|
|
print_sockfd(sockfd, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
switch (how) {
|
|
|
|
case SHUT_RD:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SHUT_RD");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case SHUT_WR:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SHUT_WR");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case SHUT_RDWR:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SHUT_RDWR");
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, how, 1);
|
|
|
|
break;
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_msg(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong sockfd, msg, flags;
|
|
|
|
|
|
|
|
get_user_ualx(sockfd, arg1, 0);
|
|
|
|
get_user_ualx(msg, arg1, 1);
|
|
|
|
get_user_ualx(flags, arg1, 2);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2019-10-21 14:48:54 +03:00
|
|
|
print_sockfd(sockfd, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
print_pointer(msg, 0);
|
|
|
|
print_flags(msg_flags, flags, 1);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void do_print_sockopt(const char *name, abi_long arg1)
|
|
|
|
{
|
|
|
|
abi_ulong sockfd, level, optname, optval, optlen;
|
|
|
|
|
|
|
|
get_user_ualx(sockfd, arg1, 0);
|
|
|
|
get_user_ualx(level, arg1, 1);
|
|
|
|
get_user_ualx(optname, arg1, 2);
|
|
|
|
get_user_ualx(optval, arg1, 3);
|
|
|
|
get_user_ualx(optlen, arg1, 4);
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s(", name);
|
2019-10-21 14:48:54 +03:00
|
|
|
print_sockfd(sockfd, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
switch (level) {
|
|
|
|
case SOL_TCP:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOL_TCP,");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
|
|
|
|
print_pointer(optval, 0);
|
2020-12-18 22:32:11 +03:00
|
|
|
break;
|
|
|
|
case SOL_UDP:
|
|
|
|
qemu_log("SOL_UDP,");
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
|
|
|
|
print_pointer(optval, 0);
|
2016-06-11 03:19:45 +03:00
|
|
|
break;
|
|
|
|
case SOL_IP:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOL_IP,");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
case SOL_RAW:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOL_RAW,");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
case TARGET_SOL_SOCKET:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SOL_SOCKET,");
|
2016-06-11 03:19:45 +03:00
|
|
|
switch (optname) {
|
|
|
|
case TARGET_SO_DEBUG:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_DEBUG,");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_optint:
|
|
|
|
print_number(optval, 0);
|
|
|
|
break;
|
|
|
|
case TARGET_SO_REUSEADDR:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_REUSEADDR,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
2018-10-30 15:55:08 +03:00
|
|
|
case TARGET_SO_REUSEPORT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_REUSEPORT,");
|
2018-10-30 15:55:08 +03:00
|
|
|
goto print_optint;
|
2016-06-11 03:19:45 +03:00
|
|
|
case TARGET_SO_TYPE:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_TYPE,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_ERROR:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_ERROR,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_DONTROUTE:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_DONTROUTE,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_BROADCAST:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_BROADCAST,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_SNDBUF:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_SNDBUF,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_RCVBUF:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_RCVBUF,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_KEEPALIVE:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_KEEPALIVE,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_OOBINLINE:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_OOBINLINE,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_NO_CHECK:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_NO_CHECK,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_PRIORITY:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_PRIORITY,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_BSDCOMPAT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_BSDCOMPAT,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_PASSCRED:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_PASSCRED,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_TIMESTAMP:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_TIMESTAMP,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_RCVLOWAT:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_RCVLOWAT,");
|
2016-06-11 03:19:45 +03:00
|
|
|
goto print_optint;
|
|
|
|
case TARGET_SO_RCVTIMEO:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_RCVTIMEO,");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_timeval(optval, 0);
|
|
|
|
break;
|
|
|
|
case TARGET_SO_SNDTIMEO:
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_SNDTIMEO,");
|
2016-06-11 03:19:45 +03:00
|
|
|
print_timeval(optval, 0);
|
|
|
|
break;
|
|
|
|
case TARGET_SO_ATTACH_FILTER: {
|
|
|
|
struct target_sock_fprog *fprog;
|
|
|
|
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("SO_ATTACH_FILTER,");
|
2016-06-11 03:19:45 +03:00
|
|
|
|
|
|
|
if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
|
|
|
|
struct target_sock_filter *filter;
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("{");
|
2016-06-11 03:19:45 +03:00
|
|
|
if (lock_user_struct(VERIFY_READ, filter,
|
|
|
|
tswapal(fprog->filter), 0)) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < tswap16(fprog->len) - 1; i++) {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("[%d]{0x%x,%d,%d,0x%x},",
|
2016-06-11 03:19:45 +03:00
|
|
|
i, tswap16(filter[i].code),
|
|
|
|
filter[i].jt, filter[i].jf,
|
|
|
|
tswap32(filter[i].k));
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("[%d]{0x%x,%d,%d,0x%x}",
|
2016-06-11 03:19:45 +03:00
|
|
|
i, tswap16(filter[i].code),
|
|
|
|
filter[i].jt, filter[i].jf,
|
|
|
|
tswap32(filter[i].k));
|
|
|
|
} else {
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(",%d},", tswap16(fprog->len));
|
2016-06-11 03:19:45 +03:00
|
|
|
unlock_user(fprog, optval, 0);
|
|
|
|
} else {
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2020-12-18 22:32:13 +03:00
|
|
|
case SOL_IPV6:
|
|
|
|
qemu_log("SOL_IPV6,");
|
|
|
|
switch (optname) {
|
|
|
|
case IPV6_MTU_DISCOVER:
|
|
|
|
qemu_log("IPV6_MTU_DISCOVER,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_MTU:
|
|
|
|
qemu_log("IPV6_MTU,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_V6ONLY:
|
|
|
|
qemu_log("IPV6_V6ONLY,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_RECVPKTINFO:
|
|
|
|
qemu_log("IPV6_RECVPKTINFO,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_UNICAST_HOPS:
|
|
|
|
qemu_log("IPV6_UNICAST_HOPS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_MULTICAST_HOPS:
|
|
|
|
qemu_log("IPV6_MULTICAST_HOPS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_MULTICAST_LOOP:
|
|
|
|
qemu_log("IPV6_MULTICAST_LOOP,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_RECVERR:
|
|
|
|
qemu_log("IPV6_RECVERR,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_RECVHOPLIMIT:
|
|
|
|
qemu_log("IPV6_RECVHOPLIMIT,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_2292HOPLIMIT:
|
|
|
|
qemu_log("IPV6_2292HOPLIMIT,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_CHECKSUM:
|
|
|
|
qemu_log("IPV6_CHECKSUM,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_ADDRFORM:
|
|
|
|
qemu_log("IPV6_ADDRFORM,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_2292PKTINFO:
|
|
|
|
qemu_log("IPV6_2292PKTINFO,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_RECVTCLASS:
|
|
|
|
qemu_log("IPV6_RECVTCLASS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_RECVRTHDR:
|
|
|
|
qemu_log("IPV6_RECVRTHDR,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_2292RTHDR:
|
|
|
|
qemu_log("IPV6_2292RTHDR,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_RECVHOPOPTS:
|
|
|
|
qemu_log("IPV6_RECVHOPOPTS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_2292HOPOPTS:
|
|
|
|
qemu_log("IPV6_2292HOPOPTS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_RECVDSTOPTS:
|
|
|
|
qemu_log("IPV6_RECVDSTOPTS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_2292DSTOPTS:
|
|
|
|
qemu_log("IPV6_2292DSTOPTS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_TCLASS:
|
|
|
|
qemu_log("IPV6_TCLASS,");
|
|
|
|
goto print_optint;
|
|
|
|
case IPV6_ADDR_PREFERENCES:
|
|
|
|
qemu_log("IPV6_ADDR_PREFERENCES,");
|
|
|
|
goto print_optint;
|
|
|
|
#ifdef IPV6_RECVPATHMTU
|
|
|
|
case IPV6_RECVPATHMTU:
|
|
|
|
qemu_log("IPV6_RECVPATHMTU,");
|
|
|
|
goto print_optint;
|
|
|
|
#endif
|
|
|
|
#ifdef IPV6_TRANSPARENT
|
|
|
|
case IPV6_TRANSPARENT:
|
|
|
|
qemu_log("IPV6_TRANSPARENT,");
|
|
|
|
goto print_optint;
|
|
|
|
#endif
|
|
|
|
#ifdef IPV6_FREEBIND
|
|
|
|
case IPV6_FREEBIND:
|
|
|
|
qemu_log("IPV6_FREEBIND,");
|
|
|
|
goto print_optint;
|
|
|
|
#endif
|
|
|
|
#ifdef IPV6_RECVORIGDSTADDR
|
|
|
|
case IPV6_RECVORIGDSTADDR:
|
|
|
|
qemu_log("IPV6_RECVORIGDSTADDR,");
|
|
|
|
goto print_optint;
|
|
|
|
#endif
|
|
|
|
case IPV6_PKTINFO:
|
|
|
|
qemu_log("IPV6_PKTINFO,");
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
case IPV6_ADD_MEMBERSHIP:
|
|
|
|
qemu_log("IPV6_ADD_MEMBERSHIP,");
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
case IPV6_DROP_MEMBERSHIP:
|
|
|
|
qemu_log("IPV6_DROP_MEMBERSHIP,");
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2016-06-11 03:19:45 +03:00
|
|
|
default:
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, level, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
|
|
|
|
print_pointer(optval, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log(")");
|
2016-06-11 03:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#define PRINT_SOCKOP(name, func) \
|
linux-user: Fix socketcall() syscall support
Since not all Linux host platforms support socketcall() (most notably
Intel), do_socketcall() function in Qemu's syscalls.c is implemented to
mirror the corespondant implementation of socketcall() in Linux kernel,
and to utilise individual socket operations that are supported on all
Linux platforms. (see kernel source file net/socket.c, definition of
socketcall).
However, error codes produced by Qemu implementation are wrong for the
cases of invalid values of the first argument. Also, naming of constants
is not consistent with kernel one, and not consistant with Qemu convention
of prefixing such constants with "TARGET_". This patch in that light
brings do_socketcall() closer to its kernel counterpart, and in that way
fixes the errors and yields more consisrtent Qemu code.
There were also three missing cases (among 20) for strace support for
socketcall(). The array that contains pointers for appropriate printing
functions is updated with 3 elements, however pointers to functions are
left NULL, and its implementation is left for future.
Also, this patch fixes failure of LTP test socketcall02, if executed on some
Qemu emulated sywstems (uer mode).
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-09-22 19:56:57 +03:00
|
|
|
[TARGET_SYS_##name] = { #name, func }
|
2016-06-11 03:19:45 +03:00
|
|
|
|
|
|
|
static struct {
|
|
|
|
const char *name;
|
|
|
|
void (*print)(const char *, abi_long);
|
|
|
|
} scall[] = {
|
linux-user: Fix socketcall() syscall support
Since not all Linux host platforms support socketcall() (most notably
Intel), do_socketcall() function in Qemu's syscalls.c is implemented to
mirror the corespondant implementation of socketcall() in Linux kernel,
and to utilise individual socket operations that are supported on all
Linux platforms. (see kernel source file net/socket.c, definition of
socketcall).
However, error codes produced by Qemu implementation are wrong for the
cases of invalid values of the first argument. Also, naming of constants
is not consistent with kernel one, and not consistant with Qemu convention
of prefixing such constants with "TARGET_". This patch in that light
brings do_socketcall() closer to its kernel counterpart, and in that way
fixes the errors and yields more consisrtent Qemu code.
There were also three missing cases (among 20) for strace support for
socketcall(). The array that contains pointers for appropriate printing
functions is updated with 3 elements, however pointers to functions are
left NULL, and its implementation is left for future.
Also, this patch fixes failure of LTP test socketcall02, if executed on some
Qemu emulated sywstems (uer mode).
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-09-22 19:56:57 +03:00
|
|
|
PRINT_SOCKOP(SOCKET, do_print_socket),
|
|
|
|
PRINT_SOCKOP(BIND, do_print_sockaddr),
|
|
|
|
PRINT_SOCKOP(CONNECT, do_print_sockaddr),
|
|
|
|
PRINT_SOCKOP(LISTEN, do_print_listen),
|
|
|
|
PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
|
|
|
|
PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
|
|
|
|
PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
|
|
|
|
PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
|
|
|
|
PRINT_SOCKOP(SEND, do_print_sendrecv),
|
|
|
|
PRINT_SOCKOP(RECV, do_print_sendrecv),
|
|
|
|
PRINT_SOCKOP(SENDTO, do_print_msgaddr),
|
|
|
|
PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
|
|
|
|
PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
|
|
|
|
PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
|
|
|
|
PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
|
|
|
|
PRINT_SOCKOP(SENDMSG, do_print_msg),
|
|
|
|
PRINT_SOCKOP(RECVMSG, do_print_msg),
|
|
|
|
PRINT_SOCKOP(ACCEPT4, NULL),
|
|
|
|
PRINT_SOCKOP(RECVMMSG, NULL),
|
|
|
|
PRINT_SOCKOP(SENDMMSG, NULL),
|
2016-06-11 03:19:45 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_socketcall(CPUArchState *cpu_env, const struct syscallname *name,
|
2016-06-11 03:19:45 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
|
|
|
|
scall[arg0].print(scall[arg0].name, arg1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-10-21 14:48:55 +03:00
|
|
|
#if defined(TARGET_NR_bind)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_bind(CPUArchState *cpu_env, const struct syscallname *name,
|
2019-10-21 14:48:55 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_sockfd(arg0, 0);
|
|
|
|
print_sockaddr(arg1, arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-08-07 15:43:06 +03:00
|
|
|
#ifdef TARGET_NR_recvfrom
|
|
|
|
static void
|
|
|
|
print_recvfrom(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_sockfd(arg0, 0);
|
|
|
|
print_pointer(arg1, 0); /* output */
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
|
|
|
|
print_flags(msg_flags, arg3, 0);
|
|
|
|
print_pointer(arg4, 0); /* output */
|
|
|
|
print_pointer(arg5, 1); /* in/out */
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-08-07 15:43:05 +03:00
|
|
|
#ifdef TARGET_NR_sendto
|
|
|
|
static void
|
|
|
|
print_sendto(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_sockfd(arg0, 0);
|
|
|
|
print_buf_len(arg1, arg2, 0);
|
|
|
|
print_flags(msg_flags, arg3, 0);
|
|
|
|
print_sockaddr(arg4, arg5, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
|
|
|
|
defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_stat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_lstat print_stat
|
|
|
|
#define print_stat64 print_stat
|
|
|
|
#define print_lstat64 print_stat
|
|
|
|
#endif
|
|
|
|
|
2022-09-06 03:08:37 +03:00
|
|
|
#if defined(TARGET_NR_madvise)
|
|
|
|
static struct enums madvise_advice[] = {
|
|
|
|
ENUM_TARGET(MADV_NORMAL),
|
|
|
|
ENUM_TARGET(MADV_RANDOM),
|
|
|
|
ENUM_TARGET(MADV_SEQUENTIAL),
|
|
|
|
ENUM_TARGET(MADV_WILLNEED),
|
|
|
|
ENUM_TARGET(MADV_DONTNEED),
|
|
|
|
ENUM_TARGET(MADV_FREE),
|
|
|
|
ENUM_TARGET(MADV_REMOVE),
|
|
|
|
ENUM_TARGET(MADV_DONTFORK),
|
|
|
|
ENUM_TARGET(MADV_DOFORK),
|
|
|
|
ENUM_TARGET(MADV_MERGEABLE),
|
|
|
|
ENUM_TARGET(MADV_UNMERGEABLE),
|
|
|
|
ENUM_TARGET(MADV_HUGEPAGE),
|
|
|
|
ENUM_TARGET(MADV_NOHUGEPAGE),
|
|
|
|
ENUM_TARGET(MADV_DONTDUMP),
|
|
|
|
ENUM_TARGET(MADV_DODUMP),
|
|
|
|
ENUM_TARGET(MADV_WIPEONFORK),
|
|
|
|
ENUM_TARGET(MADV_KEEPONFORK),
|
|
|
|
ENUM_TARGET(MADV_COLD),
|
|
|
|
ENUM_TARGET(MADV_PAGEOUT),
|
|
|
|
ENUM_TARGET(MADV_POPULATE_READ),
|
|
|
|
ENUM_TARGET(MADV_POPULATE_WRITE),
|
|
|
|
ENUM_TARGET(MADV_DONTNEED_LOCKED),
|
|
|
|
ENUM_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_madvise(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_pointer(arg0, 0);
|
|
|
|
print_raw_param("%d", arg1, 0);
|
|
|
|
print_enums(madvise_advice, arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fstat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg0, 0);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_fstat64 print_fstat
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_mkdir
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mkdir(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_file_mode(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_mkdirat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mkdirat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_file_mode(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-15 23:10:43 +03:00
|
|
|
#ifdef TARGET_NR_rmdir
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_rmdir(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2011-02-15 23:10:43 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-07 02:25:32 +04:00
|
|
|
#ifdef TARGET_NR_rt_sigaction
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_rt_sigaction(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2011-04-07 02:25:32 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_signal(arg0, 0);
|
|
|
|
print_pointer(arg1, 0);
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_rt_sigprocmask
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2011-04-07 02:25:32 +04:00
|
|
|
{
|
|
|
|
const char *how = "UNKNOWN";
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
switch(arg0) {
|
|
|
|
case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
|
|
|
|
case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
|
|
|
|
case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s,", how);
|
linux-user: Trace rt_sigprocmask's sigsets
Add a function for formatting target sigsets. It can be useful for
other syscalls in the future, so put it into the beginning of strace.c.
For simplicity, do not implement the strace's ~[] output syntax.
Add a rt_sigprocmask return handler.
Example outputs:
753914 rt_sigprocmask(SIG_BLOCK,[SIGCHLD SIGTSTP SIGTTIN SIGTTOU],0x00007f80fddfe380,8) = 0 (oldset=[SIGTTOU])
753914 rt_sigprocmask(SIG_SETMASK,[SIGCHLD],NULL,8) = 0
753914 rt_sigprocmask(SIG_BLOCK,NULL,0x00007f80fddff3c0,8) = 0 (oldset=[])
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241022102726.18520-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 13:26:16 +03:00
|
|
|
print_target_sigset_t(arg1, arg3, 0);
|
2023-01-31 01:20:53 +03:00
|
|
|
print_pointer(arg2, 0);
|
|
|
|
print_raw_param("%u", arg3, 1);
|
2011-04-07 02:25:32 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
linux-user: Trace rt_sigprocmask's sigsets
Add a function for formatting target sigsets. It can be useful for
other syscalls in the future, so put it into the beginning of strace.c.
For simplicity, do not implement the strace's ~[] output syntax.
Add a rt_sigprocmask return handler.
Example outputs:
753914 rt_sigprocmask(SIG_BLOCK,[SIGCHLD SIGTSTP SIGTTIN SIGTTOU],0x00007f80fddfe380,8) = 0 (oldset=[SIGTTOU])
753914 rt_sigprocmask(SIG_SETMASK,[SIGCHLD],NULL,8) = 0
753914 rt_sigprocmask(SIG_BLOCK,NULL,0x00007f80fddff3c0,8) = 0 (oldset=[])
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241022102726.18520-1-iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2024-10-22 13:26:16 +03:00
|
|
|
|
|
|
|
static void
|
|
|
|
print_rt_sigprocmask_ret(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
if (arg2) {
|
|
|
|
qemu_log(" (oldset=");
|
|
|
|
print_target_sigset_t(arg2, arg3, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
2011-04-07 02:25:32 +04:00
|
|
|
#endif
|
|
|
|
|
linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace
Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
by implementing print functions that match arguments types of the system
calls and add them to the corresponding starce.list entry.
tkill:
Prior to this commit, typical strace output used to look like this:
4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
After this commit, it looks like this:
4886 tkill(4886,50) = 0
tgkill:
Prior to this commit, typical strace output used to look like this:
4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
After this commit, it looks like this:
4890 tgkill(4890,4890,50) = 0
rt_sigqueueinfo:
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:42 +03:00
|
|
|
#ifdef TARGET_NR_rt_sigqueueinfo
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_rt_sigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace
Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
by implementing print functions that match arguments types of the system
calls and add them to the corresponding starce.list entry.
tkill:
Prior to this commit, typical strace output used to look like this:
4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
After this commit, it looks like this:
4886 tkill(4886,50) = 0
tgkill:
Prior to this commit, typical strace output used to look like this:
4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
After this commit, it looks like this:
4890 tgkill(4890,4890,50) = 0
rt_sigqueueinfo:
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:42 +03:00
|
|
|
{
|
linux-user: add strace support for uinfo structure of rt_sigqueueinfo() and rt_tgsigqueueinfo()
This commit adds support for printing the content of the target_siginfo_t
structure in a similar way to how it is printed by the host strace. The
pointer to this structure is sent as the last argument of the
rt_sigqueueinfo() and rt_tgsigqueueinfo() system calls.
For this purpose, print_siginfo() is used and the get_target_siginfo()
function is implemented in order to get the information obtained from
the pointer into the form that print_siginfo() expects.
The get_target_siginfo() function is based on
host_to_target_siginfo_noswap() in linux-user mode, but here both
arguments are pointers to target_siginfo_t, so instead of converting
the information to siginfo_t it just extracts and copies it to a
target_siginfo_t structure.
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,{si_signo=50, si_code=SI_QUEUE, si_pid=8307,
si_uid=1000, si_sigval=17716762128}) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:49 +03:00
|
|
|
void *p;
|
|
|
|
target_siginfo_t uinfo;
|
|
|
|
|
linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace
Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
by implementing print functions that match arguments types of the system
calls and add them to the corresponding starce.list entry.
tkill:
Prior to this commit, typical strace output used to look like this:
4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
After this commit, it looks like this:
4886 tkill(4886,50) = 0
tgkill:
Prior to this commit, typical strace output used to look like this:
4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
After this commit, it looks like this:
4890 tgkill(4890,4890,50) = 0
rt_sigqueueinfo:
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:42 +03:00
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_signal(arg1, 0);
|
linux-user: add strace support for uinfo structure of rt_sigqueueinfo() and rt_tgsigqueueinfo()
This commit adds support for printing the content of the target_siginfo_t
structure in a similar way to how it is printed by the host strace. The
pointer to this structure is sent as the last argument of the
rt_sigqueueinfo() and rt_tgsigqueueinfo() system calls.
For this purpose, print_siginfo() is used and the get_target_siginfo()
function is implemented in order to get the information obtained from
the pointer into the form that print_siginfo() expects.
The get_target_siginfo() function is based on
host_to_target_siginfo_noswap() in linux-user mode, but here both
arguments are pointers to target_siginfo_t, so instead of converting
the information to siginfo_t it just extracts and copies it to a
target_siginfo_t structure.
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,{si_signo=50, si_code=SI_QUEUE, si_pid=8307,
si_uid=1000, si_sigval=17716762128}) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:49 +03:00
|
|
|
p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
|
|
|
|
if (p) {
|
|
|
|
get_target_siginfo(&uinfo, p);
|
|
|
|
print_siginfo(&uinfo);
|
|
|
|
|
|
|
|
unlock_user(p, arg2, 0);
|
|
|
|
} else {
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
}
|
linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace
Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
by implementing print functions that match arguments types of the system
calls and add them to the corresponding starce.list entry.
tkill:
Prior to this commit, typical strace output used to look like this:
4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
After this commit, it looks like this:
4886 tkill(4886,50) = 0
tgkill:
Prior to this commit, typical strace output used to look like this:
4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
After this commit, it looks like this:
4890 tgkill(4890,4890,50) = 0
rt_sigqueueinfo:
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:42 +03:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: add rt_tgsigqueueinfo() strace
This commit improves strace support for syscall rt_tgsigqueueinfo().
Prior to this commit, typical strace output used to look like this:
7775 rt_tgsigqueueinfo(7775,7775,50,1996483164,0,0) = 0
After this commit, it looks like this:
7775 rt_tgsigqueueinfo(7775,7775,50,0x76ffea5c) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:47 +03:00
|
|
|
#ifdef TARGET_NR_rt_tgsigqueueinfo
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_rt_tgsigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: add rt_tgsigqueueinfo() strace
This commit improves strace support for syscall rt_tgsigqueueinfo().
Prior to this commit, typical strace output used to look like this:
7775 rt_tgsigqueueinfo(7775,7775,50,1996483164,0,0) = 0
After this commit, it looks like this:
7775 rt_tgsigqueueinfo(7775,7775,50,0x76ffea5c) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:47 +03:00
|
|
|
{
|
linux-user: add strace support for uinfo structure of rt_sigqueueinfo() and rt_tgsigqueueinfo()
This commit adds support for printing the content of the target_siginfo_t
structure in a similar way to how it is printed by the host strace. The
pointer to this structure is sent as the last argument of the
rt_sigqueueinfo() and rt_tgsigqueueinfo() system calls.
For this purpose, print_siginfo() is used and the get_target_siginfo()
function is implemented in order to get the information obtained from
the pointer into the form that print_siginfo() expects.
The get_target_siginfo() function is based on
host_to_target_siginfo_noswap() in linux-user mode, but here both
arguments are pointers to target_siginfo_t, so instead of converting
the information to siginfo_t it just extracts and copies it to a
target_siginfo_t structure.
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,{si_signo=50, si_code=SI_QUEUE, si_pid=8307,
si_uid=1000, si_sigval=17716762128}) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:49 +03:00
|
|
|
void *p;
|
|
|
|
target_siginfo_t uinfo;
|
|
|
|
|
linux-user: add rt_tgsigqueueinfo() strace
This commit improves strace support for syscall rt_tgsigqueueinfo().
Prior to this commit, typical strace output used to look like this:
7775 rt_tgsigqueueinfo(7775,7775,50,1996483164,0,0) = 0
After this commit, it looks like this:
7775 rt_tgsigqueueinfo(7775,7775,50,0x76ffea5c) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:47 +03:00
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_raw_param("%d", arg1, 0);
|
|
|
|
print_signal(arg2, 0);
|
linux-user: add strace support for uinfo structure of rt_sigqueueinfo() and rt_tgsigqueueinfo()
This commit adds support for printing the content of the target_siginfo_t
structure in a similar way to how it is printed by the host strace. The
pointer to this structure is sent as the last argument of the
rt_sigqueueinfo() and rt_tgsigqueueinfo() system calls.
For this purpose, print_siginfo() is used and the get_target_siginfo()
function is implemented in order to get the information obtained from
the pointer into the form that print_siginfo() expects.
The get_target_siginfo() function is based on
host_to_target_siginfo_noswap() in linux-user mode, but here both
arguments are pointers to target_siginfo_t, so instead of converting
the information to siginfo_t it just extracts and copies it to a
target_siginfo_t structure.
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,{si_signo=50, si_code=SI_QUEUE, si_pid=8307,
si_uid=1000, si_sigval=17716762128}) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:49 +03:00
|
|
|
p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
|
|
|
|
if (p) {
|
|
|
|
get_target_siginfo(&uinfo, p);
|
|
|
|
print_siginfo(&uinfo);
|
|
|
|
|
|
|
|
unlock_user(p, arg3, 0);
|
|
|
|
} else {
|
|
|
|
print_pointer(arg3, 1);
|
|
|
|
}
|
linux-user: add rt_tgsigqueueinfo() strace
This commit improves strace support for syscall rt_tgsigqueueinfo().
Prior to this commit, typical strace output used to look like this:
7775 rt_tgsigqueueinfo(7775,7775,50,1996483164,0,0) = 0
After this commit, it looks like this:
7775 rt_tgsigqueueinfo(7775,7775,50,0x76ffea5c) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:47 +03:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: Fix syslog() syscall support
There are currently several problems related to syslog() support.
For example, if the second argument "bufp" of target syslog() syscall
is NULL, the current implementation always returns error code EFAULT.
However, NULL is a perfectly valid value for the second argument for
many use cases of this syscall. This is, for example, visible from
this excerpt of man page for syslog(2):
> EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is
> NULL, or len is less than zero; or for type 8, the level is
> outside the range 1 to 8).
Moreover, the argument "bufp" is ignored for all cases of values of the
first argument, except 2, 3 and 4. This means that for such cases
(the first argument is not 2, 3 or 4), there is no need to pass "buf"
between host and target, and it can be set to NULL while calling host's
syslog(), without loss of emulation accuracy.
Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the
correct returned error code is EINVAL, not EFAULT.
All these details are reflected in this patch.
"#ifdef TARGET_NR_syslog" is also proprerly inserted when needed.
Support for Qemu's "-strace" switch for syslog() syscall is included too.
LTP tests syslog11 and syslog12 pass with this patch (while fail without
it), on any platform.
Changes to original patch by Riku Voipio:
fixed error paths in TARGET_SYSLOG_ACTION_READ_ALL to match
http://lxr.free-electrons.com/source/kernel/printk/printk.c?v=4.7#L1335
Should fix also the build error in:
https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg03721.html
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-09-22 19:56:58 +03:00
|
|
|
#ifdef TARGET_NR_syslog
|
|
|
|
static void
|
|
|
|
print_syslog_action(abi_ulong arg, int last)
|
|
|
|
{
|
|
|
|
const char *type;
|
|
|
|
|
|
|
|
switch (arg) {
|
|
|
|
case TARGET_SYSLOG_ACTION_CLOSE: {
|
|
|
|
type = "SYSLOG_ACTION_CLOSE";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_OPEN: {
|
|
|
|
type = "SYSLOG_ACTION_OPEN";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_READ: {
|
|
|
|
type = "SYSLOG_ACTION_READ";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_READ_ALL: {
|
|
|
|
type = "SYSLOG_ACTION_READ_ALL";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_READ_CLEAR: {
|
|
|
|
type = "SYSLOG_ACTION_READ_CLEAR";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_CLEAR: {
|
|
|
|
type = "SYSLOG_ACTION_CLEAR";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
|
|
|
|
type = "SYSLOG_ACTION_CONSOLE_OFF";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
|
|
|
|
type = "SYSLOG_ACTION_CONSOLE_ON";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
|
|
|
|
type = "SYSLOG_ACTION_CONSOLE_LEVEL";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
|
|
|
|
type = "SYSLOG_ACTION_SIZE_UNREAD";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
|
|
|
|
type = "SYSLOG_ACTION_SIZE_BUFFER";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
print_raw_param("%ld", arg, last);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-02-04 05:54:14 +03:00
|
|
|
qemu_log("%s%s", type, get_comma(last));
|
linux-user: Fix syslog() syscall support
There are currently several problems related to syslog() support.
For example, if the second argument "bufp" of target syslog() syscall
is NULL, the current implementation always returns error code EFAULT.
However, NULL is a perfectly valid value for the second argument for
many use cases of this syscall. This is, for example, visible from
this excerpt of man page for syslog(2):
> EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is
> NULL, or len is less than zero; or for type 8, the level is
> outside the range 1 to 8).
Moreover, the argument "bufp" is ignored for all cases of values of the
first argument, except 2, 3 and 4. This means that for such cases
(the first argument is not 2, 3 or 4), there is no need to pass "buf"
between host and target, and it can be set to NULL while calling host's
syslog(), without loss of emulation accuracy.
Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the
correct returned error code is EINVAL, not EFAULT.
All these details are reflected in this patch.
"#ifdef TARGET_NR_syslog" is also proprerly inserted when needed.
Support for Qemu's "-strace" switch for syslog() syscall is included too.
LTP tests syslog11 and syslog12 pass with this patch (while fail without
it), on any platform.
Changes to original patch by Riku Voipio:
fixed error paths in TARGET_SYSLOG_ACTION_READ_ALL to match
http://lxr.free-electrons.com/source/kernel/printk/printk.c?v=4.7#L1335
Should fix also the build error in:
https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg03721.html
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-09-22 19:56:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syslog(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: Fix syslog() syscall support
There are currently several problems related to syslog() support.
For example, if the second argument "bufp" of target syslog() syscall
is NULL, the current implementation always returns error code EFAULT.
However, NULL is a perfectly valid value for the second argument for
many use cases of this syscall. This is, for example, visible from
this excerpt of man page for syslog(2):
> EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is
> NULL, or len is less than zero; or for type 8, the level is
> outside the range 1 to 8).
Moreover, the argument "bufp" is ignored for all cases of values of the
first argument, except 2, 3 and 4. This means that for such cases
(the first argument is not 2, 3 or 4), there is no need to pass "buf"
between host and target, and it can be set to NULL while calling host's
syslog(), without loss of emulation accuracy.
Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the
correct returned error code is EINVAL, not EFAULT.
All these details are reflected in this patch.
"#ifdef TARGET_NR_syslog" is also proprerly inserted when needed.
Support for Qemu's "-strace" switch for syslog() syscall is included too.
LTP tests syslog11 and syslog12 pass with this patch (while fail without
it), on any platform.
Changes to original patch by Riku Voipio:
fixed error paths in TARGET_SYSLOG_ACTION_READ_ALL to match
http://lxr.free-electrons.com/source/kernel/printk/printk.c?v=4.7#L1335
Should fix also the build error in:
https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg03721.html
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-09-22 19:56:58 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_syslog_action(arg0, 0);
|
|
|
|
print_pointer(arg1, 0);
|
|
|
|
print_raw_param("%d", arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_mknod
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mknod(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
|
2009-04-07 17:57:29 +04:00
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_file_mode(arg1, (hasdev == 0));
|
|
|
|
if (hasdev) {
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("makedev(%d", major(arg2), 0);
|
|
|
|
print_raw_param("%d)", minor(arg2), 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_mknodat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mknodat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
|
2009-04-07 17:57:29 +04:00
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_file_mode(arg2, (hasdev == 0));
|
|
|
|
if (hasdev) {
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("makedev(%d", major(arg3), 0);
|
|
|
|
print_raw_param("%d)", minor(arg3), 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_mq_open
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mq_open(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
int is_creat = (arg1 & TARGET_O_CREAT);
|
2009-04-07 17:57:29 +04:00
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_open_flags(arg1, (is_creat == 0));
|
|
|
|
if (is_creat) {
|
|
|
|
print_file_mode(arg2, 0);
|
|
|
|
print_pointer(arg3, 1);
|
|
|
|
}
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_open
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_open(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
int is_creat = (arg1 & TARGET_O_CREAT);
|
2009-04-07 17:57:29 +04:00
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_open_flags(arg1, (is_creat == 0));
|
|
|
|
if (is_creat)
|
|
|
|
print_file_mode(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_openat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_openat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
int is_creat = (arg2 & TARGET_O_CREAT);
|
2009-04-07 17:57:29 +04:00
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_open_flags(arg2, (is_creat == 0));
|
|
|
|
if (is_creat)
|
|
|
|
print_file_mode(arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-10-01 18:14:54 +03:00
|
|
|
#ifdef TARGET_NR_openat2
|
|
|
|
static void
|
|
|
|
print_openat2(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
struct open_how_ver0 how;
|
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
|
|
|
|
if ((abi_ulong)arg3 >= sizeof(struct target_open_how_ver0) &&
|
|
|
|
copy_struct_from_user(&how, sizeof(how), arg2, arg3) == 0) {
|
|
|
|
how.flags = tswap64(how.flags);
|
|
|
|
how.mode = tswap64(how.mode);
|
|
|
|
how.resolve = tswap64(how.resolve);
|
|
|
|
qemu_log("{");
|
|
|
|
print_open_flags(how.flags, 0);
|
|
|
|
if (how.flags & TARGET_O_CREAT) {
|
|
|
|
print_file_mode(how.mode, 0);
|
|
|
|
}
|
|
|
|
print_flags(openat2_resolve_flags, how.resolve, 1);
|
|
|
|
qemu_log("},");
|
|
|
|
} else {
|
|
|
|
print_pointer(arg2, 0);
|
|
|
|
}
|
|
|
|
print_raw_param(TARGET_ABI_FMT_lu, arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-09-18 22:45:46 +03:00
|
|
|
#ifdef TARGET_NR_pidfd_send_signal
|
|
|
|
static void
|
|
|
|
print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
target_siginfo_t uinfo;
|
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_signal(arg1, 0);
|
|
|
|
|
|
|
|
p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
|
|
|
|
if (p) {
|
|
|
|
get_target_siginfo(&uinfo, p);
|
|
|
|
print_siginfo(&uinfo);
|
|
|
|
|
|
|
|
unlock_user(p, arg2, 0);
|
|
|
|
} else {
|
2022-10-05 19:38:26 +03:00
|
|
|
print_pointer(arg2, 0);
|
2022-09-18 22:45:46 +03:00
|
|
|
}
|
|
|
|
|
2022-10-05 19:38:26 +03:00
|
|
|
print_raw_param("%u", arg3, 1);
|
2022-09-18 22:45:46 +03:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_mq_unlink
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_fstatat64(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_pointer(arg2, 0);
|
|
|
|
print_flags(at_file_flags, arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#define print_newfstatat print_fstatat64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_readlink
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_readlink(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_pointer(arg1, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%u", arg2, 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_readlinkat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_readlinkat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_pointer(arg2, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%u", arg3, 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_rename
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_rename(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_string(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_renameat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_renameat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_at_dirfd(arg2, 0);
|
|
|
|
print_string(arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_statfs
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_statfs(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
2018-08-02 17:16:00 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_statfs64
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_statfs64(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2018-08-02 17:16:00 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
2009-04-07 17:57:29 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_symlink
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_symlink(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_string(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_symlinkat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_symlinkat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_at_dirfd(arg1, 0);
|
|
|
|
print_string(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_mount
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mount(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_string(arg2, 0);
|
|
|
|
print_flags(mount_flags, arg3, 0);
|
|
|
|
print_pointer(arg4, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_umount
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_umount(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_umount2
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_umount2(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_flags(umount2_flags, arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_unlink
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_unlink(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_unlinkat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_unlinkat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_flags(unlinkat_flags, arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-04-06 17:42:03 +03:00
|
|
|
#ifdef TARGET_NR_unshare
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_unshare(CPUArchState *cpu_env, const struct syscallname *name,
|
2021-04-06 17:42:03 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_flags(clone_flags, arg0, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-09-18 22:45:52 +03:00
|
|
|
#ifdef TARGET_NR_clock_nanosleep
|
|
|
|
static void
|
|
|
|
print_clock_nanosleep(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_enums(clockids, arg0, 0);
|
|
|
|
print_raw_param("%d", arg1, 0);
|
|
|
|
print_timespec(arg2, 0);
|
|
|
|
print_timespec(arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-07 17:57:29 +04:00
|
|
|
#ifdef TARGET_NR_utime
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_utime(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_utimes
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_utimes(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_string(arg0, 0);
|
|
|
|
print_pointer(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_utimensat
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_utimensat(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_pointer(arg2, 0);
|
|
|
|
print_flags(at_file_flags, arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-07 09:05:57 +03:00
|
|
|
#if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
|
2009-04-07 17:57:29 +04:00
|
|
|
static void
|
2023-07-17 20:06:32 +03:00
|
|
|
print_mmap_both(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
2023-07-17 20:06:32 +03:00
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5,
|
|
|
|
bool is_old_mmap)
|
|
|
|
{
|
|
|
|
if (is_old_mmap) {
|
|
|
|
abi_ulong *v;
|
|
|
|
abi_ulong argp = arg0;
|
|
|
|
if (!(v = lock_user(VERIFY_READ, argp, 6 * sizeof(abi_ulong), 1)))
|
|
|
|
return;
|
|
|
|
arg0 = tswapal(v[0]);
|
|
|
|
arg1 = tswapal(v[1]);
|
|
|
|
arg2 = tswapal(v[2]);
|
|
|
|
arg3 = tswapal(v[3]);
|
|
|
|
arg4 = tswapal(v[4]);
|
|
|
|
arg5 = tswapal(v[5]);
|
|
|
|
unlock_user(v, argp, 0);
|
|
|
|
}
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_pointer(arg0, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg1, 0);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_flags(mmap_prot_flags, arg2, 0);
|
|
|
|
print_flags(mmap_flags, arg3, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg4, 0);
|
|
|
|
print_raw_param("%#x", arg5, 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
2023-07-17 20:06:32 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_mmap)
|
|
|
|
static void
|
|
|
|
print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3,
|
|
|
|
arg4, arg5,
|
|
|
|
#if defined(TARGET_NR_mmap2)
|
|
|
|
true
|
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TARGET_NR_mmap2)
|
|
|
|
static void
|
|
|
|
print_mmap2(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
return print_mmap_both(cpu_env, name, arg0, arg1, arg2, arg3,
|
|
|
|
arg4, arg5, false);
|
|
|
|
}
|
2009-04-07 17:57:29 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_mprotect
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_mprotect(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_pointer(arg0, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg1, 0);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_flags(mmap_prot_flags, arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_munmap
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_munmap(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_pointer(arg0, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg1, 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_futex
|
2022-08-29 05:10:04 +03:00
|
|
|
static void print_futex_op(int cmd, int last)
|
|
|
|
{
|
|
|
|
static const char * const futex_names[] = {
|
|
|
|
#define NAME(X) [X] = #X
|
|
|
|
NAME(FUTEX_WAIT),
|
|
|
|
NAME(FUTEX_WAKE),
|
|
|
|
NAME(FUTEX_FD),
|
|
|
|
NAME(FUTEX_REQUEUE),
|
|
|
|
NAME(FUTEX_CMP_REQUEUE),
|
|
|
|
NAME(FUTEX_WAKE_OP),
|
|
|
|
NAME(FUTEX_LOCK_PI),
|
|
|
|
NAME(FUTEX_UNLOCK_PI),
|
|
|
|
NAME(FUTEX_TRYLOCK_PI),
|
|
|
|
NAME(FUTEX_WAIT_BITSET),
|
|
|
|
NAME(FUTEX_WAKE_BITSET),
|
|
|
|
NAME(FUTEX_WAIT_REQUEUE_PI),
|
|
|
|
NAME(FUTEX_CMP_REQUEUE_PI),
|
|
|
|
NAME(FUTEX_LOCK_PI2),
|
|
|
|
#undef NAME
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned base_cmd = cmd & FUTEX_CMD_MASK;
|
|
|
|
|
|
|
|
if (base_cmd < ARRAY_SIZE(futex_names)) {
|
|
|
|
qemu_log("%s%s%s",
|
|
|
|
(cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""),
|
|
|
|
(cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""),
|
|
|
|
futex_names[base_cmd]);
|
|
|
|
} else {
|
|
|
|
qemu_log("0x%x", cmd);
|
2013-02-24 03:14:08 +04:00
|
|
|
}
|
2009-04-07 17:57:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_futex(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2009-04-07 17:57:29 +04:00
|
|
|
{
|
2022-09-18 22:45:53 +03:00
|
|
|
abi_long op = arg1 & FUTEX_CMD_MASK;
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_pointer(arg0, 0);
|
|
|
|
print_futex_op(arg1, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param(",%d", arg2, 0);
|
2022-09-18 22:45:53 +03:00
|
|
|
switch (op) {
|
|
|
|
case FUTEX_WAIT:
|
|
|
|
case FUTEX_WAIT_BITSET:
|
2022-08-29 05:10:04 +03:00
|
|
|
case FUTEX_LOCK_PI:
|
|
|
|
case FUTEX_LOCK_PI2:
|
|
|
|
case FUTEX_WAIT_REQUEUE_PI:
|
2022-09-18 22:45:53 +03:00
|
|
|
print_timespec(arg3, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
print_pointer(arg3, 0);
|
|
|
|
break;
|
|
|
|
}
|
2009-04-07 17:57:29 +04:00
|
|
|
print_pointer(arg4, 0);
|
linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.
This patch removes useless tswap() from strace.c
$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...
without tswap()
...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...
natively:
$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...
$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-15 23:10:44 +03:00
|
|
|
print_raw_param("%d", arg4, 1);
|
2009-04-07 17:57:29 +04:00
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-12-22 22:06:39 +03:00
|
|
|
#ifdef TARGET_NR_prlimit64
|
|
|
|
static const char *target_ressource_string(abi_ulong r)
|
|
|
|
{
|
|
|
|
#define RET_RES_ENTRY(res) case TARGET_##res: return #res;
|
|
|
|
switch (r) {
|
|
|
|
RET_RES_ENTRY(RLIMIT_AS);
|
|
|
|
RET_RES_ENTRY(RLIMIT_CORE);
|
|
|
|
RET_RES_ENTRY(RLIMIT_CPU);
|
|
|
|
RET_RES_ENTRY(RLIMIT_DATA);
|
|
|
|
RET_RES_ENTRY(RLIMIT_FSIZE);
|
|
|
|
RET_RES_ENTRY(RLIMIT_LOCKS);
|
|
|
|
RET_RES_ENTRY(RLIMIT_MEMLOCK);
|
|
|
|
RET_RES_ENTRY(RLIMIT_MSGQUEUE);
|
|
|
|
RET_RES_ENTRY(RLIMIT_NICE);
|
|
|
|
RET_RES_ENTRY(RLIMIT_NOFILE);
|
|
|
|
RET_RES_ENTRY(RLIMIT_NPROC);
|
|
|
|
RET_RES_ENTRY(RLIMIT_RSS);
|
|
|
|
RET_RES_ENTRY(RLIMIT_RTPRIO);
|
|
|
|
#ifdef RLIMIT_RTTIME
|
|
|
|
RET_RES_ENTRY(RLIMIT_RTTIME);
|
|
|
|
#endif
|
|
|
|
RET_RES_ENTRY(RLIMIT_SIGPENDING);
|
|
|
|
RET_RES_ENTRY(RLIMIT_STACK);
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#undef RET_RES_ENTRY
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_rlimit64(abi_ulong rlim_addr, int last)
|
|
|
|
{
|
|
|
|
if (rlim_addr) {
|
|
|
|
struct target_rlimit64 *rl;
|
|
|
|
|
|
|
|
rl = lock_user(VERIFY_READ, rlim_addr, sizeof(*rl), 1);
|
|
|
|
if (!rl) {
|
|
|
|
print_pointer(rlim_addr, last);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
print_raw_param64("{rlim_cur=%" PRId64, tswap64(rl->rlim_cur), 0);
|
|
|
|
print_raw_param64("rlim_max=%" PRId64 "}", tswap64(rl->rlim_max),
|
|
|
|
last);
|
|
|
|
unlock_user(rl, rlim_addr, 0);
|
|
|
|
} else {
|
|
|
|
qemu_log("NULL%s", get_comma(last));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_prlimit64(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
const char *rlim_name;
|
|
|
|
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
rlim_name = target_ressource_string(arg1);
|
|
|
|
if (rlim_name) {
|
|
|
|
qemu_log("%s,", rlim_name);
|
|
|
|
} else {
|
|
|
|
print_raw_param("%d", arg1, 0);
|
|
|
|
}
|
|
|
|
print_rlimit64(arg2, 0);
|
|
|
|
print_pointer(arg3, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_syscall_ret_prlimit64(CPUArchState *cpu_env,
|
|
|
|
const struct syscallname *name,
|
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
if (!print_syscall_err(ret)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld, ret);
|
|
|
|
if (arg3) {
|
|
|
|
qemu_log(" (");
|
|
|
|
print_rlimit64(arg3, 1);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-07 02:25:32 +04:00
|
|
|
#ifdef TARGET_NR_kill
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_kill(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
2011-04-07 02:25:32 +04:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_signal(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace
Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
by implementing print functions that match arguments types of the system
calls and add them to the corresponding starce.list entry.
tkill:
Prior to this commit, typical strace output used to look like this:
4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
After this commit, it looks like this:
4886 tkill(4886,50) = 0
tgkill:
Prior to this commit, typical strace output used to look like this:
4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
After this commit, it looks like this:
4890 tgkill(4890,4890,50) = 0
rt_sigqueueinfo:
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:42 +03:00
|
|
|
#ifdef TARGET_NR_tkill
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_tkill(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace
Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
by implementing print functions that match arguments types of the system
calls and add them to the corresponding starce.list entry.
tkill:
Prior to this commit, typical strace output used to look like this:
4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
After this commit, it looks like this:
4886 tkill(4886,50) = 0
tgkill:
Prior to this commit, typical strace output used to look like this:
4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
After this commit, it looks like this:
4890 tgkill(4890,4890,50) = 0
rt_sigqueueinfo:
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:42 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_signal(arg1, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_tgkill
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_tgkill(CPUArchState *cpu_env, const struct syscallname *name,
|
2020-08-11 19:45:49 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
linux-user: add tkill(), tgkill() and rt_sigqueueinfo() strace
Improve strace support for syscall tkill(), tgkill() and rt_sigqueueinfo()
by implementing print functions that match arguments types of the system
calls and add them to the corresponding starce.list entry.
tkill:
Prior to this commit, typical strace output used to look like this:
4886 tkill(4886,50,0,4832615904,0,-9151031864016699136) = 0
After this commit, it looks like this:
4886 tkill(4886,50) = 0
tgkill:
Prior to this commit, typical strace output used to look like this:
4890 tgkill(4890,4890,50,8,4832630528,4832615904) = 0
After this commit, it looks like this:
4890 tgkill(4890,4890,50) = 0
rt_sigqueueinfo:
Prior to this commit, typical strace output used to look like this:
8307 rt_sigqueueinfo(8307,50,1996483164,0,0,50) = 0
After this commit, it looks like this:
8307 rt_sigqueueinfo(8307,50,0x00000040007ff6b0) = 0
Signed-off-by: Miloš Stojanović <Milos.Stojanovic@rt-rk.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-05-15 17:59:42 +03:00
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_raw_param("%d", arg1, 0);
|
|
|
|
print_signal(arg2, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-03-13 01:17:13 +03:00
|
|
|
#if defined(TARGET_NR_pread64) || defined(TARGET_NR_pwrite64)
|
|
|
|
static void
|
|
|
|
print_pread64(CPUArchState *cpu_env, const struct syscallname *name,
|
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
if (regpairs_aligned(cpu_env, TARGET_NR_pread64)) {
|
|
|
|
arg3 = arg4;
|
|
|
|
arg4 = arg5;
|
|
|
|
}
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
print_pointer(arg1, 0);
|
|
|
|
print_raw_param("%d", arg2, 0);
|
|
|
|
print_raw_param("%" PRIu64, target_offset64(arg3, arg4), 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-06-28 13:43:35 +03:00
|
|
|
#ifdef TARGET_NR_statx
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_statx(CPUArchState *cpu_env, const struct syscallname *name,
|
2019-06-28 13:43:35 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_at_dirfd(arg0, 0);
|
|
|
|
print_string(arg1, 0);
|
|
|
|
print_flags(statx_flags, arg2, 0);
|
|
|
|
print_flags(statx_mask, arg3, 0);
|
|
|
|
print_pointer(arg4, 1);
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
linux-user: Add strace support for printing arguments of ioctl()
This patch implements functionality for strace argument printing for ioctls.
When running ioctls through qemu with "-strace", they get printed in format:
"ioctl(fd_num,0x*,0x*) = ret_value"
where the request code an the ioctl's third argument get printed in a hexadicemal
format. This patch changes that by enabling strace to print both the request code
name and the contents of the third argument. For example, when running ioctl
RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
this way:
"ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
In case of IOC_R type ioctls, the contents of the third argument get printed
after the return value, and the argument inside the ioctl call gets printed
as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
"-strace", with changes from this patch, it gets printed in this way:
"ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
In case of IOC_RW type ioctls, the contents of the third argument get printed
both inside the ioctl call and after the return value.
Implementation notes:
Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
in "strace.c", are listed in file "strace.list" as "call" and "result"
value for ioctl. Structure definition "IOCTLEntry" as well as predefined
values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
to file "qemu.h" so that they can be used by these functions to print the
contents of the third ioctl argument. Also, the "static" identifier for array
"ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
so that it can also be used by these functions. To decode the structure type
of the ioctl third argument, function "thunk_print()" was defined in file
"thunk.c" and its definition is somewhat simillar to that of function
"thunk_convert()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
[lv: fix close-bracket]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:47:27 +03:00
|
|
|
#ifdef TARGET_NR_ioctl
|
|
|
|
static void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
|
linux-user: Add strace support for printing arguments of ioctl()
This patch implements functionality for strace argument printing for ioctls.
When running ioctls through qemu with "-strace", they get printed in format:
"ioctl(fd_num,0x*,0x*) = ret_value"
where the request code an the ioctl's third argument get printed in a hexadicemal
format. This patch changes that by enabling strace to print both the request code
name and the contents of the third argument. For example, when running ioctl
RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
this way:
"ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
In case of IOC_R type ioctls, the contents of the third argument get printed
after the return value, and the argument inside the ioctl call gets printed
as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
"-strace", with changes from this patch, it gets printed in this way:
"ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
In case of IOC_RW type ioctls, the contents of the third argument get printed
both inside the ioctl call and after the return value.
Implementation notes:
Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
in "strace.c", are listed in file "strace.list" as "call" and "result"
value for ioctl. Structure definition "IOCTLEntry" as well as predefined
values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
to file "qemu.h" so that they can be used by these functions to print the
contents of the third ioctl argument. Also, the "static" identifier for array
"ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
so that it can also be used by these functions. To decode the structure type
of the ioctl third argument, function "thunk_print()" was defined in file
"thunk.c" and its definition is somewhat simillar to that of function
"thunk_convert()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
[lv: fix close-bracket]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:47:27 +03:00
|
|
|
abi_long arg0, abi_long arg1, abi_long arg2,
|
|
|
|
abi_long arg3, abi_long arg4, abi_long arg5)
|
|
|
|
{
|
|
|
|
print_syscall_prologue(name);
|
|
|
|
print_raw_param("%d", arg0, 0);
|
|
|
|
|
|
|
|
const IOCTLEntry *ie;
|
|
|
|
const argtype *arg_type;
|
|
|
|
void *argptr;
|
|
|
|
int target_size;
|
|
|
|
|
|
|
|
for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
|
|
|
|
if (ie->target_cmd == arg1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ie->target_cmd == 0) {
|
|
|
|
print_raw_param("%#x", arg1, 0);
|
|
|
|
print_raw_param("%#x", arg2, 1);
|
|
|
|
} else {
|
|
|
|
qemu_log("%s", ie->name);
|
|
|
|
arg_type = ie->arg_type;
|
|
|
|
|
|
|
|
if (arg_type[0] != TYPE_NULL) {
|
|
|
|
qemu_log(",");
|
|
|
|
|
|
|
|
switch (arg_type[0]) {
|
|
|
|
case TYPE_PTRVOID:
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case TYPE_CHAR:
|
|
|
|
case TYPE_SHORT:
|
|
|
|
case TYPE_INT:
|
|
|
|
print_raw_param("%d", arg2, 1);
|
|
|
|
break;
|
|
|
|
case TYPE_LONG:
|
|
|
|
print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
|
|
|
|
break;
|
|
|
|
case TYPE_ULONG:
|
|
|
|
print_raw_param(TARGET_ABI_FMT_lu, arg2, 1);
|
|
|
|
break;
|
|
|
|
case TYPE_PTR:
|
|
|
|
switch (ie->access) {
|
|
|
|
case IOC_R:
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
break;
|
|
|
|
case IOC_W:
|
|
|
|
case IOC_RW:
|
|
|
|
arg_type++;
|
|
|
|
target_size = thunk_type_size(arg_type, 0);
|
|
|
|
argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
|
linux-user: Fix Coverity CID 1430271 / CID 1430272
In new functions print_ioctl() and print_syscall_ret_ioctl(), we don't
check if lock_user() returns NULL and this would cause a segfault in
thunk_print().
If lock_user() returns NULL don't call thunk_print() but prints only the
value of the (invalid) pointer.
Tested with:
# cat ioctl.c
#include <unistd.h>
#include <sys/ioctl.h>
int main(void)
{
int ret;
ret = ioctl(STDOUT_FILENO, TCGETS, 0xdeadbeef);
ret = ioctl(STDOUT_FILENO, TCSETSF, 0xdeadbeef);
return 0;
}
# QEMU_STRACE= ./ioctl
...
578 ioctl(1,TCGETS,0xdeadbeef) = -1 errno=2 (Bad address)
578 ioctl(1,TCSETSF,0xdeadbeef) = -1 errno=2 (Bad address)
...
# QEMU_STRACE= passwd
...
623 ioctl(0,TCGETS,0x3fffed04) = 0 ({})
623 ioctl(0,TCSETSF,{}) = 0
...
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: 79482e5987c8 ("linux-user: Add strace support for printing arguments of ioctl()")
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2020-07-09 22:22:17 +03:00
|
|
|
if (argptr) {
|
|
|
|
thunk_print(argptr, arg_type);
|
|
|
|
unlock_user(argptr, arg2, target_size);
|
|
|
|
} else {
|
|
|
|
print_pointer(arg2, 1);
|
|
|
|
}
|
linux-user: Add strace support for printing arguments of ioctl()
This patch implements functionality for strace argument printing for ioctls.
When running ioctls through qemu with "-strace", they get printed in format:
"ioctl(fd_num,0x*,0x*) = ret_value"
where the request code an the ioctl's third argument get printed in a hexadicemal
format. This patch changes that by enabling strace to print both the request code
name and the contents of the third argument. For example, when running ioctl
RTC_SET_TIME with "-strace", with changes from this patch, it gets printed in
this way:
"ioctl(3,RTC_SET_TIME,{12,13,15,20,10,119,0,0,0}) = 0"
In case of IOC_R type ioctls, the contents of the third argument get printed
after the return value, and the argument inside the ioctl call gets printed
as pointer in hexadecimal format. For example, when running RTC_RD_TIME with
"-strace", with changes from this patch, it gets printed in this way:
"ioctl(3,RTC_RD_TIME,0x40800374) = 0 ({22,9,13,11,5,120,0,0,0})"
In case of IOC_RW type ioctls, the contents of the third argument get printed
both inside the ioctl call and after the return value.
Implementation notes:
Functions "print_ioctl()" and "print_syscall_ret_ioctl()", that are defined
in "strace.c", are listed in file "strace.list" as "call" and "result"
value for ioctl. Structure definition "IOCTLEntry" as well as predefined
values for IOC_R, IOC_W and IOC_RW were cut and pasted from file "syscall.c"
to file "qemu.h" so that they can be used by these functions to print the
contents of the third ioctl argument. Also, the "static" identifier for array
"ioctl_entries[]" was removed and this array was declared as "extern" in "qemu.h"
so that it can also be used by these functions. To decode the structure type
of the ioctl third argument, function "thunk_print()" was defined in file
"thunk.c" and its definition is somewhat simillar to that of function
"thunk_convert()".
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200619124727.18080-3-filip.bozuta@syrmia.com>
[lv: fix close-bracket]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-06-19 15:47:27 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print_syscall_epilogue(name);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-10-01 22:32:08 +03:00
|
|
|
#if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid)
|
|
|
|
static void print_wstatus(int wstatus)
|
|
|
|
{
|
|
|
|
if (WIFSIGNALED(wstatus)) {
|
|
|
|
qemu_log("{WIFSIGNALED(s) && WTERMSIG(s) == ");
|
|
|
|
print_signal(WTERMSIG(wstatus), 1);
|
|
|
|
if (WCOREDUMP(wstatus)) {
|
|
|
|
qemu_log(" && WCOREDUMP(s)");
|
|
|
|
}
|
|
|
|
qemu_log("}");
|
|
|
|
} else if (WIFEXITED(wstatus)) {
|
|
|
|
qemu_log("{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
|
|
|
|
WEXITSTATUS(wstatus));
|
|
|
|
} else {
|
|
|
|
print_number(wstatus, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_ret_wstatus(abi_long ret, abi_long wstatus_addr)
|
|
|
|
{
|
|
|
|
int wstatus;
|
|
|
|
|
|
|
|
if (!print_syscall_err(ret)
|
|
|
|
&& wstatus_addr
|
|
|
|
&& get_user_s32(wstatus, wstatus_addr)) {
|
|
|
|
qemu_log(TARGET_ABI_FMT_ld " (wstatus=", ret);
|
|
|
|
print_wstatus(wstatus);
|
|
|
|
qemu_log(")");
|
|
|
|
}
|
|
|
|
qemu_log("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_wait4
|
|
|
|
static void
|
|
|
|
print_syscall_ret_wait4(CPUArchState *cpu_env,
|
|
|
|
const struct syscallname *name,
|
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
print_ret_wstatus(ret, arg1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TARGET_NR_waitpid
|
|
|
|
static void
|
|
|
|
print_syscall_ret_waitpid(CPUArchState *cpu_env,
|
|
|
|
const struct syscallname *name,
|
|
|
|
abi_long ret, abi_long arg0, abi_long arg1,
|
|
|
|
abi_long arg2, abi_long arg3, abi_long arg4,
|
|
|
|
abi_long arg5)
|
|
|
|
{
|
|
|
|
print_ret_wstatus(ret, arg1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-11-01 03:13:36 +03:00
|
|
|
/*
|
|
|
|
* An array of all of the syscalls we know about
|
|
|
|
*/
|
|
|
|
|
2008-09-14 10:45:34 +04:00
|
|
|
static const struct syscallname scnames[] = {
|
2007-11-01 03:13:36 +03:00
|
|
|
#include "strace.list"
|
|
|
|
};
|
|
|
|
|
2008-12-22 23:33:55 +03:00
|
|
|
static int nsyscalls = ARRAY_SIZE(scnames);
|
2007-11-01 03:13:36 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The public interface to this module.
|
|
|
|
*/
|
|
|
|
void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall(CPUArchState *cpu_env, int num,
|
2007-11-11 20:23:29 +03:00
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
|
|
|
int i;
|
2022-08-29 05:10:05 +03:00
|
|
|
FILE *f;
|
|
|
|
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 ")";
|
2007-11-01 03:13:36 +03:00
|
|
|
|
2022-08-29 05:10:05 +03:00
|
|
|
f = qemu_log_trylock();
|
|
|
|
if (!f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fprintf(f, "%d ", getpid());
|
2007-11-01 03:13:36 +03:00
|
|
|
|
2022-08-29 05:10:05 +03:00
|
|
|
for (i = 0; i < nsyscalls; i++) {
|
|
|
|
if (scnames[i].nr == num) {
|
|
|
|
if (scnames[i].call != NULL) {
|
|
|
|
scnames[i].call(cpu_env, &scnames[i], arg1, arg2, arg3,
|
|
|
|
arg4, arg5, arg6);
|
2007-11-01 03:13:36 +03:00
|
|
|
} else {
|
2007-11-14 21:04:05 +03:00
|
|
|
/* XXX: this format system is broken because it uses
|
|
|
|
host types and host pointers for strings */
|
2022-08-29 05:10:05 +03:00
|
|
|
if (scnames[i].format != NULL) {
|
2007-11-01 03:13:36 +03:00
|
|
|
format = scnames[i].format;
|
2022-08-29 05:10:05 +03:00
|
|
|
}
|
|
|
|
fprintf(f, format, scnames[i].name, arg1, arg2,
|
|
|
|
arg3, arg4, arg5, arg6);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2022-08-29 05:10:05 +03:00
|
|
|
qemu_log_unlock(f);
|
2008-05-29 17:49:09 +04:00
|
|
|
return;
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2022-08-29 05:10:05 +03:00
|
|
|
}
|
|
|
|
fprintf(f, "Unknown syscall %d\n", num);
|
|
|
|
qemu_log_unlock(f);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2022-05-09 23:57:27 +03:00
|
|
|
print_syscall_ret(CPUArchState *cpu_env, int num, abi_long ret,
|
2020-06-19 15:33:26 +03:00
|
|
|
abi_long arg1, abi_long arg2, abi_long arg3,
|
|
|
|
abi_long arg4, abi_long arg5, abi_long arg6)
|
2007-11-01 03:13:36 +03:00
|
|
|
{
|
|
|
|
int i;
|
2022-08-29 05:10:05 +03:00
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
f = qemu_log_trylock();
|
|
|
|
if (!f) {
|
|
|
|
return;
|
|
|
|
}
|
2007-11-01 03:13:36 +03:00
|
|
|
|
2022-08-29 05:10:05 +03:00
|
|
|
for (i = 0; i < nsyscalls; i++) {
|
|
|
|
if (scnames[i].nr == num) {
|
|
|
|
if (scnames[i].result != NULL) {
|
2020-08-11 19:45:49 +03:00
|
|
|
scnames[i].result(cpu_env, &scnames[i], ret,
|
2020-06-19 15:33:26 +03:00
|
|
|
arg1, arg2, arg3,
|
|
|
|
arg4, arg5, arg6);
|
2007-11-01 03:13:36 +03:00
|
|
|
} else {
|
2020-07-08 18:24:35 +03:00
|
|
|
if (!print_syscall_err(ret)) {
|
2022-08-29 05:10:05 +03:00
|
|
|
fprintf(f, TARGET_ABI_FMT_ld, ret);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2022-08-29 05:10:05 +03:00
|
|
|
fprintf(f, "\n");
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2022-08-29 05:10:05 +03:00
|
|
|
}
|
|
|
|
qemu_log_unlock(f);
|
2007-11-01 03:13:36 +03:00
|
|
|
}
|
2016-07-18 20:12:24 +03:00
|
|
|
|
|
|
|
void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
|
|
|
|
{
|
|
|
|
/* Print the strace output for a signal being taken:
|
|
|
|
* --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
|
|
|
|
*/
|
2022-08-29 05:10:05 +03:00
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
f = qemu_log_trylock();
|
|
|
|
if (!f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(f, "--- ");
|
2016-07-18 20:12:24 +03:00
|
|
|
print_signal(target_signum, 1);
|
2022-08-29 05:10:05 +03:00
|
|
|
fprintf(f, " ");
|
2016-07-18 20:12:24 +03:00
|
|
|
print_siginfo(tinfo);
|
2022-08-29 05:10:05 +03:00
|
|
|
fprintf(f, " ---\n");
|
|
|
|
qemu_log_unlock(f);
|
2016-07-18 20:12:24 +03:00
|
|
|
}
|