Exemplo n.º 1
0
        static void PostDebugEventHandler(object sender, CustomPostCallbackEventArgs e)
        {
            MDbgStopOptions stopOptions = Shell.Properties[MDbgStopOptions.PropertyName]
                as MDbgStopOptions;

            stopOptions.ActOnCallback(sender as MDbgProcess, e);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Acts on the current callback, based on the current debugger behavior for this stop
        /// option policy.
        /// </summary>
        /// <param name="currentProcess">Current MDbgProcess.</param>
        /// <param name="args">Callback arguments.</param>
        public override void ActOnCallback(MDbgProcess currentProcess, CustomPostCallbackEventArgs args)
        {
            CorEventArgs eventArgs = args.CallbackArgs as CorEventArgs;
            switch (m_behavior)
            {
                case DebuggerBehavior.Stop:
                    args.Controller.Stop(eventArgs.Thread, MDbgUtil.CreateStopReasonFromEventArgs(eventArgs, currentProcess));
                    break;
                case DebuggerBehavior.Log:
                    CommandBase.WriteOutput(eventArgs.ToString() + "\n");
                    break;
                case DebuggerBehavior.Notify:
                    CommandBase.WriteOutput(eventArgs.ToString() + "\n");
                    MDbgThread currentThread = currentProcess.Threads.GetThreadFromThreadId((args.CallbackArgs as CorThreadEventArgs).Thread.Id);

                    try
                    {
                        // Getting the current notification may not be implemented.
                        MDbgValue notification = currentThread.CurrentNotification;
                        if (notification != null)
                        {
                            CommandBase.WriteOutput(notification.GetStringValue(true));
                        }
                        else
                        {
                            CommandBase.WriteOutput("custom notification is null\n");
                        }
                    }
                    catch (NotImplementedException)
                    {
                        Trace.WriteLine("Custom Notifications Not Implemented");
                    }
                    break;

            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Acts on debugger callback.
 /// </summary>
 /// <param name="currentProcess">The current MDbgProcess. </param>
 /// <param name="args">The callback arguments.</param>
 public abstract void ActOnCallback(MDbgProcess currentProcess, CustomPostCallbackEventArgs args);
Exemplo n.º 4
0
 /// <summary>
 /// Does nothing - an ExceptionEnhancedStopOptionPolicy object  is only meant to control the 
 /// ExceptionEnhanced switch in an ExceptionStopOptionPolicy object, not to directly stop the 
 /// debugger or to log a callback. 
 /// </summary>
 /// <param name="currentProcess">Current MDbgProcess.</param>
 /// <param name="args">Callback arguments.</param>
 public override void ActOnCallback(MDbgProcess currentProcess, CustomPostCallbackEventArgs args)
 {
 }
Exemplo n.º 5
0
        /// <summary>
        /// Acts on the debugger callback, based on the stop option policy settings and the 
        /// type of exception thrown.
        /// </summary>
        /// <param name="currentProcess">Current MDbgProcess.</param>
        /// <param name="args">Callback arguments.</param>
        public override void ActOnCallback(MDbgProcess currentProcess, CustomPostCallbackEventArgs args)
        {
            CorException2EventArgs ea = args.CallbackArgs as CorException2EventArgs;
            CorExceptionUnwind2EventArgs ua = args.CallbackArgs as CorExceptionUnwind2EventArgs;
            bool bException2 = (ea != null);

            if (m_exceptionEnhancedOn ||
               (bException2 && (ea.EventType == CorDebugExceptionCallbackType.DEBUG_EXCEPTION_FIRST_CHANCE)))
            {
                MDbgThread currentThread = null;
                currentThread = currentProcess.Threads.GetThreadFromThreadId((args.CallbackArgs as CorThreadEventArgs).Thread.Id);

                string exceptionType = null;
                DebuggerBehavior behavior;
                try
                {
                    // Getting the current exception may not be implemented.
                    exceptionType = currentThread.CurrentException.TypeName;
                    behavior = DetermineBehavior(exceptionType);
                }
                catch (NotImplementedException)
                {
                    behavior = this.m_default;
                }

                switch (behavior)
                {
                    case DebuggerBehavior.Stop:
                        if (bException2)
                        {
                            args.Controller.Stop(ea.Thread, new ExceptionThrownStopReason(ea.AppDomain,
                                ea.Thread, ea.Frame, ea.Offset, ea.EventType, ea.Flags, m_exceptionEnhancedOn));
                        }
                        else
                        {
                            args.Controller.Stop(ua.Thread, new ExceptionUnwindStopReason(ua.AppDomain,
                                ua.Thread, ua.EventType, ua.Flags));
                        }
                        break;
                    case DebuggerBehavior.Log:
                        string output = "Exception thrown: " + currentThread.CurrentException.TypeName +
                                        " at function " + currentThread.CurrentFrame.Function.FullName;
                        if (currentThread.CurrentSourcePosition != null)
                        {
                            output += " in source file " + currentThread.CurrentSourcePosition.Path +
                                      ":" + currentThread.CurrentSourcePosition.Line;
                        }
                        CommandBase.WriteOutput(output);
                        if (m_exceptionEnhancedOn)
                        {
                            if (bException2)
                            {
                                CommandBase.WriteOutput("Event type: " + ea.EventType);
                            }
                            else
                            {
                                CommandBase.WriteOutput("Event type: " + ua.EventType);
                            }
                        }
                        CommandBase.WriteOutput("");
                        break;
                }
            }
        }