[DTrace-devel] [PATCH] Trigger DIVZERO fault when the divider is 0

Eugene Loh eugene.loh at oracle.com
Thu Jan 21 18:22:24 PST 2021


The code looks good.  My comments are only around the tests, which are 
most of the patch anyhow.

I'm not sure if the copyright dates should include 2006 or not. 
Regardless, the years should probably match for
     tst.DTRACEFLT_DIVZERO.div.d
     tst.DTRACEFLT_DIVZERO.mod.d

The tests should not check arg5 since we document arg5 as undefined for 
DTRACEFLT_DIVZERO.  As a result, one can just get rid of the .r.p file 
(which you do anyhow) but also just print the other args for .r checking 
instead of all that ERROR-probe code to check args.

Actually, one can check the args in the ERROR probe, but just do 
something simpler like this:
     ERROR { exit(arga != vala || argb != valb || argc != valc); }
rather than replicating
     ERROR /arga != vala || argb != valb || argc != valc/ { exit(1); }
     ERROR /arga == vala && argb == valb && argc != valc/ { exit(0); }
along with the increased chance of making a mistake (as is done above).

The reason we would want to check the args in the ERROR probe (as above) 
rather than dump for comparison with a .r file is because arg4's value 
should be arg4 == DTRACEFLT_DIVZERO, which is something we can check in 
the ERROR probe.  In contrast, if we dump the numerical value, it 
becomes "4", which is not a documented value.  That is, we can check:
     ERROR { exit(arg1 != val1 || arg2 != val2 || arg3 != val3 || arg4 
!= DTRACEFLT_DIVZERO); }

I see that the old test checked arg1 (EPID), while its replacements do 
not.  Can we add a check for arg1?

And, I remain disappointed/uneasy that we have lost arg3 (DIF offset).




More information about the DTrace-devel mailing list