Directory
One, BoundsChecker Introduction
Second, Installation Environment
Third, two working modes of BoundsChecker
3.1 Activecheck
3.2 Finalcheck
Four, Features and Benefits
Five, Detection Samples
5.1 Memory Leak Detection sample
5.2 Wild Pointer Detection sample
5.3 Array out of bounds detection example
5.4 GDI Resource leak Detection sample
5.5 Handle Resource leak detection sample
5.6 Deadlock Detection Sample
5.7 MS c-runtime Library Built-in detection function example
Six, Configuration
6.1 Suppression
6.2 Filter
6.3 Setting
6.4 Code Control
6.5 Setting the application association bounds Checker
Seven, Attention Matters
Eight, Summary
First, BoundsChecker Brief Introduction
BoundsChecker is a run-time error detection tool that primarily locates various errors that occur during the run-time of a program. It accelerates application development by automating debugging handlers that reside within the Visual C + + development environment, shortening the time for product release. BoundsChecker for programming errors, most of which are specific to C + + provide a clear and detailed analysis. It can detect and diagnose errors in the static, stack memory, and memory and resource leaks. In run state, BoundsChecker validates over 8700APIs and OLE methods, including the latest Windows APIS,ODBC, Activex,directx, COM, and Internet APIs.
BoundsChecker uses a technique called Code injection to intercept calls to functions that allocate memory and release memory. Simply put, when your program starts running, the BoundsChecker DLL is automatically loaded into the process's address space, and then it modifies the process's function calls to memory allocation and release, allowing those calls to go first to its code and then to the original code. BoundsChecker does not need to modify the source code or the project configuration file of the debugger when doing these actions, which makes it very simple and straightforward to use.
Programmers may encounter this problem frequently during the development process: debugging, there is no problem with the syntax, the code is not wrong, but the application run is abnormal or even panic, in fact, this may be due to logic errors caused by memory overflow or resource leakage problems, these errors are generally not easy to detect. This type of error is one of the BoundsChecker error detection scopes.
Through the operation of the application under test, BoundsChecker provides clear, detailed error analysis, automatic identification of static stack errors and memory/resource leaks, and the ability to quickly locate faulty source code, even in the absence of source code, to check for Third-party component errors.
BoundsChecker can detect errors including:
1 pointer operation and memory, resource leakage error.
For example: memory leaks, resource leaks, and error actions on pointer variables.
2 Error in memory operation.
For example: memory read, write overflow, use of uninitialized memory.
3 API function Usage error.
Second, the installation environment
BoundsChecker 7.2 supports language and host platforms including C + +, Delphi
Windows NT, windows95/98/2000
Supports Visual C + + 6.0 sp6,visual studio. NET 2002,visual Studio. NET 2003.
Installation Instructions:
1. First make sure you have uninstalled the old version of the program.
2. Run the files in the Setup directory to install.
3. Start the installer and use the Bc72.dat file registration program in the Setup/crack directory.
4. Completion is 0K.
5. There are two ways to debug
A. Direct Start BC.exe
B. Integrated in VC, start the debug of VC
The interface for BoundsChecker integrated in 6.0 menu items and toolbars is as follows:
figure (1) menu item
Figure (2) tool bar
Third, BoundsChecker two modes of operation
Using BoundsChecker to detect Run-time errors for a program, there are two modes of use to choose from. A pattern is called activecheck, and a pattern is called Finalcheck. The following are described separately.
3.1 Activecheck
Activecheck is a convenient and fast error detection mode provided by BoundsChecker, which can detect a limited range of errors, including memory leaks, resource leaks, and API function usage errors. To use the Activecheck mode to detect run-time errors of a program, simply open the BoundsChecker feature in the VC + + integrated development environment and run the program from the debug state. At this point the Activecheck will run automatically in the background to detect if an error has occurred in the program at any time. Here are some specific steps to use.
First of all, in the VC + + integrated development environment to open the program you want to test it, while ensuring that the project is in debug compile state.
Second, ensure that the [Boundschecker/error Detection] menu items and [boundschecker/log Events] Menus are in the selected state in the VC + + integrated development environment. Only if these two items are selected, BoundsChecker will play a role in the process of running the program. Finally, in the VC + + integrated development environment SELECT [Build/start debug/go] menu command, in the Debug state run the program, Activecheck also started running in the background.
3.2 Finalcheck
Finalcheck has all the error-checking features provided by BoundsChecker. Finalcheck is a superset of activecheck that, in addition to detecting errors that Activecheck can detect, can also detect many Activecheck errors that cannot be detected, including: pointer manipulation errors, memory operation overruns, use of uninitialized memory, and so on. And, for Activecheck can detect errors, Finalcheck can give more detailed information about the error. So, we can think of Finalcheck as a Activecheck feature enhanced version. The price we pay is that the program slows down and sometimes even slows down. To test the program in Finalcheck mode, you cannot use the compiler connector provided by the VC + + integrated development environment to construct the program, and you must compile the linker using the compiler connector provided by BoundsChecker. When the BoundsChecker compilation connector compiles the linker, it inserts some error detection code into the program, which is why Finalcheck can find more errors than Activecheck. Here's how to test your program in Finalcheck mode:
(1) in the VC + + integrated development environment to open the project you want to test.
(2) because you want to recompile the linker with the BoundsChecker compiler connector, we construct a folder for BoundsChecker alone. In VC + + integrated development environment, the concrete operation method is:
A) Click [Build/configurations ...] menu commands.
(B) Click the ad button in the pop-up dialog box. Add the name of the folder you created for BoundsChecker in the configuration edit box, which is arbitrary, such as we named Boundchecker.
(C) Select the Xxx-win32 debug item in the Copy settings from combo box, click the OK button, and then click the Close button. Now, we've constructed a folder for Finalcheck.
(3) Click [Build/set Active Configuration ...] menu command, select the folder you just built for BoundsChecker, and then click the OK button. This boundschecker the intermediate files and executable programs that are generated when the connection program is compiled, and is placed under that folder.
(4) Select the [Boundschecker/rebuild all with BoundsChecker] menu command to compile the connection again, in which case BoundsChecker adds the error detection code to the program being tested. When the compilation connection is complete, BoundsChecker builds the executable file in the folder you constructed for BoundsChecker. In Finalcheck mode, the preparation for testing the program has been done, you can start the program to start testing, the steps and in the Activechecker mode is no different. The specific steps are as follows:
Ensure that the [Boundschecker/error Detection] menu items and [boundschecker/log Events] Menus are selected in the VC + + integrated development environment, and are set outside [boundschecker/setting] The Enable Finalcheckt in the Memory tracking option is selected.
Click the [Build/start Debug] Menu and select the Go menu item. The program starts running in debug state. Follow the test cases you have set up to operate the program.
When BoundsChecker detects an error, it pops up a window to report to you, you can do it at that time, or you can wait until your operation is complete, exit the program, and then analyze the errors listed. It all depends on whether you have selected the [Boundschecker/display Error and Pause] menu item.
After exiting the program, BoundsChecker will give a list of error detection results. The error list is exactly the same as the list of errors given by Activechecker. Only the information reported in this list will be more and more detailed.
Activechecker, Finalcheck These two models, compared to each have the length. Activechecker easy to use, just run the program directly in the debug state, and the program runs faster, but the type of error detected is limited; Finalcheck mode, You need to recompile the connection to build the executable using the BoundsChecker compiler connector, and the program runs slowly, but the type of error is detected, and the error information provided is greater than activechecker. Therefore, when to use the model should be based on the specific circumstances at that time.
Iv. characteristics and Advantages
1. Resource Leak Detection: BoundsChecker can automatically locate the memory leaks that are difficult to discover, and monitor the stack and static memory status. This saves you time and enables you to develop more reliable, less problematic applications.
2.Active API Check: This feature will reduce your debugging time and provide the most comprehensive Windows API checksum in the industry. This results in higher-quality code that will not fail when the program is released.
3.IDE Integration: BoundsChecker lets you debug transparently. It provides menus, toolbars, and settings for direct access to BoundsChecker in C + +, allowing developers to fix errors immediately.
4. Compatibility check: BoundsChecker allows you to easily build and publish applications across the Microsoft platform. BoundsChecker a multiple-platform Colonel Code, and then produces a report that identifies all issues related to Windows platform compatibility.
Program Features:
1. Local Application deadlock Checking
2. Memory and Resource Viewer
3.COM Call Report
4.NET Call Report
5. Garbage collection (garbage collection) notice
BoundsChecker error detection range mainly includes:
1). Pointers and leak errors
Interface leaks
Memory leaks
Resource leaks
Unassigned Pointer Error
2). Memory error
Dynamic storage Overflow
Invalid handle locked
Handle is not locked
Memory allocation conflict
Stack space Overflow
Static storage Overflow
3). APIs and OLE errors
API function return failed
API function not executed
Invalid variable (including pointer variable, string variable, etc.)
Invalid variable for OLE interface method
Ole interface method failed
Thread Calling library function error
V. Testing Samples
5.1 Memory leak Detection sample
Code Snippets
Class TempClass.cpp;
Tempclass::tempclass ()
{
cout<< "Construct Object Tempclass" <<endl;
}
void Tempclass::P rint ()
{
cout<< "Tempclass.print ()" <<endl;
}
#include "stdafx.h"
#include "ostream. H
#include "TempClass.h"
int main (int argc, char* argv[])
{
printf ("-----boundschecker use case-----------!/n");
tempclass* mytemppoint = new Tempclass ();
Delete Mytemppoint;
Mytemppoint = NULL;
/*
if (NULL = = Mytemppoint)
{
cout<< "For Empty" <<endl;
}
Else
{
Mytemppoint->print ();
}*/
return 0;
}
figure (3) test Results window
Double click on the tab below to enter the memory leaks
figure (4) Memory leaks window
figure (5) More information of Memory leak
figure (6) Source Code window
The results show that there is a memory leak when the program exits with the 11 lines of the main function in the file BoundChecker.cpp Mytemppoint have been allocated between the two.
5.2 Wild pointer Detection sample
#include "stdafx.h"
#include "ostream. H
#include "TempClass.h"
int main (int argc, char* argv[])
{
printf ("-----boundschecker use case-----------!/n");
tempclass* mytemppoint = new Tempclass ();
Delete Mytemppoint;
Mytemppoint = NULL;
if (NULL = = Mytemppoint)
{
cout<< "For Empty" <<endl;
}
Else
{
Mytemppoint->print ();
}
return 0;
}
figure (7) The results of debug in Activecheck mode
You can't check the swing pointer in Activecheck mode.
Finalcheck Detection:
figure (8) Setting the Enable Finalcheck option
Figure (9) Comparison of files in the debug directory after switching mode
figure (a) the results of debug in Finalcheck mode
The result shows that the object of the pointer has been released when the main function is mytemppoint as a wild pointer.
5.3 array bounds detection sample
int iartemp[8];
for (int i = 0; I <= 8; i++)
{
Iartemp[i] = i;
}
cout<< "Print array data" <<endl;
for (i = 0; I <= 8; i++)
{
cout<<iartemp[i]<<endl;
}
return 0;
Here you select the Display error and Pause option, so in the debug process, the error message is immediately popped out, as shown in the following figure.
figure (one) error message that pops up when debug
the error message that pops up when you debug the diagram
Explain: Get help.
Memory/resource Viewer: View memory and resource allocations.
Suppress: Terminates a certain type of error.
Debug: Switch to the Debug window.
Halt: Interrupted.
Continue: Continue to detect
Don T Show this error: You can mask a type of error. (dropdown box to select criteria)
Disable Event Logg: Whether to write events to the test results.
figure (13) test results
results of the errors option
The results show that in the main () function, the local variable iaritemp the error of reading and writing out of bounds, and it is necessary to select the Finalcheck mode in Activecheck mode to check that the array is out of bounds.
5.4 GDI Resource Leak Detection sample
void Cgdicheckerdlg::onpaint ()
{
CPAINTDC DC (this); Device context for painting
CDC PDC;
Pdc.createcompatibledc (&DC);
CRect RC;
GetClientRect (RC);
cbitmap* poldbmp = NULL;
M_imgbk.loadbitmap (idb_test_bmp);
Poldbmp = Pdc.selectobject (&M_IMGBK);
dc. BitBlt (RC.LEFT,RC.TOP,RC. Width (), RC. Height (), &pdc,0,0,srccopy);
//