How to use Codeguard in BCB

Source: Internet
Author: User
Tags command line resource win32

One, why write this article?

I need to check a lot of things when I write some programs using BCB5. For example, memory leaks, resources are released and so on, in the use of a lot of tools, found BCB5 itself with the tools--codeguard, very good, very convenient to use, but groping for a long time (and the search for some information, including help) is considered to be used. The purpose of writing this article hope that there are problems in this area friends can draw on, we learn from each other and common progress. My contact method: email:szbug@szbug.com, I hope that friends of like-minded to exchange letters. The following article is a patchwork of articles, some of which are found in books and some on help. First of all, I declare my language and English proficiency is very limited, there is wrong or wrong translation of the place, also hope to point out. Special thanks to xx love to help me proofread ...

Second, what is Codeguard

Codeguard is a tool that appears in the C++builder5. Codeguard is an inspector in the runtime of a program in C++builder that checks the use of memory or resources and the validation of function calls.

Codeguard can detect the following program Run-time errors:

Illegal memory release.

Invalid handle or file stream.

Illegal pointers.

Use a pointer that has been freed.

Memory leaks.

The memory variable allocated but not released at the end.

Incorrect arguments passed to the function (including VCL and WIN32 functions).

Error returning value for function. (including VCL and WIN32 functions).

For example, in an application that attempts to free the same resource (or a resource that has been freed) multiple times, attempts to access the memory that has been freed.

Iii. How to use codeguard--configuration in BCB5 Codeguard

If you want to use Codeguard, some code must be compiled into your application, so after changing these settings. Must recompile all (remember!!! )。 First, open the application's Engineering Options codeguard page box, codeguard validation front tick.

There are three other options in the Project option. The first option allows Codeguard to check for invalid pointers and data overflows that point to local, global, and static variables. The second option allows Codeguard to detect calls to methods of illegal (invalid, deleted) objects. The third option allows Codeguard to verify the access of the embedded pointer (in some cases, opening this option will cause the program to execute slowly, and I have tested it, if the project is not very large, it is not obvious, acceptable.) The general debugging is to open all the options (the default selection is all opened).

With the Codeguard Configuration tool, you can configure some of the Codeguard options to perform CGCONFIG.EXE at the command line. You can see a dialog box.

The Preferences tab page is used to set the global options for the Codeguard tool. The Enable option can be used without recompiling the application or without using Codeguard, which is typically enabled. If you use Codeguard, it is recommended that you set up engineering options to prohibit or use Codeguard. The stack fill frequency padding stack frequency is the detection of invalid access to the runtime stack. The report and Error message box option is the way to set Codeguard reporting errors. In the paper, the Stiatistics option turns on the Statistics tab of the Codeguard output allocation and release memory, the call to use WIN32API, the usage of the resource, and adds a list of modules to the log file to check for errors. The Resource leaks option is to tell the Codeguard to report resource leaks after the end of the application. With the error message box option selected, when an application is not running in the IDE, if Codeguard detects an error, a dialog box is used to tell the user. Other options are generally not used, and you can see online Help for C++builder.

The resource Options and Function Options page boxes in the Codeguard Configuration tool allow users to set various tracking options for the application's resources, files, and functional calls. Unless you need to change the default configuration for a specific reason, use the default settings. A more common option on the function Options page is to record each invocation of a particular function.

The Ignored Modules page box allows you to tell Codeguard that you can ignore some run-time errors (usually referring to certain DLLs or packages) when testing. This option is generally not used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.