Example #1
0
        private MessageResult DoAttach(AttachMessage message)
        {
            int hr = _debugger.AttachProcess(
                Defaults.NoServer,
                (uint)message.ProcessId,
                DEBUG_ATTACH.DEFAULT);

            if (hr != HResult.Ok)
                return new AttachMessageResult($"Error attaching to process: {hr.ToString("X8")}");

            hr = _control.WaitForEvent(DEBUG_WAIT.DEFAULT, uint.MaxValue);
            if (hr != HResult.Ok)
                return new AttachMessageResult($"Error attaching debugger: {hr.ToString("X8")}");

            var process = Process.GetProcessById(message.ProcessId);
            if (process == null)
                return new AttachMessageResult($"Error reading process info.");

            hr = InitializeSources(_options.SourcePaths);
            if (hr != HResult.Ok)
                return new AttachMessageResult($"Error setting source paths: {hr.ToString("X8")}");

            var moduleName = GetModuleName(out hr);
            if (hr != HResult.Ok)
                return new AttachMessageResult($"Error reading main module name: {hr.ToString("X8")}");

            hr = InitializeSymbols(process.StartInfo.FileName, _options.SymbolPaths);
            if (hr != HResult.Ok)
                return new AttachMessageResult($"Error setting symbol paths: {hr.ToString("X8")}");

            hr = ForceLoadSymbols(moduleName);
            if (hr != HResult.Ok)
                return new AttachMessageResult($"Error loading debug symbols: {hr.ToString("X8")}");

            SetDebugSettings();
            CreateProcessInfo((uint)message.ProcessId);
            InitializeVisualizers();

            return new AttachMessageResult();
        }
Example #2
0
        private MessageResult DoAttach(AttachMessage message)
        {
            int hr = _debugger.AttachProcess(
                Defaults.NoServer,
                (uint)message.ProcessId,
                DEBUG_ATTACH.DEFAULT);

            if (hr != HResult.Ok)
            {
                return(new AttachMessageResult($"Error attaching to process: {hr.ToString("X8")}"));
            }

            hr = _control.WaitForEvent(DEBUG_WAIT.DEFAULT, uint.MaxValue);
            if (hr != HResult.Ok)
            {
                return(new AttachMessageResult($"Error attaching debugger: {hr.ToString("X8")}"));
            }

            var process = Process.GetProcessById(message.ProcessId);

            if (process == null)
            {
                return(new AttachMessageResult($"Error reading process info."));
            }

            hr = ForceLoadSymbols(process.StartInfo.FileName);
            if (hr != HResult.Ok)
            {
                return(new AttachMessageResult($"Error loading debug symbols: {hr.ToString("X8")}"));
            }

            SetDebugSettings();
            PostInitialize();

            return(new AttachMessageResult());
        }