Restrictions for debugging self-modifying code
z/OS® Debugger cannot debug self-modifying code. If your program contains self-modifying code that modifies an instruction while the containing compilation unit is being debugged, the result can be unpredictable, including an abnormal termination (ABEND) of z/OS Debugger. If your program contains self-modifying code that completely replaces an instruction while the containing compilation unit is being debugged, the result might not be an ABEND. However, z/OS Debugger might miss a breakpoint on that instruction or display a message indicating an invalid hook address at delete.
The following coding techniques can be used to minimize problems debugging self-modifying code:
- Do not modify part of an instruction. Instead, replace an instruction.
The following table compares coding techniques:
Coding that modifies an instructions Coding that replaces an instruction ModInst BC 0,Target ... MVI ModInst+1,X'F0'
ModInst BC 0,Target ... MVC ModInst(4),NewInst ... NewInst BC 15,Target
- Define instructions to be modified by using DC instructions instead
of executable instructions. For example, use the instruction
ModInst DC X'4700',S(Target)
instead of the instructionMVC ModInst(4),NewInst
.