如何在代码中模拟Delphi断点?

发布于 2024-07-07 16:09:14 字数 328 浏览 7 评论 0原文

我很确定我以前见过这个,但我还没有找到/记得如何做到这一点。 我想要一行代码,当从 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 技术交流群。

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

发布评论

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

评论(2

蹲在坟头点根烟 2024-07-14 16:09:14

要从代码触发调试器(据说,我没有方便尝试的delphi副本):

asm int 3 end;

请参阅此页面:

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):

asm int 3 end;

See this page:

http://17slon.com/blogs/gabr/2008/03/debugging-with-lazy-breakpoints.html

晨曦÷微暖 2024-07-14 16:09:14

正如 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.

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