Search code examples
javadebuggingjdijpda

StepRequest with StepRequest.STEP_MIN parameter


In Java Debug Interface, What does StepRequest with StepRequest.STEP_MIN parameter mean ? https://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/com/sun/jdi/request/StepRequest.html Java Docs says "Step to the next available location". What is next available location ? I understand StepRequest.STEP_LINE parameter to run line by line but what is StepRequest.STEP_MIN parameter ? When I ran with this parameter there are multiple step requests for a single line, and I am not able to understand it.


Solution

  • From RequestManager javadoc:

    A sizevalue of StepRequest.STEP_MIN will generate a step event each time the code index changes. It represents the smallest step size available and often maps to the instruction level. A size value of StepRequest.STEP_LINE will generate a step event each time the source line changes unless line number information is not available, in which case a STEP_MIN will be done instead

    Looking at The class file format#The LineNumberTable

    The LineNumberTable attribute is an optional variable-length attribute in the attributes table of a Code (§4.7.3) attribute. It may be used by debuggers to determine which part of the Java Virtual Machine code array corresponds to a given line number in the original source file.

    Probably a StepRequest use code-array and line-number-table to determine the next step location.