Exemple #1
0
        public void AttachToProcess(long pid, DebuggerSessionOptions sessionOptions)
        {
            Report.Initialize();

            this.SessionOptions = sessionOptions;
            DebuggerConfiguration config = new DebuggerConfiguration();

            mdbAdaptor.Configuration = config;
            mdbAdaptor.InitializeConfiguration();
            config.LoadConfiguration();
            debugger = new MD.Debugger(config);

            DebuggerOptions options = DebuggerOptions.ParseCommandLine(new string[0]);

            options.StopInMain = false;
            session            = new MD.DebuggerSession(config, options, "main", (IExpressionParser)null);
            mdbAdaptor.Session = session;

            Process proc = debugger.Attach(session, (int)pid);

            OnInitialized(debugger, proc);

            ST.ThreadPool.QueueUserWorkItem(delegate {
                NotifyStarted();
            });
        }
 public EmonicInterpreter(DebuggerConfiguration config,
                          DebuggerOptions options)
     : base(true, config, options)
 {
     DebuggerEngine = new EmonicDebuggerEngine(this);
     thisReference  = this;
 }
Exemple #3
0
        public async Task <AttachDebugUIResult> AttachAsync(char[] Password, DebuggerOptions Options)
        {
            var requestParameters = new RequestParameters("attachDebugUI");

            var request = Context.NewSessionRequest <RDBGAttachDebugUIRequest>();

            //if (password.length > 0)
            //{
            //    var credentials = StringUtils.toByteArray(password);
            //    request.setCredentials(credentials);
            //}
            request.Options = Options;

            var response = await Executor.ExecuteAsync <RDBGAttachDebugUIResponse>(request, requestParameters);

            var result = response.Result;

            //Logger.LogDebug("Debug attach result is {result}", Result);

            lock (this)
            {
                Attached = result.Equals(AttachDebugUIResult.Registered);

                if (Attached)
                {
                    StartTimer();
                }
            }

            return(result);
        }
Exemple #4
0
        private DebuggerOptions CreateDebuggerOptions()
        {
            var opts = new DebuggerOptions(this);

            opts.Load();
            return(opts);
        }
Exemple #5
0
 public ProjectOptions(DebuggerOptions debugger, VisualizerOptions visualizer, SliceVisualizerOptions slice, VisualizerAppearance appearance, DebugVisualizer.ColumnStylingOptions styling)
 {
     DebuggerOptions         = debugger;
     VisualizerOptions       = visualizer;
     SliceVisualizerOptions  = slice;
     VisualizerAppearance    = appearance;
     VisualizerColumnStyling = styling;
 }
        private static DebuggerOptions CreateOptions(string application, string[] args)
        {
            DebuggerOptions options = DebuggerOptions.ParseCommandLine(args);

            options.IsScript     = true;
            options.File         = application;
            options.InferiorArgs = args;

            return(options);
        }
        public void FromAgentOptionsThrows_Both()
        {
            var agentOptions = new AgentOptions
            {
                ApplicationId           = _processId,
                ApplicationStartCommand = _startCmd
            };

            Assert.Throws <ArgumentException>(() => DebuggerOptions.FromAgentOptions(agentOptions));
        }
        internal ProcessStart(DebuggerSession session, int pid)
        {
            this.session = session;
            this.options = session.Options;
            this.PID     = pid;

            stop_in_main = options.StopInMain;

            IsNative = true;
        }
Exemple #9
0
        internal PythonToolsService(IServiceContainer container)
        {
            _container = container;

            var langService = new PythonLanguageInfo(container);

            _container.AddService(langService.GetType(), langService, true);

            IVsTextManager textMgr = (IVsTextManager)container.GetService(typeof(SVsTextManager));

            if (textMgr != null)
            {
                var langPrefs = new LANGPREFERENCES[1];
                langPrefs[0].guidLang = typeof(PythonLanguageInfo).GUID;
                ErrorHandler.ThrowOnFailure(textMgr.GetUserPreferences(null, null, langPrefs, null));
                _langPrefs = new LanguagePreferences(this, langPrefs[0]);

                Guid             guid = typeof(IVsTextManagerEvents2).GUID;
                IConnectionPoint connectionPoint;
                ((IConnectionPointContainer)textMgr).FindConnectionPoint(ref guid, out connectionPoint);
                connectionPoint.Advise(_langPrefs, out _langPrefsTextManagerCookie);
            }

            _optionsService = (IPythonToolsOptionsService)container.GetService(typeof(IPythonToolsOptionsService));
            var compModel = (IComponentModel)container.GetService(typeof(SComponentModel));

            _interpreterRegistry = compModel.GetService <IInterpreterRegistryService>();
            if (_interpreterRegistry != null)
            {
                _interpreterRegistry.InterpretersChanged += InterpretersChanged;
            }

            _interpreterOptionsService = compModel.GetService <IInterpreterOptionsService>();
            if (_interpreterOptionsService != null)     // not available in some test cases...
            {
                _interpreterOptionsService.DefaultInterpreterChanged += UpdateDefaultAnalyzer;
                LoadInterpreterOptions();
            }

            _idleManager              = new IdleManager(container);
            _advancedOptions          = new AdvancedEditorOptions(this);
            _debuggerOptions          = new DebuggerOptions(this);
            _generalOptions           = new GeneralOptions(this);
            _surveyNews               = new SurveyNewsService(container);
            _suppressDialogOptions    = new SuppressDialogOptions(this);
            _globalInterpreterOptions = new GlobalInterpreterOptions(this, _interpreterOptionsService, _interpreterRegistry);
            _globalInterpreterOptions.Load();
            _interactiveOptions = new PythonInteractiveOptions(this, "Interactive");
            _interactiveOptions.Load();
            _debugInteractiveOptions = new PythonInteractiveOptions(this, "Debug Interactive Window");
            _debuggerOptions.Load();
            _factoryProviders = ComponentModel.DefaultExportProvider.GetExports <IPythonInterpreterFactoryProvider, Dictionary <string, object> >();
            _logger           = new PythonToolsLogger(ComponentModel.GetExtensions <IPythonToolsLogger>().ToArray());
            InitializeLogging();
        }
Exemple #10
0
        internal CommandLineInterpreter(DebuggerOptions options, bool is_interactive)
        {
            if (options.HasDebugFlags)
            {
                Report.Initialize(options.DebugOutput, options.DebugFlags);
            }
            else
            {
                Report.Initialize();
            }

            Configuration = new DebuggerConfiguration();
#if HAVE_XSP
            if (options.StartXSP)
            {
                Configuration.SetupXSP();
            }
            else
            {
                Configuration.LoadConfiguration();
            }
#else
            Configuration.LoadConfiguration();
#endif

            Configuration.SetupCLI();

            interpreter     = new Interpreter(is_interactive, Configuration, options);
            interpreter.CLI = this;

            engine = interpreter.DebuggerEngine;
            parser = new LineParser(engine);

            if (!interpreter.IsScript)
            {
                line_editor = new LineEditor("mdb");

                line_editor.AutoCompleteEvent += delegate(string text, int pos) {
                    return(engine.Completer.Complete(text, pos));
                };

                Console.CancelKeyPress += control_c_event;
            }

            interrupt_event          = new ST.AutoResetEvent(false);
            nested_break_state_event = new ST.AutoResetEvent(false);

            main_loop_stack = new Stack <MainLoop> ();
            main_loop_stack.Push(new MainLoop(interpreter));

            main_thread = new ST.Thread(new ST.ThreadStart(main_thread_main));
            main_thread.IsBackground = true;
        }
Exemple #11
0
        public static void Main(string[] args)
        {
            DebuggerOptions options = DebuggerOptions.ParseCommandLine(args);

            Console.WriteLine("Mono Debugger");

            CommandLineInterpreter interpreter = new CommandLineInterpreter(options, true);

            interpreter.RunMainLoop();

            interpreter.Configuration.SaveConfiguration();
        }
        internal ProcessStart(ProcessStart parent, int pid)
        {
            this.PID = pid;

            this.session  = parent.session;
            this.options  = parent.options;
            this.cwd      = parent.cwd;
            this.argv     = parent.argv;
            this.base_dir = parent.base_dir;

            SetupEnvironment();
        }
        public void FromAgentOptions()
        {
            var agentOptions = new AgentOptions
            {
                ApplicationId = _processId,
            };
            var options = DebuggerOptions.FromAgentOptions(agentOptions);

            Assert.False(options.PropertyEvaluation);
            Assert.False(options.MethodEvaluation);
            Assert.Null(options.ApplicationStartCommand);
            Assert.Equal(_processId, options.ApplicationId);
            Assert.StartsWith(Constants.PipeName, options.PipeName);
        }
        public void ToString_StartCommand()
        {
            var agentOptions = new AgentOptions
            {
                ApplicationStartCommand = _startCmd,
            };
            var options       = DebuggerOptions.FromAgentOptions(agentOptions);
            var optionsString = options.ToString();

            Assert.Contains($"{DebuggerOptions.PipeNameOption}={Constants.PipeName}", optionsString);
            Assert.Contains($"{DebuggerOptions.ApplicationStartCommandOption}=\"{_startCmd}\"", optionsString);
            Assert.DoesNotContain(DebuggerOptions.PropertyEvaluationOption, optionsString);
            Assert.DoesNotContain(DebuggerOptions.MethodEvaluationOption, optionsString);
            Assert.DoesNotContain(DebuggerOptions.ApplicationIdOption, optionsString);
        }
        public void FromAgentOptions_ConditionEval()
        {
            var agentOptions = new AgentOptions
            {
                ApplicationStartCommand = _startCmd,
                MethodEvaluation        = true
            };
            var options = DebuggerOptions.FromAgentOptions(agentOptions);

            Assert.False(options.PropertyEvaluation);
            Assert.True(options.MethodEvaluation);
            Assert.Null(options.ApplicationId);
            Assert.Equal(_startCmd, options.ApplicationStartCommand);
            Assert.StartsWith(Constants.PipeName, options.PipeName);
        }
        protected DebuggerTestFixture(string exe_file, string src_file, params string[] args)
        {
            ExeFileName = Path.GetFullPath(Path.Combine(BuildDirectory, exe_file));
            FileName    = Path.GetFullPath(Path.Combine(SourceDirectory, src_file));

            config = new DebuggerConfiguration();
            config.RedirectOutput = true;

            config.SetupCLI();

            options = CreateOptions(ExeFileName, args);

            inferior_stdout = new LineReader();
            inferior_stderr = new LineReader();
        }
Exemple #17
0
        private DebuggerService(string[] args)
        {
            mono_debugger_server_static_init();

            bool is_interactive = true;

            DebuggerConfiguration config = new DebuggerConfiguration();

            config.LoadConfiguration();

            DebuggerOptions options = DebuggerOptions.ParseCommandLine(args);

            if (options.HasDebugFlags)
            {
                Report.Initialize(options.DebugOutput, options.DebugFlags);
            }
            else
            {
                Report.Initialize();
            }

            // Redirect the Reporter output stream   HACK: Using reflection
            reporterOutput = new MemoryStream();
            FieldInfo    writerField = typeof(ReportWriter).GetField("writer", BindingFlags.NonPublic | BindingFlags.Instance);
            StreamWriter writer      = new StreamWriter(reporterOutput);

            writer.AutoFlush = true;
            writerField.SetValue(Report.ReportWriter, writer);
            // Redirect the console
            //Console.SetOut(writer);
            //Console.SetError(writer);

            interpreter = new GuiInterpreter(this, is_interactive, config, options);
            engine      = interpreter.DebuggerEngine;
            parser      = new LineParser(engine);

            this.breakpointsStore = new BreakpointsStore(this, interpreter);
            this.callstackStore   = new CallstackStore(this, interpreter);
            this.localsStore      = new LocalsStore(this, interpreter);
            this.threadsStore     = new ThreadsStore(this, interpreter);

            if (interpreter.Options.StartTarget)
            {
                interpreter.Start();
            }

            NotifyStateChange();
        }
        public void SetupApplication(string exe_file, string cwd, string[] cmdline_args)
        {
            this.cwd = cwd;

            cmdline_args [0] = exe_file;
            this.argv        = cmdline_args;

            base_dir = GetFullPath(Path.GetDirectoryName(argv [0]));

            options                  = options.Clone();
            options.File             = exe_file;
            options.InferiorArgs     = cmdline_args;
            options.WorkingDirectory = cwd;

            SetupEnvironment();
        }
Exemple #19
0
        public void StartMdb(string cmdLine)
        {
            string[] args = cmdLine.Split(' ');
            DebuggerConfiguration config = new DebuggerConfiguration();

            config.LoadConfiguration();
            DebuggerOptions options = DebuggerOptions.ParseCommandLine(args);

            System.Console.WriteLine("Mono Debugger");
            EmonicLineInterpreter interpreter = new EmonicLineInterpreter(config, options);

            interpreter.RunMainLoop();
            // we don't want an automatic breakpoint in Main(), and we want to be able
            // to set a breakpoint there, so we delete the automatic one
            EmonicLineInterpreter.AddCmd("delete 1");
        }
        public void ToString_ApplicationId()
        {
            var agentOptions = new AgentOptions
            {
                ApplicationId      = _processId,
                PropertyEvaluation = true,
                MethodEvaluation   = true,
            };
            var options       = DebuggerOptions.FromAgentOptions(agentOptions);
            var optionsString = options.ToString();

            Assert.Contains($"{DebuggerOptions.PipeNameOption}={Constants.PipeName}", optionsString);
            Assert.Contains($"{DebuggerOptions.ApplicationIdOption}={_processId}", optionsString);
            Assert.Contains($"{DebuggerOptions.PropertyEvaluationOption}", optionsString);
            Assert.Contains($"{DebuggerOptions.MethodEvaluationOption}", optionsString);
            Assert.DoesNotContain(DebuggerOptions.ApplicationStartCommandOption, optionsString);
        }
Exemple #21
0
        internal PythonToolsService(IServiceContainer container)
        {
            _container = container;

            var langService = new PythonLanguageInfo(container);

            _container.AddService(langService.GetType(), langService, true);

            _langPrefs = new Lazy <LanguagePreferences>(() => new LanguagePreferences(this, typeof(PythonLanguageInfo).GUID));

            _optionsService = (IPythonToolsOptionsService)container.GetService(typeof(IPythonToolsOptionsService));
            var compModel = (IComponentModel)container.GetService(typeof(SComponentModel));

            _interpreterRegistry = compModel.GetService <IInterpreterRegistryService>();
            if (_interpreterRegistry != null)
            {
                _interpreterRegistry.InterpretersChanged += InterpretersChanged;
            }

            _interpreterOptionsService = compModel.GetService <IInterpreterOptionsService>();
            if (_interpreterOptionsService != null)     // not available in some test cases...
            {
                _interpreterOptionsService.DefaultInterpreterChanged += UpdateDefaultAnalyzer;
                LoadInterpreterOptions();
            }

            _idleManager              = new IdleManager(container);
            _advancedOptions          = new AdvancedEditorOptions(this);
            _debuggerOptions          = new DebuggerOptions(this);
            _generalOptions           = new GeneralOptions(this);
            _surveyNews               = new SurveyNewsService(container);
            _suppressDialogOptions    = new SuppressDialogOptions(this);
            _globalInterpreterOptions = new GlobalInterpreterOptions(this, _interpreterOptionsService, _interpreterRegistry);
            _globalInterpreterOptions.Load();
            _interactiveOptions = new PythonInteractiveOptions(this, "Interactive");
            _interactiveOptions.Load();
            _debugInteractiveOptions = new PythonInteractiveOptions(this, "Debug Interactive Window");
            _debuggerOptions.Load();
            _factoryProviders = ComponentModel.DefaultExportProvider.GetExports <IPythonInterpreterFactoryProvider, Dictionary <string, object> >();
            _logger           = new PythonToolsLogger(ComponentModel.GetExtensions <IPythonToolsLogger>().ToArray());
            InitializeLogging();
        }
        public EmonicLineInterpreter(DebuggerConfiguration config, DebuggerOptions options)
        {
            if (options.HasDebugFlags)
            {
                Report.Initialize(options.DebugOutput, options.DebugFlags);
            }
            else
            {
                Report.Initialize();
            }

            interpreter = new EmonicInterpreter(config, options);
            engine      = interpreter.DebuggerEngine;
            parser      = new LineParser(engine);
            main_thread = new ST.Thread(new System.Threading.ThreadStart(main_thread_main));
            main_thread.IsBackground = true;

            command_thread = new ST.Thread(new ST.ThreadStart(command_thread_main));
            command_thread.IsBackground = true;
        }
Exemple #23
0
        public Interpreter(bool is_interactive, DebuggerConfiguration config,
                           DebuggerOptions options)
        {
            this.config         = config;
            this.is_interactive = is_interactive;
            this.is_script      = options.IsScript;
            this.parser         = new ExpressionParser(this);
            this.session        = new DebuggerSession(config, options, "main", parser);
            this.engine         = new DebuggerEngine(this);

            parser.Session = session;

            source_factory = new SourceFileFactory();

            interrupt_event = new ManualResetEvent(false);
            process_event   = new ManualResetEvent(false);

            styles = new Hashtable();
            styles.Add("cli", new StyleCLI(this));
            styles.Add("emacs", new StyleEmacs(this));
            current_style = (StyleBase)styles ["cli"];
        }
        internal NUnitInterpreter(DebuggerConfiguration config, DebuggerOptions options,
                                  LineReader inferior_stdout, LineReader inferior_stderr)
            : base(false, config, options)
        {
            this.inferior_stdout = inferior_stdout;
            this.inferior_stderr = inferior_stderr;

            config.FollowFork = true;

            queue      = Queue.Synchronized(new Queue());
            wait_event = new ST.ManualResetEvent(false);

            Style = style_nunit = new StyleNUnit(this);
            style_nunit.TargetEventEvent += delegate(Thread thread, TargetEventArgs args) {
                if (IgnoreThreadCreation && (args.Type == TargetEventType.TargetExited))
                {
                    return;
                }
                AddEvent(new DebuggerEvent(DebuggerEventType.TargetEvent, thread, args));
            };

            ST.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            ObjectFormatter.WrapLines = false;
        }
Exemple #25
0
 protected override void OnInitialized()
 {
     options = VolatileSettings.DebuggerOptions;
     logger  = VolatileSettings.DebuggerLog;
 }
Exemple #26
0
        public void Run(MonoDebuggerStartInfo startInfo, DebuggerSessionOptions sessionOptions)
        {
            try {
                if (startInfo == null)
                {
                    throw new ArgumentNullException("startInfo");
                }

                Console.WriteLine("MDB version: " + mdbAdaptor.MdbVersion);

                this.SessionOptions  = sessionOptions;
                mdbAdaptor.StartInfo = startInfo;

                Report.Initialize();

                DebuggerConfiguration config = new DebuggerConfiguration();
                config.LoadConfiguration();
                mdbAdaptor.Configuration = config;
                mdbAdaptor.InitializeConfiguration();

                debugger = new MD.Debugger(config);

                debugger.ModuleLoadedEvent   += OnModuleLoadedEvent;
                debugger.ModuleUnLoadedEvent += OnModuleUnLoadedEvent;

                debugger.ProcessReachedMainEvent += delegate(MD.Debugger deb, MD.Process proc) {
                    OnInitialized(deb, proc);
                };

                if (startInfo.IsXsp)
                {
                    mdbAdaptor.SetupXsp();
                    config.FollowFork = false;
                }
                config.OpaqueFileNames = false;

                DebuggerOptions options = DebuggerOptions.ParseCommandLine(new string[] { startInfo.Command });
                options.WorkingDirectory     = startInfo.WorkingDirectory;
                Environment.CurrentDirectory = startInfo.WorkingDirectory;
                options.StopInMain           = false;

                if (!string.IsNullOrEmpty(startInfo.Arguments))
                {
                    options.InferiorArgs = ToArgsArray(startInfo.Arguments);
                }

                if (startInfo.EnvironmentVariables != null)
                {
                    foreach (KeyValuePair <string, string> env in startInfo.EnvironmentVariables)
                    {
                        options.SetEnvironment(env.Key, env.Value);
                    }
                }
                session            = new MD.DebuggerSession(config, options, "main", null);
                mdbAdaptor.Session = session;
                mdbAdaptor.InitializeSession();

                ST.ThreadPool.QueueUserWorkItem(delegate {
                    // Run in a thread to avoid a deadlock, since NotifyStarted calls back to the client.
                    NotifyStarted();
                    debugger.Run(session);
                });
            } catch (Exception e) {
                Console.WriteLine("error: " + e.ToString());
                throw;
            }
        }
        internal ProcessStart(DebuggerSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException();
            }

            this.session = session;
            this.options = session.Options;

#if HAVE_XSP
            if (options.StartXSP)
            {
                options.File = BuildInfo.xsp;
            }
#endif

            if ((options.File == null) || (options.File == ""))
            {
                throw new ArgumentException("options.File null or empty", "options");
            }
            if (options.InferiorArgs == null)
            {
                throw new ArgumentException("InferiorArgs null", "options");
            }

            stop_in_main    = options.StopInMain;
            redirect_output = session.Config.RedirectOutput;

            cwd = options.WorkingDirectory;
            if (cwd == null)
            {
                cwd = options.WorkingDirectory = System.Environment.CurrentDirectory;
            }
            string mono_path = options.MonoPath ?? MonoPath;

#if HAVE_XSP
            if (options.StartXSP)
            {
                IsNative = false;

                ArrayList start_argv = new ArrayList();
                start_argv.Add(mono_path);
                start_argv.Add("--inside-mdb");
                if (options.JitOptimizations != null)
                {
                    start_argv.Add("--optimize=" + options.JitOptimizations);
                }
                if (options.JitArguments != null)
                {
                    start_argv.AddRange(options.JitArguments);
                }
                start_argv.Add(BuildInfo.xsp);
                start_argv.Add("--nonstop");
                if (options.XSP_Root != null)
                {
                    start_argv.Add("--root");
                    start_argv.Add(options.XSP_Root);
                }

                this.argv = new string [options.InferiorArgs.Length + start_argv.Count];
                start_argv.CopyTo(this.argv, 0);
                if (options.InferiorArgs.Length > 0)
                {
                    options.InferiorArgs.CopyTo(this.argv, start_argv.Count);
                }
            }
            else
#endif
            if (IsMonoAssembly(options.File))
            {
                IsNative = false;

                ArrayList start_argv = new ArrayList();
                start_argv.Add(mono_path);
                start_argv.Add("--inside-mdb");
                if (options.JitOptimizations != null)
                {
                    start_argv.Add("--optimize=" + options.JitOptimizations);
                }
                if (options.JitArguments != null)
                {
                    start_argv.AddRange(options.JitArguments);
                }

                this.argv = new string [options.InferiorArgs.Length + start_argv.Count + 1];
                start_argv.CopyTo(this.argv, 0);
                argv [start_argv.Count] = options.File;
                options.InferiorArgs.CopyTo(this.argv, start_argv.Count + 1);
            }
            else
            {
                IsNative = true;

                this.argv = new string [options.InferiorArgs.Length + 1];
                argv [0]  = options.File;
                options.InferiorArgs.CopyTo(this.argv, 1);
            }

            if (!File.Exists(options.File))
            {
                throw new TargetException(TargetError.CannotStartTarget,
                                          "No such file or directory: `{0}'",
                                          options.File);
            }

            try {
                base_dir = GetFullPath(Path.GetDirectoryName(options.File));
            } catch {
                throw new TargetException(TargetError.CannotStartTarget,
                                          "Invalid directory: `{0}'", options.File);
            }

            SetupEnvironment();
        }
Exemple #28
0
 public GuiInterpreter(DebuggerService debuggerService, bool is_interactive, DebuggerConfiguration config, DebuggerOptions options)
     : base(is_interactive, config, options)
 {
     this.debuggerService = debuggerService;
 }
 public PythonDebugOptionsService(IServiceProvider serviceProvider)
 {
     debugOptions = ((PythonToolsService)serviceProvider
                     .GetService(typeof(PythonToolsService))).DebuggerOptions;
 }
 public void FromAgentOptionsThrows_None() =>
 Assert.Throws <ArgumentException>(() => DebuggerOptions.FromAgentOptions(new AgentOptions()));
Exemple #31
0
		public GuiInterpreter(DebuggerService debuggerService, bool is_interactive, DebuggerConfiguration config, DebuggerOptions options)
			:base(is_interactive, config, options)
		{
			this.debuggerService = debuggerService;
		}