public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib) { if (riidEvent == typeof(IDebugProgramCreateEvent2).GUID) { Guid processId; // A program was created and attached if (pProcess != null) { if (VSConstants.S_OK == pProcess.GetProcessId(out processId)) { DkmProcess dkmProcess = DkmProcess.FindProcess(processId); if (dkmProcess != null) { var debugTrigger = DkmExceptionCodeTrigger.Create(DkmExceptionProcessingStage.Thrown, null, DkmExceptionCategory.Win32, RemoteDebugStartExceptionCode); var attachTrigger = DkmExceptionCodeTrigger.Create(DkmExceptionProcessingStage.Thrown, null, DkmExceptionCategory.Win32, RemoteDebugAttachExceptionCode); // Try to add exception trigger for when a remote debugger server is started for Python dkmProcess.AddExceptionTrigger(RemoteDebugExceptionGuid, debugTrigger); dkmProcess.AddExceptionTrigger(RemoteDebugExceptionGuid, attachTrigger); } } } } return(VSConstants.S_OK); }
public DkmCustomMessage SendLower(DkmCustomMessage customMessage) { try { Debug.Assert(customMessage.SourceId == PackageServices.VsDebuggerMessageGuid); VsDebuggerMessage code = (VsDebuggerMessage)customMessage.MessageCode; switch (code) { case VsDebuggerMessage.EnableChildProcessDebugging: Guid processGuid = (Guid)customMessage.Parameter1; DkmProcess process = DkmProcess.FindProcess(processGuid); if (process != null) { process.SetDataItem( DkmDataCreationDisposition.CreateNew, new RuntimeBreakpointHandler()); process.SetDataItem( DkmDataCreationDisposition.CreateNew, new AutoAttachToChildHandler()); Logger.LogInfo( "Successfully delay-enabled child debugging for process {0}.", processGuid); } else { Logger.LogError( "Unable to find process {0} while trying to enable child process debugging.", processGuid); } break; default: Logger.LogError("Debug component received unknown message code {0}.", code); break; } } catch (DkmException exception) { Logger.LogError( exception, "An error occurred while handling a debugger message. HR = 0x{0:X}", exception.HResult); } return(null); }