Dtrace was implemented under Solaris 8, which ironically did not support dtrace. Instead, a version of dtrace was hacked into the Sun's (now
Oracle's) build machines. This dtrace version supported an early version of the USDT user space dtrace probes that I'll call USDT1.
When Apple introduced dtrace into its Leopard OS, it used a later version of Sun's dtrace that has a different probe style. Oracle has
not been able to move to the newer probe style because it still has builds that require the older versions of Solaris.
The USDT1 probes require a bunch of macros in the code (src/share/vm/utilities/dtrace.hpp):
A typical USDT1 probe is shown below.
USDT2 probes are much simpler:
We can dispense with all of the macro definitions and setup because the dtrace command (/usr/sbin/dtrace on Mac OS) takes
care of the details. From hotspot.d, which defines the probes,
it translates the code:
and generates the following macro in hotspot.h (via dtrace.make, early in the hotspot build). Thus,
we end up with a simpler call and all the support macros are built automatically.
While inserting the USDT2 probes in the OpenJDK code base, I tried to make minimal disruptions to the USDT1 probes.
However, there are two complications.
First, many of the dtrace probes are wrapped in macros. The example above looks like this:
Due to the complications of nested macros and my inability to do test builds on Solaris 8, I elected to duplicate
the entire macro when translating to USDT2. This results in significant amounts of duplicated code. If the old
style probes are never going to be updated, this code should probably be consolidated by restructuring the macros.
The second problem is the use of lower case probe names in the code. For example, the following
probe takes a type argument that is encorporated into the probe name with preprocessor token
Since the USDT2 probe macros are automatically generated in upper case, the USDT2 code uses macros to translate
the lower case type names into the required upper case names: