Skip to content

Commit

Permalink
linux-user: Fix strace output for old_mmap
Browse files Browse the repository at this point in the history
The old_mmap syscall (e.g. on i386) hands over the parameters in
a struct. Adjust the strace output to print the correct values.

Signed-off-by: Helge Deller <deller@gmx.de>
Reported-by: John Reiser <jreiser@BitWagon.com>
Closes: https://gitlab.com/qemu-project/qemu/-/issues/1760
  • Loading branch information
hdeller committed Jul 18, 2023
1 parent eac78a4 commit d971040
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions linux-user/strace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3767,10 +3767,24 @@ print_utimensat(CPUArchState *cpu_env, const struct syscallname *name,

#if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
static void
print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
print_mmap_both(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)
{
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);
}
print_syscall_prologue(name);
print_pointer(arg0, 0);
print_raw_param("%d", arg1, 0);
Expand All @@ -3780,7 +3794,34 @@ print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
print_raw_param("%#x", arg5, 1);
print_syscall_epilogue(name);
}
#define print_mmap2 print_mmap
#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);
}
#endif

#ifdef TARGET_NR_mprotect
Expand Down

0 comments on commit d971040

Please sign in to comment.