diff options
author | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2021-09-03 16:45:46 +0000 |
---|---|---|
committer | Jasper Lievisse Adriaanse <jasper@cvs.openbsd.org> | 2021-09-03 16:45:46 +0000 |
commit | fce04b0e80489062d30507672c4c064fbab3538c (patch) | |
tree | d6f516ec863b671ee396c63daaaae1bfcfff5a8a /usr.sbin/btrace/btrace.c | |
parent | 562bd13c16f2bafe89c42489d0ec06b2b02c5e32 (diff) |
add kprobes provider for dt
this allows us to dynamically trace function boundaries with btrace by patching
prologues and epilogues with a breakpoint upon which the handler records the data,
sends it back to userland for btrace to consume.
currently it's hidden behind DDBPROF, and there is still a lot to cleanup and
improve, but basic scripts that observe return codes from a probed function
work.
from Tom Rollet, with various changes by me
feedback and ok mpi@
Diffstat (limited to 'usr.sbin/btrace/btrace.c')
-rw-r--r-- | usr.sbin/btrace/btrace.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index b4bb8864e07..2530126271a 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.46 2021/09/02 17:21:39 jasper Exp $ */ +/* $OpenBSD: btrace.c,v 1.47 2021/09/03 16:45:44 jasper Exp $ */ /* * Copyright (c) 2019 - 2021 Martin Pieuchot <mpi@openbsd.org> @@ -503,15 +503,18 @@ rules_teardown(int fd) } TAILQ_FOREACH(r, &g_rules, br_next) { + dtrq = r->br_cookie; if (r->br_type != B_RT_PROBE) { if (r->br_type == B_RT_END) rend = r; continue; - } + } else { + if (ioctl(fd, DTIOCPRBDISABLE, dtrq)) + err(1, "DTIOCPRBDISABLE"); + } - dtrq = r->br_cookie; - if (dtrq->dtrq_evtflags & DTEVT_KSTACK) - dokstack = 1; + if (dtrq->dtrq_evtflags & DTEVT_KSTACK) + dokstack = 1; } if (dokstack) |