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.
- 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)
(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.
(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)