Example #1
0
        public static MICommandFactory GetInstance(MIMode mode, Debugger debugger)
        {
            MICommandFactory commandFactory;

            switch (mode)
            {
            case MIMode.Gdb:
                commandFactory = new GdbMICommandyFactory();
                break;

            case MIMode.Lldb:
                commandFactory = new LlldbMICommandFactory();
                break;

            case MIMode.Clrdbg:
                commandFactory = new ClrdbgMICommandFactory();
                break;

            default:
                throw new ArgumentException("mode");
            }

            commandFactory._debugger = debugger;
            commandFactory.Mode      = mode;
            commandFactory.Radix     = 10;
            return(commandFactory);
        }
Example #2
0
        internal static bool GetRequiresRootAttach(MIMode mode)
        {
            // If "ptrace_scope" is a value other than 0, only root can attach to arbitrary processes
            if (GetPtraceScope() != 0)
            {
                return(true); // Attaching to any non-child process requires root
            }

            return(false);
        }
Example #3
0
        internal static bool GetRequiresRootAttach(MIMode mode)
        {
            if (mode != MIMode.Clrdbg)
            {
                // If "ptrace_scope" is a value other than 0, only root can attach to arbitrary processes
                if (GetPtraceScope() != 0)
                {
                    return true; // Attaching to any non-child process requires root
                }
            }

            return false;
        }
Example #4
0
        public static MICommandFactory GetInstance(MIMode mode, Debugger debugger)
        {
            MICommandFactory commandFactory;

            switch (mode)
            {
                case MIMode.Gdb:
                    commandFactory = new GdbMICommandFactory();
                    break;
                case MIMode.Lldb:
                    commandFactory = new LlldbMICommandFactory();
                    break;
                case MIMode.Clrdbg:
                    commandFactory = new ClrdbgMICommandFactory();
                    break;
                default:
                    throw new ArgumentException("mode");
            }
            commandFactory._debugger = debugger;
            commandFactory.Mode = mode;
            commandFactory.Radix = 10;
            return commandFactory;
        }
Example #5
0
        public static UnixShellPortLaunchOptions CreateForAttachRequest(Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.IDebugUnixShellPort unixPort,
            int processId,
            MIMode miMode,
            string getClrDbgUrl,
            string remoteDebuggingDirectory,
            string remoteDebuggingSubDirectory,
            string debuggerVersion)
        {
            var @this = new UnixShellPortLaunchOptions(startRemoteDebuggerCommand: null,
                                                       unixPort: unixPort,
                                                       miMode: miMode,
                                                       baseLaunchOptions: null,
                                                       getClrDbgUrl: getClrDbgUrl,
                                                       remoteDebuggerInstallationDirectory: remoteDebuggingDirectory,
                                                       remoteDebuggerInstallationSubDirectory: remoteDebuggingSubDirectory,
                                                       clrdbgVersion: debuggerVersion);

            @this.ProcessId = processId;
            @this.SetupCommands = new ReadOnlyCollection<LaunchCommand>(new LaunchCommand[] { });
            @this.SetInitializationComplete();

            return @this;
        }
Example #6
0
        public UnixShellPortLaunchOptions(string startRemoteDebuggerCommand,
                Microsoft.VisualStudio.Debugger.Interop.UnixPortSupplier.IDebugUnixShellPort unixPort,
                MIMode miMode,
                BaseLaunchOptions baseLaunchOptions,
                string getClrDbgUrl = null,
                string remoteDebuggerInstallationDirectory = null,
                string remoteDebuggerInstallationSubDirectory = null,
                string clrdbgVersion = null)
        {
            this.UnixPort = unixPort;
            this.DebuggerMIMode = miMode;

            if (!string.IsNullOrWhiteSpace(getClrDbgUrl))
            {
                GetClrDbgUrl = getClrDbgUrl;
            }

            if (!string.IsNullOrWhiteSpace(remoteDebuggerInstallationDirectory))
            {
                DebuggerInstallationDirectory = remoteDebuggerInstallationDirectory;
            }

            if (!string.IsNullOrWhiteSpace(remoteDebuggerInstallationSubDirectory))
            {
                ClrDbgInstallationSubDirectory = remoteDebuggerInstallationSubDirectory;
            }

            if (!string.IsNullOrWhiteSpace(clrdbgVersion))
            {
                ClrDbgVersion = clrdbgVersion;
            }

            if (string.IsNullOrEmpty(startRemoteDebuggerCommand))
            {
                switch (miMode)
                {
                    case MIMode.Gdb:
                        startRemoteDebuggerCommand = "gdb --interpreter=mi";
                        break;
                    case MIMode.Lldb:
                        // TODO: Someday we should likely use a download script here too
                        startRemoteDebuggerCommand = "lldb-mi --interpreter=mi";
                        break;
                    case MIMode.Clrdbg:
                        string debuggerHomeDirectory;
                        if (DebuggerInstallationDirectory.StartsWith("/", StringComparison.OrdinalIgnoreCase))
                        {
                            debuggerHomeDirectory = DebuggerInstallationDirectory;
                        }
                        else
                        {
                            string userHomeDirectory = UnixPort.GetUserHomeDirectory();
                            debuggerHomeDirectory = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", userHomeDirectory, DebuggerInstallationDirectory);
                        }

                        if (!HasSuccessfulPreviousLaunch(this))
                        {
                            startRemoteDebuggerCommand = string.Format(CultureInfo.InvariantCulture, ClrdbgFirstLaunchCommand, debuggerHomeDirectory, ClrDbgVersion, ClrDbgInstallationSubDirectory);
                        }
                        else
                        {
                            startRemoteDebuggerCommand = string.Format(CultureInfo.InvariantCulture, ClrdbgSubsequentLaunchCommand, debuggerHomeDirectory, ClrDbgVersion, ClrDbgInstallationSubDirectory);
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("miMode");
                }
            }

            this.StartRemoteDebuggerCommand = startRemoteDebuggerCommand;

            if (baseLaunchOptions != null)
            {
                this.InitializeCommonOptions(baseLaunchOptions);
                this.BaseOptions = baseLaunchOptions;
            }
        }