Microsoft KB Archive/154764

= PRB: Excluding Libraries with the Visual C++ Profiler =

Article ID: 154764

Article Last Modified on 11/18/2003

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q154764



SYMPTOMS
The documentation on "Selective Profiling" in the Visual C++ User's Guide, under the chapter "Profiling Code" says:

... The [profiler] section of TOOLS.INI specifies libraries and object (.OBJ) files for the profiler to ignore. By default, TOOLS.INI excludes the Win32 libraries, Microsoft Foundation Class (MFC) libraries, and C run-time libraries...

If you exclude a library and profile for line coverage from the IDE, the profiler does not exclude profiling information related to the source files corresponding to the library. However, when you profile for function timing or function coverage, it does exclude profiling information related to the functions defined in that library.

Similarly, if you exclude a source file and profile for function timing or function coverage, the profiler does not exclude profiling information related to the functions defined in that source file. However, when you profile for line coverage, it does exclude profiling information for that source file.

See the More Information section below for an example.



RESOLUTION
Exclude the library for function timing and function coverage, and exclude the source file for line coverage.

You can exclude both the library and source files so that it will work for all profiling methods. You may get the following warning in this case, but you can safely ignore it.

PREP : warning PRF4106: function/source/object/lib test.cpp was never matched



MORE INFORMATION
Follow these steps to see the behavior:   Create a new project of type static library with a Test.cpp file containing the following code and build a Test.lib file. void TestFunction { int j = 0;

for (int i = 0; i < 100; i++) j = i; }   Create another project of type console application with a Main.cpp file containing the following code: void TestFunction;

void main { TestFunction; }                        Include Test.lib into this project and build Test.exe. Make sure you have the "Enable profiling" option checked in the Project Settings, Link tab.  Insert the following statement under the [profiler] section of TOOLS.INI file and make sure the INIT environment variable is pointing to the directory containing TOOLS.INI. exclude:Test.lib  Run the profiler by clicking the Tools, Profile menu and clicking Line coverage.

Notice the output in the Profile window. It does contain profiling information for Test.cpp. The "exclude:Test.lib" statement didn't work for line coverage! Now, do the following:  Run the profiler and select Function timing or Function coverage.</li> Notice that the output does not contain profiling information for the TestFunction. It worked!</li>  Remove the "exclude:Test.lib" line that you inserted into TOOLS.INI in step 4 above, and add the following line: exclude:Test.cpp(0-0) </li> Repeat step 5.</li> Notice that the output does not contain profiling information for Test.cpp. It worked!</li> Repeat step 2.</li> Notice that the output does contain profiling information for the TestFunction. The "exclude:Test.cpp(0-0)" statement didn't work for function profiling!</li> Include both of the above exclude statements and notice that it works for all profiling methods!</li></ol>

Keywords: kbprb kbusage KB154764

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.