How do I stop the debugger from stepping into Delp

2019-02-17 19:15发布

问题:

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.

For example, on an error in my program, the debugger is stepping into Controls.pas, into TControl.Click. The normal case (right after installation) is for Delphi to step over these methods.

Should I recompile Controls.pas without debug information? 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). So we want to recompile to Controls.pas to replace the Mouse Position getter code. Then:

  1. I created a folder for it: "c:\D\Common\Delphi_Patches\Delphi_6\"
  2. I put the original Controls.pas into it.
  3. I modified the Controls.pas, replaced the position getter code.
  4. I set the Delphi's Library path, set the first folder to "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.

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... :-(

We don't use "Use Debug DCU-s" in any codes.

I tried to remove "Debug Information" from compiler options, but it is no matter, the Delphi is opens the original Controls.pas...

So I search the way to Delphi don't step into "Controls.pas", but use my dcu...

I hope this provide better context to understand the problem.

回答1:

I think that you need to Shift+Ctrl+F11 (tools/options) then in Compiler, uncheck "Use debug DCU"...Then if an exception occurs it wont break into the RTL or VCL sources.



回答2:

Since you are compiling your own version of a Delphi unit, you can disable debug info in that unit. Add {$D-} to the source code of the unit(s) in question.



回答3:

As I see the solution is:

  1. create a project the uses only the new Controls.pas.

  2. unset the "Debug information" option in compiler options.

  3. build dcu

  4. put the dcu into a library folder

  5. hide the new Controls.pas from this library folders.

Wite this trick the I cannot "step into" controls.pas.

Regards: dd



回答4:

I had this same problem with Delphi XE8.

You can untick the "Project >> Option >> Compiling >> Use debug .dcus" and it will continue tracing into System unit and so on.

I found that the best way to stop this is to open your Application.dproj file - which is in 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>