Exemplo n.º 1
0
        private static void process_Exception(CorExceptionEventArgs ev)
        {
            Console.WriteLine("Exception hit.");

            DisplayException(ev);
            DisplayCallstack(ev.thread);

            ProcessCommand((ev.Controller is CorProcess) ? (CorProcess)ev.Controller : ((CorAppDomain)ev.Controller).GetProcess());
        }
Exemplo n.º 2
0
        void OnPostDebugEvent(object sender, CustomPostCallbackEventArgs e)
        {
            if (e.CallbackType == ManagedCallbackType.OnProcessExit)
            {
                ReportDebugTermination();
            }

            if (e.CallbackType == ManagedCallbackType.OnBreakpoint || e.CallbackType == ManagedCallbackType.OnBreak || e.CallbackType == ManagedCallbackType.OnStepComplete)
            {
                if (GetCurrentSourcePosition() == null)
                {
                    MessageQueue.AddNotification(NppCategory.State + "NOSOURCEBREAK"); //can be caused by 'Debugger.Break();'
                }
            }

            if (e.CallbackType == ManagedCallbackType.OnLogMessage)
            {
                var args = e.CallbackArgs as CorLogMessageEventArgs;
                ReportLogMessage(args.Message);
            }

            if (breakOnException && e.CallbackType == ManagedCallbackType.OnException)
            {
                string position = GetCurrentSourcePosition();

                CorExceptionEventArgs args = (CorExceptionEventArgs)e.CallbackArgs;

                string info = SerializeException(args.Thread.CurrentException).Replace("\r\n", "\n").Replace("\n", "{$NL}");

                if (position != null)
                {
                    if (!position.Contains("css_dbg.cs|")) //If it is a script launcher then just ignore it.
                    {
                        bool isDifferentThread = SwitchToThread(args.Thread);
                        if (!isDifferentThread)
                        {
                            BreakAndReport();
                            MessageQueue.AddNotification(NppCategory.Exception + "user+:User code Exception.{$NL}Location: " + position + "{$NL}" + info);
                        }
                    }
                }
                else
                {
                    MessageQueue.AddNotification(NppCategory.Exception + "user-:Non-user code Exception." + "{$NL}" + info);
                    BreakAndReport();
                }
            }

            WriteOutput("meta=>", e.CallbackType.ToString());
            ReportBreakMode();
        }
Exemplo n.º 3
0
        private static void DisplayException(CorExceptionEventArgs ev)
        {
            Console.WriteLine("Display Exception:");
            ConsoleColor oldcolor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Red;

            CorException exception = ev.thread.CurrentException;

            Console.WriteLine("Name: " + exception.Name);
            Console.WriteLine("Type: " + (ev.unHandled == 0 ? "First Chance Exception": "Second Chance Exception"));

            Console.ForegroundColor = oldcolor;
            Console.WriteLine();
        }
        /// <summary>
        /// Handle the Debug Event of the MDbgProcess.
        /// </summary>
        void MDbgProcess_PostDebugEvent(object sender, CustomPostCallbackEventArgs e)
        {
            this.stopReason = e.CallbackType;

            switch (this.stopReason)
            {
            case ManagedCallbackType.OnException:
                CorExceptionEventArgs exceptionEventArgs =
                    e.CallbackArgs as CorExceptionEventArgs;
                this.isExceptionUnhandled =
                    exceptionEventArgs != null && exceptionEventArgs.Unhandled;
                break;

            default:
                break;
            }
        }