Column Debug Information
You know how you're debugging, and you reach a method call that looks like
methodCall(anotherMethod()) and you want to step over the call to anotherMethod but step into the call to methodCall? That's where column-level debugger information could come handy.
And there are other cases as well:
- Chained boolean evaluations: Imagine being able to tell which boolean evaluation is taking place now in the next code:
if ((a.equals(b) || b.size() > 5) && a.size() != 0). Most of us just have to press F8 (or whatever key we use for "next step") and determine later why the boolean failed or succeeded. - Conditional assignments: Being able to separating the steps in the ?: operator, such as
a = condition ? b : c. Again, most of the time it's just stepping through the condition and checking what was assigned toa. - As mentioned before,
forloops (both classic orforeachstyle).
for loop, so for the following code: for (int i = 0; i < arr.size() && i < n; i++) the breakpoint would occur only when i is bigger than arr.size(), and not (as it is today) whenever the code reaches any of the three parts of the statement definition.
Another great benefit is code coverage, where tools today cannot tell whether an if statement was reached through all possible conditions - Information which could be of great help when analysing code through code coverage utilities.
And the change to make this work? Well, it requires modification to the JVM, I can tell you that. But it can be deemed as an optional change. The current specification of LineNumberTable specifies that a Code attribute of a method, which is used by debuggers to determine which line in the source code is attached to which part of bytecode sequence. What is needed is an extension to the LineNumberTable structure to include the column-start and column-end of the code at that line. For example, the structure might become like the following (changes from origin are bolded):
NewLineNumberTable_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 line_number_table_length;
{ u2 start_pc;
u2 line_number;
u2 col_start;
u2 col_end;
} line_number_table[line_number_table_length];
}
Comments (1)