Wednesday, June 19, 2013

Logging in Jikes RVM

Jikes RVM development often requires debugging without proper debugger support. We may use gdb for debugging. However log outputs, using the org.mmtk.utility.Log class are often useful for the debugging purposes. The below code segment is such a log statement.
Log.write("Using collector"); Log.write(head); Log.writeln();
Here, VERBOSE is defined as,
public static boolean VERBOSE = false;
and during the development and testing phase, we changed it to true in the respective classes, as required. Many of the debug statements included during the development stage are later removed, when they were no more necessary. The remaining in MMTk are changed to use the verbose command line option of rvm, by including the log statements inside the below block.
if (VM.VERIFY_ASSERTIONS && Options.verbose.getValue() >= 9) { … }
These logs are displayed only when the RVM is run with the respective verbosity, as given below.
./rvm -showfullversion -X:gc:verbose=9 HelloWorld
Our debug statements will be printed only if the verbose level is set to 9 or more by a command line argument. Hence, for the verbosity level of 8 or less, they won't be logged. This methodology avoids logging overhead in the production builds, while enabling detailed logs for the development and debugging efforts without any code changes.

No comments:

Post a Comment

You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.