On 10/23/24 16:47, J. Neuschäfer wrote:
This aligns with strace, and is very useful when tracing multi-threaded
programs. The result is the same in single-threaded programs.

See also "-D log.%d -d tid -strace" which will split the output into per-tid 
files.


gettid() requires the _GNU_SOURCE feature test macro, so it might be
unavailable in rare cases. I don't expect it to be a problem though,
because it's implemented by both glibc and musl.

Signed-off-by: J. Neuschäfer <j.neuschae...@gmx.net>
---
  linux-user/strace.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 
c3eb3a2706a93fdcaf693b3413b13921a3c97e8e..93e8c73de8a4a307e6e0df5555bee4c769e41e64
 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -4337,7 +4337,7 @@ print_syscall(CPUArchState *cpu_env, int num,
      if (!f) {
          return;
      }
-    fprintf(f, "%d ", getpid());
+    fprintf(f, "%d ", gettid());

Probably better as qemu_get_thread_id(), but otherwise

Reviewed-by: Richard Henderson <richard.hender...@linaro.org>


r~

Reply via email to