Microsoft Developer Network > Forenhomepage > Building Development and Diagnostic Tools for .Net > How to use the Break and BreakPoint functions in the ICorDebugManagedCallback interface
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetHow to use the Break and BreakPoint functions in the ICorDebugManagedCallback interface

  • Donnerstag, 5. März 2009 03:34Nicoleshu TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     

    Now I want to write a .NET Debugger using CLR debugging API cordebug.tlb.When I implement the ICorDebugManagedCallback interface,I find I am not clearly about the Break and BreakPoint events.

    When meeting with a breakpoint,the debugger needs to judge if the breakpoint address is at the entry or at the return of a function.If it is a breakpoint at entry,we log the function name,param value,otherwise log the breakpoint information at the return site.

    In c++,there is a structure named DEBUG_EVENT,we can do this when the ExceptionCode is EXCEPTION_BREAKPOINT.But I don't know  corresponding event in the CLR API.


    By the way,there is a Exception in my program.
                ICorDebug m_pICorDebug;
                int size;
                NativeApi.GetCORVersion(null, 0, out size);
                Debug.Assert(size > 0);
                StringBuilder sb = new StringBuilder(size);
                int hr = NativeApi.GetCORVersion(sb, sb.Capacity, out size);
                Marshal.ThrowExceptionForHR(hr);
                string debuggerVersion = sb.ToString();

                if (debuggerVersion.StartsWith("v1"))
                {
                    throw new ArgumentException("Can't debug a version 1 CLR process (\"" + debuggerVersion +"\").  Run application in a version 2 CLR, or use a version 1 debugger instead.");
                }

                NativeApi.CreateDebuggingInterfaceFromVersion((int)NativeApi.CorDebuggerVersion.Whidbey, debuggerVersion, out m_pICorDebug);
                Debug.Assert(m_pICorDebug != null);
                if (m_pICorDebug == null)
                    throw new ArgumentException("Cannot be null.", "m_pICorDebug");


                ManagedEventHander m_pManagedCallback = new ManagedEventHander(this);
                m_pICorDebug.Initialize();
                if (m_pManagedCallback != null)
                {
                    m_pICorDebug.SetManagedHandler((ICorDebugManagedCallback )m_pManagedCallback);
                }


    System.InvalidCastException:Specified cast is not valid.
    at CORDBLib.ICorDebug.SetManagedHander<ICorDebugManagedCallback pCallback>

    'CMonitor.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'CMonitor.exe' (Managed): Loaded 'E:\CMonitor\CMonitor\bin\Debug\CMonitor.exe', Symbols loaded.
    'CMonitor.exe' (Managed): Loaded 'E:\CMonitor\CMonitor\bin\Debug\CORDBLib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'CMonitor.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'CMonitor.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'CMonitor.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'CMonitor.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'CMonitor.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    The program '[1832] CMonitor.exe: Managed' has exited with code -1073741510 (0xc000013a).


    I don't know what's wrong with my program .Can somebody help me?


    Thank you! And Best Wishes! 










    • VerschobenGuo Surfer Montag, 9. März 2009 06:53 (Moved from Visual C# General to Building Development and Diagnostic Tools for .Net)
    •  

Antworten

Alle Antworten