When building with Insure++, the source code is instrumented and mutation testing is performed. Insure++ then compiles and links the instrumented code with your native compiler. Test results are reported in the Insra interface, which differs depending on whether you are using Insure++ on Windows (see Viewing Results) or a Unix-based system (see Viewing Results).
Insure++ is also able to report code coverage data with or without performing runtime error detection. The interface for viewing code coverage differs depending on whether you are on Windows (see Code Coverage) or a Unix-based system (see Code Coverage).
Recompile your program with Insure++ instead of your normal compiler and run the program under Insure++. The Insra component will report errors and include details that help you track down and correct problems.
Instrumenting and building your project with Insure++ provides thorough error detection. When you run non-instrumented code under Insure++, however, Insure++ is still able to perform less-thorough error detection on that code. For the most thorough checking possible, compile and link source code with Insure++. You can then run the program as normal. For example commands, see Example Compilation and Linking Commands.
When you do not have the time to build and run an instrumented application, re-link your code with Insure++ and run the program as normal. This provides a basic level of checking for heap corruption, errors in calls to common C functions, and memory leaks. For example commands, see see Example Compilation and Linking Commands.
Compiling with Insure++ creates a version of your code that includes calls to the Insure++ library. The instrumented code is passed to your normal compiler. During the compilation an execution, Insure++ detects and reports various programming errors. See Errors Detected for an exhaustive description of the types of errors detected. For each error reported, you will see the source line that appears to be incorrect and an explanation of what type of error occurred. Normally, Insure++ sends its output to stderr
, but it can send its output to Insra, a graphical tool for viewing error messages. For more information, see Viewing Results.
Command Line
On Windows, run your compilation and link commands as you normally would but replace your compiler command with the insure
command:
insure <OPTIONS> <INPUT_FILE>
On Windows systems, the the compiler is always cl
(Microsoft's compiler), so there is no need to include cl
as part of the command.
For example, the following command could be used to compile the the hello.c example into hello.obj:
cl /c /Zi /EHsc hello.c
To compile with Insure++, replace the compiler command with insure
:
insure /c /Zi /EHsc hello.c
Similarly, you can link .obj files into an .exe file by replacing link
command with inslink
:
inslink /debug hello.exe
On Unix systems, the simplest way to compile and link source code with Insure++ is to prepend your normal compile and link command lines with the insure
command. The following table shows some examples for Unix systems:
Without Insure++ | With Insure++ |
---|---|
gcc -c foo.c | insure gcc -c foo.c |
g++ -c bar.cc | insure g++ -c bar.cc |
/usr/local/gcc-3.4.0/bin/g++ -g bar.cc -o bar | insure /usr/local/gcc-3.4.0/bin/g++ -g bar.cc -o bar |
You can use the same options that you normally use to compile and link your program. For example, you would use the following command to to build bubble1.c
:
insure cc -g -o bubble1 bubble1.c
If you have a makefile that uses the variable CC to define the compiler name, you can build your program with Insure++ by using the command make CC=’insure cc’
.
Insure Command Line Options
If necessary, you can use the following options with Insure++:
Option | Description |
---|---|
-Zcov | Compiles and links for code coverage. No error checking is performed. |
-Zoi <OPTION> | Runs Insure++ with a specific option. Refer to the Configuration Options (psrc) section for available options. |
-Zop <FILE> | Runs Insure++ with a specific .psrc file. Refer to the Configuration Options (psrc) section for additional information about .psrc files. |
-Zsl | Runs Insure++ in safe link mode, which may be necessary on some platforms. Insure++ will print a message to the console indicating when safe link mode is necessary. |