Esempio n. 1
0
        // O2.Debugger.Mdbg.OriginalMdbgCode.mdbg.mdbgCommandsCustomizedForO2
        // , O2Thread.FuncVoid<string> o2Callback)
        public static bool AttachCmd(string arguments, O2Thread.FuncVoidT1 <string> o2Callback)
        {
            try
            {
                var ap = new ArgParser(arguments);
                if (ap.Count > 1)
                {
                    DI.log.error("in AttachCmd: Wrong # of arguments.");
                    return(false);
                }

                if (!ap.Exists(0))
                {
                    DI.log.error("in AttachCmd: Please choose some process to attach");
                    MdbgCommands.ProcessEnumCmd("");
                    return(false);
                }
                int pid = ap.AsInt(0);

                if (Process.GetCurrentProcess().Id == pid)
                {
                    DI.log.error("in AttachCmd: Cannot attach to myself!");
                    return(false);
                }

                MDbgProcess p = CommandBase.Debugger.Attach(pid);
                p.Go().WaitOne();
                return(true);
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in AttachCmd");
                return(false);
            }
        }
Esempio n. 2
0
        protected virtual void PrintStartupLogo()
        {
            string myVersion = GetBinaryVersion();

            IO.WriteOutput(MDbgOutputConstants.StdOutput,
                           "MDbg (Managed debugger) v" + myVersion + " started.\n");
            IO.WriteOutput(MDbgOutputConstants.StdOutput,
                           "Copyright (C) Microsoft Corporation. All rights reserved.\n");
            IO.WriteOutput(MDbgOutputConstants.StdOutput,
                           "\nFor information about commands type \"help\";\nto exit program type \"quit\".\n\n");

            // Check for and output any debugging warnings
            try
            {
                (new CorDebugger(CorDebugger.GetDefaultDebuggerVersion())).CanLaunchOrAttach(0, false);
                MdbgCommands.LoadCmd("gui");
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                IO.WriteOutput(MDbgOutputConstants.StdOutput, "WARNING: " + e.Message + "\n\n");
            }
        }
Esempio n. 3
0
        public static void DeleteCmd(string arguments, O2Thread.FuncVoidT1 <string> o2Callback)

        {
            var ap = new ArgParser(arguments);

            if (ap.Count != 1)
            {
                CommandBase.WriteOutput("Please choose some breakpoint to delete");
                MdbgCommands.BreakCmd("");
                return;
            }

            MDbgBreakpoint breakpoint = CommandBase.Debugger.Processes.Active.Breakpoints[ap.AsInt(0)];

            if (breakpoint == null)
            {
                throw new MDbgShellException("Could not find breakpint #:" + ap.AsInt(0));
            }
            else
            {
                breakpoint.Delete();
            }
        }
Esempio n. 4
0
        //////////////////////////////////////////////////////////////////////////////////
        //
        // Customization methods (to be overriden in aditional skins).
        //
        //////////////////////////////////////////////////////////////////////////////////

        protected virtual void Init(string[] commandLineArguments)
        {
            string[] initialCommands = null;

            // process startup commands
            if (commandLineArguments.Length != 0)
            {
                ArrayList startupCommands = new ArrayList();
                if (commandLineArguments[0].Length > 1 && commandLineArguments[0][0] == '!')
                {
                    // ! commands on command line
                    int i = 0;
                    while (i < commandLineArguments.Length)
                    {
                        StringBuilder sb = new StringBuilder();
                        Debug.Assert(commandLineArguments[i][0] == '!');
                        sb.Append(commandLineArguments[i].Substring(1));
                        ++i;
                        while (i < commandLineArguments.Length &&
                               !(commandLineArguments[i].Length > 1 && commandLineArguments[i][0] == '!'))
                        {
                            sb.Append(' ');
                            sb.Append(commandLineArguments[i]);
                            ++i;
                        }
                        startupCommands.Add(sb.ToString());
                    }
                }
                else
                {
                    // it is name of executable on the command line
                    StringBuilder sb = new StringBuilder("run");
                    for (int i = 0; i < commandLineArguments.Length; i++)
                    {
                        sb.Append(' ');
                        string arg = commandLineArguments[i];
                        if (arg.IndexOf(' ') != -1)
                        {
                            // argument contains spaces, need to quote it
                            sb.Append('\"').Append(arg).Append('\"');
                        }
                        else
                        {
                            sb.Append(arg);
                        }
                    }
                    startupCommands.Add(sb.ToString());
                }

                initialCommands = (string[])startupCommands.ToArray(typeof(string));
            }

            this.IO = new MDbgIO(this, initialCommands);

            MdbgCommands.Shell = this;

            m_debugger = new MDbgEngine();
            MdbgCommands.Initialize();

            OnCommandExecuted += new CommandExecutedEventHandler(MdbgCommands.WhenHandler);

            ProcessAutoExec();
        }