Ejemplo n.º 1
0
        // returns true if the CustomPostCallback requested stop.
        private bool HandleCustomPostCallback(ManagedCallbackType callbackType, CorEventArgs callbackArgs)
        {
            bool stopRequested = false;
            bool needAsyncStopCall = false;
            if (!needAsyncStopCall)
            {
                Threads.RefreshStack();
            }


            using (var psc = new MDbgProcessStopController(this, callbackArgs, needAsyncStopCall))
            {
                if (PostDebugEvent != null)
                {
                    PostDebugEvent(this, new CustomPostCallbackEventArgs(psc, callbackType, callbackArgs));
                    stopRequested = psc.CustomStopRequested;
                }
            } // end using

            return stopRequested;
        }
Ejemplo n.º 2
0
        private void EvalExceptionEventHandler(Object sender, CorEvalEventArgs e)
        {
            OriginalMDbgMessages.WriteLine("ManagedCallback::EvalException");
            if (InternalHandleRawMode(ManagedCallbackType.OnEvalException, e))
                return;

            // custom eval handling
            if (customEvals != null
                && customEvals.Contains(e.Eval))
            {
                using (var psc = new MDbgProcessStopController(this, e, false))
                {
                    var handler = (customEvals[e.Eval] as CustomEvalEventHandler);
                    customEvals.Remove(e.Eval);
                    handler(this, new CustomEvalEventArgs(psc, e, CustomEvalEventArgs.EvalCallbackType.EvalException));
                }
                return; // this was custom eval, no additional action necessary.
            }

            e.Continue = false;
            InternalSignalRuntimeIsStopped(e.Thread, new EvalExceptionStopReason(e.Eval));
        }
Ejemplo n.º 3
0
        private void StepCompleteEventHandler(Object sender, CorStepCompleteEventArgs e)
        {
            OriginalMDbgMessages.WriteLine("ManagedCallback::StepComplete");
            if (InternalHandleRawMode(ManagedCallbackType.OnStepComplete, e))
                return;

            // custom stepper handling
            if (customSteppers != null
                && customSteppers.Contains(e.Stepper))
            {
                using (var psc = new MDbgProcessStopController(this, e, false))
                {
                    var handler = (customSteppers[e.Stepper] as CustomStepperEventHandler);
                    customSteppers.Remove(e.Stepper);
                    handler(this, new CustomStepCompleteEventArgs(psc, e));
                }

                return; // this was custom stepper, no additional action necessary.
            }

            // we need to deliver step complete for cordbg skin, so that we can print
            // enhanced diagnostics. 
            if (HandleCustomPostCallback(ManagedCallbackType.OnStepComplete, e))
                return;

            // we will stop only if this callback is from our own stepper.
            if (e.Stepper == m_activeStepper)
            {
                m_activeStepper = null;
                e.Continue = false;
                InternalSignalRuntimeIsStopped(e.Thread, new StepCompleteStopReason(e.Stepper, e.StepReason));
            }
        }
Ejemplo n.º 4
0
        //////////////////////////////////////////////////////////////////////////////////
        //
        // Callbacks implementation
        //
        //////////////////////////////////////////////////////////////////////////////////

        private void BreakpointEventHandler(Object sender, CorBreakpointEventArgs e)
        {
         /*   if (DI.o2MDbg.AutoContinueOnBreakPointEvent)
            {
                O2MDbgUtils.setCurrentLocationFromActiveThread();
                return;         // DC (if this is set means some other breakpoint handler has already processed this and set the e.Continue flag to true
            }*/
            OriginalMDbgMessages.WriteLine("ManagedCallback::Breakpoint");
            if (InternalHandleRawMode(ManagedCallbackType.OnBreakpoint, e))
                return;

            // custom breakpoint handling. All normal MDbg shell breakpoints (including our user breakpoint)
            // register their own handlers here, so this is the very common case.
            if (customBreakpoints != null
                && customBreakpoints.Contains(e.Breakpoint))
            {
                using (var psc = new MDbgProcessStopController(this, e, false))
                {
                    var handler = (customBreakpoints[e.Breakpoint] as CustomBreakpointEventHandler);

                    // Invoke custom callback handler. This may stop the shell.                    
                    handler(this, new CustomBreakpointEventArgs(psc, e));
                }
                return; // this was custom breakpoint, no additional action necessary.
            }

            // We have an unknown breakpoint that no handler was registered for. This should be a very
            // uncommon case and indicate some bug in MDbg or an extension.
            e.Continue = false;
            InternalSignalRuntimeIsStopped(e.Thread, "Unexpected raw breakpoint hit");
        }
Ejemplo n.º 5
0
        private void EvalCompleteEventHandler(Object sender, CorEvalEventArgs e)
        {
            Trace.WriteLine("ManagedCallback::EvalComplete");
            BeginManagedDebugEvent();
            try
            {
                if (InternalHandleRawMode(ManagedCallbackType.OnEvalComplete, e))
                    return;

                // custom eval handling
                if (customEvals != null
                    && customEvals.Contains(e.Eval))
                {
                    using (MDbgProcessStopController psc = new MDbgProcessStopController(this, e, false))
                    {
                        CustomEvalEventHandler handler = (customEvals[e.Eval] as CustomEvalEventHandler);
                        customEvals.Remove(e.Eval);
                        handler(this, new CustomEvalEventArgs(psc, e, CustomEvalEventArgs.EvalCallbackType.EvalComplete));
                    }
                    return;         // this was custom eval, no additional action necessary.
                }

                e.Continue = false;
                InternalSignalRuntimeIsStopped(e.Thread, new EvalCompleteStopReason(e.Eval));
            }
            finally
            {
                EndManagedDebugEvent(e);
            }
        }
Ejemplo n.º 6
0
        private void BreakpointEventHandler(Object sender, CorBreakpointEventArgs e)
        {
            Trace.WriteLine("ManagedCallback::Breakpoint");
            BeginManagedDebugEvent();
            try
            {
                if (InternalHandleRawMode(ManagedCallbackType.OnBreakpoint, e))
                    return;

                bool fHandled = false;

                // custom breakpoint handling. All normal MDbg shell breakpoints (including our user breakpoint)
                // register their own handlers here, so this is the very common case.
                if (customBreakpoints != null
                    && customBreakpoints.Contains(e.Breakpoint))
                {
                    using (MDbgProcessStopController psc = new MDbgProcessStopController(this, e, false))
                    {
                        CustomBreakpointEventHandler handler = (customBreakpoints[e.Breakpoint] as CustomBreakpointEventHandler);

                        // Invoke custom callback handler. This may stop the shell.
                        handler(this, new CustomBreakpointEventArgs(psc, e));
                    }
                    fHandled = true;
                }

                if (HandleCustomPostCallback(ManagedCallbackType.OnBreakpoint, e))
                {
                    return;
                }

                if (fHandled)
                {
                    return;         // this was custom breakpoint, no additional action necessary.
                }

                // We have an unknown breakpoint that no handler was registered for. This should be a very
                // uncommon case and indicate some bug in MDbg or an extension.
                e.Continue = false;
                InternalSignalRuntimeIsStopped(e.Thread, "Unexpected raw breakpoint hit");
            }
            finally
            {
                EndManagedDebugEvent(e);
            }
        }