about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-01-02 20:04:57 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-01-02 20:04:57 +0100
commitf26931d3c13e326740ea2f7ee78192f737c51742 (patch)
tree3f104dcaa7c1868710ba3f511c9b957c24b66019
parent06a771fcfb511d2fab024d5970c9f4495abab8c3 (diff)
downloadextrace-f26931d3c13e326740ea2f7ee78192f737c51742.tar.gz
extrace-f26931d3c13e326740ea2f7ee78192f737c51742.tar.xz
extrace-f26931d3c13e326740ea2f7ee78192f737c51742.zip
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.
-rw-r--r--extrace.c11
1 files changed, 10 insertions, 1 deletions
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;