Skip to contentSkip to conversation

linux-user: Show SIGCHLD in clone() strace output

PATCH In review Helge Deller 2 participants 4 messages Jan 25, 2023 – Jan 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 linux-user: Show SIGCHLD in clone() strace output

When stracing a program, show up the SIGCHLD value the same way as it's done when running strace natively, e.g.:
clone(child_stack=0xf7af0040, flags=CLONE_VM|CLONE_VFORK|SIGCHLD, ...

---
 linux-user/strace.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/strace.c +1 -0
index 82dc1a1e20..3157e4b420 100644
@@ -1136,6 +1136,7 @@ UNUSED static struct flags clone_flags[] = {
 #if defined(CLONE_IO)
     FLAG_GENERIC(CLONE_IO),
 #endif
+    FLAG_TARGET(SIGCHLD),
     FLAG_END,
 };
 

--
2.38.1

#1 lore raw

PATCH 2/2 linux-user: Show 4th argument of rt_sigprocmask() in strace

Add output for the missing 4th parameter (size_t sigsetsize).

---
 linux-user/strace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/strace.c +2 -1
index 3157e4b420..e3aa994678 100644
@@ -3146,7 +3146,8 @@ print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name,
     }
     qemu_log("%s,", how);
     print_pointer(arg1, 0);
-    print_pointer(arg2, 1);
+    print_pointer(arg2, 0);
+    print_raw_param("%d", arg3, 1);
     print_syscall_epilogue(name);
 }
 #endif

--
2.38.1

#2 lore raw

Re: [PATCH 2/2] linux-user: Show 4th argument of rt_sigprocmask() in strace

Le 25/01/2023 à 14:57, Helge Deller a écrit :

Quoted 12 lines

Add output for the missing 4th parameter (size_t sigsetsize).

---
  linux-user/strace.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
linux-user/strace.c +0 -0
index 3157e4b420..e3aa994678 100644

linux-user/strace.c print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name, · line 3150

Quoted 6 lines
linux-user/strace.c +2 -1
@@ -3146,7 +3146,8 @@ print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name,
      }
      qemu_log("%s,", how);
      print_pointer(arg1, 0);
-    print_pointer(arg2, 1);
+    print_pointer(arg2, 0);
+    print_raw_param("%d", arg3, 1);

Better with "%u" as size_t is unsigned.

Thanks,
Laurent

Quoted 7 lines
linux-user/strace.c +0 -1
      print_syscall_epilogue(name);
  }
  #endif
--

2.38.1

#3 lore raw
In reply to Helge Deller
Quoted 14 lines · Helge Deller

When stracing a program, show up the SIGCHLD value the same way as it's done when running strace natively, e.g.:
clone(child_stack=0xf7af0040, flags=CLONE_VM|CLONE_VFORK|SIGCHLD, ...

---
  linux-user/strace.c | 1 +
  1 file changed, 1 insertion(+)
linux-user/strace.c +0 -0
index 82dc1a1e20..3157e4b420 100644

linux-user/strace.c UNUSED static struct flags clone_flags[] = { · line 1139

Quoted 4 lines
linux-user/strace.c +1 -0
@@ -1136,6 +1136,7 @@ UNUSED static struct flags clone_flags[] = {
  #if defined(CLONE_IO)
      FLAG_GENERIC(CLONE_IO),
  #endif
+    FLAG_TARGET(SIGCHLD),

It's actually not 100% correct, as this would trigger for other SIGxxx values too, which have the same bits set as TARGET_SIGCHLD. Given the fact that we only support TARGET_SIGCHLD in clone(), it would nevertheless in most cases show the correct output.

So, probably it's best to not apply this patch it as-is.

Helge