When Calling a Function Hundreds of Times, How Do I know Which Call Failed?
This topic applies to:
Edition |
Visual Basic |
C# |
C++ |
Web Developer |
---|---|---|---|---|
Express |
Native only |
|||
Standard |
Native only |
|||
Pro and Team |
Native only |
Table legend:
Applies |
|
Does not apply |
|
Command or commands hidden by default. |
Problem Description
My program fails on a call to a certain function, CnvtV. The program probably calls that function a couple hundred times before it fails. If I set a location breakpoint on CnvtV, the program stops on every call to that function, and I do not want that. I do not know what conditions cause the call to fail, so I cannot set a conditional breakpoint. What can I do?
Solution
You can set a breakpoint on the function with the Hit Count field to a value so high that it will never be reached. In this case, because you believe the function CnvtV is called a couple hundred times, you might set Hit Count to 1000 or more. Then run the program and wait for the call to fail. When it does, open the Breakpoints window and look at the list of breakpoints. The breakpoint you set on CnvtV appears, followed by the hit count and number of iterations remaining:
CnvtV(int) (no condition) when hit count is equal to 1000 (currently 101)
You now know that the function failed on the 101st call. If you reset the breakpoint with a hit count of 101 and run the program again, the program stops at the call to CnvtV that caused it to fail.