Example: using CEETEST to start z/OS Debugger from C/C++

The following examples show how to use the Language Environment® callable service CEETEST to start z/OS® Debugger from C or C++ programs.
Example 1
In this example, an empty command string is passed to z/OS Debugger and a pointer to the Language Environment feedback code is returned. If no other TEST run-time options have been compiled into the program, the call to CEETEST starts z/OS Debugger with all defaults in effect. After it gains control, z/OS Debugger prompts you for commands.
#include <leawi.h>
#include <string.h>
#include <stdio.h>

int main(void) {
  _VSTRING  commands;
  _FEEDBACK fc;

  strcpy(commands.string, "");
  commands.length = strlen(commands.string);

  CEETEST(&commands, &fc);

}
Example 2
In this example, a string of valid z/OS Debugger commands is passed to z/OS Debugger and a pointer to Language Environment feedback code is returned. The call to CEETEST starts z/OS Debugger and the command string is processed. At statement 23, the values of x and y are displayed in the Log, and execution of the program resumes. Barring further interrupts, the behavior at program termination depends on whether you have set AT TERMINATION:
  • If you have set AT TERMINATION, z/OS Debugger regains control and prompts you for commands.
  • If you have not set AT TERMINATION, the program terminates.
The command LIST(z) is discarded when the command GO is executed.
Note: If you include a STEP or GO in your command string, all commands after that are not processed. The command string operates like a commands file.
#include <leawi.h>
#include <string.h>
#include <stdio.h>

int main(void) {
  _VSTRING  commands;
  _FEEDBACK fc;

  strcpy(commands.string, "AT LINE 23; {LIST(x); LIST(y);} GO; LIST(z)");
  commands.length = strlen(commands.string);
⋮
  CEETEST(&commands, &fc);
⋮
}
Example 3
In this example, a string of valid z/OS Debugger commands is passed to z/OS Debugger and a pointer to the feedback code is returned. If the call to CEETEST fails, an informational message is printed.
If the call to CEETEST succeeds, z/OS Debugger is started and the command string is processed. At statement 30, the values of x and y are displayed in the Log, and execution of the program resumes. Barring further interrupts, the behavior at program termination depends on whether you have set AT TERMINATION:
  • If you have set AT TERMINATION, z/OS Debugger regains control and prompts you for commands.
  • If you have not set AT TERMINATION, the program terminates.
#include <leawi.h>
#include <string.h>
#include <stdio.h>

#define SUCCESS "\0\0\0\0"

int main (void) {

   int x,y,z;
   _VSTRING commands;
   _FEEDBACK fc;

   strcpy(commands.string,"AT LINE 30 { LIST(x); LIST(y); } GO;");
   commands.length = strlen(commands.string);
⋮
   CEETEST(&commands,&fc);
⋮
   if (memcmp(&fc,SUCCESS,4) != 0) {
      printf("CEETEST failed with message number %d\n",fc.tok_msgno);
      return(2999);
   }
}