From: dv Date: Wed, 23 Jun 2021 11:24:01 +0000 (+0000) Subject: btrace(8): init and update timespec for BEGIN/END event X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=24fbf86f117bf9bd4c63d430f09435a9807cf608;p=openbsd btrace(8): init and update timespec for BEGIN/END event BEGIN and END use a fake dt(4) event, so in order to use the nsecs var or time() it needs a timespec set. Init for BEGIN and update at END. ok mpi@ --- diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 15c67aba085..961500a3a68 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.36 2021/06/07 12:55:19 dv Exp $ */ +/* $OpenBSD: btrace.c,v 1.37 2021/06/23 11:24:01 dv Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot @@ -442,6 +442,7 @@ rules_setup(int fd) memcpy(&bt_devt.dtev_comm, getprogname(), sizeof(bt_devt.dtev_comm)); bt_devt.dtev_pid = getpid(); bt_devt.dtev_tid = getthrid(); + clock_gettime(CLOCK_REALTIME, &bt_devt.dtev_tsp); if (rbegin) rule_eval(rbegin, &bt_devt); @@ -502,6 +503,9 @@ rules_teardown(int fd) if (dokstack) kelf_close(); + /* Update "fake" event for BEGIN/END */ + clock_gettime(CLOCK_REALTIME, &bt_devt.dtev_tsp); + if (rend) rule_eval(rend, &bt_devt); else {