To self debug your application you need to instantiate MdbEng for managed processes or CdbEng for unmanaged only stuff and dispose the debugger instance when you are done.

 

Example:

        /// <summary>
        /// Issue a !Threads command and print the output to console
        /// </summary>
        private static void SelfDebug()
        {
            using (var debugger = new MdbEng())
            {
                string[] output = debugger.Execute("!Threads");
                Console.WriteLine(String.Join(Environment.NewLine, output));
            }
        }
This will give you output like this:

0:009> !Threads
ThreadCount:      5
UnstartedThread:  0
BackgroundThread: 1
PendingThread:    0
DeadThread:       3
Hosted Runtime:   no
                                                                         Lock
       ID OSID ThreadOBJ    State GC Mode     GC Alloc Context  Domain   Count Apt Exception
   0    1  d38 00402218   202a020 Preemptive  01762DA0:00000000 003fa240 0     MTA
   2    2 13a4 0040e260     2b220 Preemptive  00000000:00000000 003fa240 0     MTA (Finalizer)
XXXX    3    0 00449a78     35820 Preemptive  00000000:00000000 003fa240 0     Ukn
XXXX    4    0 00473210     35820 Preemptive  00000000:00000000 003fa240 0     Ukn
XXXX    5    0 0047c830     35820 Preemptive  00000000:00000000 003fa240 0     Ukn

Last edited Jun 22, 2012 at 9:55 PM by Alois, version 2

Comments

No comments yet.