断点命中时单元源代码与代码执行路径不匹配

发布于 2024-12-12 19:40:55 字数 602 浏览 1 评论 0原文

我正在调试使用 Delphi 6 Pro 的 DSPACK 代码库创建的 DirectShow 过滤器。当我在名为 BaseClass.pas 的特定单元中设置断点并开始跟踪时,执行点会跳转到源代码中的奇怪位置。这通常表明正在跟踪的源代码与编译到 Delphi 应用程序正在使用的包之一中的源代码不匹配。奇怪的是,它只是 BaseClass 单元,因为我跟踪了属于 DSPACK 代码库的其他单元,并且它们没有出现此问题。我没有使用运行时包。

我扫描了磁盘,只发现了一份 BaseClass.dcu 的副本,其修改日期与我上次构建该程序时的日期相同。我没有修改该单元或属于 DSPACK 的任何其他单元的源代码。由于我的 Filter 是主应用程序的一部分,这表明 BaseClass.pas 将受到双重使用情况的影响,因为它用于构建 DSPACK 组件包 (dpk),并且也由我的主应用程序直接通过 TBCSource 对象引用我的过滤器来自。请注意,我确实尝试将单位 PAS 文件直接添加到我的项目中,但这并没有解决任何问题。

我还返回并重新打开每个 DSPACK 包文件并进行了完整的重新构建。这些都没有帮助。我还可以尝试其他方法来使源代码与 BaseClass 单元的编译映像同步吗?或者完全是一个不同的问题,如果是的话,它是什么以及我该如何解决它?

I am debugging a DirectShow filter I created with the DSPACK code library using Delphi 6 Pro. When a breakpoint I set is hit in one particular unit named BaseClass.pas, and I begin tracing, the Execution Point jumps to strange places in the source code. This usually indicates that the source code being traced does not match the source code that was compiled into one of the packages being used by the Delphi application. Oddly enough it is only the BaseClass unit since I have traced other units belonging to the DSPACK code library and they do not exhibit this problem. I am not using run-time packages.

I scanned my disk and found only one copy of BaseClass.dcu with a modification date equal to the last time I built the program. I have not modified the source for that unit or any other belonging to DSPACK. Since my Filter is part of the main application this indicates that BaseClass.pas would be subject to a dual use situation since it is used to build the DSPACK component package (dpk), and is also referenced by my main application directly via the TBCSource object my Filter descends from. Note, I did try adding the unit PAS file directly to my Project but that didn't fix anything.

I also went back and re-opened each of the DSPACK package files and did a full re-build. None of this helped. Is there something else I can try to get the source synchronized with the compiled image of the BaseClass unit? Or is a different problem altogether and if so, what is it and how can I fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

清晰传感 2024-12-19 19:40:55

有时,当从网页或其他来源复制/粘贴代码并且行不以 CR/LF 对(#13#10>0x0D0A,Windows 标准),但仅以 LF(#100x0A,通常以 *nix 系统结尾的行)或 CR(#10 >#13或 0x0D,典型的是 Mac OSX/iOS)。不正确的行终止符会使调试器感到困惑——这一直是过去几个 Delphi 版本的问题。

有时,您可以通过使用记事本等文本编辑器打开源文件,进行一些无意义的小更改(例如,插入然后删除空行),然后保存文件来解决此问题。

Sometimes this happens when code is copied/pasted from web pages or other sources, and the lines don't end with CR/LF pairs (#13#10 or 0x0D0A, standard for Windows) but end in only LF (#10 or 0x0A, typically the line ending in *nix systems) or CR (#13 or 0x0D, typical with Mac OSX/iOS). The incorrect line terminators confuse the debugger - this has been an issue for the past several Delphi versions.

You can sometimes fix this by opening the source file using a text editor like Notepad, making a small meaningless change (insert and then delete a blank line, for instance), and then save the file.

小女人ら 2024-12-19 19:40:55

我遇到了同样的问题并制作了类似的实用程序。修好了。
基本上,就是这样:

procedure adjustCRLF(filename : String);  
var  
    strList : TStringList;  
begin  
    strList := TStringList.Create;  
try  
    strList.LoadFromFile(filename);  
    strList.Text := AdjustLineBreaks(strList.Text);  
    strList.SaveToFile(filename);  
finally  
    strList.Free;  
end;  
end;

I had same problem and made a similar utility. Fixed it.
Basically, just this:

procedure adjustCRLF(filename : String);  
var  
    strList : TStringList;  
begin  
    strList := TStringList.Create;  
try  
    strList.LoadFromFile(filename);  
    strList.Text := AdjustLineBreaks(strList.Text);  
    strList.SaveToFile(filename);  
finally  
    strList.Free;  
end;  
end;
你丑哭了我 2024-12-19 19:40:55

还有另一种可能会发生这种情况:如果 IDE 错误地打开另一个同名(但不同,例如早期版本)的源文件,那么所有调试点都将不正确,调试器甚至允许您单步执行文件不正确。
我曾经见过 Delphi 7 这样做过一次。

There is another way this can happen: if the IDE erroneously opens another source file with the same name (but different, such as an earlier version) then all the debug points will be incorrect, and the debugger will even allow you to step through the incorrect file.
I've seen Delphi 7 do this once.

凉薄对峙 2024-12-19 19:40:55

确保在重建它时,在项目的编译器选项中打开了“调试信息”。事实上,调试下的大多数选项都应该在项目的编译器选项中设置。

另外,如果您还没有重新启动 Delphi,请重新启动。

Make sure that when you rebuild it, that in the compiler options for your project that you have "Debug Information" turned on. In fact, most of the options under Debugging should be set in your project's Compiler options.

Also, if you haven't already, restart Delphi.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文