コード例 #1
0
ファイル: DbgEngDataReader.cs プロジェクト: xinyanmsft/clrmd
        public DbgEngDataReader(int pid, AttachFlag flags, uint msecTimeout)
        {
            IDebugClient client = CreateIDebugClient();

            CreateClient(client);

            DEBUG_ATTACH attach = flags == AttachFlag.Invasive ? DEBUG_ATTACH.DEFAULT : DEBUG_ATTACH.NONINVASIVE;
            int          hr     = _control.AddEngineOptions(DEBUG_ENGOPT.INITIAL_BREAK);

            if (hr == 0)
            {
                hr = client.AttachProcess(0, (uint)pid, attach);
            }

            if (hr == 0)
            {
                hr = _control.WaitForEvent(0, msecTimeout);
            }

            if (hr == 1)
            {
                throw new TimeoutException("Break in did not occur within the allotted timeout.");
            }

            if (hr != 0)
            {
                if ((uint)hr == 0xd00000bb)
                {
                    throw new InvalidOperationException("Mismatched architecture between this process and the target process.");
                }

                throw new ClrDiagnosticsException($"Could not attach to pid {pid:X}, HRESULT: 0x{hr:x8}", ClrDiagnosticsExceptionKind.DebuggerError, hr);
            }
        }
コード例 #2
0
ファイル: dbgengdatatarget.cs プロジェクト: modulexcite/msos
        public DbgEngDataReader(int pid, AttachFlag flags, uint msecTimeout)
        {
            IDebugClient client = CreateIDebugClient();

            CreateClient(client);

            DEBUG_ATTACH attach = (flags == AttachFlag.Invasive) ? DEBUG_ATTACH.DEFAULT : DEBUG_ATTACH.NONINVASIVE;
            int          hr     = m_control.AddEngineOptions(DEBUG_ENGOPT.INITIAL_BREAK);

            if (hr == 0)
            {
                hr = client.AttachProcess(0, (uint)pid, attach);
            }

            if (hr == 0)
            {
                hr = m_control.WaitForEvent(0, msecTimeout);
            }

            if (hr == 1)
            {
                throw new TimeoutException("Break in did not occur within the allotted timeout.");
            }
            else if (hr != 0)
            {
                throw new ClrDiagnosticsException(String.Format("Could not attach to pid {0:X}, HRESULT: 0x{1:x8}", pid, hr), ClrDiagnosticsException.HR.DebuggerError);
            }
        }