如何在代码中模拟Delphi断点?
我很确定我以前见过这个,但我还没有找到/记得如何做到这一点。 我想要一行代码,当从 Delphi 调试器执行时,我希望调试器弹出,就像该行上有一个断点一样。
比如:
FooBar := Foo(Bar);
SimulateBreakPoint; // Cause break point to occur in Delphi IDE if attached
WriteLn('Value: ' + FooBar);
希望这是有道理的。 我知道我可以使用异常,但这会比我想要的要多得多的开销。 这是一些演示代码。
提前致谢!
I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line.
Something like:
FooBar := Foo(Bar);
SimulateBreakPoint; // Cause break point to occur in Delphi IDE if attached
WriteLn('Value: ' + FooBar);
Hopefully that makes sense. I know I could use an exception, but that would be a lot more overhead then I want. It is for some demonstration code.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要从代码触发调试器(据说,我没有方便尝试的delphi副本):
请参阅此页面:
http://17slon.com/blogs/gabr/2008/03/debugging-with-lazy-breakpoints.html
To trigger the debugger from code (supposedly, I don't have a copy of delphi handy to try):
See this page:
http://17slon.com/blogs/gabr/2008/03/debugging-with-lazy-breakpoints.html
正如 Andreas Hausladen 在那篇文章的评论中所述,Win32 API DebugBreak() 函数不太像 DOS,但工作得同样好。
As Andreas Hausladen stated in comments to that artice, Win32 API DebugBreak() function is less DOS-ish and works equally well.