COR Debugger


Like ILDASM, the Common Language Runtime debugger ( cordbg ) is a useful tool supplied with the SDK. [3] It is helpful to use cordbg to demonstrate aspects of the execution system. This section provides a quick start with cordbg but does not offer a complete tutorial on its use; instead, it simply provides sufficient information to help a developer get started with this tool.

[3] As the name suggests, this tool dates back to the time when the .NET Framework was known as the Com Object Runtime (COR).

To start cordbg on a CLR executable program, type the command cordbg and the name of the program you wish to debug. For example:

 cordbg SampleIL.exe 

A useful exercise is to configue cordbg to display load events. Load events occur whenever the CLR loads new application domains, assemblies, modules, or types. Most cordbg commands can be abbreviated, with only sufficient characters to avoid ambiguity being required. The following command turns on the reporting of many load events, with most commands having been entered in a shortened format:

 (cordbg) mod App 1  AppDomain and Assembly load events are displayed (cordbg) mod cla 1 Class load events are displayed (cordbg) mod mod 1 Module load events are displayed 

After entering these commands, you can quit cordbg and then restart it on an executable. You should gain an appreciation for the work done by the runtime environment when you see how many classes are loaded. Following is the extremely abbreviated output generated by cordbg when executing the sample program that adds two integers. At this stage, readers are not expected to understand all of the output shown here, but concepts such as loading and unloading of the class System.Object from the assembly mscorlib.dll should be meaningful, for example. The output also demonstrates the use of application domains, which are described shortly, and modules, which are described in Chapter 5.

 Microsoft (R) Common Language Runtime Test Debugger Shell  Version 1.0.3705.0 Copyright (C) Microso ft Corporation 1998-2001. All rights reserved. (cordbg) Process 380/0x17c created. Appdomain #1, DefaultDomain -- Created Assembly 0x000964dc, c:\windows\...\mscorlib.dll -- Loaded   in appdomain #1, DefaultDomain Module 0x00093094, c:\...\v1.0.3705\mscorlib.dll -- Loaded   in assembly 0x000964dc, c:\windows\...\mscorlib.dll   in appdomain #1, DefaultDomain Loaded class: System.Object Loaded class: System.ICloneable Loaded class: System.Collections.IEnumerable Loaded class: System.Collections.ICollection Loaded class: System.Collections.IList ... Loaded class: System.ArgumentException Loaded class: System.ArgumentOutOfRangeException Loaded class: System.IO.Path Assembly 0x0009f724, C:\...\SampleIL.exe -- Loaded   in appdomain #1, SampleIL Module 0x0009f7c4, C:\...\SampleIL\SampleIL.exe -- Loaded   in assembly 0x0009f724, C:\...\SampleIL.exe   in appdomain #1, SampleIL Loaded class: SampleIL.EntryPoint Loaded class: System.Int32 Loaded class: System.Console ... Total is: 42 Loaded class: System.EventHandler [thread 0x434] Thread created. Unloaded class: SampleIL.EntryPoint Module 0x0009f7c4, C:\Project7\...\SampleIL.exe -- Unloaded   in assembly 0x0009f724, C:\...\SampleIL\SampleIL.exe   in appdomain #1, SampleIL.exe Assembly 0x0009f724, C:\...\SampleIL.exe -- Unloaded Unloaded class: System.Object Unloaded class: System.ICloneable Unloaded class: System.Collections.IEnumerable Unloaded class: System.Collections.ICollection Unloaded class: System.Collections.IList Unloaded class: System.Array Unloaded class: System.IComparable Unloaded class: System.IConvertible Unloaded class: System.String ... Module 0x00093094, c:\...\v1.0.3705\mscorlib.dll -- Unloaded   in assembly 0x000964dc, c:\...\mscorlib.dll   in appdomain #1, SampleIL.exe Assembly 0x000964dc, c:\windows\...\mscorlib.dll -- Unloaded Appdomain #1, SampleIL.exe -- Exited [thread 0x178] Thread exited. Process exited. 

The line Total is: 42 shown in the output is the string written to the console during execution of the program.

Typing help at the cordbg prompt will cause a few pages of information about cordbg commands to be displayed on the screen. Throughout the rest of this chapter, cordbg is used to highlight some aspects of the run-time nature of the execution system. Of course, some developers may prefer to use the graphical debugger supplied as part of Visual Studio rather than cordbg .



Programming in the .NET Environment
Programming in the .NET Environment
ISBN: 0201770180
EAN: 2147483647
Year: 2002
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net