public void Execute(IDebuggerSession session, string[] arguments, Logger output) { foreach (var process in session.GetProcesses()) { process.Terminate(); } session.StartProcess(new DebuggerProcessStartInfo { CommandLine = string.Join(" ", CommandLineArgs) }); }
public void Run() { PrintAbout(); if (CommandLineArgs.Count == 0) { _logger.WriteLine("Usage: Ladybug.Console.exe <file> [arguments]"); return; } _session = new DebuggerSession(); _session.ProcessStarted += SessionOnProcessStarted; _session.ProcessTerminated += SessionOnProcessTerminated; _session.ThreadStarted += SessionOnThreadStarted; _session.ThreadTerminated += SessionOnThreadTerminated; _session.OutputStringSent += SessionOnOutputStringSent; _session.LibraryLoaded += SessionOnLibraryLoaded; _session.LibraryUnloaded += SessionOnLibraryUnloaded; _session.ExceptionOccurred += SessionOnExceptionOccurred; _session.BreakpointHit += SessionOnBreakpointHit; _session.Paused += SessionOnPaused; _session.Stepped += SessionOnStepped; _session.StartProcess(new DebuggerProcessStartInfo { CommandLine = string.Join(" ", CommandLineArgs) }); _executor = new CommandExecutor(_logger); _executor.RegisterCommand(new KillCommand(), "kill"); _executor.RegisterCommand(new RestartCommand(CommandLineArgs), "restart"); _executor.RegisterCommand(new GoCommand(), "go", "g"); _executor.RegisterCommand(new StepInCommand(), "stepin", "si"); _executor.RegisterCommand(new StepOverCommand(), "stepover", "so"); _executor.RegisterCommand(new DumpMemoryCommand(), "dump", "dm"); _executor.RegisterCommand(new EditMemoryCommand(), "write", "wm"); _executor.RegisterCommand(new ModulesCommand(), "modules", "m"); _executor.RegisterCommand(new BreakpointCommand(), "breakpoint", "bp"); _executor.RegisterCommand(new MemoryBreakpointCommand(), "memorybreakpoint", "bm"); _executor.RegisterCommand(new BreakpointsCommand(), "breakpoints", "bps"); _executor.RegisterCommand(new DisassembleCommand(), "disassemble", "d"); _executor.RegisterCommand(new RegisterCommand(), "registers", "r"); _executor.RegisterCommand(new BreakCommand(), "break"); _executor.RegisterCommand(new ThreadsCommand(), "threads"); bool exit = false; while (!exit) { string commandLine = System.Console.ReadLine(); if (commandLine == "exit") { exit = true; } else { try { _executor.ExecuteCommandLine(_session, commandLine); } catch (Exception ex) { _logger.WriteLine(LoggerMessageType.Error, ex.ToString()); } } } }