在Delphi中:如何在调试时跳过代码段? [英] In Delphi: How to skip sections of code while debugging?

查看:270
本文介绍了在Delphi中:如何在调试时跳过代码段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



让我们开始说,我知道你可以用F8的步骤来解决我在Delphi中调试时不感兴趣的代码,并且您可以使用f4运行到某一行。



示例:

  function TMyClass.DoStuff():Integer; 
begin
//做一些东西
bla();
结束

程序TMyClass.Foo()
begin
如果DoStuff()= 0,则//输入此行时按F7
beep;
结束

示例:我想通过按F7进入DoStuff()方法,而不是去那里,我首先结束了FastMM4.FastGetMem(),这是一个大量的汇编代码,显然我现在不感兴趣。



有几种方法要做到这一点,我不喜欢任何一个:




  • bla (几乎没用,如果你只想在特殊场合进入DoStuff,像迭代23498938);


  • 而不是按F7,手动移动光标到 bla ,然后按F4(作为这个简单的例子),实际上没有);


  • 如果是FastMM,请暂时禁用fastmm;




是否有任何方法提示IDE,我永远不会有兴趣进入某个代码块,或者我总是要设置额外的断点或使用F4来尝试避免这个?



我希望像{$ NODEBUG BEGIN / END}之类的一些魔术编译器指令,或者类似的东西。


$ b $在大多数情况下,排除整个单位的情况对我而言都会很细,但是能够避免某些方法甚至行代码更好。



更新:也许codegear应该引入像 skip-points (而不是break-points)的东西: - )

解决方案

有一个魔术节点开关。 {$ D-}将禁用生成调试代码。将其放在您的FastMM单元的顶部,您不会最终跟踪它。如果你最终不会在一个功能中,SHIFT-F8会很快让你出去。 (警告:不要在堆栈中使用的汇编代码例程中使用SHIFT-F8,可能会导致不可预测的行为,而不是F4)。


I often accidently step into code that I'm not interested in while debugging in Delphi.

Let's start by saying that I know that you can step over with F8, and that you can run to a certain line with f4.

Example:

function TMyClass.DoStuff():Integer;
begin
  // do some stuff
  bla();
end;

procedure TMyClass.Foo()
begin
  if DoStuff()=0 then // press F7 when entering this line
    beep;
end;

Example: I want to step into method DoStuff() by pressing F7, but instead of going there, I first end up in FastMM4.FastGetMem(), which is a massive blob of assembly code that obviously I'm not interested in at the moment.

There are several ways to go about this, and I don't like any of them:

  • Add a breakpoint on "bla" (almost useless if you only want to step into DoStuff on special occasions, like iteration 23498938);

  • Instead of pressing F7, manually move the cursor to "bla", and press F4 (Works for this simple example. In practice, it doesn't);

  • In case of FastMM: temporarily disable fastmm;

Is there any way to hint the IDE that I'm never interested into stepping into a certain block of code, or do I always have to set extra breakpoints or use F4 to try to avoid this?

I'm hoping for some magic compiler directive like {$NODEBUG BEGIN/END} or something like that.

In most cases being able to exclude entire units would be fine-grained enough for me, but being able to avoid certain methods or even lines of code would be even better.

Update: Maybe codegear should introduce something like skip-points (as opposed to break-points) :-)

解决方案

There is a "magic nodebug switch". {$D-} will disable the generation of debug code. Place that at the top of your FastMM unit and you won't end up tracing into it. And if you do end up in a function you don't want to be in, SHIFT-F8 will get you out very quickly. (WARNING: Don't use SHIFT-F8 from inside an assembly-code routine that plays around with the stack. Unpredictable behavior can result. F4 to the bottom of it instead.)

这篇关于在Delphi中:如何在调试时跳过代码段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆