在调试发布模式二进制文件时,如何在 PostMessage/PostThreadMessage 中的函数处中断?
我的应用程序启动后立即退出。这种情况仅发生在发布模式构建上。我已经符号化了我的发布模式二进制文件。我怀疑某些辅助线程正在将 WM_QUIT 发布到我们的队列中。我正在尝试使用条件 Msg == 0x0012 ( WM_QUIT ) 在 Function PostThreadMessage 处中断。这个打不着啊为了确定,我在 PostMessage 和 SendMessage 中使用了 Break at 函数。没有运气。如果我在这里遗漏了什么,有人可以指出吗?对于 WIN32 API 的发布模式二进制文件,如何启用 Break at 函数?
真挚地, 萨勃拉曼尼亚
My application quits immediately on launching. This happens only on Release mode build. I have symbolized my release mode binary. I am suspecting that some secondary thread is posting WM_QUIT to our queue. I am trying to Break at Function PostThreadMessage with conditional Msg == 0x0012 ( WM_QUIT ). This wont hit. Just to ascertain, I used break at function in PostMessage and SendMessage. No Luck. Can someone please point out if i am missing something here? How do I enable Break at function in case of release mode binaries for WIN32 APIs?
Sincerely,
Subramanian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
DebugBreak
API 设置断点,这会导致程序崩溃。现在点击“调试”(根据您的操作系统而定)。它将带您到 DebugBreak 位置。还可以从 IDE 中调试发布版本。但是您的代码存在一些逻辑问题,而不仅仅是断点。
To set breakpoint use
DebugBreak
API, which would cause the program to crash. Now hit 'Debug' (as appropriate to your OS). It will take you toDebugBreak
location. It is also possible to debug a release build from withing IDE.But there is some logical problem with your code than just breakpoint.
这种情况通常是由于 switch/case 中缺少
break
导致代码落入 WM_QUIT 处理程序而发生的。解决此问题的第一步是将代码添加到输出 uMsg 的 WM_QUIT 处理程序中。这将告诉您 WM_QUIT 是否确实已发送,或者是否只是代码失败。可以在发布二进制文件中设置断点,但源代码不会以良好的方式与实际二进制文件相对应,因此单步调试和其他调试功能变得不太有用。
在设置断点方面,请将其设置为
{,,user32.dll}_SendMessageA@16
或{,,user32.dll}_SendMessageW@16
,具体取决于您是否是否使用 Unicode。然而这对你来说可能不是很有用。This often happens with a missing
break
in your switch/case leading to code falling through to the WM_QUIT handler. The first step I'd take to fix this is to add code to your WM_QUIT handler which outputs the uMsg. This will tell you whether WM_QUIT has really been sent or whether it's just code falling through.It is possible to breakpoint in Release binaries but the source will not correspond in a nice way to the actual binary so stepping and other debugging features become much less useful.
In terms of setting your breakpoint, set it at
{,,user32.dll}_SendMessageA@16
or{,,user32.dll}_SendMessageW@16
depending if you're using Unicode or not. However likely this will not be very useful to you.