简体   繁体   English

巨大的C文件调试问题

[英]huge C file debugging problem

I have a source file in my project, which has more than 65,536 code lines (112,444 to be exact). 我的项目中有一个源文件,它有超过65,536个代码行(确切地说是112,444)。 I'm using an "sqlite amalgamation", which comes in a single huge source file. 我正在使用“sqlite amalgamation”,它出现在一个巨大的源文件中。

I'm using MSVC 2005. The problems arrives during debugging. 我正在使用MSVC 2005.问题在调试期间到来。 Everything compiles and links ok. 一切都编译和链接确定。 But then when I'm trying to step into a function with the debugger - it shows an incorrect code line. 但是当我尝试使用调试器进入函数时 - 它显示的代码行不正确。

What's interesting is that the difference between the correct line number and the one the debugger shows is exactly 65536. This makes me suspect (almost be sure in) some unsigned short overflow. 有趣的是,正确的行号和调试器显示的行号之间的差异正好是65536.这让我怀疑(几乎可以肯定)一些无符号的短溢出。

I also suspect that it's not a bug in the MSVC itself. 我也怀疑它不是MSVC本身的错误。 Perhaps it's the limitation of the debug information format. 也许这是调试信息格式的限制。 That is, the debug information format used by MSVC stores the line numbers as 2-byte shorts. 也就是说,MSVC使用的调试信息格式将行号存储为2字节短路。

Is there anything can be done about this (apart from cutting the huge file into several smaller ones) ? 有没有什么可以做的(除了将大文件切成几个较小的文件)?

According to a MS moderator, this is a known issue with the debugger only (the compiler seems to handle it fine as you pointed out). 根据MS主持人的说法,这只是调试器的一个已知问题(编译器似乎正如你所指出的那样处理它)。 There is apparently no workaround, other than using shorter source files. 除了使用较短的源文件外,显然没有解决方法。 See official response to very similar question here 请参阅此处对非常相似问题的官方回复

Well, when I wanted to look at how sqlite works, I took the last 60000 or so lines, moved them to another file and then #include'd it. 好吧,当我想看看sqlite是如何工作的时候,我拿了最后60000左右的行,把它们移到另一个文件然后#include它。 That was easy and did the trick for me. 这很容易,并为我做了伎俩。 Also, if you do that, be careful not to split inside #ifdef . 此外,如果您这样做,请注意不要拆分#ifdef。

If you look at the documentation for the symbolic debugging info, you will see the type used for line numbers. 如果查看符号调试信息的文档,您将看到用于行号的类型。 For example, both line and column parameters for IDiaSession::findLinesByLinenum are of type DWORD . 例如, IDiaSession::findLinesByLinenum linecolumn参数都是DWORD类型。

Edit: As @valdo points out, that still doesn't mean the debugger works properly with huge line numbers. 编辑:正如@valdo所指出的,这仍然不意味着调试器可以正常使用大行号。 So you have to use shorter files. 所以你必须使用更短的文件。 It is unfortunate that such limitation exists, but even if there wasn't I'd still recommend you split your source. 不幸的是存在这样的限制,但即使没有,我仍然建议你拆分你的来源。

Have you looked into using WinDBG instead? 您是否考虑过使用WinDBG? It's pretty capable as the Windows team use it for debugging the O/S and there's some biiiig files in there, or at least there was when I last looked. 它非常强大,因为Windows团队使用它来调试O / S,并且那里有一些biiiig文件,或者至少在我上次查看的时候。

For anyone having issues with incorrect line numbers for files < 65536 lines: I found my issue was because of inconsistent line endings in the source file. 对于文件<65536行的行号不正确的人:我发现我的问题是因为源文件中的行结尾不一致 There were 129 \\r newlines where the rest of the file was \\r\\n style. 有129 \\r换行符,文件的其余部分是\\r\\n样式。 The difference between the debugger line and the correct line was 129 as well. 调试器行与正确行之间的差异也是129。

Unless you are modifying SQLite, you should just trust that it is doing its job. 除非您正在修改SQLite,否则您应该相信它正在完成它的工作。 No need to step in at all. 根本不需要介入。 SQLite is run through a large battery of tests before release. SQLite在发布之前经过大量测试。

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

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