* [PATCH] linux-user/strace: show TID instead of PID
@ 2024-10-23 23:47 J. Neuschäfer
2024-11-10 14:10 ` J. Neuschäfer
2024-11-11 14:59 ` Richard Henderson
0 siblings, 2 replies; 5+ messages in thread
From: J. Neuschäfer @ 2024-10-23 23:47 UTC (permalink / raw)
To: Laurent Vivier, All patches CC here; +Cc: 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_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.neuschaefer@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());
for (i = 0; i < nsyscalls; i++) {
if (scnames[i].nr == num) {
---
base-commit: 6f625ce2f21d6a1243065d236298277c56f972d5
change-id: 20241024-strace-a52bd8e3d305
Best regards,
--
J. Neuschäfer <j.neuschaefer@gmx.net>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] linux-user/strace: show TID instead of PID
2024-10-23 23:47 [PATCH] linux-user/strace: show TID instead of PID J. Neuschäfer
@ 2024-11-10 14:10 ` J. Neuschäfer
2024-11-11 14:59 ` Richard Henderson
1 sibling, 0 replies; 5+ messages in thread
From: J. Neuschäfer @ 2024-11-10 14:10 UTC (permalink / raw)
To: J. Neuschäfer; +Cc: Laurent Vivier, All patches CC here
On Thu, Oct 24, 2024 at 01:47:31AM +0200, 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.
>
> 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.neuschaefer@gmx.net>
> ---
Ping! Any opinions on this patch?
Best regards,
J. Neuschäfer
> 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());
>
> for (i = 0; i < nsyscalls; i++) {
> if (scnames[i].nr == num) {
>
> ---
> base-commit: 6f625ce2f21d6a1243065d236298277c56f972d5
> change-id: 20241024-strace-a52bd8e3d305
>
> Best regards,
> --
> J. Neuschäfer <j.neuschaefer@gmx.net>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] linux-user/strace: show TID instead of PID
2024-10-23 23:47 [PATCH] linux-user/strace: show TID instead of PID J. Neuschäfer
2024-11-10 14:10 ` J. Neuschäfer
@ 2024-11-11 14:59 ` Richard Henderson
2024-11-11 15:02 ` Richard Henderson
1 sibling, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2024-11-11 14:59 UTC (permalink / raw)
To: qemu-devel
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.neuschaefer@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.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] linux-user/strace: show TID instead of PID
2024-11-11 14:59 ` Richard Henderson
@ 2024-11-11 15:02 ` Richard Henderson
2024-11-20 20:23 ` Richard Henderson
0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2024-11-11 15:02 UTC (permalink / raw)
To: qemu-devel
On 11/11/24 06:59, Richard Henderson wrote:
> 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.neuschaefer@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
Or, without the syscall,
get_task_state(env_cpu(env))->ts_tid
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] linux-user/strace: show TID instead of PID
2024-11-11 15:02 ` Richard Henderson
@ 2024-11-20 20:23 ` Richard Henderson
0 siblings, 0 replies; 5+ messages in thread
From: Richard Henderson @ 2024-11-20 20:23 UTC (permalink / raw)
To: qemu-devel
On 11/11/24 09:02, Richard Henderson wrote:
> On 11/11/24 06:59, Richard Henderson wrote:
>> 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.neuschaefer@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
>
> Or, without the syscall,
>
> get_task_state(env_cpu(env))->ts_tid
Queued with this change.
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-20 20:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 23:47 [PATCH] linux-user/strace: show TID instead of PID J. Neuschäfer
2024-11-10 14:10 ` J. Neuschäfer
2024-11-11 14:59 ` Richard Henderson
2024-11-11 15:02 ` Richard Henderson
2024-11-20 20:23 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).