Ejemplo n.º 1
0
        public override void Attach(System.Diagnostics.Process existingProcess)
        {
            if (existingProcess == null)
            {
                return;
            }

            if (IsDebugging)
            {
                MessageService.ShowMessage(errorDebugging);
                return;
            }
            if (!ServiceInitialized)
            {
                InitializeService();
            }

            string version = CurrentDebugger.GetProgramVersion(existingProcess.MainModule.FileName);

            if (version.StartsWith("v1.0"))
            {
                MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}");
            }
            else
            {
                OnDebugStarting(EventArgs.Empty);

                UpdateBreakpointLines();

                try {
                    CurrentProcess = CurrentDebugger.Attach(existingProcess);
                    debugger_ProcessStarted();
                    attached = true;
                    CurrentProcess.ModuleLoaded += process_Modules_Added;
                } catch (System.Exception e) {
                    // CORDBG_E_DEBUGGER_ALREADY_ATTACHED
                    if (e is COMException || e is UnauthorizedAccessException)
                    {
                        string msg = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.CannotAttachToProcess}");
                        MessageService.ShowMessage(msg + " " + e.Message);

                        OnDebugStopped(EventArgs.Empty);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void Start(ProcessStartInfo processStartInfo)
        {
            if (IsDebugging)
            {
                MessageService.ShowMessage(errorDebugging);
                return;
            }
            if (!ServiceInitialized)
            {
                InitializeService();
            }

            string version = CurrentDebugger.GetProgramVersion(processStartInfo.FileName);

            if (version.StartsWith("v1.0"))
            {
                MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}");
            }
            else if (version.StartsWith("v1.1"))
            {
                MessageService.ShowMessage(StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.Net10NotSupported}").Replace("1.0", "1.1"));
//			} else if (string.IsNullOrEmpty(version)) {
//				// Not a managed assembly
//				MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.BadAssembly}");
            }
            else if (CurrentDebugger.IsKernelDebuggerEnabled)
            {
                MessageService.ShowMessage("${res:XML.MainMenu.DebugMenu.Error.KernelDebuggerEnabled}");
            }
            else
            {
                attached = false;
                OnDebugStarting(EventArgs.Empty);

                UpdateBreakpointLines();

                try {
                    CurrentProcess = CurrentDebugger.Start(processStartInfo.FileName, processStartInfo.WorkingDirectory, processStartInfo.Arguments, this.BreakAtBeginning);
                    debugger_ProcessStarted();
                } catch (System.Exception e) {
                    // COMException: The request is not supported. (Exception from HRESULT: 0x80070032)
                    // COMException: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1)
                    // COMException: The requested operation requires elevation. (Exception from HRESULT: 0x800702E4)
                    // COMException: The directory name is invalid. (Exception from HRESULT: 0x8007010B)
                    // BadImageFormatException:  is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
                    // UnauthorizedAccessException: Отказано в доступе. (Исключение из HRESULT: 0x80070005 (E_ACCESSDENIED))
                    if (e is COMException || e is BadImageFormatException || e is UnauthorizedAccessException)
                    {
                        string msg = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.CannotStartProcess}");
                        msg += " " + e.Message;
                        if (e is COMException && ((uint)((COMException)e).ErrorCode == 0x80070032))
                        {
                            msg += Environment.NewLine + Environment.NewLine;
                            msg += "64-bit debugging is not supported.  Please set Project -> Project Options... -> Compiling -> Target CPU to 32bit.";
                        }
                        MessageService.ShowMessage(msg);

                        OnDebugStopped(EventArgs.Empty);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }