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();
            });
        }
        private static DebuggerOptions CreateOptions(string application, string[] args)
        {
            DebuggerOptions options = DebuggerOptions.ParseCommandLine(args);

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

            return(options);
        }
Exemple #3
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();
        }
Exemple #4
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();
        }
Exemple #5
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");
        }
Exemple #6
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;
            }
        }