Debugging a Program With dbx

Suppressing Errors

RTC provides a powerful error suppression facility that allows great flexibility in limiting the number and types of errors reported. If an error occurs that you have suppressed, then no report is given, and the program continues as if no error had occurred.

Error suppression is done using the suppress command. Suppression can be undone using the unsuppress command. Suppression is persistent across run commands within the same debug session, but not across debug commands.

The following kinds of suppression are available:

In the following examples, main.cc is a file name, foo and bar are functions and a.out is the name of an executable.


suppress mel in foo

Do not report memory leaks whose allocation occurs in function foo:

Suppress reporting blocks in use allocated from libc.so.1

 suppress biu in libc.so.1

:

 suppress rui in a.out

Suppress read from uninitialized in a.out:

 suppress rua in main.cc

Do not report read from unallocated in file main.cc:


suppress duf at main.cc:10

Suppress duplicate free at line 10 of main.cc:

Suppress reporting of all errors in function


suppress all in bar

bar:

Default Suppressions

To detect all errors RTC does not require the program be compiled using the -g option (symbolic). However, symbolic information is sometimes needed to guarantee the correctness of certain errors, mostly rui. For this reason certain errors, rui for a.out and rui, aib, and air for shared libraries, are suppressed by default if no symbolic information is available. This behavior can be changed by using the -d option of the suppress and unsuppress commands.

The following command causes RTC to no longer suppress read from uninitialized memory (rui) in code that does not have symbolic information (compiled without -g):


unsuppress -d rui

Using Suppression to Manage Errors

For the initial run on a large program, the number of errors may be so large as to be overwhelming. In this case, it may be better to take a phased approach. This can be done using the suppress command to reduce the reported errors to a manageable number, fixing just those errors, and repeating the cycle; suppressing fewer and fewer errors with each iteration.

For example, you could focus on a few error types at one time. The most common error types typically encountered are rui, rua, and wua, usually in that order. rui errors are less serious errors (although they can cause more serious errors to happen later), and often a program may still work correctly with these errors. rua and wua errors are more serious because they are accesses to or from invalid memory addresses, and always indicate a coding error of some sort.

You could start by suppressing rui and rua errors. After fixing all the wua errors that occur, run the program again, this time suppressing only rui errors. After fixing all the rua errors that occur, run the program again, this time with no errors suppressed. Fix all the rui errors. Lastly, run the program a final time to ensure there are no errors left.

If you want to suppress the last reported error, use suppress -last. You also can limit the number of errors reported without using the suppress command by using dbxenv variable rtc_error_limit n instead.