示例#1
0
        public override bool Execute(CommandArguments args, IPermissible sender)
        {
            var name = args.NextString();
            if (string.IsNullOrEmpty(name))
                return false;

            if (name.Length < AccountManager.MinNameLength || name.Length > AccountManager.MaxNameLength)
                return false;

            var password = args.NextString();
            if (string.IsNullOrEmpty(password))
                return false;

            if (password.Length < AccountManager.MinPasswordLength || password.Length > AccountManager.MaxPasswordLength)
                return false;

            var email = args.NextString();
            if (string.IsNullOrEmpty(email))
                return false;

            var box = args.NextEnum<ClientBoxLevel>() ?? ClientBoxLevel.Cataclysm;
            var locale = args.NextEnum<ClientLocale>() ?? ClientLocale.English;

            AccountManager.Instance.CreateAccount(name, password, email, box, locale);
            return true;
        }
示例#2
0
        public void Execute(CommandArguments args)
        {
            var op = args.NextString(string.Empty);

            switch (op.ToLower())
            {
                case "start":
                    var fileName = args.NextString();

                    try
                    {
                        Logger.LogOutput = new StreamWriter(fileName, true);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLine("Could not open log file {0}: {1}", fileName, ex.Message);
                    }
                    return;
                case "stop":
                    Logger.LogOutput.Dispose();
                    Logger.LogOutput = null;
                    return;
            }

            Logger.WriteErrorLine("Unknown log operation: {0}", op);
        }
示例#3
0
        public void Execute(CommandArguments args)
        {
            var expr = args.NextString();

            var backtrace = SoftDebugger.Backtrace;

            if (backtrace == null)
            {
                Logger.WriteErrorLine("No backtrace available.");
                return;
            }

            var frame = backtrace.CurrentStackFrame;

            if (frame == null)
            {
                Logger.WriteErrorLine("No stack frame available.");
                return;
            }

            try
            {
                var result = frame.GetExpressionValue(expr, true);
                Logger.WriteInfoLine("[{0}] {1}", result.TypeName, result.DisplayValue);
            }
            catch (Exception)
            {
                Logger.WriteErrorLine("Error in expression.");
            }
        }
示例#4
0
        public void Execute(CommandArguments args)
        {
            var path = args.NextString();

            if (SoftDebugger.State.IsStarted())
            {
                Logger.WriteErrorLine("A process is already active.");
                return;
            }

            string progArg;
            var progArgs = string.Empty;
            while ((progArg = args.NextString(string.Empty)) != string.Empty)
                progArgs += progArg + " ";

            if (SoftDebugger.Start(path, progArgs))
                CommandLine.Suspended = true;
        }
示例#5
0
        public override bool Execute(CommandArguments args, IPermissible sender)
        {
            var fileName = args.NextString();
            if (string.IsNullOrEmpty(fileName))
                return false;

            AccountApplication.Instance.AccountDbContext.Post(x => x.Schema.Export(fileName));

            return true;
        }
示例#6
0
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var name     = args.NextString();
            var password = args.NextString();
            var email    = args.NextString();
            var box      = args.NextEnum <ClientBoxLevel>(ClientBoxLevel.Cataclysm);
            var locale   = args.NextEnum <ClientLocale>(ClientLocale.English);

            if (string.IsNullOrEmpty(name))
            {
                sender.Respond("No name given.");
                return;
            }

            if (name.Length < Constants.Accounts.MinNameLength || name.Length > Constants.Accounts.MaxNameLength)
            {
                sender.Respond("Name must be between {0} and {1} characters long.".Interpolate(Constants.Accounts.MinNameLength,
                                                                                               Constants.Accounts.MaxNameLength));
                return;
            }

            if (string.IsNullOrEmpty(password))
            {
                sender.Respond("No password given.");
                return;
            }

            if (password.Length < Constants.Accounts.MinPasswordLength || password.Length > Constants.Accounts.MaxPasswordLength)
            {
                sender.Respond("Password must be between {0} and {1} characters long.".Interpolate(Constants.Accounts.MinPasswordLength,
                                                                                                   Constants.Accounts.MaxPasswordLength));
                return;
            }

            if (string.IsNullOrEmpty(email))
            {
                sender.Respond("No email given.");
                return;
            }

            AccountManager.Instance.PostAsync(x => x.CreateAccount(name, password, email, box, locale));
        }
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var fileName = args.NextString();
            if (string.IsNullOrEmpty(fileName))
            {
                sender.Respond("No file name given.");
                return;
            }

            AccountApplication.Instance.AccountDbContext.PostAsync(x => x.Schema.Export(fileName));
        }
 public void Execute(CommandArguments args)
 {
     if (args.HasArguments)
     {
         var dir = args.NextString();
         SoftDebugger.WorkingDirectory = dir;
         Logger.WriteInfoLine("Changed working directory: {0}", dir);
     }
     else
         Logger.WriteInfoLine("Current working directory: {0}", SoftDebugger.WorkingDirectory);
 }
示例#9
0
        public void Execute(CommandArguments args)
        {
            var op = args.NextString(string.Empty);

            if (SoftDebugger.State == DebuggerState.Null)
            {
                Logger.WriteErrorLine("No session active.");
                return;
            }

            var session = SoftDebugger.Session;

            switch (op.ToLower())
            {
                case "add":
                    var excName = args.NextString();
                    session.Breakpoints.AddCatchpoint(excName);

                    Logger.WriteInfoLine("Added catchpoint for exception: {0}", excName);
                    return;
                case "del":
                    var delExcName = args.NextString();
                    session.Breakpoints.RemoveCatchpoint(delExcName);

                    Logger.WriteInfoLine("Deleted catchpoint for exception: {0}", delExcName);
                    return;
                case "clear":
                    session.Breakpoints.ClearCatchpoints();

                    Logger.WriteInfoLine("Cleared all catchpoints.");
                    return;
                case "":
                    Logger.WriteInfoLine("Catchpoints:");

                    foreach (var cp in session.Breakpoints.GetCatchpoints())
                        Logger.WriteInfoLine("{0}", cp.ExceptionName);
                    return;
            }

            Logger.WriteErrorLine("Unknown catchpoint operation: {0}", op);
        }
示例#10
0
        public override void Execute(CommandArguments args, ICommandUser sender)
        {
            var fileName = args.NextString();

            if (string.IsNullOrEmpty(fileName))
            {
                sender.Respond("No file name given.");
                return;
            }

            AccountApplication.Instance.AccountDbContext.PostAsync(x => x.Schema.Export(fileName));
        }
示例#11
0
        public void Execute(CommandArguments args)
        {
            var op = args.NextString();

            if (SoftDebugger.State == DebuggerState.Null)
            {
                Logger.WriteErrorLine("No session active.");
                return;
            }

            if (SoftDebugger.State == DebuggerState.Initialized)
            {
                Logger.WriteErrorLine("No process active.");
                return;
            }

            var breakpoints = SoftDebugger.Session.Breakpoints;
            var fileName = SoftDebugger.CurrentExecutable.FullName + ".sdb";

            switch (op.ToLower())
            {
                case "save":
                    using (var writer = XmlWriter.Create(fileName))
                    {
                        breakpoints.Save().WriteTo(writer);
                        writer.Flush();
                    }
                    return;
                case "load":
                    var doc = new XmlDocument();
                    doc.Load(fileName);
                    breakpoints.Load(doc.DocumentElement);
                    return;
            }

            Logger.WriteErrorLine("Unknown database operation: {0}", op);
        }
示例#12
0
        public void Execute(CommandArguments args)
        {
            var op = args.NextString();

            if (SoftDebugger.State == DebuggerState.Null)
            {
                Logger.WriteErrorLine("No session active.");
                return;
            }

            if (SoftDebugger.State == DebuggerState.Initialized)
            {
                Logger.WriteErrorLine("No process active.");
                return;
            }

            if (SoftDebugger.State == DebuggerState.Running)
            {
                Logger.WriteErrorLine("Process is running.");
                return;
            }

            DoStep (SoftDebugger.Session);
        }
示例#13
0
        public void Execute(CommandArguments args)
        {
            var op = args.NextString(string.Empty);

            if (SoftDebugger.State == DebuggerState.Null)
            {
                Logger.WriteErrorLine("No session active.");
                return;
            }

            var session = SoftDebugger.Session;

            switch (op.ToLower())
            {
                case "add":
                    var file = args.NextString();
                    var line = args.NextInt32();

                    if (line < 1)
                    {
                        Logger.WriteErrorLine("Invalid line number.");
                        return;
                    }

                    session.Breakpoints.Add(file, line, true);

                    Logger.WriteInfoLine("Added breakpoint: {0}:{1}", file, line);
                    return;
                case "set":
                    var frame = args.NextInt32();
                    var setLine = args.NextInt32();

                    var bt = SoftDebugger.Backtrace;

                    if (bt == null)
                    {
                        Logger.WriteErrorLine("No backtrace available.");
                        return;
                    }

                    if (frame < 0 || frame > bt.CurrentBacktrace.Count - 1)
                    {
                        Logger.WriteErrorLine("Invalid stack frame.");
                        return;
                    }

                    if (setLine < 1)
                    {
                        Logger.WriteErrorLine("Invalid line number.");
                        return;
                    }

                    var fileName = bt.CurrentBacktrace[frame].SourceLocation.FileName;
                    session.Breakpoints.Add(fileName, setLine);

                    Logger.WriteInfoLine("Set breakpoint: {0}:{1}");
                    return;
                case "del":
                    var delFile = args.NextString();
                    var delLine = args.NextInt32();

                    if (delLine < 1)
                    {
                        Logger.WriteErrorLine("Invalid line number.");
                        return;
                    }

                    session.Breakpoints.Remove(delFile, delLine);

                    Logger.WriteInfoLine("Deleted breakpoint: {0}:{1}", delFile, delLine);
                    return;
                case "clear":
                    session.Breakpoints.ClearBreakpoints();

                    Logger.WriteInfoLine("Cleared all breakpoints.");
                    return;
                case "":
                    Logger.WriteInfoLine("Breakpoints:");

                    foreach (var bp in session.Breakpoints.GetBreakpoints())
                        Logger.WriteInfoLine("{0}:{1}", bp.FileName, bp.Line);
                    return;
            }

            Logger.WriteErrorLine("Unknown breakpoint operation: {0}", op);
        }
示例#14
0
        public void Execute(CommandArguments args)
        {
            var op = args.NextString(string.Empty);
            var session = SoftDebugger.Session;

            if (session == null)
            {
                Logger.WriteErrorLine("No program loaded.");
                return;
            }

            switch (op.ToLower())
            {
                case "add":
                    var expr = args.NextString();
                    var id = session.GenerateWatchId();
                    session.Watches.Add(id, expr);

                    Logger.WriteInfoLine("Added watch {0}: {1}", id, expr);
                    return;
                case "del":
                    var delId = args.NextInt64();
                    session.Watches.Remove(delId);

                    Logger.WriteInfoLine("Deleted watch: {0}", delId);
                    return;
                case "clear":
                    session.Watches.Clear();

                    Logger.WriteInfoLine("Cleared all watches.");
                    return;
                case "":
                    var backtrace = SoftDebugger.Backtrace;

                    if (backtrace == null)
                    {
                        Logger.WriteErrorLine("No backtrace available.");
                        return;
                    }

                    var frame = backtrace.CurrentStackFrame;

                    if (frame == null)
                    {
                        Logger.WriteInfoLine("No stack frame available.");
                        return;
                    }

                    Logger.WriteInfoLine("Watches:");

                    foreach (var watch in session.Watches)
                    {
                        var evalExpr = watch.Value;
                        var prefix = string.Format("{0}: ({1}) =", watch.Key, evalExpr);

                        try
                        {
                            var result = frame.GetExpressionValue(evalExpr, true);
                            Logger.WriteInfoLine("{0} [{1}] {2}", prefix, result.TypeName, result.DisplayValue);
                        }
                        catch (Exception)
                        {
                            Logger.WriteErrorLine("{0} Error", prefix);
                        }
                    }

                    return;
            }

            Logger.WriteErrorLine("Unknown watch operation: {0}", op);
        }
示例#15
0
        public void Execute(CommandArguments args)
        {
            var backtrace = SoftDebugger.Backtrace;

            if (backtrace == null)
            {
                Logger.WriteErrorLine("No backtrace available.");
                return;
            }

            var showSource = false;
            if (args.HasArguments)
            {
                var op = args.NextString();

                switch (op.ToLower())
                {
                    case "source":
                        showSource = true;
                        break;
                    default:
                        Logger.WriteErrorLine("Unknown backtrace operation: {0}", op);
                        return;
                }
            }

            var bt = backtrace.CurrentBacktrace;

            for (var i = 0; i < bt.Count; i++)
            {
                var frame = bt[i];
                var loc = frame.SourceLocation;
                var fileName = loc.FileName;
                var location = "<unknown>";

                // We can't really rely on frame.HasDebugInfo.
                var hasSource = loc.HasSource();

                if (hasSource)
                    location = string.Format("{0}:{1}{2}", fileName, loc.Line, loc.Column == -1 ? string.Empty : "," + loc.Column);

                var str = string.Format("[{0}] {1}: {2}", i, location, frame.AddressSpace);

                if (i == backtrace.CurrentStackFrameId)
                    Logger.WriteEmphasisLine("{0}", str);
                else
                    Logger.WriteInfoLine("{0}", str);

                if (showSource && hasSource)
                {
                    // Locate the source code.
                    var reader = SoftDebugger.Session.GetSourceReader(fileName);

                    if (reader != null)
                    {
                        if (File.GetLastWriteTime(fileName) > SoftDebugger.CurrentExecutable.LastWriteTime)
                            Logger.WriteWarningLine("Source file {0} is newer than the debugged executable!", fileName);

                        for (var j = 0; j < loc.Line - 1; j++)
                            reader.ReadLine();

                        var source = reader.ReadLine();
                        Logger.WriteInfoLine("{0}", source);
                    }
                    else
                        Logger.WriteInfoLine("<no source>");
                }
            }
        }
示例#16
0
        public void Execute(CommandArguments args)
        {
            var op = args.NextString();

            if (SoftDebugger.State == DebuggerState.Null)
            {
                Logger.WriteErrorLine("No session active.");
                return;
            }

            if (SoftDebugger.State == DebuggerState.Initialized)
            {
                Logger.WriteErrorLine("No process active.");
                return;
            }

            if (SoftDebugger.State == DebuggerState.Running)
            {
                Logger.WriteErrorLine("Process is running.");
                return;
            }

            var session = SoftDebugger.Session;

            switch (op.ToLower())
            {
                case "into":
                    var intoArgs = args.NextString();

                    switch (intoArgs)
                    {
                        case "line":
                            session.NextLine();
                            return;
                        case "instr":
                            session.NextInstruction();
                            return;
                    }

                    Logger.WriteErrorLine("Unknown step into operation: {0}", intoArgs);
                    return;
                case "over":
                    var overArgs = args.NextString();

                    switch (overArgs)
                    {
                        case "line":
                            session.StepLine();
                            return;
                        case "instr":
                            session.StepInstruction();
                            return;
                    }

                    Logger.WriteErrorLine("Unknown step over operation: {0}", overArgs);
                    return;
                case "out":
                    session.Finish();
                    return;
            }

            Logger.WriteErrorLine("Unknown step operation: {0}", op);
        }