About 30-ish ports provide some sort of dtrace SDT probes, with many enabling those conditionally on a DTRACE option. Compiling dtrace-enabled ports via poudriere runs into some hurdles: * dtrace(1) expects the dtrace kernel modules to be loaded * invocations of dtrace frequently examine kernel objects under /boot * generating probes.h out of probes.d and compiling the probes does not fit very well into many build systems * in order for dtrace probes to work at runtime, the process needs to be able to access /dev/dtrace/helper poudriere's use of jails to compile means that the first two of these assumptions aren't necessarily true. The need to examine kernel objects can often be avoided by adding -xnolibs to 'gtrace -G' (generate ELF object file) and 'dtrace -h' (generate C/C++ header file)
Fixing permissions. Choosing group 141 as the next available gid from /usr/ports/GIDs, create a dtrace group and add the userids used by dtrace-able programs to it. I shall use postgresql96 as the example: ``` # pw group add -n dtrace -g 141 -M postgres # cat /etc/devfs.rules [userdtrace=10] add path dtrace/helper mode 0660 group dtrace # sysrc devfs_system_ruleset="userdtrace" ``` Will result in ownership/permissions like so (may need a reboot): ``` # ls -la /dev/dtrace/ total 1 dr-xr-xr-x 2 root wheel 512 Jun 3 11:42 ./ dr-xr-xr-x 13 root wheel 512 Jun 3 11:42 ../ crw------- 1 root wheel 0x9 Jun 3 11:42 dtmalloc crw------- 1 root wheel 0x4 Jun 3 11:42 dtrace crw------- 1 root wheel 0x7 Jun 3 11:42 fasttrap crw------- 1 root wheel 0x8 Jun 3 11:42 fbt crw-rw---- 1 root dtrace 0x5 Jun 3 11:42 helper crw------- 1 root wheel 0x6 Jun 3 11:42 profile ``` Resulting in: ``` # dtrace -l -m postgres | head -10 ID PROVIDER MODULE FUNCTION NAME 69078 postgresql79451 postgres CheckPointBuffers buffer-checkpoint-done 69079 postgresql79451 postgres CheckPointBuffers buffer-checkpoint-start 69080 postgresql79451 postgres CheckPointBuffers buffer-checkpoint-sync-start 69081 postgresql79451 postgres FlushBuffer buffer-flush-done 69082 postgresql79451 postgres FlushBuffer buffer-flush-start 69083 postgresql79451 postgres ReadBuffer_common buffer-read-done 69084 postgresql79451 postgres ReadBuffer_common buffer-read-start 69085 postgresql79451 postgres CheckPointBuffers buffer-sync-done 69086 postgresql79451 postgres CheckPointBuffers buffer-sync-start ```
https://lists.freebsd.org/pipermail/freebsd-dtrace/2014-December/000340.html
Created attachment 183624 [details] postgresql9{2,6}-server patches These patches allow poudriere to build postgresql+dtrace probes for amd64 11.0 and 10.3 on an amd64 11.0 host with dtraceall kmod loaded. Fails when trying to build i386 binaries.
Same result when building without and dtrace kernel modules loaded.
-lelf isn't necessary after base r278934 -xnolibs isn't necessary after base r283025