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:
Suppression by scope and type
You must specify which type of error to suppress. You can specify which parts of the program to suppress. The options are:
Global |
The default; applies to the whole program |
Load Object |
Applies to an entire load object, such as a shared library |
File |
Applies to all functions in a particular file |
Function |
Applies to a particular function |
Line |
Applies to a particular source line |
Address |
Applies to a particular instruction at an address |
Suppression of last error
By default, RTC suppresses the most recent error to prevent repeated reports of the same error. The is controlled by the dbxenv variable rtc_auto_suppress.
Others
You can use the dbxenv variable rtc_error_limit to limit the number of errors that will be reported.
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
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 reporting of all errors in function
suppress all in bar
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
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.