Microsoft KB Archive/118890

From BetaArchive Wiki

INFO: Using the Call-Attributed Profiler (CAP)

Q118890



The information in this article applies to:


  • Microsoft Win32 Software Development Kit (SDK)





SUMMARY

The call-attributed profiler (CAP) allows you to profile function calls within an application.



MORE INFORMATION

To profile an application using CAP, perform the following steps:

  1. Install the Windows NT debug symbols for the system DLLs that your application uses.
  2. Recompile your application using the following switches:

    Compiler: /Zi /Gh
    
    Linker: cap.lib /debug /debugtype:coff /pdb:"<target directory>/<app>.pdb" 

    To set the C/C++ compiler options:

    1. From the Project menu, select Settings, then click C/C++.
    2. Click General in the Category box and select Program Database from the Debug info pull-down list. This sets the /Zi switch.
    3. Manually add the /Gh switch to the Project Options edit box. This switch causes the compiler to add a call to __penter at the start of every method or function. Click OK.

    To set the C/C++ linker options:

    1. From the Project menu, select Settings, and then click Link.
    2. Click General in the Category box and add Cap.lib to the Object/library modules edit box. This implements __penter using Cap.dll.
    3. Click Debug in the Category box, then select Debug info and select COFF format.
    4. Click Customize in the Category box, then select Use program database. Enter the name of the .pdb file to use in the Program database name edit box.
  3. Place a Cap.ini file in either the root directory of the drive, the application directory, the WINDOWS directory, or the root of the C drive. The Cap.ini file specifies the applications for which the profiler will gather information. At minimum, Cap.ini must contain the following:

    [EXES]
    <app>.exe
    [PATCH IMPORTS]
    <app>.exe
    [PATCH CALLERS] 

    where <app> is the application to be profiled. The Cap.ini file included in the <SDK install directory>\Bin\WinNT directory provides an excellent example.

  4. Run the application. The profiling information is gathered and stored in a file with the same base name as the application and a .end extension. This information is in an ASCII format and can be viewed by any text editor. You can also use Capview.exe to produce a graphical representation of the information.

A common problem is for the profiling output to have an address in place of the function names from your application. For example:

1   <app>.exe:0x0040105a     1        4717        4717 

This occurs if you use the wrong linker options. See item 2 above.

Another common problem is to have missing module and function names. For example:

1  ???:0x0040105a        1        1577        1577 

This happens when your application or system component does not contain debug information.

Additional query words:

Keywords : kbPerformanceTool kbSDKWin32 kbDSupport kbGrpDSTools
Issue type : kbinfo
Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch


Last Reviewed: April 21, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.