PRB: Excluding Libraries with the Visual C++ Profiler
ID: Q154764
|
The information in this article applies to:
-
The Microsoft Source Profiler
-
Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.1, 4.2, 5.0, 6.0
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.
- Notice that the output does not contain profiling information for
the TestFunction(). It worked!
- 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)
- Repeat step 5.
- Notice that the output does not contain profiling information for
Test.cpp. It worked!
- Repeat step 2.
- Notice that the output does contain profiling information for the
TestFunction(). The "exclude:Test.cpp(0-0)" statement didn't work
for function profiling!
- Include both of the above exclude statements and notice that it
works for all profiling methods!
Additional query words:
Keywords : kbusage kbVC400 kbVC410 kbVC420 kbVC500 kbVC600 TlsMisc
Version :
Platform : NT WINDOWS
Issue type : kbprb
|