GOTO command

The GOTO command causes z/OS® Debugger to resume program execution at the specified statement id. The GOTO keyword cannot be abbreviated. If you want z/OS Debugger to return control to you at a target location, make sure there is a breakpoint at that location.

Read syntax diagramSkip visual syntax diagramGOTOGOTOstatement_id;

Usage notes

  • You can use the GOTO command if the SET WARNING is set to OFF and the runtime level allows GOTO without compiler enablement for the following programs:
    • A COBOL program compiled without hooks being inserted by the compiler and with optimization, if you compiled with the NOEJPD suboptions of the TEST compiler option
    • A program compiled with Enterprise COBOL for z/OS Version 5 or later and optimized by Automatic Binary Optimizer for z/OS
    • A program compiled with Open XL C/C++ for z/OS
    The use of GOTO in this case might cause unpredictable behaviors, including abends, when the GOTO command is executed or followed. You can get the best behavior of GOTO command in programs that are compiled with OPT and TEST(NOEJPD) options in either of the following situations:
    • When the target of the GOTO or JUMPTO command is a paragraph name or a section name (label).
    • When the target of the GOTO or JUMPTO command is the first statement in the paragraph or section.
    You can get the best behavior especially if the statements are targets of COBOL statements PERFORM or GOTO in the COBOL program. See SET WARNING command (C, C++, COBOL, and PL/I).
  • You cannot use the GOTO command while you debug a disassembled program.
  • If GOTO is specified in a command list (for example, as the subject of an IF command or WHEN clause), all subsequent commands in the list are ignored.
  • Statement GOTO's are not restricted if the program is compiled with minimum optimization.
  • The GOTO command cannot be used while you replay recorded statements by using the PLAYBACK command.
  • For C, C++, and PL/I, statements can be removed by the compiler during optimization, specify a reference or statement with the GOTO command that can be reached during program execution. You can issue the LIST STATEMENT NUMBERS command to determine the reachable statements.
  • PL/I allows GOTO in a command list on a call to PLITEST or CEETEST.
  • In PL/I, out-of-block GOTOs are allowed. However, qualification might be needed.
  • For COBOL, the GOTO command follows the COBOL language rules for the GOTO statement. You can use the GOTO command in the following situations:
    • A COBOL program compiled with hooks inserted by the compiler. If you are using Enterprise COBOL for z/OS, Version 4, compile your program with the HOOK suboption of the TEST compiler option. If you are using any of the following compilers, compile your program with either PATH or ALL suboption and the SYM suboption of the TEST compiler option:
      • Enterprise COBOL for z/OS and OS/390®, Version 3
      • COBOL for OS/390 & VM, Version 2
    • A COBOL program compiled without hooks inserted by the compiler and without optimization. If you are using Enterprise COBOL for z/OS, Version 4, compile your program with the NOHOOK suboption of the TEST compiler option. If you are using any of the following compilers, compile your program with the NONE suboption of the TEST compiler option:
      • Enterprise COBOL for z/OS and OS/390, Version 3 Release 2 or later
      • Enterprise COBOL for z/OS and OS/390, Version 3 Release 1, with APAR PQ63235 installed
      • COBOL for OS/390 & VM, Version 2 Release 2
      • COBOL for OS/390 & VM, Version 2 Release 1, with APAR PQ63234 installed
    • A COBOL program compiled without hooks inserted by the compiler and with optimization. You must compile your program with Enterprise COBOL for z/OS, Version 4, and specify the EJPD and NOHOOK suboption of the TEST compiler option. Specifying the EJPD suboption might cause some loss of optimization.
    • For Enterprise COBOL for z/OS Version 5, programs are always compiled without hooks inserted by the compiler. If you are using the TEST compiler option in combination with any level of the OPT compiler option, it is recommended to use the EJPD suboption of the TEST compiler option.
  • This command cannot be used if you are stopped at an AT APPEARANCE breakpoint, an AT LOAD breakpoint, or an AT DELETE breakpoint.

Examples

  • Resume execution at statement 23, where statement 23 is in a currently active block.
    GOTO 23;
    If there's no breakpoint at statement 23, z/OS Debugger will run from statement 23 until a breakpoint is hit.
  • Resume execution at statement 45, where statement 45 is in a currently active block.
    AT 45
    GOTO 45

Refer to the following topics for more information related to the material discussed in this topic.

  • Related tasks
  • IBM® z/OS Debugger User's Guide
  • Related references
  • statement_id