* [PATCH] linux-user: Provide print_raw_param64() for 64-bit values
@ 2023-01-31 17:18 Helge Deller
2023-03-07 14:21 ` Laurent Vivier
2023-03-07 15:17 ` Laurent Vivier
0 siblings, 2 replies; 3+ messages in thread
From: Helge Deller @ 2023-01-31 17:18 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel
Add a new function print_raw_param64() to print 64-bit values in the
same way as print_raw_param(). This prevents that qemu_log() is used to
work around the problem that print_raw_param() can only print 32-bit
values when compiled for 32-bit targets.
Additionally convert the existing 64-bit users in print_timespec64(),
print_rlimit64() and print_preadwrite64() over to this new function and
drop some unneccessary spaces.
Suggested-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 379536f5c9..35d22be027 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -81,6 +81,7 @@ UNUSED static void print_syscall_epilogue(const struct syscallname *);
UNUSED static void print_string(abi_long, int);
UNUSED static void print_buf(abi_long addr, abi_long len, int last);
UNUSED static void print_raw_param(const char *, abi_long, int);
+UNUSED static void print_raw_param64(const char *, long long, int last);
UNUSED static void print_timeval(abi_ulong, int);
UNUSED static void print_timespec(abi_ulong, int);
UNUSED static void print_timespec64(abi_ulong, int);
@@ -1615,6 +1616,19 @@ print_raw_param(const char *fmt, abi_long param, int last)
qemu_log(format, param);
}
+/*
+ * 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);
+}
+
+
static void
print_pointer(abi_long p, int last)
{
@@ -1691,10 +1705,8 @@ print_timespec64(abi_ulong ts_addr, int last)
print_pointer(ts_addr, last);
return;
}
- qemu_log("{tv_sec = %lld"
- ",tv_nsec = %lld}%s",
- (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
- get_comma(last));
+ print_raw_param64("{tv_sec=%" PRId64, tswap64(ts->tv_sec), 0);
+ print_raw_param64("tv_nsec=%" PRId64 "}", tswap64(ts->tv_nsec), last);
unlock_user(ts, ts_addr, 0);
} else {
qemu_log("NULL%s", get_comma(last));
@@ -3814,10 +3826,9 @@ print_rlimit64(abi_ulong rlim_addr, int last)
print_pointer(rlim_addr, last);
return;
}
- qemu_log("{rlim_cur = %lld, rlim_max = %lld}%s",
- (long long)tswap64(rl->rlim_cur),
- (long long)tswap64(rl->rlim_max),
- get_comma(last));
+ 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));
@@ -3838,7 +3849,7 @@ print_preadwrite64(CPUArchState *cpu_env, const struct syscallname *name,
print_raw_param("%d", arg0, 0);
print_pointer(arg1, 0);
print_raw_param("%d", arg2, 0);
- qemu_log("%lld", (long long)target_offset64(arg3, arg4));
+ print_raw_param64("%" PRId64, target_offset64(arg3, arg4), 1);
print_syscall_epilogue(name);
}
#endif
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-user: Provide print_raw_param64() for 64-bit values
2023-01-31 17:18 [PATCH] linux-user: Provide print_raw_param64() for 64-bit values Helge Deller
@ 2023-03-07 14:21 ` Laurent Vivier
2023-03-07 15:17 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2023-03-07 14:21 UTC (permalink / raw)
To: Helge Deller, qemu-devel
Le 31/01/2023 à 18:18, Helge Deller a écrit :
> Add a new function print_raw_param64() to print 64-bit values in the
> same way as print_raw_param(). This prevents that qemu_log() is used to
> work around the problem that print_raw_param() can only print 32-bit
> values when compiled for 32-bit targets.
>
> Additionally convert the existing 64-bit users in print_timespec64(),
> print_rlimit64() and print_preadwrite64() over to this new function and
> drop some unneccessary spaces.
>
> Suggested-by: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Helge Deller <deller@gmx.de>
>
>
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 379536f5c9..35d22be027 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -81,6 +81,7 @@ UNUSED static void print_syscall_epilogue(const struct syscallname *);
> UNUSED static void print_string(abi_long, int);
> UNUSED static void print_buf(abi_long addr, abi_long len, int last);
> UNUSED static void print_raw_param(const char *, abi_long, int);
> +UNUSED static void print_raw_param64(const char *, long long, int last);
> UNUSED static void print_timeval(abi_ulong, int);
> UNUSED static void print_timespec(abi_ulong, int);
> UNUSED static void print_timespec64(abi_ulong, int);
> @@ -1615,6 +1616,19 @@ print_raw_param(const char *fmt, abi_long param, int last)
> qemu_log(format, param);
> }
>
> +/*
> + * 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);
> +}
> +
> +
> static void
> print_pointer(abi_long p, int last)
> {
> @@ -1691,10 +1705,8 @@ print_timespec64(abi_ulong ts_addr, int last)
> print_pointer(ts_addr, last);
> return;
> }
> - qemu_log("{tv_sec = %lld"
> - ",tv_nsec = %lld}%s",
> - (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
> - get_comma(last));
> + print_raw_param64("{tv_sec=%" PRId64, tswap64(ts->tv_sec), 0);
> + print_raw_param64("tv_nsec=%" PRId64 "}", tswap64(ts->tv_nsec), last);
> unlock_user(ts, ts_addr, 0);
> } else {
> qemu_log("NULL%s", get_comma(last));
> @@ -3814,10 +3826,9 @@ print_rlimit64(abi_ulong rlim_addr, int last)
> print_pointer(rlim_addr, last);
> return;
> }
> - qemu_log("{rlim_cur = %lld, rlim_max = %lld}%s",
> - (long long)tswap64(rl->rlim_cur),
> - (long long)tswap64(rl->rlim_max),
> - get_comma(last));
> + 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));
> @@ -3838,7 +3849,7 @@ print_preadwrite64(CPUArchState *cpu_env, const struct syscallname *name,
> print_raw_param("%d", arg0, 0);
> print_pointer(arg1, 0);
> print_raw_param("%d", arg2, 0);
> - qemu_log("%lld", (long long)target_offset64(arg3, arg4));
> + print_raw_param64("%" PRId64, target_offset64(arg3, arg4), 1);
> print_syscall_epilogue(name);
> }
> #endif
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-user: Provide print_raw_param64() for 64-bit values
2023-01-31 17:18 [PATCH] linux-user: Provide print_raw_param64() for 64-bit values Helge Deller
2023-03-07 14:21 ` Laurent Vivier
@ 2023-03-07 15:17 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2023-03-07 15:17 UTC (permalink / raw)
To: Helge Deller, qemu-devel
Le 31/01/2023 à 18:18, Helge Deller a écrit :
> Add a new function print_raw_param64() to print 64-bit values in the
> same way as print_raw_param(). This prevents that qemu_log() is used to
> work around the problem that print_raw_param() can only print 32-bit
> values when compiled for 32-bit targets.
>
> Additionally convert the existing 64-bit users in print_timespec64(),
> print_rlimit64() and print_preadwrite64() over to this new function and
> drop some unneccessary spaces.
>
> Suggested-by: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Helge Deller <deller@gmx.de>
>
>
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 379536f5c9..35d22be027 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -81,6 +81,7 @@ UNUSED static void print_syscall_epilogue(const struct syscallname *);
> UNUSED static void print_string(abi_long, int);
> UNUSED static void print_buf(abi_long addr, abi_long len, int last);
> UNUSED static void print_raw_param(const char *, abi_long, int);
> +UNUSED static void print_raw_param64(const char *, long long, int last);
> UNUSED static void print_timeval(abi_ulong, int);
> UNUSED static void print_timespec(abi_ulong, int);
> UNUSED static void print_timespec64(abi_ulong, int);
> @@ -1615,6 +1616,19 @@ print_raw_param(const char *fmt, abi_long param, int last)
> qemu_log(format, param);
> }
>
> +/*
> + * 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);
> +}
> +
> +
> static void
> print_pointer(abi_long p, int last)
> {
> @@ -1691,10 +1705,8 @@ print_timespec64(abi_ulong ts_addr, int last)
> print_pointer(ts_addr, last);
> return;
> }
> - qemu_log("{tv_sec = %lld"
> - ",tv_nsec = %lld}%s",
> - (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
> - get_comma(last));
> + print_raw_param64("{tv_sec=%" PRId64, tswap64(ts->tv_sec), 0);
> + print_raw_param64("tv_nsec=%" PRId64 "}", tswap64(ts->tv_nsec), last);
> unlock_user(ts, ts_addr, 0);
> } else {
> qemu_log("NULL%s", get_comma(last));
> @@ -3814,10 +3826,9 @@ print_rlimit64(abi_ulong rlim_addr, int last)
> print_pointer(rlim_addr, last);
> return;
> }
> - qemu_log("{rlim_cur = %lld, rlim_max = %lld}%s",
> - (long long)tswap64(rl->rlim_cur),
> - (long long)tswap64(rl->rlim_max),
> - get_comma(last));
> + 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));
> @@ -3838,7 +3849,7 @@ print_preadwrite64(CPUArchState *cpu_env, const struct syscallname *name,
> print_raw_param("%d", arg0, 0);
> print_pointer(arg1, 0);
> print_raw_param("%d", arg2, 0);
> - qemu_log("%lld", (long long)target_offset64(arg3, arg4));
> + print_raw_param64("%" PRId64, target_offset64(arg3, arg4), 1);
> print_syscall_epilogue(name);
> }
> #endif
>
Applied to my linux-user-for-8.0 branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-07 15:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 17:18 [PATCH] linux-user: Provide print_raw_param64() for 64-bit values Helge Deller
2023-03-07 14:21 ` Laurent Vivier
2023-03-07 15:17 ` Laurent Vivier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.