The F# compiler produces PDB files directly, including for optimized code. These enable debugging either within Visual Studio or with other dedicated debuggers such as dbgclr.exe or cordbg.exe.
Debugging with F# for Visual Studio 2003/2005
If you are using the “F# for Visual Studio” plug-in for your F# projects you can launch debugging sessions directly from the environment. This is as simple as creating an “F# Project”, populating it with your code, pressing F11 to “step into” your program, and then you’re away!
Using Another Editor? You can still debug using Visual Studio 2003/2005!
All versions of Microsoft Visual Studio can be used as debuggers, regardless of whether you have created an F# project or even if you don’t have the F# Visual Studio plug-in installed at all (e.g., you are using the command-line compiler and Makefiles). There are five ways to start a debugging session. In all cases you should compile your code with the -g option to generate debug symbols.
Tips. If debug symbols are not found for your code or for the F# library then you will probably want to disable “Just My Code” debugging in the “Options” menu (Visual Studio 2005 only). You can also set the _NT_SYMBOL_PATH variable globally on your machine.
Debugging with DBGCLR.EXE
The .NET Framework SDK comes with an excellent lightweight graphical debugger. To use this simply compile your code with the -g, make sure dbgclr.exe is on your path and then run it, e.g.,
Using Visual C# 2005 Express and Friends
Visual C# 2005 Express, Visual Basic 2005 Express and some similar products are no-cost downloads from Microsoft site, and can all be used with F# code, or with multi-language programs. To use them with F#, open a console project and set the properties on the project to indicate the F# program to run.
This is the command-line debug shell from the .NET Framework SDK, and can be used with F# code. e.g.,
C:devsrccode>cordbg (cordbg) run cdebug.exe (cordbg) help (cordbg) show 20 (cordbg) si (cordbg) si (cordbg) si (cordbg) w