This sample provides the source files for CLR command line debugger, mdbg. These sources demonstrate how to use the CLR Debugging interfaces. As a corollary, they also show usage of the CLR MetaData, Symbol Store, and Process Publishing interfaces.
The sample also demonstrates use of advanced debugger features implemented in Whidbey:
This debugger is also accompanied by three extensions that enhance its functionality:
(Once built, simply type "load <file>" to load the desired extension.)
Winforms Graphical User Interface extension for easier debugging (gui)
Edit & Continue extension for modification of debugged programs (enc)
IL disassembler extension for display of IL code being executed (ildasm)
To build the mdbg sample you will need to have a .NET SDK version 2.0 installed on your system. If you have Visual Studio 2005, you already have this. The sample can be built using either the Visual Studio 2005 solution file, or it can be built using nmake and the makefile script.
This is the easiest and recommended method.
· Open the mdbg.sln file.
· From the "Build" menu, select "Build Solution"
· The solution file uses "Debug" as the default, but you can simply select "Release" from the dropdown menu at the top if you want that instead.
· Ensure that the environment (command shell) is set up to build using nmake. The makefile assumes that the location of the CLR libraries are included in the Win32 environment variables INCLUDE and LIB. If you have Visual Studio installed, opening the "Visual Studio .NET Whidbey Command Prompt" from the Visual Studio Start menu will set the correct environment variables for you.
If you have downloaded only Whidbey CLR SDK 2.0, you'll need to execute sdkvars.bat file to set your environment.
· From the directory containing the makefile, invoke
nmake
to build the sample. The end result should be a debug version of mdbg.exe. To build an optimized retail version of the program, environment variable MDBG_RETAIL_BUILD should be set by calling the set command as shown:
set MDBG_RETAIL_BUILD=1
Run mdbg.exe from the bin directory, or by pressing F5 in Visual Studio. Mdbg commands are similar to cordbg commands. Please refer to the cordbg manual, mdbg's help command, or the source code for more information on how to use various debugger commands.
Be sure to try the Graphical User Interface extension which makes debugging managed programs easier and more natural. To load this extension simply type "load gui" on the mdbg command line.
This sample also contains API-level documentation for two libraries, mdbgeng.dll and mdbgext.dll. Documentation for these libraries can be found in the DOC subdirectory.
This sample is presented courtesy of the CLR Debugger Team. It is intended for use as a demonstration on writing .NET managed debuggers in managed code. If you have any questions about the sample or the managed debugging APIs, or if you would like to send us a suggestion about the sample, please contact us at following email address: clrmdbg@microsoft.com.