diff mbox series

[PULL,1/2] linux-user: Print tid not pid with strace

Message ID 20241123150706.19740-2-richard.henderson@linaro.org (mailing list archive)
State New
Headers show
Series [PULL,1/2] linux-user: Print tid not pid with strace | expand

Commit Message

Richard Henderson Nov. 23, 2024, 3:07 p.m. UTC
From: J. Neuschäfer <j.neuschaefer@gmx.net>

This aligns with strace, and is very useful when tracing multi-threaded
programs. The result is the same in single-threaded programs.

Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
Message-Id: 20241024-strace-v1-1-56c4161431cd@gmx.net
[rth: Use TaskState.ts_tid via get_task_state()]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/strace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

J. Neuschäfer Nov. 23, 2024, 7:42 p.m. UTC | #1
On Sat, Nov 23, 2024 at 09:07:05AM -0600, Richard Henderson wrote:
> From: J. Neuschäfer <j.neuschaefer@gmx.net>
>
> This aligns with strace, and is very useful when tracing multi-threaded
> programs. The result is the same in single-threaded programs.
>
> Signed-off-by: J. Neuschäfer <j.neuschaefer@gmx.net>
> Message-Id: 20241024-strace-v1-1-56c4161431cd@gmx.net
> [rth: Use TaskState.ts_tid via get_task_state()]
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  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 b70eadc19e..f68c5cdc44 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -4401,7 +4401,7 @@ print_syscall(CPUArchState *cpu_env, int num,
>      if (!f) {
>          return;
>      }
> -    fprintf(f, "%d ", getpid());
> +    fprintf(f, "%d ", get_task_state(env_cpu(cpu_env))->ts_tid);

Ah, that works too. Thanks for taking care of this patch!

J.
diff mbox series

Patch

diff --git a/linux-user/strace.c b/linux-user/strace.c
index b70eadc19e..f68c5cdc44 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -4401,7 +4401,7 @@  print_syscall(CPUArchState *cpu_env, int num,
     if (!f) {
         return;
     }
-    fprintf(f, "%d ", getpid());
+    fprintf(f, "%d ", get_task_state(env_cpu(cpu_env))->ts_tid);
 
     for (i = 0; i < nsyscalls; i++) {
         if (scnames[i].nr == num) {