Reputation: 36838
I would like Visual Studio debugger to break within a function only when the call is from a specific sequence of callers. Is there a way to set such a breakpoint? Or perhaps some alternative hack?
I ask this in the context of native (C++) as well as managed (C#) code.
Upvotes: 0
Views: 125
Reputation: 12499
I think you could set a conditional breakpoint that utilizes the System.Diagnostics.StackTrace class.
EDIT: GrayWizardx has pointed out in a comment that this may not be possible. In that case you could cause your code to break programmatically:
#if DEBUG
// Use StackTrace class in this conditional to determine whether or not to break:
if (yourConditionIsTrue)
{
System.Diagnostics.Debugger.Break();
}
#endif
Upvotes: 4