Example #1
0
        void IDkmExceptionTriggerHitNotification.OnExceptionTriggerHit(DkmExceptionTriggerHit hit, DkmEventDescriptorS eventDescriptor)
        {
            ThreadHelper.JoinableTaskFactory.Run(async() => {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                var exceptionInfo = hit.Exception as VisualStudio.Debugger.Native.DkmWin32ExceptionInformation;

                if (exceptionInfo.Code == RemoteDebugStartExceptionCode)
                {
                    // Parameters expected are the flag to indicate the debugger is present and JSON to write to the target for configuration
                    // of the debugger
                    const int exceptionParameterCount = 3;

                    if (exceptionInfo.ExceptionParameters.Count == exceptionParameterCount)
                    {
                        // If we have a port and debug id, we'll go ahead and tell the client we are present
                        if (Instance.AttachRemoteProcessFunction != null && Instance.RemoteDebugCommandInfo != null)
                        {
                            if (Instance.RemoteDebugCommandInfo.Length <= (int)exceptionInfo.ExceptionParameters[2])
                            {
                                // Write back that debugger is present
                                hit.Process.WriteMemory(exceptionInfo.ExceptionParameters[0], BitConverter.GetBytes(true));

                                // Write back the details of the debugger arguments
                                hit.Process.WriteMemory(exceptionInfo.ExceptionParameters[1], Instance.RemoteDebugCommandInfo);
                            }
                        }
                    }
                }
                else if (exceptionInfo.Code == RemoteDebugAttachExceptionCode)
                {
                    // Parameters expected are the flag to indicate the debugger is present and XML to write to the target for configuration
                    // of the debugger
                    const int exceptionAttachParameterCount = 1;

                    if (exceptionInfo.ExceptionParameters.Count == exceptionAttachParameterCount)
                    {
                        // If we have a port and debug id, we'll go ahead and tell the client we are present
                        if (Instance.AttachRemoteProcessFunction != null)
                        {
                            // Write back that debugger is present
                            hit.Process.WriteMemory(exceptionInfo.ExceptionParameters[0], BitConverter.GetBytes(true));

                            // Start the task to attach to the remote Python debugger session
                            StartAttachRemoteProcess();
                        }
                    }
                }
            });

            eventDescriptor.Suppress();
        }
Example #2
0
        void IDkmExceptionTriggerHitNotification.OnExceptionTriggerHit(DkmExceptionTriggerHit hit, DkmEventDescriptorS eventDescriptor) {
            ThreadHelper.Generic.Invoke(() => {
                var exceptionInfo = hit.Exception as VisualStudio.Debugger.Native.DkmWin32ExceptionInformation;

                if (exceptionInfo.Code == RemoteDebugStartExceptionCode) {
                    // Parameters expected are the flag to indicate the debugger is present and JSON to write to the target for configuration
                    // of the debugger
                    const int exceptionParameterCount = 3;

                    if (exceptionInfo.ExceptionParameters.Count == exceptionParameterCount) {
                        // If we have a port and debug id, we'll go ahead and tell the client we are present
                        if (Instance.AttachRemoteProcessFunction != null && Instance.RemoteDebugCommandInfo != null) {
                            if (Instance.RemoteDebugCommandInfo.Length <= (int)exceptionInfo.ExceptionParameters[2]) {
                                // Write back that debugger is present
                                hit.Process.WriteMemory(exceptionInfo.ExceptionParameters[0], BitConverter.GetBytes(true));

                                // Write back the details of the debugger arguments
                                hit.Process.WriteMemory(exceptionInfo.ExceptionParameters[1], Instance.RemoteDebugCommandInfo);
                            }
                        }
                    }
                } else if (exceptionInfo.Code == RemoteDebugAttachExceptionCode) {
                    // Parameters expected are the flag to indicate the debugger is present and XML to write to the target for configuration
                    // of the debugger
                    const int exceptionAttachParameterCount = 1;

                    if (exceptionInfo.ExceptionParameters.Count == exceptionAttachParameterCount) {
                        // If we have a port and debug id, we'll go ahead and tell the client we are present
                        if (Instance.AttachRemoteProcessFunction != null) {
                            // Write back that debugger is present
                            hit.Process.WriteMemory(exceptionInfo.ExceptionParameters[0], BitConverter.GetBytes(true));

                            // Start the task to attach to the remote Python debugger session
                            System.Threading.Tasks.Task.Factory.StartNew(Instance.AttachRemoteProcessFunction);
                        }
                    }
                }
            });

            eventDescriptor.Suppress();
        }