コード例 #1
0
        public void Attach(IDebugProgram2 program)
        {
            IDebugProcess2 process;

            program.GetProcess(out process);
            Guid processId;

            process.GetProcessId(out processId);


            if (processId != _processId.guidProcessId)
            {
                throw new DebuggerInitializeException("Cannot attach to specified program.");
            }

            EngineUtils.RequireOk(program.GetProgramId(out _programId));

            Task.Run(() =>
            {
                _waiter.WaitOne();

                var ipAddress = new IPAddress(new byte[] { 0x7f, 0x00, 0x00, 0x01 });
                Session.Run(new SoftDebuggerStartInfo(new SoftDebuggerConnectArgs("samp-server", ipAddress, DebuggerAddress.Port)),
                            new DebuggerSessionOptions
                {
                    EvaluationOptions     = EvaluationOptions.DefaultOptions,
                    ProjectAssembliesOnly = false
                });
            });

            MonoEngineCreateEvent.Send(_engine);
            SampSharpCreateEvent.Send(_engine);
        }
コード例 #2
0
        public static int GetProcessId(IDebugProgram2 program)
        {
            IDebugProcess2 process;
            RequireOk(program.GetProcess(out process));

            return GetProcessId(process);
        }
コード例 #3
0
        public static int GetProcessId(IDebugProgram2 program)
        {
            IDebugProcess2 process;

            RequireOk(program.GetProcess(out process));

            return(GetProcessId(process));
        }
コード例 #4
0
        public static AD_PROCESS_ID GetProcessId(IDebugProgram2 program)
        {
            IDebugProcess2 process;

            RequireOk(program.GetProcess(out process));

            return(GetProcessId(process));
        }
コード例 #5
0
        public static IDebugProcess2 GetProcess(this IDebugProgram2 program)
        {
            Contract.Requires <ArgumentNullException>(program != null, "program");

            IDebugProcess2 process;

            ErrorHandler.ThrowOnFailure(program.GetProcess(out process));
            return(process);
        }
コード例 #6
0
ファイル: QmlDebugAD7Program.cs プロジェクト: qt-labs/vstools
        int IDebugEventCallback2.Event(
            IDebugEngine2 pEngine,
            IDebugProcess2 pProcess,
            IDebugProgram2 pProgram,
            IDebugThread2 pThread,
            IDebugEvent2 pEvent,
            ref Guid riidEvent,
            uint dwAttrib)
        {
            if (pEngine == Engine)
            {
                return(VSConstants.S_OK);
            }

            if (pProcess == null && pProgram == null)
            {
                return(VSConstants.S_OK);
            }

            if (pProcess == null)
            {
                if (pProgram.GetProcess(out pProcess) != VSConstants.S_OK || pProcess == null)
                {
                    return(VSConstants.S_OK);
                }
            }

            var pProcessId = new AD_PROCESS_ID[1];

            if (pProcess.GetPhysicalProcessId(pProcessId) != VSConstants.S_OK)
            {
                return(VSConstants.S_OK);
            }

            if (pProcessId[0].dwProcessId != NativeProcId)
            {
                return(VSConstants.S_OK);
            }

            if (riidEvent == typeof(IDebugProgramDestroyEvent2).GUID)
            {
                TerminateProcess();
            }

            return(VSConstants.S_OK);
        }
コード例 #7
0
        public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason)
        {
            Debug.Assert(_program != null);

            IDebugProcess2 process;
            IDebugProgram2 program = rgpPrograms[0];

            EngineUtils.RequireOk(program.GetProcess(out process));

            Guid attachedGuid;

            EngineUtils.RequireOk(program.GetProgramId(out attachedGuid));
            _program.AttachDebugger(attachedGuid);

            Debug.WriteLine("IDebugEngine2.Attach: invoking load callbacks");
            // The SDM will invoke ContinueFromSynchronousEvent with AD7LoadCompleteEvent. At that point,
            // breakpoints from design mode will have already been placed, and the program can be launched.
            _callbacks.OnAttach();

            return(VSConstants.S_OK);
        }
コード例 #8
0
        // Attach the debug engine to a program.
        public int Attach(IDebugProgram2[] portProgramArray, IDebugProgramNode2[] programNodeArray, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason)
        {
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            if (celtPrograms != 1)
            {
                Debug.Fail("SampleEngine only expects to see one program in a process");
                throw new ArgumentException();
            }
            IDebugProgram2 portProgram = portProgramArray[0];

            Exception exception = null;

            try
            {
                IDebugProcess2 process;
                EngineUtils.RequireOk(portProgram.GetProcess(out process));

                AD_PROCESS_ID processId = EngineUtils.GetProcessId(process);

                EngineUtils.RequireOk(portProgram.GetProgramId(out _ad7ProgramId));

                // Attach can either be called to attach to a new process, or to complete an attach
                // to a launched process
                if (_pollThread == null)
                {
                    if (processId.ProcessIdType != (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM)
                    {
                        Debug.Fail("Invalid process to attach to");
                        throw new ArgumentException();
                    }

                    IDebugPort2 port;
                    EngineUtils.RequireOk(process.GetPort(out port));

                    Debug.Assert(_engineCallback == null);
                    Debug.Assert(_debuggedProcess == null);

                    _engineCallback = new EngineCallback(this, ad7Callback);
                    LaunchOptions launchOptions = CreateAttachLaunchOptions(processId.dwProcessId, port);
                    StartDebugging(launchOptions);
                }
                else
                {
                    if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
                    {
                        Debug.Fail("Asked to attach to a process while we are debugging");
                        return(Constants.E_FAIL);
                    }
                }

                AD7EngineCreateEvent.Send(this);
                AD7ProgramCreateEvent.Send(this);
                this.ProgramCreateEventSent = true;

                return(Constants.S_OK);
            }
            catch (Exception e) when(ExceptionHelper.BeforeCatch(e, Logger, reportOnlyCorrupting: true))
            {
                exception = e;
            }

            // If we just return the exception as an HRESULT, we will lose our message, so we instead send up an error event, and
            // return that the attach was canceled
            OnStartDebuggingFailed(exception);
            return(AD7_HRESULT.E_ATTACH_USER_CANCELED);
        }
コード例 #9
0
        private static bool IsDebuggingPythonOnly(IDebugProgram2 program)
        {
            IDebugProcess2 process;
            program.GetProcess(out process);

            IEnumDebugPrograms2 enumPrograms;
            process.EnumPrograms(out enumPrograms);

            while (true) {
                IDebugProgram2[] programs = new IDebugProgram2[1];
                uint fetched = 0;
                if (enumPrograms.Next(1, programs, ref fetched) != VSConstants.S_OK || fetched != 1 || programs[0] == null) {
                    break;
                }

                string engineName;
                Guid engineGuid;
                programs[0].GetEngineInfo(out engineName, out engineGuid);
                if (engineGuid != AD7Engine.DebugEngineGuid) {
                    return false;
                }
            }

            return true;
        }
コード例 #10
0
ファイル: QmlDebugLauncher.cs プロジェクト: qt-labs/vstools
        int IDebugEventCallback2.Event(
            IDebugEngine2 pEngine,
            IDebugProcess2 pProcess,
            IDebugProgram2 pProgram,
            IDebugThread2 pThread,
            IDebugEvent2 pEvent,
            ref Guid riidEvent,
            uint dwAttrib)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (!QtVsToolsPackage.Instance.Options.QmlDebuggerEnabled)
            {
                return(VSConstants.S_OK);
            }

            if (riidEvent != typeof(IDebugThreadCreateEvent2).GUID &&
                riidEvent != typeof(IDebugProgramDestroyEvent2).GUID)
            {
                return(VSConstants.S_OK);
            }

            if (pProcess == null && pProgram.GetProcess(out pProcess) != VSConstants.S_OK)
            {
                return(VSConstants.S_OK);
            }

            if (pProcess.GetProcessId(out Guid procGuid) != VSConstants.S_OK)
            {
                return(VSConstants.S_OK);
            }

            // Run only once per process
            if (riidEvent == typeof(IDebugProgramDestroyEvent2).GUID)
            {
                ExcludedProcesses.Remove(procGuid);
                return(VSConstants.S_OK);
            }
            else if (ExcludedProcesses.Contains(procGuid))
            {
                return(VSConstants.S_OK);
            }
            else
            {
                ExcludedProcesses.Add(procGuid);
            }

            if (!(pEvent is IDebugLoadCompleteEvent2 || pEvent is IDebugThreadCreateEvent2))
            {
                return(VSConstants.S_OK);
            }

            if (pProgram == null)
            {
                return(VSConstants.S_OK);
            }

            bool native;
            Guid engineId = GetEngineId(pProgram);

            if (engineId == NativeEngine.Id)
            {
                native = true;
            }
            else if (engineId == GdbEngine.Id)
            {
                native = false;
            }
            else
            {
                return(VSConstants.S_OK);
            }

            if (!GetProcessInfo(pProcess, native, out string execPath, out uint procId))
            {
                return(VSConstants.S_OK);
            }

            if (!GetProjectInfo(execPath, native, out string execCmd, out IEnumerable <string> rccItems))
            {
                return(VSConstants.S_OK);
            }

            LaunchDebug(execPath, execCmd, procId, rccItems);
            return(VSConstants.S_OK);
        }
コード例 #11
0
 int IDebugProgram3.GetProcess(out IDebugProcess2 ppProcess)
 {
     return(IDebugProgram2.GetProcess(out ppProcess));
 }
コード例 #12
0
        int IDebugEventCallback2.Event(
            IDebugEngine2 pEngine,
            IDebugProcess2 pProcess,
            IDebugProgram2 pProgram,
            IDebugThread2 pThread,
            IDebugEvent2 pEvent,
            ref Guid riidEvent,
            uint dwAttrib)
        {
            if (!(pEvent is IDebugLoadCompleteEvent2 || pEvent is IDebugThreadCreateEvent2))
            {
                return(VSConstants.S_OK);
            }

            if (pProgram == null)
            {
                return(VSConstants.S_OK);
            }

            if (pProcess == null && pProgram.GetProcess(out pProcess) != VSConstants.S_OK)
            {
                return(VSConstants.S_OK);
            }

            bool native;
            Guid engineId = GetEngineId(pProgram);

            if (engineId == NativeEngine.Id)
            {
                native = true;
            }
            else if (engineId == GdbEngine.Id)
            {
                native = false;
            }
            else
            {
                return(VSConstants.S_OK);
            }

            if (pEvent is IDebugLoadCompleteEvent2)
            {
                started = false;
            }
            else if (started)
            {
                return(VSConstants.S_OK);
            }

            string execPath;
            uint   procId;

            if (!GetProcessInfo(pProcess, native, out execPath, out procId))
            {
                return(VSConstants.S_OK);
            }

            string execCmd;
            IEnumerable <string> rccItems;

            if (!GetProjectInfo(execPath, native, out execCmd, out rccItems))
            {
                return(VSConstants.S_OK);
            }

            started = true;

            LaunchDebug(execPath, execCmd, procId, rccItems);
            return(VSConstants.S_OK);
        }