From f26931d3c13e326740ea2f7ee78192f737c51742 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 2 Jan 2022 20:04:57 +0100 Subject: fix bug where exec() calls would create duplicate entries in pid_db Also print execution times for processes that exec'd when -t is used. --- extrace.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extrace.c b/extrace.c index 9f5f166..9753f43 100644 --- a/extrace.c +++ b/extrace.c @@ -362,12 +362,21 @@ handle_msg(struct cn_msg *cn_hdr) if (show_exit || !flat) { for (i = 0; i < PID_DB_SIZE - 1; i++) - if (pid_db[i].pid == 0) + if (pid_db[i].pid == 0 || pid_db[i].pid == pid) break; if (i == PID_DB_SIZE - 1) print_runtime_error("extrace: warning: pid_db of " "size %d overflowed\n", PID_DB_SIZE); + if (show_exit && pid_db[i].pid == pid) { + if (!flat) + fprintf(output, "%*s", 2*d, ""); + fprintf(output, "%d- %s execed time=%.3fs\n", + pid, + pid_db[i].cmdline, + (ev->timestamp_ns - pid_db[i].start) / 1e9); + } + pid_db[i].pid = pid; pid_db[i].depth = d; pid_db[i].start = ev->timestamp_ns; -- cgit 1.4.1