执行路径特定断点

发布于 2024-08-15 14:41:06 字数 119 浏览 5 评论 0原文

我希望 Visual Studio 调试器仅在调用来自特定的调用者序列时才在函数中中断。有没有办法设置这样的断点?或者也许是一些替代黑客?

我在本机 (C++) 和托管 (C#) 代码的上下文中提出这个问题。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初雪 2024-08-22 14:41:06

我认为您可以设置一个利用 条件断点 ="http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace%28VS.80%29.aspx" rel="nofollow noreferrer">System.Diagnostics.StackTrace 类。

编辑:GrayWizardx 在评论中指出这可能是不可能的。在这种情况下,您可能会导致代码以编程方式中断:

#if DEBUG
    // Use StackTrace class in this conditional to determine whether or not to break:
    if (yourConditionIsTrue)
    {
        System.Diagnostics.Debugger.Break();
    }
#endif

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文