Thursday, January 10, 2008

Fun with the Visual Studio 2003 Debugger

Debugging a crash in Perl, and discovered a nice little nuance in the Visual Studio 2003 Debugger.

Take a look at this screenshot:


Notice how the second frame in the stack doesn't have a line number? I thought perhaps the DLL had not been compiled with debug symbols for some reason (or that the symbols had not been loaded). Neither problem was the case.

The problem didn't reveal itself until I went back and looked at the compile log file (which fortunately I had immediately at my disposal since I just rebuilt our Perl yesterday):

cl -c -I. -IHandler -Ic:\include -D_REENTRANT -DWIN32 -DHAS_BOOL -TP -GX -MD -Zi -DNDEBUG -O1 -DVERSION=\"2.7.0-0\" -DXS_VERSION=\"2.7.0-0\" "-IC:\perl\lib\CORE" Xerces.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

Xerces.cpp
Xerces.cpp(65537) : warning C4049: compiler limit : terminating line number emission
Compiler limit for line number is 65535


It turns out that Visual Studio 2003 doesn't support line numbers greater than 65535. Fortunately, it looks like they increased the limit to 16,777,215 in Visual Studio 2005.

http://msdn2.microsoft.com/en-us/library/8skb5hay(VS.80).aspx

Normally, you might ask, "why on Earth would he have a single source file with more than 65535 lines?". Well, the module in question is XML::Xerces, and the C/C++ source code more the module is autogenerated by SWIG (a framework for wrapping native code so it can be called by high level languages like Perl or PHP).

Add one more reason to my list of why I want to upgrade to Visual Studio 2005.