next up previous contents
Next: Debugging the core dumps: Up: No Title Previous: Execution Monitoring

Debugging tools

The IRIX system provides a source level debugger called dbx. It can be invoked from the command line as dbx exec_program The `exec_program' is the name of the executable program to be debugged. This program must have been compiled by the `-g' option when compiling the C source code. After we run dbx we get a prompt > on which we issue the various commands to monitor the execution of the program.

Starting the execution: The program is executed by the command run [argument list]. Here argument list is the list of arguments that is normally passed when running the program on the command line. The program execution continues till a break point.

If at any point of time we want to reexecute the program from start, we can use the command rerun.

Setting a breakpoint: We can set the break point at any line in the soure code by giving the a line number (line numbers are shown in dbx). The command is, stop at NN , where NN is the line number at which you want to set the break point.

We can set a break point just after entering a function. The command is, stop in func_name, where func_name is the name of the function at which the break point is to be set.

Single stepping: After the program encounters a break point, the execution is controlled by us, normally single stepping. The command is next or n. This command will execute the statements sequentially. So we have to just keep on doing next every time.

Stepping inside a function: The command step allows to single step inside a function call.

Continuing execution: When we are single stepping, we can set new break points or continue execution by the command cont. This command continues execution till the next break point.

Printing a value of a variable: The command print variable_name prints the present value of variable_name. We do not have to specify the type of the variable so it is properly taken care of by the dbx itself.

Determining the type of the variable: The command whatis variable_name gives us the type of the variable variable_name.

Selecting a source file: The command e source_file edits a particular source file.

Listing the source file: The command list lists the next ten lines of the source file currently selected. If we say list line_number, the next ten lines starting with the specified line number is shown.

Editing a source file: The command edit source_file allows the editing of source_file. It invokes the vi editor for editing the source file.




next up previous contents
Next: Debugging the core dumps: Up: No Title Previous: Execution Monitoring

Sushil Prasad
Fri Oct 9 10:28:36 EDT 1998