Sun Studio 12: Debugging a Program With dbx

Setting a stop Breakpoint at a Line of Source Code

You can set a breakpoint at a line number, using the stop at command, where n is a source code line number and filename is an optional program file name qualifier.

(dbx) stop at filename: n

For example

(dbx) stop at

If the line specified is not an executable line of source code, dbx sets the breakpoint at the next executable line. If there is no executable line, dbx issues an error.

You can determine the line at which you wish to stop by using the file command to set the current file and the list command to list the function in which you wish to stop. Then use the stop at command to set the breakpoint on the source line:

(dbx) file t.c
(dbx) list main
10    main(int argc, char *argv[])
11    {
12        char *msg = "hello world\n";
13        printit(msg);
14    }
(dbx) stop at 13

For more information on specifying at an location event, see at [filename:]line_number.