Ejemplo n.º 1
0
        public static void ModeCmd(string arguments)
        {
            // get mode settings first
            var modeSettings = Shell.Properties[MDbgModeSettings.PropertyName]
                               as MDbgModeSettings;
            Debug.Assert(modeSettings != null);
            if (modeSettings == null)
                throw new MDbgShellException("corrupted internal state.");


            var ap = new ArgParser(arguments);
            if (!ap.Exists(0))
            {
                WriteOutput("Debugging modes:");
                foreach (MDbgModeItem item in modeSettings.Items)
                {
                    WriteOutput(string.Format(CultureInfo.InvariantCulture, "({0}) {1}: {2}", item.ShortCut,
                                              item.Description.PadRight(50), item.OnOff ? "On" : "Off"));
                }
            }
            else
            {
                bool on = ap.AsCommand(1, new CommandArgument("on", "off")) == "on";
                string shortcut = ap.AsString(0);

                // now find the correct modeItem
                MDbgModeItem item = null;
                foreach (MDbgModeItem i in modeSettings.Items)
                    if (i.ShortCut == shortcut)
                    {
                        item = i;
                        break;
                    }
                if (item == null)
                    throw new MDbgShellException("Invalid mode option.  Modes are in (here).");

                item.OnOff = on;
            }
        }
Ejemplo n.º 2
0
        /*
         * We want to have following commnads:
         *
         * symbol path "value"    -- sets symbol paths
         * symbol addpath "value" -- adds symbol path
         * symbol reload [module] -- reloads symbol for a module
         * symbol list [module]   -- shows currently loaded symbols
         */
        public static void SymbolCmd(string arguments)
        {
            var ap = new ArgParser(arguments);
            if (!ap.Exists(0))
            {
                ExecuteCommand("help symbol");
                return;
            }
            switch (ap.AsCommand(0, new CommandArgument("path", "addpath", "reload", "list")))
            {
                case "path":
                    if (!ap.Exists(1))
                    {
                        // we want to print current path
                        string p = Debugger.Options.SymbolPath;
                        WriteOutput("Current symbol path: " + p);
                    }
                    else
                    {
                        // we are setting path
                        Debugger.Options.SymbolPath = ap.AsString(1);
                        WriteOutput("Current symbol path: " + Debugger.Options.SymbolPath);
                    }
                    break;

                case "addpath":
                    Debugger.Options.SymbolPath = Debugger.Options.SymbolPath + Path.PathSeparator + ap.AsString(1);
                    WriteOutput("Current symbol path: " + Debugger.Options.SymbolPath);
                    break;

                case "reload":
                    {
                        IEnumerable modules;
                        if (ap.Exists(1))
                        {
                            // we want to reload only one module

                            MDbgModule m = Debugger.Processes.Active.Modules.Lookup(ap.AsString(1));
                            if (m == null)
                            {
                                throw new MDbgShellException("No such module.");
                            }
                            modules = new[] {m};
                        }
                        else
                        {
                            modules = Debugger.Processes.Active.Modules;
                        }

                        foreach (MDbgModule m in modules)
                        {
                            WriteOutput("Reloading symbols for module " + m.CorModule.Name);
                            m.ReloadSymbols(true);
                            WriteModuleStatus(m, true);
                        }
                    }
                    break;
                case "list":
                    {
                        IEnumerable modules;
                        if (ap.Exists(1))
                        {
                            // we want to list only one module
                            MDbgModule m = Debugger.Processes.Active.Modules.Lookup(ap.AsString(1));
                            if (m == null)
                            {
                                throw new MDbgShellException("No such module.");
                            }
                            modules = new[] {m};
                        }
                        else
                        {
                            modules = Debugger.Processes.Active.Modules;
                        }

                        foreach (MDbgModule m in modules)
                        {
                            WriteModuleStatus(m, false);
                        }
                    }
                    break;
                default:
                    Debug.Assert(false);
                    break;
            }
        }
Ejemplo n.º 3
0
        public static void ConfigCmd(string arguments)
        {
            const string extPathCmd = "extpath";
            const string extPathAddCmd = "extpath+";

            var ap = new ArgParser(arguments);
            if (!ap.Exists(0))
            {
                WriteOutput("Current configuration:");
                WriteOutput(string.Format("\tExtensionPath={0}", ExtensionPath));
                return;
            }

            switch (ap.AsCommand(0, new CommandArgument(extPathCmd, extPathAddCmd)))
            {
                case extPathCmd:
                    ExtensionPath = ap.AsString(1);
                    PrintExt:
                    WriteOutput(string.Format("ExtensionPath={0}", ExtensionPath));
                    break;
                case extPathAddCmd:
                    ExtensionPath = ExtensionPath + Path.PathSeparator + ap.AsString(1);
                    goto PrintExt;
                default:
                    Debug.Assert(false);
                    break;
            }
        }
Ejemplo n.º 4
0
        public static void ListCmd(string arguments)
        {
            const string verboseOpt = "v";
            bool bVerbose;
            var ap = new ArgParser(arguments, verboseOpt);
            string listWhat = ap.AsCommand(0, new CommandArgument("modules", "appdomains", "assemblies"));
            switch (listWhat)
            {
                case "modules":
                    bVerbose = ap.OptionPassed(verboseOpt);
                    if (ap.Exists(1))
                    {
                        // user specified module to display info for
                        MDbgModule m = Debugger.Processes.Active.Modules.Lookup(ap.AsString(1));
                        if (m == null)
                        {
                            throw new MDbgShellException("No such module.");
                        }
                        ListModuleInternal(m, true);
                    }
                    else
                    {
                        // we list all modules
                        WriteOutput("Loaded Modules:");
                        foreach (MDbgModule m in Debugger.Processes.Active.Modules)
                        {
                            ListModuleInternal(m, bVerbose);
                        }
                    }
                    break;
                case "appdomains":
                    WriteOutput("Current appDomains:");
                    foreach (MDbgAppDomain ad in Debugger.Processes.Active.AppDomains)
                    {
                        WriteOutput(ad.Number + ". - " + ad.CorAppDomain.Name);
                    }
                    break;

                case "assemblies":
                    WriteOutput("Current assemblies:");
                    foreach (MDbgAppDomain ad in Debugger.Processes.Active.AppDomains)
                    {
                        foreach (CorAssembly assem in ad.CorAppDomain.Assemblies)
                        {
                            WriteOutput("\t" + assem.Name);
                        }
                    }

                    break;
                default:
                    Debug.Assert(false);
                    break;
            }
        }