public CommandViewModel(DebugManager debug, UIManager ui) { DebugManager = debug; UI = ui; _dispatcher = Dispatcher.CurrentDispatcher; _historyColors = new Dictionary <DEBUG_OUTPUT, RgbColor> { [DEBUG_OUTPUT.ERROR] = new RgbColor { R = 255 }, [DEBUG_OUTPUT.EXTENSION_WARNING] = new RgbColor { R = 128 }, [DEBUG_OUTPUT.WARNING] = new RgbColor { R = 128, G = 128 }, [DEBUG_OUTPUT.DEBUGGEE] = new RgbColor { B = 255 }, [DEBUG_OUTPUT.SYMBOLS] = new RgbColor { G = 128 } }; _debugger = DebugManager.Debugger; _debugger.StatusChanged += _debugger_StatusChanged; _debugger.OutputCallback += _debugger_OutputCallback; }
protected override void ProcessRecord() { ConnectionState state = ConnectionState.GetConnectionState(); state.IsConnected = true; state.ProcessPath = ProcessPath; if (SymbolPath == null) { SymbolPath = "srv*"; } IDebugClient client = DebugClient.DebugCreateEx(0x60); ((IDebugSymbols5)client).SetSymbolPathWide(SymbolPath); ((IDebugClient7)client).CreateProcessAndAttach(0, ProcessPath, 0x00000002); ((IDebugControl7)client).WaitForEvent(0, uint.MaxValue); // For live debugging disable caching. // Context.EnableUserCastedVariableCaching = false; Context.EnableVariableCaching = false; Context.Initalize(client); WriteDebug("Connection successfully initialized"); }
/// <summary> /// Initializes the test class with the specified dump file. /// </summary> /// <param name="dumpFile">The dump file.</param> /// <param name="symbolPath">The symbol path.</param> /// <param name="addSymbolServer">if set to <c>true</c> symbol server will be added to the symbol path.</param> protected static void InitializeDump(string dumpFile, string symbolPath, bool addSymbolServer = true) { NormalizeDebugPaths(ref dumpFile, ref symbolPath, addSymbolServer); client = DebugClient.OpenDumpFile(dumpFile, symbolPath); Context.Initalize(client); }
protected override void ProcessRecord() { ConnectionState state = ConnectionState.GetConnectionState(); state.IsConnected = true; state.ProcessPath = ProcessPath; if (SymbolPath == null) { SymbolPath = "srv*"; } IDebugClient client = DebugClient.DebugCreateEx(0x60); ((IDebugSymbols5)client).SetSymbolPathWide(SymbolPath); ((IDebugClient7)client).CreateProcessAndAttach(0, ProcessPath, DebugCreateProcess.DebugOnlyThisProcess, 0, DebugAttach.Default); ((IDebugControl7)client).WaitForEvent(0, uint.MaxValue); // For live debugging disable caching. // Context.EnableUserCastedVariableCaching = false; Context.EnableVariableCaching = false; IDebuggerEngine debugger = new DbgEngDll(client); ISymbolProvider symbolProvider = new DiaSymbolProvider(debugger.GetDefaultSymbolProvider()); Context.InitializeDebugger(debugger, symbolProvider); WriteDebug("Connection successfully initialized"); }
public static void EnterDebugger() { Screen.Color = 0x0; Screen.Clear(); Screen.GotoTop(); Screen.Color = 0x0E; Screen.Write('D'); Screen.Write('E'); Screen.Write('B'); Screen.Write('U'); Screen.Write('G'); Screen.NextLine(); Screen.NextLine(); DebugClient.Setup(Serial.COM1); byte last = 0; while (true) { byte second = CMOS.Second; if (second % 10 != 5 & last != second) { last = CMOS.Second; DebugClient.SendAlive(); } } }
public override void Execute(string[] args, DebugClient client) { if (client.IsRunning) { client.SendPacket(new PacketRequest(DebugRequest.BREAK, 0, 0, 0, 0, new byte[] { })); client.WaitForEvent(); } }
internal async Task AttachDebugger(DebugOptions debugOptions) { string appHash = ComputeHash(debugOptions.StartupAssemblyPath); Project startup = GetStartupProject(); bool isWeb = ((object[])startup.ExtenderNames).Any(x => x.ToString() == "WebApplication"); ApplicationType appType = isWeb ? ApplicationType.Webapplication : ApplicationType.Desktopapplication; if (appType == ApplicationType.Webapplication) { debugOptions.OutputDirectory += @"\..\..\"; } var client = new DebugClient(appType, debugOptions.TargetExeFileName, debugOptions.StartArguments, debugOptions.OutputDirectory, appHash); DebugSession session = await client.ConnectToServerAsync(debugOptions.UserSettings.LastIp); var debugSessionStarted = await session.RestartDebuggingAsync(debugOptions.UserSettings.LastTimeout); if (!debugSessionStarted) { await session.TransferFilesAsync(); await session.WaitForAnswerAsync(debugOptions.UserSettings.LastTimeout); } IntPtr pInfo = GetDebugInfo(debugOptions); var sp = new ServiceProvider((IServiceProvider)_dte); try { var dbg = (IVsDebugger)sp.GetService(typeof(SVsShellDebugger)); int hr = dbg.LaunchDebugTargets(1, pInfo); Marshal.ThrowExceptionForHR(hr); DebuggedProcess.Instance.AssociateDebugSession(session); } catch (Exception ex) { logger.Error(ex); string msg; var sh = (IVsUIShell)sp.GetService(typeof(SVsUIShell)); sh.GetErrorInfo(out msg); if (!string.IsNullOrWhiteSpace(msg)) { logger.Error(msg); } throw; } finally { if (pInfo != IntPtr.Zero) { Marshal.FreeCoTaskMem(pInfo); } } }
static void Main(string[] args) { using (DebugClient app = new DebugClient()) { app.AddModule<DebugModule>(null, new object[] { app }); app.Start(); } }
public async static Task <ExecutiveProcess> FromListEntry(DebugClient debugger, ulong address) { if (EProcessTypeId == 0) { await GetTypeIds(debugger); } address -= ListEntryOffset; return(await CreateInternal(debugger, address)); }
public override void Execute(string[] args, DebugClient client) { if (!client.IsRunning) { client.SendPacket(new PacketRequest(DebugRequest.STEP, 0, 0, 0, 0, new byte[] { })); PacketEvent e = client.WaitForEvent(); Instruction ins = Instruction.Fetch(e.Argument0, e.Data); Console.WriteLine("Step 0x{0:X8}\t{1}", e.Argument0, ins.ToString()); } }
internal async Task AttachDebugger(string ipAddress) { string path = GetStartupAssemblyPath(); string targetExe = Path.GetFileName(path); string outputDirectory = Path.GetDirectoryName(path); Project startup = GetStartupProject(); bool isWeb = ((object[])startup.ExtenderNames).Any(x => x.ToString() == "WebApplication"); ApplicationType appType = isWeb ? ApplicationType.Webapplication : ApplicationType.Desktopapplication; if (appType == ApplicationType.Webapplication) { outputDirectory += @"\..\..\"; } var client = new DebugClient(appType, targetExe, outputDirectory); DebugSession session = await client.ConnectToServerAsync(ipAddress); await session.TransferFilesAsync(); await session.WaitForAnswerAsync(); IntPtr pInfo = GetDebugInfo(ipAddress, targetExe, outputDirectory); var sp = new ServiceProvider((IServiceProvider)_dte); try { var dbg = (IVsDebugger)sp.GetService(typeof(SVsShellDebugger)); int hr = dbg.LaunchDebugTargets(1, pInfo); Marshal.ThrowExceptionForHR(hr); DebuggedProcess.Instance.AssociateDebugSession(session); } catch (Exception ex) { logger.Error(ex); string msg; var sh = (IVsUIShell)sp.GetService(typeof(SVsUIShell)); sh.GetErrorInfo(out msg); if (!string.IsNullOrWhiteSpace(msg)) { logger.Error(msg); } throw; } finally { if (pInfo != IntPtr.Zero) { Marshal.FreeCoTaskMem(pInfo); } } }
public void TestInitialize() { Task mtaTask = new Task(() => { //Initialize(DefaultDumpFile, DefaultSymbolPath); new Executor().InitializeContext(DebugClient.DebugCreateEx(0)); }); mtaTask.Start(); mtaTask.Wait(); }
private DebugManager() { Debugger = DebugClient.Create(); Debugger.StatusChanged += Debugger_StatusChanged; Debugger.ProcessCreated += Debugger_ProcessCreated; Debugger.ThreadCreated += Debugger_ThreadCreated; Debugger.ThreadExited += Debugger_ThreadExited; Debugger.ProcessExited += Debugger_ProcessExited; Debugger.ModuleLoaded += Debugger_ModuleLoaded; Debugger.ModuleUnloaded += Debugger_ModuleUnloaded; }
/// <summary> /// Attaches debugger to the already running specified process. /// </summary> /// <param name="processId">The process identifier.</param> /// <param name="attachFlags">The attaching flags.</param> /// <param name="symbolPaths">Array of paths where debugger will look for symbols.</param> public static void AttachToProcess(uint processId, DebugAttach attachFlags = DebugAttach.Noninvasive, params string[] symbolPaths) { IDebugClient debugClient = DebugClient.DebugCreate(); IDebugSymbols5 symbols = (IDebugSymbols5)debugClient; IDebugControl7 control = (IDebugControl7)debugClient; symbols.SetSymbolPathWide(string.Join(";", symbolPaths)); debugClient.AttachProcess(0, processId, attachFlags); control.WaitForEvent(0, uint.MaxValue); InitializeDbgEng(debugClient); }
static int Main(string[] args) { DebugClient cli = null; DebugControl ctrl = null; try { cli = new DebugClient(); ctrl = new DebugControl(cli); // ctrl.Execute(OutputControl.ToAllClients, "sxe ibp", ExecuteOptions.Default); ctrl.EngineOptions |= EngineOptions.InitialBreak; //cli.OnExceptionDebugEvent += new ExceptionEventHandler(HandleException); //cli.OnExitProcessDebugEvent += new ExitProcessEventHandler(HandleExitProcess); //cli.OnBreakpointDebugEvent += new BreakpointEventHandler(HandleBp); //cli.CreateProcess(0, "notepad.exe", CreateProcessOptions.DebugOnlyThisProcess); cli.CreateProcessAndAttach(0, @"notepad.exe", CreateProcessOptions.DebugOnlyThisProcess, 0, ProcessAttachMode.InvasiveResumeProcess); Console.WriteLine(cli.ToString()); //Identity.ToString()); Console.WriteLine(ctrl.WaitForEvent()); // <-- BREAKS HERE!!! DebugEventInfo lastEvent = ctrl.GetLastEventInformation(); Console.WriteLine("Last event: {0}", lastEvent.Description); /*for (int i = 0; i < 200; i++) * Console.WriteLine(cli.ToString()); */ } catch (Exception e) { Console.Error.WriteLine("Exception thrown: {0}", e); return(1); } finally { if (cli != null) { cli.Dispose(); } if (ctrl != null) { ctrl.Dispose(); } } return(0); }
public ClientContext(FrontEndConnection connection, PacketTransmitter packetTransmitter) : base(connection, packetTransmitter) { _debugClient = new DebugClient(this); _authClient = new AuthenticationClient(this); _tpmClient = new TPMClient(this); RegisterSubsystem(new TPMClientSubsystem(this)); _configured = true; _configuredEvent.Set(); }
/// <summary> /// Initializes the test class with the specified process file. /// </summary> /// <param name="processPath">Path to the process to be started.</param> /// <param name="symbolPath">Symbol path.</param> /// <param name="addSymbolServer">if set to <c>true</c> symbol server will be added to the symbol path.</param> /// <param name="debugEngineOptions">Debug create options. Default is to start in break mode, and break on process exit.</param> protected static void InitializeProcess(string processPath, string processArguments, string symbolPath, bool addSymbolServer = true, uint debugEngineOptions = (uint)(Defines.DebugEngoptInitialBreak | Defines.DebugEngoptFinalBreak)) { NormalizeDebugPaths(ref processPath, ref symbolPath, addSymbolServer); // Disable caching. // Context.EnableUserCastedVariableCaching = false; Context.EnableVariableCaching = false; client = DebugClient.OpenProcess(processPath, processArguments, symbolPath, debugEngineOptions); Context.Initalize(client); }
public DebuggerEngine(DebuggerRunner runner, DebugClient client, DebugControl control, Dia.DiaSessionLoader diaLoader) { this.runner = runner; this.client = client; this.client.OutputMask = OutputModes.Normal; this.control = control; this.isPointer64Bit = (this.control.EffectiveProcessorType == Processor.Amd64); this.symbolCache = new SymbolCache(this.client); this.dataSpaces = new DebugDataSpaces(this.client); this.symbols = new DebugSymbols(this.client); this.diaLoader = diaLoader; }
public TestEnviroment(int buyers_count) { debugger = new DebugClient(); // this is the key for the NEO "issuer" in the virtual chain used for testing owner_keys = KeyPair.GenerateAddress(); this.api = new NeoEmulator(owner_keys); this.api.SetLogger(x => { if (api.Chain.HasDebugger) { debugger.WriteLine(x); } Debug.WriteLine(x); }); // create a random key for the team team_keys = KeyPair.GenerateAddress(); // since the real team address is hardcoded in the contract, use BypassKey to give same permissions to this key this.api.Chain.BypassKey(new UInt160(PhantasmaContract.Team_Address), new UInt160(team_keys.address.AddressToScriptHash())); api.Chain.AttachDebugger(debugger); Transaction tx; tx = api.SendAsset(owner_keys, team_keys.address, "GAS", 800); Assert.IsNotNull(tx); var balances = api.GetAssetBalancesOf(team_keys.address); Assert.IsTrue(balances.ContainsKey("GAS")); Assert.IsTrue(balances["GAS"] == 800); tx = api.DeployContract(team_keys, ContractTests.contract_script_bytes, "0710".HexToBytes(), 5, ContractPropertyState.HasStorage, "Phantasma", "1.0", "phantasma.io", "*****@*****.**", "Phantasma Smart Contract"); Assert.IsNotNull(tx); if (buyers_count > 0) { whitelisted_buyerKeys = new KeyPair[buyers_count]; for (int i = 0; i < whitelisted_buyerKeys.Length; i++) { whitelisted_buyerKeys[i] = KeyPair.GenerateAddress(); api.SendAsset(owner_keys, whitelisted_buyerKeys[i].address, "NEO", 100); api.CallContract(team_keys, ContractTests.contract_script_hash, "whitelistAdd", new object[] { whitelisted_buyerKeys[i].address.AddressToScriptHash() }); } } this.token = new NEP5(api, ContractTests.contract_script_hash); }
public override void Execute(string[] args, DebugClient client) { if (!client.IsRunning) { uint start = uint.Parse(args[1], System.Globalization.NumberStyles.AllowHexSpecifier); uint end = uint.Parse(args[1], System.Globalization.NumberStyles.AllowHexSpecifier); client.SendPacket(new PacketRequest(DebugRequest.READ, start, end, 0, 0, new byte[] { })); PacketEvent e = client.WaitForEvent(); using (BinaryReader br = new BinaryReader(new MemoryStream(e.Data))) { } } }
public static async Task AsyncMain(string[] args) { var browser = new BrowserInstance(IPAddress.Loopback, 8881); var tabs = await browser.EnumerateTabs(); var tab = tabs.FirstOrDefault(t => t.url.Contains("queryselector.html")); if (tab == null) { throw new Exception("No tab containing queryselector.html found"); } var conn = new DebugClient(browser, tab) { DefaultDescriptionDepth = 0, ReceiveTraceStream = Console.Out, SendTraceStream = Console.Out }; Console.WriteLine("Connecting"); await conn.Connect(); Console.WriteLine("Querying selectors"); var div = await conn.API.QueryAndDescribeSelector("div"); if (div == null) { throw new Exception("Failed to find div"); } var span1 = await conn.API.QueryAndDescribeSelector("span#span1"); var span2 = await conn.API.QueryAndDescribeSelector("span#span2", div.Id); if (span1 == null || span2 == null) { throw new Exception("Failed to find span1 and span2"); } Console.WriteLine("Waiting 10 seconds"); await Task.Delay(10000); span1 = await conn.API.QueryAndDescribeSelector("span#span1"); span2 = await conn.API.QueryAndDescribeSelector("span#span2", div.Id); if (span1 == null || span2 == null) { throw new Exception("Failed to find span1 and span2"); } }
private Dumper(string applicationPath, string dumpPath, bool miniDump) { this.dumpPath = dumpPath; this.miniDump = miniDump; // Create debugging client IDebugClient clientBase = DebugClient.DebugCreate(); // Cast to upper clients client = (IDebugClient7)clientBase; control = (IDebugControl7)client; client.SetEventCallbacks(this); client.CreateProcessAndAttach(0, applicationPath, 0x00000002); }
public override void Execute(string[] args, DebugClient client) { if (!client.IsRunning) { client.SendPacket(new PacketRequest(DebugRequest.REGISTERS, 0, 0, 0, 0, new byte[] { })); PacketEvent e = client.WaitForEvent(); using (BinaryReader br = new BinaryReader(new MemoryStream(e.Data))) { while (br.BaseStream.Position < br.BaseStream.Length) { Console.WriteLine("{0} = 0x{1:X8}", br.ReadString().PadRight(4), br.ReadUInt32()); } } } }
/// <summary> /// Initializes debugger for processing the specified dump. /// </summary> /// <param name="dumpPath">Path to the dump.</param> /// <param name="symbolPaths">Array of paths where debugger will look for symbols.</param> public static void OpenDump(string dumpPath, params string[] symbolPaths) { try { IDebugClient debugClient = DebugClient.OpenDumpFile(dumpPath, string.Join(";", symbolPaths)); InitializeDbgEng(debugClient); } catch { IDebuggerEngine engine = new ElfCoreDumpDebuggingEngine(dumpPath); Context.InitializeDebugger(engine); } }
public DbgEngDumpInitialization(string dumpPath, string defaultModuleName, string symbolPath = DefaultDumpPath, bool addSymbolServer = true, bool useDia = true, bool useDwarf = false) : base(dumpPath, defaultModuleName, FixSymbolPath(symbolPath, addSymbolServer)) { IDebugClient client = DebugClient.OpenDumpFile(DumpPath, SymbolPath); DbgEngDll.InitializeContext(client); if (!useDia && !useDwarf) { Context.InitializeDebugger(Context.Debugger); } else if (useDwarf) { Context.InitializeDebugger(Context.Debugger, new DwarfSymbolProvider.DwarfSymbolProvider()); } }
public static void Process() { byte last = 0; while (true) { if (CMOS.Second != last) { last = CMOS.Second; DebugClient.SendAlive(); Screen.Write('.'); } Native.Hlt(); } }
private static async Task <ExecutiveProcess> CreateInternal(DebugClient debugger, ulong address) { var process = new ExecutiveProcess(address) { ProcessId = (uint)await debugger.GetFieldValue(KernelBase, EProcessTypeId, "UniqueProcessId", address), ParentProcessId = (uint)await debugger.GetFieldValue(KernelBase, EProcessTypeId, "InheritedFromUniqueProcessId", address), Flags = (ExecutiveProcessFlags)await debugger.GetFieldValue(KernelBase, EProcessTypeId, "Flags", address), Flags2 = (ExecutiveProcessFlags2)await debugger.GetFieldValue(KernelBase, EProcessTypeId, "Flags2", address), CreateTime = new TimeSpan((long)await debugger.GetFieldValue(KernelBase, EProcessTypeId, "CreateTime", address)), PeakVirtualSize = (ulong)await debugger.GetFieldValue(KernelBase, EProcessTypeId, "PeakVirtualSize", address), VirtualSize = (ulong)await debugger.GetFieldValue(KernelBase, EProcessTypeId, "VirtualSize", address), //Name = new string((char*)await debugger.GetFieldValue(_kernelBase, _EProcessTypeId, "ImageFileName", address)), }; return(process); }
/// <summary> /// Initializes the test class with the specified process file. /// </summary> /// <param name="processPath">Path to the process to be started.</param> /// <param name="processArguments">Arguments for process to be started.</param> /// <param name="symbolPath">Symbol path.</param> /// <param name="addSymbolServer">if set to <c>true</c> symbol server will be added to the symbol path.</param> /// <param name="debugEngineOptions">Debug create options. Default is to start in break mode, and break on process exit.</param> protected static void InitializeProcess(string processPath, string processArguments, string symbolPath, bool addSymbolServer = true, uint debugEngineOptions = (uint)(Defines.DebugEngoptInitialBreak | Defines.DebugEngoptFinalBreak)) { processPath = GetAbsoluteBinPath(processPath); symbolPath = GetAbsoluteBinPath(symbolPath); if (addSymbolServer) { symbolPath += ";srv*"; } // Disable caching. // Context.EnableUserCastedVariableCaching = false; Context.EnableVariableCaching = false; IDebugClient client = DebugClient.OpenProcess(processPath, processArguments, symbolPath, debugEngineOptions); DbgEngDll.InitializeContext(client); }
protected override void ProcessRecord() { ConnectionState state = ConnectionState.GetConnectionState(); state.IsConnected = true; state.ProcessPath = ProcessPath; if (SymbolPath == null) { SymbolPath = "srv*"; } IDebugClient client = DebugClient.OpenProcess(ProcessPath, null, SymbolPath, (uint)(Defines.DebugEngoptInitialBreak | Defines.DebugEngoptFinalBreak)); WriteDebug("Connection successfully initialized"); DbgEngDll.InitializeContext(client); }
private void CreateClient(IntPtr ptr) { _systemObjects = new DebugSystemObjects(_library, ptr); _client = new DebugClient(_library, ptr, _systemObjects); _control = new DebugControl(_library, ptr, _systemObjects); _spaces = new DebugDataSpaces(_library, ptr, _systemObjects); _advanced = new DebugAdvanced(_library, ptr, _systemObjects); _symbols = new DebugSymbols(_library, ptr, _systemObjects); _client.SuppressRelease(); _control.SuppressRelease(); _spaces.SuppressRelease(); _advanced.SuppressRelease(); _symbols.SuppressRelease(); _systemObjects.SuppressRelease(); Interlocked.Increment(ref s_totalInstanceCount); }
public DbgEngDumpInitialization(string dumpPath, string defaultModuleName, string symbolPath = DefaultDumpPath, bool addSymbolServer = true, bool useDia = true, bool useDwarf = false, bool useILCodeGen = false) : base(dumpPath, defaultModuleName, FixSymbolPath(symbolPath, addSymbolServer), useILCodeGen) { // Clear all processes being debugged with DbgEng.dll... (Context.Debugger as DbgEngDll)?.Client?.EndSession(DebugEnd.ActiveTerminate); IDebugClient client = DebugClient.OpenDumpFile(DumpPath, SymbolPath); DbgEngDll.InitializeContext(client); if (!useDia && !useDwarf) { Context.InitializeDebugger(Context.Debugger); } else if (useDwarf) { Context.InitializeDebugger(Context.Debugger, new DwarfSymbolProvider.DwarfSymbolProvider()); } }