{{Short description|Software}} {{Lowercase title}} {{Infobox software | name = ktrace | programming language = C<ref>{{cite web|url=https://cgit.freebsd.org/src/plain/usr.bin/ktrace/ktrace.c|title=C source of ktrace utility in FreeBSD|website=cgit.freebsd.org|access-date=2024-03-07}}</ref> | operating system = BSD Unix and Mac OS X | language = English | genre = Tracing }}

'''ktrace''' is a utility included with certain versions of BSD Unix and Mac OS X that traces kernel interaction with a program and dumps it to disk for the purposes of debugging and analysis. Traced kernel operations include system calls, name translations, signal processing, and I/O.<ref>{{cite web |url=http://www.freebsd.org/cgi/man.cgi?ktrace |title=ktrace(1) manpage |website=freebsd.org |date=2012-05-31 |access-date=2014-07-23}}</ref>

Trace files generated by ktrace (named {{mono|ktrace.out}} by default) can be viewed in human-readable form by using the '''kdump''' utility.<ref>{{cite web |url=http://www.freebsd.org/cgi/man.cgi?kdump |title=kdump(1) manpage |website=freebsd.org |date=2014-03-28 |access-date=2014-07-23}}</ref>

Since Mac OS X Leopard, ktrace has been replaced by DTrace.<ref>{{cite web|url=https://discussions.apple.com/thread/1756145|title=What happened to ktrace and kdump|website=discussions.apple.com|date=2008-10-17}}</ref> The identically-named ktrace program in recent macOS versions does not have the same functions as this utility.

== See also == * DTrace, Sun Microsystems's trace version, now running on OpenSolaris, FreeBSD, macOS, and Windows * kdump (Linux), Linux kernel's crash dump mechanism, which internally uses kexec * SystemTap * trace on Linux, part of the Linux Trace Toolkit

== References == {{Reflist}}

{{Mac-software-stub}} {{unix-stub}}

Category:Unix programming tools