DTrace

Overlay repository
The ebuilds for dtrace are placed (in time of writing) in github repository.

https://github.com/robertek/dtrace-portage-overlay

To activate the repository just add new repository configuration to your portage config.

$ cat /etc/portage/repos.conf/dtrace [dtrace] location = /var/lib/portage/dtrace sync-type = git sync-uri = https://github.com/robertek/dtrace-portage-overlay auto-sync = yes

Then sync portage tree.

Installation
DTrace support on Gentoo consists of kernel sources with patches and userspace utilities. It is packed in 3 packages:
 * libctf => library for CTF debug info handling, needed for both the kernel and user utilities
 * dtrace-user => userspace part, mainly the dtrace(1) command and libdtrace
 * dtrace-sources => kernel 4.14.x sources containing dtrace patches and working initial .config

The default installation can be done installing just the dtrace-user:

$ emerge -av dtrace-user

Note: the dtrace-sources is needed for dtrace-user because of header dependencies. If you plan to manage your local sources in git or different way you need link

/usr/include/linux/dtrace -> /your/src/path/dtrace-linux-src/include/uapi/linux/dtrace

Kernel
Build the kernel your way. The main difference to normal building is executing "make ctf" before kernel installation. This will generate CTF debug data for dtrace to work.

Example steps: $ cd /usr/src/linux-4.14.28-dtrace $ make oldconfig $ make $ make ctf $ make install $ make modules_install

There is one important nit. Do not expect to be able to create kernel with custom config, it may end with dwarf2ctf tool crashing (when I developed these ebuilds I tried my own config for 4.14 without luck). I would suggest using the config provided from dtrace-sources (which is based on Oracle UEK kernel config) and than striping it down or up your way.

Test it
When everything passed correctly you may try some basic dtrace oneliner.

$ dtrace -n 'proc:::exec-success { trace(curpsinfo->pr_psargs); }' dtrace: description 'proc:::exec-success ' matched 1 probe CPU    ID                    FUNCTION:NAME 3  2017  do_execveat_common:exec-success   /usr/bin/konsole 3  2017  do_execveat_common:exec-success   git --version 3  2017  do_execveat_common:exec-success   grep --color=auto 3  2017  do_execveat_common:exec-success   grep --exclude-dir=.cvs 3  2017  do_execveat_common:exec-success   dircolors -b 3  2017  do_execveat_common:exec-success   ls --color -d.