aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-05-30 22:58:04 +0200
committerMattias Andrée <maandree@kth.se>2020-05-30 22:58:04 +0200
commit783dc9ce1c729ce171a4a460703bdd413bce6364 (patch)
treeaf846446517b4c184e216fd82aa83a2c83034796 /util.c
parentAdd todo about different (bad) behaviour under valgrind (diff)
downloadsctrace-783dc9ce1c729ce171a4a460703bdd413bce6364.tar.gz
sctrace-783dc9ce1c729ce171a4a460703bdd413bce6364.tar.bz2
sctrace-783dc9ce1c729ce171a4a460703bdd413bce6364.tar.xz
Do not print PID numbers if only configured to trace one thread
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--util.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/util.c b/util.c
index 76a8a36..7ee9c51 100644
--- a/util.c
+++ b/util.c
@@ -5,11 +5,13 @@
static FILE *trace_fp;
static char last_char = '\n';
static pid_t last_pid = 0;
+static int multiproctrace;
void
-set_trace_output(FILE *fp)
+setup_trace_output(FILE *fp, int multiprocess)
{
+ multiproctrace = multiprocess;
trace_fp = fp;
}
@@ -22,10 +24,12 @@ tprintf(struct process *proc, const char *fmt, ...)
last_pid = 0;
fmt = &fmt[1];
}
- 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 (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);
+ }
va_start(ap, fmt);
vfprintf(trace_fp, fmt, ap);
last_pid = proc->pid;