INFO: Troubleshooting CAP/WST Utilities Under Windows NTLast reviewed: March 4, 1998Article ID: Q169275 |
The information in this article applies to:
SUMMARYThis article provides a collection of tips, tricks, and traps to you can use to avoid and solve common problems that you may encounter while using the Call Attribute Profiler (CAP) and Working Set Tuner (WST) utilities for Windows NT. Note that these utilities are included with the Win32 Software Development Kit. You can use these powerful utilities to make your application run faster and use less RAM. This article assumes that you have read the preliminary information on the use of these tools that is available in the Win32 SDK Tools documentation. The information in this article applies to the versions of CAP/WST utilities that are shipped on the January 97 Win32 SDK or later.
MORE INFORMATION
Preparing Your ApplicationWe recommend that you build applications that you want to tune with CAP or WST with slightly different switches than the documentation suggests. For the compiler, use /Zi or /Z7 (don't forget /Gh). For the linker, use /debug /debugtype:both and /pdb:<name>.pdb or /pdb:none. We recommend using the C7- style symbols: /Z7 with the compiler and /pdb:none with the linker for best results. One benefit of using these switches is that you can do full symbolic debugging under the Visual C++ or Windbg debugger in case either the CAP or WST utility manages to flush out a problem in your code. This is more common than you may think, for example /Gh causes the compiler to insert a call to a function called _penter() in front of each and every function in your code. This global increase in code size causes your functions to load into slightly different offsets in memory, which may cause a pointer bug or array-overrun bug in your code to now show itself. By using these switches, you can debug your application normally when it is compiled for CAP/WST. TIP: We recommend that you do not use capsetup.exe to prepare your applications for tuning. Instead, building your applications with the proper switches works more reliably. TRAP: Running "capsetup -a" and then building your application for tuning causes the CAP utility to not work. Just avoid Capsetup.exe if you can.
Tuning/Profiling DLLs and OCXsTuning DLLs and OCXs is fairly straightforward for both CAP and WST, once you know the details, though the procedure is slightly different for each. WST: When an executable compiled for WST is initialized, WST gets control and looks at all the DLLs loaded in that process's memory space. Only DLLs that are present and built for WST are tuned, which means that the DLLs must be statically linked. Dynamically-loaded DLLs (and OCXs) are not tuned even though they may be compiled for tuning. TRICK: However, you can tune all DLLs/OCXs. The trick is to build only the DLL/OCX that you want to tune for tuning. Do not build the executable for tuning. Then do the following:
CAP: Fortunately, CAP supports dynamically loaded libraries without any special caveats. You just need to make sure that loadlibrary=on in the CAP.INI file. However, if you're not getting symbolic information for your DLLs, you can try something similar to the procedure for WST--except you must put the name of the .EXE in the [exes] section, unlike for WST.
Known Problems, LimitationsThe following is a list of known problems and limitations with the CAP and WST utilities. It's best to contact Microsoft Technical Support for help with any problems encountered with these utilities. A support engineer may be able to provide a workaround or help with critical problems.
CAP Memory Usage InformationCAP memory usage can be a factor in the performance of your application. If CAP's memory usage becomes too great (usually due to a lot of chronological data), this will result in a lot of swapping, which in turn can affect the performance of your application. CAP's memory usage can be divided into the following three groups (ordered from smallest to largest):
The calling tree structure is continuously built as the profiled application executes. Each node in this tree represents one caller-callee pair. For example, the first time function A calls function B, a new node is created. Each additional call from function A to function B changes the profiling values in node A-B, but does not increase the storage space. So the size of the calling tree is dependent on the number of caller-callee relations that are actually exercised by the application. Each node requires 80 bytes of memory. The calling tree information is dumped to the log file and provides the input for Capview.exe. It contains information such as the number of times function A called function B, the shortest/longest/average time function B executed when called by function A, and how much of function B's time was due to calls that it made itself. Chronological calling data is by far the largest user of CAP memory. Unlike the calling tree data, the chronological data contains a data cell for every function call that occurs. If function A calls function B 100 times, 100 cells are created. This allows for a very detailed log that shows the exact order that calls were made and how much time each call took. The size of the chronological data, then, depends on how many function calls are made by the application. Each data cell requires 40 bytes.
Preparing to Contact Technical SupportWhen CAP or WST fails, the most common symptoms are failure to produce any output or an exception while your application executes (usually during initialization). To determine if the failure is due to a problem in CAP.DLL or WST.DLL, you will have to debug your application. When you hit a 2nd- chance exception in the debugger (ignore all 1st-chance exceptions - they are normal and are handled by an exception handler in CAP/WST), look at the top of the call stack to see if the exception occurred in CAP or WST. To do this, use LINK -dump -headers on CAP.DLL or WST.DLL (or you can do a "quick view" in Windows Explorer on the DLL) and note the image base address and the "size of image" value. If the address where the exception occurred is within image base + size of image, then you have most likely encountered a bug in CAP.DLL or WST.DLL. Before contacting Microsoft Technical Support for help in diagnosing the problem, please debug your application and do the following (these instructions are for an x86 machine):
Windbg: On the Options menu, click Exceptions, set "Access Violation" (0xc0000005) to "Notify", and then click Change. Visual C debugger: On the Debug menu, click Exceptions and make sure that "access violation" is set to "stop if not handled".
REFERENCESWin32 SDK Tools documentation
|
Additional query words: debug tls base
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |