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

            stopOptions.ActOnCallback(sender as MDbgProcess, e);
        }
 /// <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);
 /// <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)
 {
 }
        /// <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)
        {
            var ea = args.CallbackArgs as CorException2EventArgs;
            var 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 = currentThread.CurrentException.TypeName;

                switch (DetermineBehavior(exceptionType))
                {
                    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:
                        CommandBase.WriteOutput("Exception thrown: " + currentThread.CurrentException.TypeName +
                                                " at function " + currentThread.CurrentFrame.Function.FullName +
                                                " in source file " + currentThread.CurrentSourcePosition.Path +
                                                ":" + currentThread.CurrentSourcePosition.Line);
                        if (m_exceptionEnhancedOn)
                        {
                            if (bException2)
                            {
                                CommandBase.WriteOutput("Event type: " + ea.EventType);
                            }
                            else
                            {
                                CommandBase.WriteOutput("Event type: " + ua.EventType);
                            }
                        }
                        CommandBase.WriteOutput("");
                        break;
                }
            }
        }
 /// <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)
 {
     var 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 + "\n");
             break;
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Acts on debugger callback based on the contained stop option policies matching
 /// the callback type.
 /// </summary>
 /// <param name="currentProcess">Current MDbgProcess.</param>
 /// <param name="args">Debugger callback arguments.</param>
 public void ActOnCallback(MDbgProcess currentProcess, CustomPostCallbackEventArgs args)
 {
     if (m_stopOptions[(int) args.CallbackType] != null)
     {
         foreach (MDbgStopOptionPolicy sop in m_stopOptions[(int) args.CallbackType])
         {
             sop.ActOnCallback(currentProcess, args);
         }
     }
 }