It also contains the information about how to add custom DTrace probes to user applications. I was a bit surprised when I first read that, as it's only a couple of pages long.
It turns out that adding DTrace probes really is that simple...
The first thing I did was write a definition file for the probes. This was commit 1057. If you look at provider.d you'll see that I've defined two probes for the moment.
The first is going to fire when Sendmail starts reading a queue directory looking for items to deliver. The second will fire when Sendmail finishes reading the queue directory.
With the provider defined I needed to add the probe points.
At the moment
sendmail/queue.c:gatherq()looks like being the function to instrument. Accordingly, I've added
DTRACE_PROBE()calls at the apropriate points.
The other piece of the puzzle is for
provider.dto be processed by dtrace(1) to generate
provider.o. This then needs to be added to the files that are linked in to the Sendmail binary in order for the probes to work.
You can see the work I had to do to the Sendmail build process as part of the same commit, 1058, in the changes to
sendmail/Makefile.m4. That looks like it will need some cleanup, and for consistency I should be wrapping all these changes in
checks. But that would complicate things at this point, where I'm trying to do the bare minimum to get things to work.
I did bump in to one issue. If you review change 1058 you'll see that I had to remove the
staticdeclaration from the definition for
gatherq(). Without that change things fail at link time --
provider.ocan't see the
gatherqsymbol. I'm not completely happy about this, so more investigation needs to happen there.
And does it work? Well, everything compiles, which is a good start. The next step is to configure the test zones that I created earlier to use the new Sendmail binary. Then testing can start in earnest.