aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-05-30 23:18:42 +0200
committerMattias Andrée <maandree@kth.se>2020-05-30 23:18:42 +0200
commitb3b9cf7dc1912c4df8c9d8dd740144dab8050bff (patch)
tree0d945745dc9644910c184dd93bf4ad1c29b5ee4c /util.c
parentDo not print PID numbers if only configured to trace one thread (diff)
downloadsctrace-b3b9cf7dc1912c4df8c9d8dd740144dab8050bff.tar.gz
sctrace-b3b9cf7dc1912c4df8c9d8dd740144dab8050bff.tar.bz2
sctrace-b3b9cf7dc1912c4df8c9d8dd740144dab8050bff.tar.xz
Add support for tracing threads
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'util.c')
-rw-r--r--util.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/util.c b/util.c
index 7ee9c51..521f73a 100644
--- a/util.c
+++ b/util.c
@@ -25,10 +25,17 @@ tprintf(struct process *proc, const char *fmt, ...)
fmt = &fmt[1];
}
if (multiproctrace) {
- if (last_char == '\n')
- fprintf(trace_fp, "[%ju] ", (uintmax_t)proc->pid);
- else if (proc->pid != last_pid)
- fprintf(trace_fp, "\n[%ju] ", (uintmax_t)proc->pid);
+ if (proc->thread_group_leader) {
+ if (last_char == '\n')
+ fprintf(trace_fp, "[%ju, %ju] ", (uintmax_t)proc->thread_group_leader, (uintmax_t)proc->pid);
+ else if (proc->pid != last_pid)
+ fprintf(trace_fp, "\n[%ju, %ju] ", (uintmax_t)proc->thread_group_leader, (uintmax_t)proc->pid);
+ } else {
+ if (last_char == '\n')
+ fprintf(trace_fp, "[%ju] ", (uintmax_t)proc->pid);
+ else if (proc->pid != last_pid)
+ fprintf(trace_fp, "\n[%ju] ", (uintmax_t)proc->pid);
+ }
}
va_start(ap, fmt);
vfprintf(trace_fp, fmt, ap);