c++ 中没有断点的中断进程
在 Visual Studio 2008 MFC 应用程序中,当我按下按钮时,有没有办法在没有断点的情况下停止调试?问题是,这是一个相当大的共享项目,所以我的代码被另一个“模块”调用,但我不知道调用了我的哪些函数,所以我不知道在哪里放置断点。我的目标是在调用我的任何函数时打破该过程。
In Visual Studio 2008 MFC application is there a way to stop the debugging without a breakpoint, when I press a button? The problem is, it's a pretty big and shared project, so my code is called by another "module", but I don't know which of my functions are called, so I don't know where to put a breakpoint. My goal would be to break the process, if any of my functions are called.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 DebugBreak()功能。
You can use the DebugBreak() function.
您可以编写一个 Visual Studio 宏,在源代码的每一行上放置一个断点。您可以让它更聪明一点,只在每个函数启动时放置断点,但这需要一些解析。将该宏绑定到一个键。运行 MFC 应用程序,当您想要开始中断您自己的代码时,切换到 Visual Studio,按下该键,然后很快,您将在第一次使用代码时中断。
另一种选择是创建一个 C++ 宏来检查全局布尔值是否已设置,并在设置时执行 asm { int 3 }。在代码的每个(高级)函数的开头使用此宏。添加在 MFC 应用程序中按下某个按钮时设置全局布尔值的代码。这仅适用于 32 位可执行文件,您需要 64 位可执行文件中的一些内在函数,但我不知道。
希望这有帮助。
干杯,
塞巴斯蒂安
You could write a Visual Studio macro that puts a breakpoint on every line in your source code. You could make it a bit smarter and only put breakpoints on each function start, but that would require some parsing. Bind that macro to a key. Run the MFC application and when you want to start breaking on your own code, switch to Visual Studio, press the key and presto, you will break on the first use of your code.
The other option is to make a C++ macro that checks if a global boolean has been set and executes asm { int 3 } when it has. Use this macro at the start of every (high level) function of your code. Add code that sets the global boolean when a certain button is pressed in the MFC application. This will only work in a 32-bit executable, you'll need some intrinsic in a 64-bit executable, which I don't know by head.
Hope this helps.
Cheers,
Sebastiaan
有一个“暂停”按钮可以中断执行...或者您可以在所有可能的嫌疑点上设置断点。您不知道调用了哪个函数 - 对所有函数都进行中断。然后你就会实现你的目标。
There's a "Pause" button that breaks the execution... Or you can put a breakpoint on all the possible suspects. You don't know which of your functions is called - put a break on all of them. Then you'll achieve your goal.