linux-user/strace: show TID instead of PID
PATCH 1/1 linux-user/strace: show TID instead of PID
This aligns with strace, and is very useful when tracing multi-threaded programs. The result is the same in single-threaded programs.
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.
--- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/strace.c +1 -1
@@ -4337,7 +4337,7 @@ print_syscall(CPUArchState *cpu_env, int num,if (!f) {return ; } -fprintf (f,"%d " ,getpid ()); +fprintf (f,"%d " ,gettid ());for (i =0 ; i < nsyscalls; i++) {if (scnames[i].nr == num) {
---
base-commit: 6f625ce2f21d6a1243065d236298277c56f972d5
change-id: 20241024-strace-a52bd8e3d305
Best regards,
--
J. Neuschäfer <[email protected]>
Quoted 9 lines · J. Neuschäfer
This aligns with strace, and is very useful when tracing multi-threaded programs. The result is the same in single-threaded programs.
gettid()requires the_GNU_SOURCEfeature 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 <[email protected]>---
Ping! Any opinions on this patch?
Best regards,
J. Neuschäfer
Quoted 26 lines
linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/strace.c +1
-2@@ -4337,7 +4337,7 @@ print_syscall(CPUArchState *cpu_env, int num,if (!f) {return ; } -fprintf (f,"%d " ,getpid ()); +fprintf (f,"%d " ,gettid ());for (i =0 ; i < nsyscalls; i++) {if (scnames[i].nr == num) { ---base-commit:
6f625ce2f21d6a1243065d236298277c56f972d5
change-id: 20241024-strace-a52bd8e3d305Best regards,
--
J. Neuschäfer <[email protected]>
Quoted 2 lines · J. Neuschäfer
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.
Quoted 15 lines
gettid()requires the_GNU_SOURCEfeature 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 <[email protected]>--- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/strace.c +0
-0
linux-user/strace.c print_syscall(CPUArchState *cpu_env, int num, · line 4340
Quoted 5 lines
linux-user/strace.c +1
-1@@ -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
r~
Quoted 16 lines · Richard Henderson
Quoted 2 lines · J. Neuschäfer
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.
Quoted 10 lines
gettid()requires the_GNU_SOURCEfeature 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 <[email protected]>---
linux-user/strace.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
linux-user/strace.c print_syscall(CPUArchState *cpu_env, int num, · line 4340
Quoted 10 lines
linux-user/strace.c +1
-1@@ -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
Or, without the syscall,
get_task_state(env_cpu(env))->ts_tid
r~
Quoted 30 lines · Richard Henderson
Quoted 16 lines · Richard Henderson
Quoted 2 lines · J. Neuschäfer
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.
Quoted 10 lines
gettid()requires the_GNU_SOURCEfeature 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 <[email protected]>---
linux-user/strace.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 12 lines
linux-user/strace.c print_syscall(CPUArchState *cpu_env, int num, · line 4340
Quoted 10 lines
linux-user/strace.c +1
-1@@ -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
Quoted 3 lines
Or, without the syscall,
get_task_state(env_cpu(env))->ts_tid
Queued with this change.
r~