INFO: Using the Call-Attributed Profiler (CAP)

ID: 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. To find out which DLLs your application uses, run the Apf32cvt.exe utility provided with the Win32 SDK. The syntax to use is as follows:
    apf32cvt <application>

    This will list the DLLs to which your program is linked.


  2. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
    Q148659 How to Setup Windows NT Debug Symbols
  3. 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.




  4. 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.


  5. 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
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: February 2, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.