Debugging TRPL


Unfortunately, TRPL is not yet enabled for source-level debugging. We have a plan to switch TRPL to a Scala based environment, but until that time we must make do. The following tips are intended to help with this process.

Connecting a Debugger

You can add the following to the ConversionDriver command line:

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=2080,server=y,suspend=y

You can choose a different port than 2080. The conversion process will block (suspend=y) until you connect. Set your breakpoints and debug as you normally would.

Useful Techniques

Output Statements

If you are trying to debug the TRPL rules, a good starting point is to put debug output statements in the TRPL itself where you can co-locate with problem rules, output state and only conditionally output something. The global printf() function is especially useful.

Breakpoint Locations

In the com.goldencode.p2j.pattern package there are the Rule, RuleSet and RuleContainer classes which are used by the PatternEngine to execute the TRPL rules. Each expression is compiled using the com.goldencode.expr package.

If you want to see the state of the conversion environment in the debugger at a particular line of TRPL code, you can set a conditional breakpoint in, at the top of the execute() method. Set a condition like:

return infix.equals("some TRPL expression");

Of course, you can use any String method here... startsWith(), endsWith(), etc.

This will be very slow, since it is doing a lot of string processing in the breakpoint. However, it can be useful on occasion.

© 2004-2019 Golden Code Development Corporation. ALL RIGHTS RESERVED.