Setting and deleting breakpoints to step through a program

An alternative to setting breakpoints is to run your program one line or instruction at a time, a procedure known as single-stepping. This section discusses how to set and delete breakpoints, begin program execution, and control program execution.

Use the stop subcommand to set breakpoints in dbx. There are four variations of the stop subcommand for programs compiled with the debug flag (the c89 -g option):
stop at linenumber [if Condition]
Stops the program at a specified source line number. The linenumber parameter consists of an optional filename and a : (colon), followed by a line number. For example, “hello.c”:23 and 23 are valid linenumber parameters. The optional if condition flag specifies that execution should be halted at the specified line number if the condition is true when the line number is reached. Line numbers are relative to the beginning of the source file. A condition is an expression that evaluates to true or false. For example:
(dbx) stop at "zinfo.c":57
stop in procedure [if condition]
Stops the program at the first executable statement in a procedure or function. For example:
(dbx) stop in main
stop variable [in procedure at linenumber] [if condition]
Stops the program when the value of variable changes.
For example:
(dbx) stop x
stop if condition
Stops the program whenever condition evaluates to true.
For example:
(dbx) stop if (x > y) and (x < 20000)
Note: See z/OS UNIX System Services Command Reference for more information on the stop subcommand.
After any of the preceding subcommands, dbx responds with a message reporting the event it has built as a result of your command. The message includes the event ID associated with your breakpoint along with an interpretation of your command. The syntax of the interpretation might not be exactly the same as your command. The following are examples:
(dbx) stop in main
[1] stop in main
(dbx) stop at 19 if x == 3
[2] if x = 3 { stop } at "hello.c":19

The numbers in the brackets are the event identifiers associated with the breakpoints. When the program is halted as a result of one of the events, the event identifier is displayed along with the current line to show what event caused the program to stop. The events you create coexist with internal events created by dbx, so event identifiers might not always be sequential.

Use the status command to display all current events. You can redirect output from status to a z/OS UNIX file. Each event is displayed in the same form as it was when stored.

The clear and delete commands remove breakpoints. The clear command deletes breakpoints by line number. The delete command eliminates events by event identifier. Use delete all to remove all breakpoints and trace events.

The following examples show how to display the active events and remove them:
(dbx) status
 
[1] stop in main
[2] if x = 3 { stop } at "hello.c":19
(dbx) delete 1
(dbx) status
 
[2] if x = 3 { stop } at "hello.c":19
(dbx) clear 19
(dbx) status
(dbx)