Oracle® Solaris Studio 12.4: Debugging a Program With dbx

Exit Print View

Updated: January 2015
 
 

Setting a Breakpoint at a Line of Source Code

You can set a breakpoint at a line number by 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 main.cc:3

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, as shown in the following example.

(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 Event Specification.