简体   繁体   English

如何阻止调试器进入Delphi提供的单元?

[英]How do I stop the debugger from stepping into Delphi-supplied units?

The debugger steps into the source code on errors (like with F7 ), but I want to restore the normal working mode where the Delphi basic DCUs (the library) are only compiled into my code, and the sources are not used in debugging. 调试器在错误的源代码中步入(如F7 ),但我想恢复正常工作模式,其中Delphi基本DCU(库)只编译到我的代码中,并且源不用于调试。

For example, on an error in my program, the debugger is stepping into Controls.pas, into TControl.Click . 例如,在我的程序中出现错误时,调试器正在进入Controls.pas,进入TControl.Click The normal case (right after installation) is for Delphi to step over these methods. 正常情况(安装后)是Delphi跨越这些方法的。

Should I recompile Controls.pas without debug information? 我应该在没有调试信息的情况下重新编译Controls.pas吗? If so, how? 如果是这样,怎么样?


I extending this theme with additional information to better understanding: 我通过附加信息扩展这个主题,以便更好地理解:

We use Delphi6 Prof. what have problem with Mouse (System Error Code 5). 我们使用Delphi6 Prof. Mouse有什么问题(系统错误代码5)。 So we want to recompile to Controls.pas to replace the Mouse Position getter code. 因此,我们要重新编译为Controls.pas以替换Mouse Position getter代码。 Then: 然后:

  1. I created a folder for it: "c:\\D\\Common\\Delphi_Patches\\Delphi_6\\" 我为它创建了一个文件夹:“c:\\ D \\ Common \\ Delphi_Patches \\ Delphi_6 \\”
  2. I put the original Controls.pas into it. 我将原始的Controls.pas放入其中。
  3. I modified the Controls.pas, replaced the position getter code. 我修改了Controls.pas,取代了位置getter代码。
  4. I set the Delphi's Library path, set the first folder to "c:\\D\\Common\\Delphi_Patches\\Delphi_6\\" 我设置了Delphi的Library路径,将第一个文件夹设置为“c:\\ D \\ Common \\ Delphi_Patches \\ Delphi_6 \\”

With these steps I can compiled the source with mouse-safe code. 通过这些步骤,我可以使用鼠标安全代码编译源代码。

Ok, but then the Delphi everytime steps into Controls.pas on F7, and on any exceptions - this is very "angermaker" thing. 好的,但随后德尔福每次都会在F7上进入Controls.pas,并且在任何例外情况下 - 这都是非常“愤怒”的事情。

No matter that I removed the "Controls.pas" from the Library path - then the debugger is finding the original "Controls.pas" for it, and opens it... :-( 无论我从库路径中删除了“Controls.pas” - 然后调试器为它找到原始的“Controls.pas”,然后打开它...... :-(

We don't use "Use Debug DCU-s" in any codes. 我们不在任何代码中使用“Use Debug DCU-s”。

I tried to remove "Debug Information" from compiler options, but it is no matter, the Delphi is opens the original Controls.pas... 我试图从编译器选项中删除“Debug Information”,但不管怎么说,Delphi打开原来的Controls.pas ...

So I search the way to Delphi don't step into "Controls.pas", but use my dcu... 所以我搜索到Delphi的方式不要进入“Controls.pas”,但是使用我的dcu ......

I hope this provide better context to understand the problem. 我希望这能为解决问题提供更好的背景。

我认为您需要Shift + Ctrl + F11 (工具/选项)然后在编译器中 ,取消选中“使用调试DCU”...然后,如果发生异常,它将不会进入RTL或VCL源。

Since you are compiling your own version of a Delphi unit, you can disable debug info in that unit. 由于您正在编译自己的Delphi版本,因此可以在该单元中禁用调试信息。 Add {$D-} to the source code of the unit(s) in question. {$D-}添加到相关单元的源代码中。

As I see the solution is: 我认为解决方案是:

  1. create a project the uses only the new Controls.pas. 创建一个只使用新的Controls.pas的项目。

  2. unset the "Debug information" option in compiler options. 取消设置编译器选项中的“调试信息”选项。

  3. build dcu 建立dcu

  4. put the dcu into a library folder 将dcu放入库文件夹中

  5. hide the new Controls.pas from this library folders. 从此库文件夹中隐藏新的Controls.pas。

Wite this trick the I cannot "step into" controls.pas. 我不能“进入”controls.pas这个技巧。

Regards: dd 问候:dd

I had this same problem with Delphi XE8. 我在Delphi XE8上遇到了同样的问题。

You can untick the "Project >> Option >> Compiling >> Use debug .dcus" and it will continue tracing into System unit and so on. 您可以取消选中“Project >> Option >> Compiling >> Use debug .dcus”,它将继续跟踪到System unit等等。

I found that the best way to stop this is to open your Application.dproj file - which is in XML. 我发现阻止它的最好方法是打开Application.dproj文件 - 它是XML格式的。 In it, you can change the settings as follows: 在其中,您可以按如下方式更改设置:

<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
    <DCC_AssertionsAtRuntime>false</DCC_AssertionsAtRuntime>  <--- note false
    <DCC_DebugDCUs>false</DCC_DebugDCUs>
    <VerInfo_Locale>1033</VerInfo_Locale>
    <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
    <DCC_RemoteDebug>false</DCC_RemoteDebug>
</PropertyGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM