简体   繁体   English

如何调试Delphi项目?

[英]How to debug Delphi project?

I'm a .NET developer, but I have got a quest - I must find errors in a Delphi project. 我是.NET开发人员,但我有一个任务 - 我必须在Delphi项目中发现错误。

After opening a project (Borland Delphi 7) and trying to debug it ('Run' menu), I've noticed all debugging options are inactive (gray). 打开一个项目(Borland Delphi 7)并尝试调试它('Run'菜单)后,我注意到所有调试选项都处于非活动状态(灰色)。

How can I make it usable? 我怎样才能使它可用?

I'm not sure why the pause button doesn't work, but I have seen Delphi 7 get "confused" and refuse to stop on legitimate breakpoints before. 我不知道为什么暂停按钮不起作用,但我看到Delphi 7变得“迷茫”并拒绝停止合法断点。

  • Make a backup of everything, just in case you don't have the source for all of the DCUs. 备份所有内容,以防您没有所有DCU的源。
  • Delete the project's DCUs. 删除项目的DCU。
  • Make sure you're including debug information in the project's options. 确保在项目选项中包含调试信息。
  • Do a full build (not just a recompile). 做一个完整的构建(而不仅仅是重新编译)。

I hope this helps. 我希望这有帮助。

The debugger is always active, unless it is explicitly deactivated. 除非明确停用,否则调试器始终处于活动状态。 Just run the application and the inactive menu items will become active. 只需运行应用程序,非活动菜单项就会变为活动状态。 (For some options you have to have to pause the running application) (对于某些选项,您必须暂停正在运行的应用程序)

Just try pressing F8. 试试按F8。 This will run the application and pause at the first line of executable code and most of the debugging items will become active. 这将运行应用程序并暂停第一行可执行代码,大多数调试项将变为活动状态。

Hard to tell just from that description, but here are a few pointers. 很难从这个描述中分辨出来,但这里有一些指示。

  • Make sure you've got a project (.dpr) loaded, and not just a source (.pas) file. 确保已加载项目(.dpr),而不仅仅是源(.pas)文件。
  • Try to build the project with SHIFT-F9. 尝试使用SHIFT-F9构建项目。 When it's done, if everything compiles successfully, you'll see blue dots in the "gutter" at the left side of the text editor, showing which lines actually contain debuggable code. 完成后,如果所有内容都成功编译,您将在文本编辑器左侧的“装订线”中看到蓝点,显示哪些行实际包含可调试代码。 If you don't get any of those, go into Project Options and turn on the Debug option, then rebuild. 如果你没有得到任何这些,请进入项目选项并打开调试选项,然后重建。

Once you've done that you should be able to run and debug the app. 完成后,您应该能够运行和调试应用程序。

工具 - > 调试器选项确保选中集成调试

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

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