It's possible to declare a dependency on a DTrace module using pragmas;
for instance, siftr.d currently contains
#pragma D depends_on module siftr
libdtrace currently resolves this by looking through its module list,
which includes the list of loaded KLDs (e.g. siftr.ko). However, many
kernel modules can be compiled into the kernel, in which case they won't
appear in libdtrace's module list, so libdtrace will incorrectly skip
processing of the library. Note that a DTrace module isn't necessarily a
kernel object; DTrace may define modules that correspond to userland
libraries.
This change fixes the problem by keeping track of loaded kernel modules
as well as KLDs, and allowing a module dependency to be satisfied by
either a KLD or a kernel module. Ideally we would only look at either
KLDs or kernel modules, but libdtrace's notion of a module doesn't
really map perfectly to either of them, so the only real solution I can
see to the above-described problem is to check both.