Delphi 应用程序有“无调试信息”调试时
我们构建了一个使用包和组件的应用程序。当我们调试应用程序时,IDE 中的“事件日志”通常会显示我们的 BPL 正在加载,但没有调试信息(“无调试信息”)。这是没有意义的,因为我们所有的包和 EXE 都是通过调试构建的。
_(each project) | Options | Compiling_
[ x ] Assertions
[ x ] Debug information
[ x ] Local symbols
Symbol reference info = "Reference info"
[ ] Use debug .dcus
[ x ] Use imported data references
_(each project) | Options | Linking_
[ x ] Debug information
Map file = Detailed
我们有 4 个项目,全部使用运行时包构建:
- Core.bpl
- Components.bpl
- Plugin.bpl(同时使用 #1 和 #2)
- MainApp.exe(使用 #1)
观察到的问题
1) 许多有时,当我们调试时,Components.bpl 会加载调试信息,但“局部变量”窗口中的所有值都是空白的。如果将鼠标悬停在代码中的变量上,则不会弹出窗口,并且评估窗口也不会显示任何内容(“结果”窗格始终为空白)。
2) 有时,事件日志会显示各种 BPL 的“无调试信息”。例如,如果我们激活 Plugin.bpl 项目并将其设置为 Run |将参数的主机应用程序设置为 MainApp.exe,然后按 F9,除了 Plugin.bpl 模块之外,所有模块似乎都加载了“Has Debug Info”。加载时,事件日志显示“无调试信息”。但是,如果我们关闭应用程序并立即按 F9,它将再次运行它而不重新编译任何内容,并且这次 Plugin.bpl 加载了调试(“具有调试信息”)。
问题
1) 什么会导致“局部变量”窗口不显示值?
2) 当 BPL 符合调试并且所有调试文件(dcu、map 等)可用时,为什么有时会在没有调试信息的情况下加载 BPL?
We have built an application that uses packages and components. When we debug the application, the "Event Log" in the IDE often shows the our BPLs are being loaded without debug information ("No Debug Info"). This doesn't make sense because all our packages and EXEs are built with debug.
_(each project) | Options | Compiling_
[ x ] Assertions
[ x ] Debug information
[ x ] Local symbols
Symbol reference info = "Reference info"
[ ] Use debug .dcus
[ x ] Use imported data references
_(each project) | Options | Linking_
[ x ] Debug information
Map file = Detailed
We have 4 projects, all built with runtime pacakges:
- Core.bpl
- Components.bpl
- Plugin.bpl (uses both #1 & #2)
- MainApp.exe (uses #1)
Problems Observed
1) Many times when we debug, the Components.bpl is loaded with debug info, but all values in the "Local Variables" window are blank. If you hover your mouse over a variable in the code, there is no popup, and Evaluate window also shows nothing (the "Result" pane is always blank).
2) Sometimes the Event Log shows "No Debug Info" for various BPLs. For instance, if we activate the Plugin.bpl project and set it's Run | Parameter's Host Application to be the MainApp.exe, and then press F9, all modules seems to load with "Has Debug Info" except for the Plugin.bpl module. When it loads, the Event Log shows "No Debug Info". However, if we close the app and immediately press F9, it will run it again without recompiling anything and this time Plugin.bpl is loaded with debug ("Has Debug Info").
Questions
1) What would cause the "Local Variables" window to not display the values?
2) Why are BPLs sometimes loaded without debug info when the BPL was complied with debug and all the debug files (dcu, map, etc.) are available?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我会用它来描述我的问题。
我使用 LoadPackage 函数动态加载包。
我可以在
SysInternals.com Process Monitor
中看到 packagename.DCP 在LoadPackage
处理后打开并成功读取 - 没有文件 I/O 失败,没有尝试查找错误地方,没有什么可疑之处。 所以,也许 DCP 中的某些构造会使 IDE 调试器变得疯狂。我渴望Turbo Debugger
可用于 Delphi。顺便说一句,如果开发人员创建了 packagename.RSM,则同样如此。
然后(在断点或步骤跟踪处暂停)我打开查看/调试窗口/模块并看到最后一个模块是我的 - 并且它有空的“符号信息”单元格。我右键单击它,选择“重新加载符号”操作 - 就在这里,从现在开始我可以调试。
附言。不知道这是否会帮助我调试初始化部分 - 希望“
break on load
”菜单项即使在动态LoadPackage
调用中也能工作...PPS。即使 IDE 重新启动,它确实可以工作。因此,现在我在使用
CPU View
加载 BPL 时收到警报,我按下CTRL+ALT+M
,滚动到底部找到我的 BPL,右键单击以重新加载Symbols
,按 Enter,然后关闭Modules
和CPU
视图并按F9(运行)
。在初始化
部分完成后,我再次收到CPU View
的警报 - 在退出LoadPackage
之前只需几个JMP
-所以我关闭了CPU View
并再次按下F9
。相当繁琐,但仍然比 IDE 重启要好。I would describe my issue with it.
I dynamically load package using
LoadPackage
function.I can see in
SysInternals.com Process Monitor
that packagename.DCP got open and read succesfuly afterLoadPackage
processed - no file I/O failed, no attempt to find it in wrong places, nothing suspicious. So perhaps there is some construct in DCP that makes IDE debugger go nuts. I long for times whenTurbo Debugger
was available for Delphi.BTW, same is for packagename.RSM if developer creates such.
Then (while paused at breakpoint or Step Trace) i open View / Debug Windows / Modules and see last module is mine - and it has empty "symbol information" cell. I right-click it, choose "Re-load symbols" action - and here it is, from now on i can debug.
PS. Dunno if that would help me to debug initialization sections though - hopefully "
break on load
" menu item would work even with dynamicalLoadPackage
calls...PPS. It does work indeed, even across IDE restarts. So now i am alerted at BPL loading with
CPU View
, i strikeCTRL+ALT+M
, scroll to bottom to find my BPL, r-click toReload Symbols
, press Enter, then closeModules
andCPU
Views and strikeF9 (Run)
. Afterinitialization
sections completes i am again alerted byCPU View
- just fewJMP
s before exit out ofLoadPackage
- so i closeCPU View
and stikeF9
yet again. Quite tedious, yet still better than IDE restart.我们在项目中也遇到过类似的问题。不幸的是,我们有数十个 bpl,因此我们无法将它们合并为一个。
这个问题是在我们迁移到 XE2 并更改了编译目标的文件夹结构后出现的。
虽然很难说较新版本的 Delphi 是否引入了该问题,但我们可以通过在路径环境变量中添加编译 bpls 的文件夹来解决该问题。使用IDE的路径覆盖功能。在 Delphi 2010 中不需要这种类型的配置...
We have encountered a similar issue in our project. Unfortunately we have dozens of bpl so we cannot merge them in one.
This issue appeared after we migrated to XE2 and changed the folder structure of our compile target.
While it is difficult to say if newer versions of Delphi introduced the issue or not, we could fix the issue by adding the folder where the bpls are compiled in the path environment variable. Using the path override function of the IDE. This type of configuration was not necessary in Delphi 2010...
这个非官方工具修复了 Delphi 的许多问题。它为我修复了没有调试信息的模块加载。所有功劳均归于 magicandre1981。
This non-official tool fixes many issues with Delphi. It fixed the module loading without debug info for me. All the credits to magicandre1981.
您必须使用调试信息构建单独的包,并且您最终会希望在不进行调试的情况下构建它们 - 所以您将在两个位置都有它们。然后您想使用调试信息构建应用程序项目。检查路径以确保在调试项目构建中包含启用调试的包源。听起来您可能包含了未经调试而构建的包,因为您包含的来源错误。您必须确保没有包含两个路径,如果 Delphi 在两个位置找到相同的包,则让 Delphi 选择要包含的内容。
You have to build your separate packages with debug info, and you will eventually want to build them without debug also - so you will have both in 2 spots. Then you want to build your app project with debug info. Check your paths to ensure that you are including the debug-enabled package source in your debug project builds. It sounds like you may be including packages that were built without debug because you are including from the wrong source. You have to make sure you don't have both paths included, leaving Delphi to select what to include if it finds the same package in two places.
对于我们的特定情况,我们能够通过将 Core.pbl 和 Components.bpl 合并到单个 BPL 中来解决该问题。现在,所有模块都加载了调试信息,并且局部窗口不显示变量值的偶尔问题已得到解决。
For our particular situation we were able to fix the issue by combining the Core.pbl and Components.bpl into a single BPL. Now all modules are loaded with debug info and the occasional issue where the Locals Window wouldn't display values for the variables is resolved.
这个问题可能与QC#109291有关:
当Delphi IDE开始引入时.dproj 文件和带有选项集的构建配置,它极大地改进了项目发布管理。
然而,它也有一个副作用,很难重放和捕获,我认为这是 IDE 中的错误。这个问题应该总是让用户感到困惑,因为某些项目无法在 IDE 调试器中进行调试。即使我们检查项目中编译器和链接选项的所有相关设置,调试器也不会在项目上激活。有些项目有效,有些项目则无效。我们甚至认为是内存问题或者cpu问题。
我注意到问题是由于 .dproj 文件设置未存储正确的信息。如果相关的 .dproj 文件具有类似以下内容:
Release.optset
绑定到Cfg_2
和Debug.optset
绑定到Cfg_1< /code>,但
Release
配置使用Cfg_1
,Debug
配置使用Cfg_2
。构建项目时,调试信息不会在调试配置中生成,而是在发布配置中生成。
解决方案是使用任何文本编辑器(但不是 Delphi IDE)打开 .dproj,然后更新为:
This problem might be releated to QC#109291:
When Delphi IDE start introduce .dproj file and build configuration with option sets, it improve the project release management a lot.
However, it also has a side effect that is hard to replay and catch and I thought it was bugs in IDE. The problem should have always confuse the users where some project is not able to debug in IDE debugger. Even we check all the related settings the compiler and linking options in project, the debugger won't activate on the project. Some project works and some project doesn't. We even regard is to be memory problem or cpu problem.
I notice the problem is due to the .dproj file setting doesn't store correct information. If the related .dproj file has something like this:
The
Release.optset
bind toCfg_2
andDebug.optset
bind toCfg_1
butRelease
configuration is usingCfg_1
andDebug
configuration is usingCfg_2
.When build the project, the debug info will not generate for in debug configuration but generate on release configuration.
A workaround solution is open .dproj with any text editor but not Delphi IDE, and update to:
我在 .dprj 文件中的 Cfg_2 详细信息中发现一行,其值 Debugger_LoadAllSymbols 设置为 false。我确实将其设置为true。问题解决了。也许与您的情况不相似,但可能会有所帮助。
I found in the .dprj file one line in the Cfg_2 détails with value Debugger_LoadAllSymbols which was set to false. I did set it to true. Problem solved. Maybe not similar to your case, but may help.