NAME

docs/dev/debugging_with_msvc.pod - Debugging Parrot with Microsoft Visual C++

DESCRIPTION

This document describes how to get started with debugging on Microsoft Windows using Visual C++ 7 and later.

Compiler Options

Probably the easiest way to get going with debugging is to add some compiler options. One way to go about this is to run perl Configure.pl, look at the CFLAGS in Makefile and then run perl Configure.pl --ccflags="..." with the new flags. Once done, consider saving your Configure call in a batch file so you have it available the next time.

/Wall

Listen to your compiler.

/RTCcsu - Enables run-time error checking

This enables three different runtime checks: Conversion to smaller type, stacke frame and use of uninitialized local variable. See http://msdn2.microsoft.com/en-us/library/8wtf2dfz(VS.80).aspx.

/GS - Buffers security check

Detect some buffer overruns. See http://msdn2.microsoft.com/en-us/library/8dbf701c(VS.80).aspx.

/Wp64 - Detect 64-bit compatibility problems

Don't use this one. Leave 64-bit checking to the real 64-bit compilers.

/D_DEBUG vs. /DNDEBUG

_DEBUG enables the use of the debugging versions of the runtime functions. NDEBUG disables the debug function assert. Beware that the Visual C++ specific assertion macro _ASSERT is only enabled if _DEBUG is defined!

It's probably best to start with making sure that NDEBUG is not defined and enable the debugging C runtime later.

Debugging C runtime

Two steps are necessary to use the debugging C runtime. First change the -MD flag to -MDd. This will implicitly define _DEBUG. Often this is enough, but Parrot lists the libraries explicitly, so you'd need to replace MSVCRT.lib with MSVCRTd.lib. For this, run perl Configure.pl, look at C_LIBS in the Makefile and run perl Configure.pl --libs="..." with the new libs.

/analyze

Microsoft added more static source code analysis to the their compiler, but this is only available with certain editions. If not supported you'll see the following warning.

  cl : Command line warning D9040 : ignoring option '/analyze'; Code
  Analysis warnings are not available in this edition of the compiler 

Examples

Here's an example how the new Configure call might look like.

  perl Configure.pl ^
      --ccflags="-nologo -Wall -MDd -Zi -Od -GS -RTCcsu -DWIN32 -D_CONSOLE" ^
      --linkflags="-nologo -nodefaultlib -machine:x86 -debug -incremental:no" ^
      --ldflags="-nologo -nodefaultlib -machine:x86 -debug -incremental:no" ^
      --libs="kernel32.lib ws2_32.lib msvcrtd.lib oldnames.lib" ^
      %*

Debugging Tools for Windows

TODO

http://www.microsoft.com/whdc/devtools/debugging/default.mspx

Examples

TODO

Microsoft Application Verifier

TODO

http://www.microsoft.com/technet/prodtechnol/windows/appcompatibility/appverifier.mspx

Examples

TODO

Frequently Asked Questions

TODO

SEE ALSO

Debugging Native Code
http://msdn2.microsoft.com/en-us/library/k70yt3e2(VS.80).aspx

AUTHOR

Ronald Blaschke <ron@rblasch.org>