public void Execute(IDebuggerSession session, string[] arguments, Logger output) { foreach (var thread in session.GetProcesses().First().Threads) { output.WriteLine("{0}: {1:X8}", thread.Id, thread.StartAddress.ToInt64()); } }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { foreach (var process in session.GetProcesses()) { process.Break(); } }
public void Initialize(OutputViewer outputViewer, IDebuggerSession debuggerSession) { _outputViewer = outputViewer; _debuggerSession = debuggerSession; foreach (var tabItem in TabSourceViewer.Items.Cast<DebuggerTabItem>().ToArray()) { TabSourceViewer.RemoveTabItemWithoutBindingError(tabItem); } _viewers.Clear(); WatchItems.Clear(); foreach (var watchItem in _outputViewer.DocumentPage.WorkDocument.WatchItems) { WatchItems.Add(new WatchItem { Name = watchItem }); } if (!_isInitialized) { TabDebuggerOptions.SelectedIndex = _outputViewer.DocumentPage.WorkDocument.DebuggerViewDefaultTabIndex; _isInitialized = true; } _debuggerSession.Attached += delegate { Dispatcher.Invoke(DebuggerAttachedHandler); }; }
public void Initialize(OutputViewer outputViewer, IDebuggerSession debuggerSession) { _outputViewer = outputViewer; _debuggerSession = debuggerSession; foreach (var tabItem in TabSourceViewer.Items.Cast <DebuggerTabItem>().ToArray()) { TabSourceViewer.RemoveTabItemWithoutBindingError(tabItem); } _viewers.Clear(); WatchItems.Clear(); foreach (var watchItem in _outputViewer.DocumentPage.WorkDocument.WatchItems) { WatchItems.Add(new WatchItem { Name = watchItem }); } if (!_isInitialized) { TabDebuggerOptions.SelectedIndex = _outputViewer.DocumentPage.WorkDocument.DebuggerViewDefaultTabIndex; _isInitialized = true; } _debuggerSession.Attached += delegate { Dispatcher.Invoke(DebuggerAttachedHandler); }; }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { if (arguments.Length < 2) { throw new ArgumentException("Not enough arguments."); } ulong address = ulong.Parse(arguments[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture); var debuggeeProcess = session.GetProcesses().First(); switch (arguments[0].ToLowerInvariant()) { case "set": debuggeeProcess.SetSoftwareBreakpoint((IntPtr)address); break; case "remove": debuggeeProcess.RemoveSoftwareBreakpoint( debuggeeProcess.GetSoftwareBreakpointByAddress((IntPtr)address)); break; case "enable": debuggeeProcess.GetSoftwareBreakpointByAddress((IntPtr)address).Enabled = true; break; case "disable": debuggeeProcess.GetSoftwareBreakpointByAddress((IntPtr)address).Enabled = false; break; default: throw new ArgumentOutOfRangeException("Invalid switch " + arguments[1]); } }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { switch (arguments.Length) { case 0: { int maxLength = _parent._prefixesByCommand.Max(x => string.Join(", ", x.Value).Length); foreach (var command in _parent._prefixesByCommand.OrderBy(x => x.Value[0])) { output.WriteLine(string.Join(", ", command.Value).PadRight(maxLength + 5) + command.Key.Description); } break; } case 1: { var command = _parent._commands[arguments[0]]; output.WriteLine("Description: " + command.Description); output.WriteLine("Usage: " + arguments[0] + " " + command.Usage); output.WriteLine("Equivalent commands: " + string.Join(", ", _parent._prefixesByCommand[command].Where(x => x != arguments[0]))); break; } } }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { var process = session.GetProcesses().First(); if (process != _process) { _process = process; _reader = new ProcessMemoryReader(process) { NegateBreakpoints = true }; _disassembler = new X86Disassembler(_reader); } if (arguments.Length > 0) { _reader.Position = long.Parse(arguments[0], NumberStyles.HexNumber); } int count = 5; if (arguments.Length > 1) { count = int.Parse(arguments[1]); } for (int i = 0; i < count; i++) { var instruction = _disassembler.ReadNextInstruction(); _printer.PrintInstruction(instruction, process.GetSoftwareBreakpointByAddress((IntPtr)instruction.Offset)); } }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { foreach (var lib in session.GetProcesses().First().Libraries) { output.WriteLine("{0:X8}: {1}", lib.BaseOfLibrary.ToInt64(), (lib.Name ?? "<no name>")); } }
public BaseDebuggerSessionTest() { var container = new CompositionContainer (new DirectoryCatalog (Environment.CurrentDirectory)); session = container.GetExportedValue<IDebuggerSession> (); typeProvider = session.TypeProvider; typeProvider.AddFilter (Path.GetDirectoryName (typeof (type1).Assembly.Location)); vm = session.VM as VirtualMachine; }
public LocalsWindow(IDebuggerSession session, IExecutionProvider executionProvider) { this.session = session; this.executionProvider = executionProvider; this.executionProvider.Suspended += (thread) => { QueueUserWorkItem (() => pendingFrame = thread.GetFrames ().FirstOrDefault()); }; }
public LocalsWindow(IDebuggerSession session, IExecutionProvider executionProvider) { this.session = session; this.executionProvider = executionProvider; this.executionProvider.Suspended += (thread) => { QueueUserWorkItem(() => pendingFrame = thread.GetFrames().FirstOrDefault()); }; }
public UnityAdditionalValuesProvider(IDebuggerSession session, IValueServicesFacade <TValue> valueServices, IUnityOptions unityOptions, ILogger logger) { // We can't use EvaluationOptions here, it hasn't been set yet mySession = session; myValueServices = valueServices; myUnityOptions = unityOptions; myLogger = logger; }
public CallstackWindow(IDebuggerSession session, IExecutionProvider executionProvider, IThreadProvider threadProvider, ISourceNavigator sourceNavigator) { this.session = session; this.executionProvider = executionProvider; this.threadProvider = threadProvider; this.executionProvider.Suspended += (thread) => pendingFrames = thread.GetFrames();; this.sourceNavigator = sourceNavigator; }
public BaseDebuggerSessionTest() { var container = new CompositionContainer(new DirectoryCatalog(Environment.CurrentDirectory)); session = container.GetExportedValue <IDebuggerSession> (); typeProvider = session.TypeProvider; typeProvider.AddFilter(Path.GetDirectoryName(typeof(type1).Assembly.Location)); vm = session.VM as VirtualMachine; }
public BreakpointsWindow(IDebuggerSession session, IBreakpointProvider breakpointProvider, ISourceNavigator sourceNavigator ) { this.session = session; this.breakpointProvider = breakpointProvider; this.sourceNavigator = sourceNavigator; }
public CallStackDisplay(IDebuggerSession session, IExecutionProvider executionProvider, IThreadProvider threadProvider, ISourceNavigator sourceNavigator) { this.session = session; this.executionProvider = executionProvider; this.threadProvider = threadProvider; this.executionProvider.Suspended += RefreshFrames; this.sourceNavigator = sourceNavigator; }
public CallstackWindow(IDebuggerSession session, IExecutionProvider executionProvider, IThreadProvider threadProvider, ISourceNavigator sourceNavigator) { this.session = session; this.executionProvider = executionProvider; this.threadProvider = threadProvider; this.executionProvider.Suspended += (thread) => pendingFrames = thread.GetFrames ();; this.sourceNavigator = sourceNavigator; }
public MainWindow( IDebuggerSession session, ITypeProvider typeProvider, DebuggerWindowManager windowManager ) { this.session = session; this.typeProvider = typeProvider; this.windowManager = windowManager; }
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 ExecuteCommandLine(IDebuggerSession session, string commandLine) { if (!string.IsNullOrWhiteSpace(commandLine)) { var args = commandLine.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (!_commands.TryGetValue(args[0], out var command)) { throw new ArgumentException("Command " + args[0] + " is not a registered command."); } command.Execute(session, args.Skip(1).ToArray(), _logger); } }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { var process = session.GetProcesses().First(); if (arguments.Length < 1) { throw new ArgumentException("Expected address."); } if (arguments.Length < 2) { throw new ArgumentException("Expected value size."); } if (arguments.Length < 3) { throw new ArgumentException("Expected at least one value to write."); } ulong address = ulong.Parse(arguments[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture); int size = 1; switch (arguments[1].ToLowerInvariant()) { case "b": size = 1; break; case "w": size = 2; break; case "dw": size = 4; break; default: throw new ArgumentOutOfRangeException("Invalid switch " + arguments[1]); } var buffer = new byte[(arguments.Length - 2) * size]; for (int i = 0; i < arguments.Length - 2; i++) { ulong currentValue = ulong.Parse(arguments[i + 2], NumberStyles.HexNumber, CultureInfo.InvariantCulture); var bytes = BitConverter.GetBytes(currentValue); Buffer.BlockCopy(bytes, 0, buffer, i * size, size); } process.WriteMemory((IntPtr)address, buffer, 0, buffer.Length); }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { if (arguments.Length > 0) { if (arguments[0] != "pass") { throw new ArgumentException("Invalid switch " + arguments[0]); } session.Step(StepType.StepOver, DebuggerAction.ContinueWithException); } session.Step(StepType.StepOver, DebuggerAction.Continue); }
public ExecutionWindow(IDebuggerSession session, IExecutionProvider executionProvider) { this.session = session; this.executionProvider = executionProvider; this.executionProvider.Break += location => { if (lastStop == location) { executionProvider.Resume (); return; } lastStop = location; SourceNavigator.ShowSourceLocation (location); }; }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { var threadContext = _currentThread.GetThreadContext(); if (arguments.Length == 0) { DumpRegisters(threadContext, output); } else if (arguments.Length > 0) { var register = threadContext.GetRegisterByName(arguments[0]); if (arguments.Length < 2) { DumpRegister(register, output); } else { string newValue = arguments[1]; switch (register.Size) { case 1: register.Value = newValue == "1"; break; case 8: register.Value = byte.Parse(newValue, NumberStyles.HexNumber); break; case 16: register.Value = ushort.Parse(newValue, NumberStyles.HexNumber); break; case 32: register.Value = uint.Parse(newValue, NumberStyles.HexNumber); break; case 64: register.Value = ulong.Parse(newValue, NumberStyles.HexNumber); break; default: throw new NotSupportedException($"Invalid or unsupported register size {register.Size}."); } threadContext.Flush(); } } }
public ExecutionWindow(IDebuggerSession session, IExecutionProvider executionProvider) { this.session = session; this.executionProvider = executionProvider; this.executionProvider.Break += location => { if (lastStop == location) { executionProvider.Resume(); return; } lastStop = location; SourceNavigator.ShowSourceLocation(location); }; }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { output.WriteLine("Software Breakpoints:"); foreach (var breakpoint in session.GetProcesses().SelectMany(x => x.GetSoftwareBreakpoints())) { output.WriteLine("- {0:X8} : {1}", breakpoint.Address.ToInt64(), breakpoint.Enabled ? "Enabled" : "Disabled"); } output.WriteLine("Memory Breakpoints:"); foreach (var breakpoint in session.GetProcesses().SelectMany(x => x.GetMemoryBreakpoints())) { output.WriteLine("- {0:X8} : {1}", breakpoint.Address.ToInt64(), breakpoint.Enabled ? "Enabled" : "Disabled"); } }
public MainWindow( IDebuggerSession session, ISourcesProvider sourcesProvider, SourcesWindow sourcesWindow, SourceWindow sourceWindow, LogWindow log, CallStackDisplay callStackDisplay, ExecutionWindow executionWindow, DebuggerWindowManager windowManager ) { this.log = log; this.callStackDisplay = callStackDisplay; this.executionWindow = executionWindow; this.sourcesWindow = sourcesWindow; this.sourceWindow = sourceWindow; this.session = session; this.windowManager = windowManager; if (HasArguments ()) this.session.Port = SdbPortFromCommandLine (); Camera.main.backgroundColor = new Color (0.125f, 0.125f, 0.125f, 0); Application.runInBackground = true; AdjustLayout (); if (!HasArguments ()) return; this.session.TraceCallback += s => Trace (s); sourcesProvider.Path = ProjectPathFromCommandLine (); sourcesWindow.StartRefreshing (); session.Start (); }
public void Execute(IDebuggerSession session, string[] arguments, Logger output) { if (arguments.Length == 0) { throw new ArgumentException("Expected address."); } ulong address = ulong.Parse(arguments[0], NumberStyles.HexNumber, CultureInfo.InvariantCulture); var size = X86OperandSize.Byte; if (arguments.Length > 1) { switch (arguments[1].ToLowerInvariant()) { case "b": size = X86OperandSize.Byte; break; case "w": size = X86OperandSize.Word; break; case "dw": size = X86OperandSize.Dword; break; default: throw new ArgumentOutOfRangeException("Invalid switch " + arguments[1]); } } var process = session.GetProcesses().First(); DumpMemory(process, address, 5, size, output); }
public ComponentChildrenRenderer(IDebuggerSession session, IUnityOptions unityOptions) { mySession = session; myUnityOptions = unityOptions; }
internal DebuggeeProcess(IDebuggerSession session, PROCESS_INFORMATION processInfo) { Session = session ?? throw new ArgumentNullException(nameof(session)); _processHandle = processInfo.hProcess; Id = processInfo.dwProcessId; }
internal DebuggeeProcess(IDebuggerSession session, IntPtr handle, int id) { Session = session ?? throw new ArgumentNullException(nameof(session)); _processHandle = handle; Id = id; }
public ThreadsDisplay(IDebuggerSession session, IThreadProvider threadProvider) { this.session = session; this.threadProvider = threadProvider; }
public ExecutionWindow(IDebuggerSession session, IExecutionProvider executionProvider) { this.session = session; this.executionProvider = executionProvider; }
public UnityAdditionalValuesProvider(IDebuggerSession session, IValueServicesFacade <Value> valueServices, IUnityOptions unityOptions, ILogger logger) : base(session, valueServices, unityOptions, logger) { }
protected DebuggerSessionEventArgs(IDebuggerSession session) { Session = session; NextAction = DebuggerAction.Continue; }
public GameObjectChildrenRenderer(IDebuggerSession session, IUnityOptions unityOptions) { mySession = session; myUnityOptions = unityOptions; }
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()); } } } }