How do I set a Data Breakpoint in mixed( C#/C++ ) debugging?

前端 未结 4 2001
醉话见心
醉话见心 2021-02-04 01:04

I launch my program in C#, which then calls some unmanaged C++.

When I break on a line in the unmanaged C++, the \'New Data Breakpoint\' menu item is grayed out.

<
相关标签:
4条回答
  • 2021-02-04 01:44

    A very useful trick which works everywhere is to call breakpoints from code in special conditions:

    If (Condition)
        System.Diagnostics.Debugger.Break()
    
    0 讨论(0)
  • 2021-02-04 01:51

    The suggested solution doesn't work all the time. Even when debugging in Native mode, with the program broken in Native piece of code, when trying to set a 'New Data Breakpoint' I get a popup "The breakpoint cannot be set. Data breakpoints are not supported in the Common Language Runtime"

    The alternative is to add data breakpoints from code directly. See the article here.

    This works well in mixed-mode, it only requires Native debugging mode to be active (as suggested above)

    0 讨论(0)
  • 2021-02-04 01:53

    So to do this I had to:

    • set the unmanaged dll as the startup project
    • set the managed program as the startup command
    • set debug mode as Native
    • "break execution" or hit a breakpoint so that you are in the "debugging" state

    yech

    0 讨论(0)
  • 2021-02-04 02:10

    To set a data breakpoint in the native portion of a mixed mode process, see the answer posted by jyoung.

    Visual Studio disables data breakpoints when running anything but pure, native code. See this post for a partial explanation why from a VS Program Manager.

    0 讨论(0)
提交回复
热议问题