| |||
| Home > Working with the CLI > Source patching with macros > Patching example to jump over lines of source code | |||
You can also use a similar approach to jump over or skip lines of source code:
Define a macro to set the PC to a point beyond the lines that are not executed.
Start a debugging session and set a breakpoint on the first line to be skipped.
Attach your macro to this breakpoint.
Run the program until execution stops at the breakpoint.
The source statements in your macro are interpreted and executed. The macro completes.
Program execution continues normally from the new position of the PC.
You can also use the JUMP command for looping and skipping over commands. The JUMP command takes a label and an expression. If the expression evaluates to True then control jumps to the specified label. If the label is positioned earlier in the file, this loops. If the label is positioned later in the file, all intermediate commands are skipped.
The expression can test:
symbols, using the isalive keyword
results
local symbols, created with ADD
file tests, using macros.
Example 1.5 shows a script command fragment containing the JUMP command.
Example 1.5. Using the JUMP command
add int cnt = 20initialize:repeat /* loop 20 times */some_commandsjump repeat,cnt /* repeat until cnt==0 */ ; ; define some local vars if not defined. ; jump nodefine,isalive(cnt)==1some_commands:nodefine