public HttpResponseMessage InfoPackage() { var tempFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); try { using (var file = new FileStream(tempFileName, FileMode.Create)) using (var package = new ZipArchive(file, ZipArchiveMode.Create)) { DebugInfoProvider.CreateInfoPackageForDatabase(package, Database, RequestManager); } var response = new HttpResponseMessage(); response.Content = new StreamContent(new FileStream(tempFileName, FileMode.Open, FileAccess.Read)) { Headers = { ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = string.Format("Debug-Info-{0}.zip",SystemTime.UtcNow), }, ContentType = new MediaTypeHeaderValue("application/octet-stream") } }; return(response); } finally { IOExtensions.DeleteFile(tempFileName); } }
public HttpResponseMessage Tasks() { return(new HttpResponseMessage { Content = new PushStreamContent((stream, content, context) => { using (var writer = new StreamWriter(stream)) { var tasks = DebugInfoProvider.GetTasksForDebug(Database); writer.WriteLine("Id,IndexId,IndexName,AddedTime,Type"); foreach (var task in tasks) { writer.WriteLine("{0},{1},{2},{3},{4}", task.Id, task.IndexId, task.IndexName, task.AddedTime, task.Type); } writer.Flush(); stream.Flush(); } }) { Headers = { ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "tasks.csv", }, ContentType = new MediaTypeHeaderValue("text/csv") } } }); }
/// <summary> /// Initializes the members used by a solution /// </summary> private void OnSolutionOpened() { CheckCpsFiles(); // --- Let's create the ZX Spectrum virtual machine view model // --- that is used all around in tool windows CodeDiscoverySolution = new SolutionStructure(); CodeDiscoverySolution.CollectProjects(); // --- Every time a new solution has been opened, initialize the // --- Spectrum virtual machine with all of its accessories var vm = MachineViewModel = CreateProjectMachine(); // --- Set up the debug info provider DebugInfoProvider.Prepare(); vm.DebugInfoProvider = DebugInfoProvider; // --- Prepare the virtual machine vm.PrepareStartupConfig(); vm.MachineController.EnsureMachine(); SolutionOpened?.Invoke(this, EventArgs.Empty); // --- Let initialize these tool windows even before showing up them GetToolWindow(typeof(SpectrumEmulatorToolWindow)); GetToolWindow(typeof(AssemblerOutputToolWindow)); GetToolWindow(typeof(MemoryToolWindow)); GetToolWindow(typeof(DisassemblyToolWindow)); }
public override void before_each() { base.before_each(); string wrongBinaryPath = @".\some\wrong\path\to\library.dll"; provider = new DebugInfoProvider(wrongBinaryPath, logger); }
public override void before_each() { base.before_each(); string binaryPath = SpecSampleFileInfo.ThisBinaryFilePath; provider = new DebugInfoProvider(binaryPath, logger); }
/// <summary> /// Cleans up after closing a solution /// </summary> private void OnSolutionClosed() { // --- When the current solution has been closed, // --- stop the virtual machine and clean up SolutionClosed?.Invoke(this, EventArgs.Empty); DebugInfoProvider.Clear(); MachineViewModel?.StopVm(); }
public HttpResponseMessage InfoPackage() { var tempFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); try { var jsonSerializer = new JsonSerializer { Formatting = Formatting.Indented }; jsonSerializer.Converters.Add(new EtagJsonConverter()); using (var file = new FileStream(tempFileName, FileMode.Create)) using (var package = new ZipArchive(file, ZipArchiveMode.Create)) { var adminStats = package.CreateEntry("admin_stats.txt", CompressionLevel.Optimal); using (var metricsStream = adminStats.Open()) using (var streamWriter = new StreamWriter(metricsStream)) { jsonSerializer.Serialize(streamWriter, CreateAdminStats()); streamWriter.Flush(); } DatabasesLandlord.ForAllDatabases(database => { var prefix = string.IsNullOrWhiteSpace(database.Name) ? "System" : database.Name; DebugInfoProvider.CreateInfoPackageForDatabase(package, database, RequestManager, prefix + "/"); }); var stacktraceRequsted = GetQueryStringValue("stacktrace"); if (stacktraceRequsted != null) { DumpStacktrace(package); } } var response = new HttpResponseMessage(); response.Content = new StreamContent(new FileStream(tempFileName, FileMode.Open, FileAccess.Read)) { Headers = { ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = string.Format("Admin-Debug-Info-{0}.zip",SystemTime.UtcNow), }, ContentType = new MediaTypeHeaderValue("application/octet-stream") } }; return(response); } finally { IOExtensions.DeleteFile(tempFileName); } }
/// <summary> /// Initializes the members used by a solution /// </summary> private void OnSolutionOpened() { CheckCpsFiles(); // --- Let's create the ZX Spectrum virtual machine view model // --- that is used all around in tool windows CodeDiscoverySolution = new SolutionStructure(); CodeDiscoverySolution.CollectProjects(); // --- Every time a new solution has been opened, initialize the // --- Spectrum virtual machine with all of its accessories var spectrumConfig = CodeDiscoverySolution.CurrentProject.SpectrumConfiguration; var vm = MachineViewModel = new MachineViewModel(); vm.MachineController = new MachineController(); vm.ScreenConfiguration = spectrumConfig.Screen; // --- Create devices according to the project's Spectrum model var modelName = CodeDiscoverySolution.CurrentProject.ModelName; switch (modelName) { case SpectrumModels.ZX_SPECTRUM_128: vm.DeviceData = CreateSpectrum128Devices(spectrumConfig); break; case SpectrumModels.ZX_SPECTRUM_P3_E: vm.DeviceData = CreateSpectrumP3Devices(spectrumConfig); break; case SpectrumModels.ZX_SPECTRUM_NEXT: vm.DeviceData = CreateSpectrum48Devices(spectrumConfig); break; default: vm.DeviceData = CreateSpectrum48Devices(spectrumConfig); break; } vm.AllowKeyboardScan = true; vm.StackDebugSupport = new SimpleStackDebugSupport(); vm.DisplayMode = SpectrumDisplayMode.Fit; // --- Set up the debug info provider DebugInfoProvider.Prepare(); vm.DebugInfoProvider = DebugInfoProvider; // --- Prepare the virtual machine vm.PrepareStartupConfig(); vm.MachineController.EnsureMachine(); SolutionOpened?.Invoke(this, EventArgs.Empty); // --- Let initializethese tool windows even before showing up them GetToolWindow(typeof(AssemblerOutputToolWindow)); GetToolWindow(typeof(MemoryToolWindow)); GetToolWindow(typeof(DisassemblyToolWindow)); }
public HttpResponseMessage RequestTracing() { if (CanExposeConfigOverTheWire() == false) { return(GetEmptyMessage(HttpStatusCode.Forbidden)); } return(GetMessageWithObject(DebugInfoProvider.GetRequestTrackingForDebug(RequestManager, DatabaseName))); }
public HttpResponseMessage Config() { if (CanExposeConfigOverTheWire() == false) { return(GetEmptyMessage(HttpStatusCode.Forbidden)); } return(GetMessageWithObject(DebugInfoProvider.GetConfigForDebug(Database))); }
public ExampleRunner( string testAssemblyPath, Action <DiscoveredExample> onDiscovered, Action <ExecutedExample> onExecuted) { this.testAssemblyPath = testAssemblyPath; this.onDiscovered = onDiscovered; this.onExecuted = onExecuted; debugInfoProvider = new DebugInfoProvider(testAssemblyPath); }
public HttpResponseMessage TasksSummary() { var debugInfo = DebugInfoProvider.GetTasksForDebug(Database); var debugSummary = debugInfo .GroupBy(x => new { x.Type, x.IndexId, x.IndexName }) .Select(x => new { Type = x.Key.Type, IndexId = x.Key.IndexId, IndexName = x.Key.IndexName, Count = x.Count(), MinDate = x.Min(item => item.AddedTime), MaxDate = x.Max(item => item.AddedTime) }) .ToList(); return(GetMessageWithObject(debugSummary)); }
/// <summary> /// Initializes the members used by a solution /// </summary> private async void OnSolutionOpened() { try { CheckCpsFiles(); await Task.Delay(2000); // --- Let's create the ZX Spectrum virtual machine view model // --- that is used all around in tool windows CodeDiscoverySolution = new SolutionStructure(); CodeDiscoverySolution.CollectProjects(); // --- Every time a new solution has been opened, initialize the // --- Spectrum virtual machine with all of its accessories var vm = MachineViewModel = CreateProjectMachine(); // --- Create an expression evaluation context and bind the machine with it DebugEvaluationContext = new SymbolAwareSpectrumEvaluationContext(vm.SpectrumVm); // --- Set up the debug info provider DebugInfoProvider.Prepare(); vm.DebugInfoProvider = DebugInfoProvider; SolutionOpened?.Invoke(this, EventArgs.Empty); // --- Let initialize these tool windows even before showing up them GetToolWindow(typeof(SpectrumEmulatorToolWindow)); GetToolWindow(typeof(AssemblerOutputToolWindow)); GetToolWindow(typeof(MemoryToolWindow)); GetToolWindow(typeof(DisassemblyToolWindow)); GetToolWindow(typeof(WatchToolWindow)); } catch (Exception e) { if (!(GetService(typeof(SVsActivityLog)) is IVsActivityLog log)) { return; } log.LogEntry((uint)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR, "OnSolutionOpen", $"Exception raised: {e}"); } }
/// <summary> /// Cleans up after closing a solution /// </summary> private void OnSolutionClosed() { try { // --- When the current solution has been closed, // --- stop the virtual machine and clean up SolutionClosed?.Invoke(this, EventArgs.Empty); ErrorList.Clear(); DebugInfoProvider.Clear(); MachineViewModel?.Stop(); CodeDiscoverySolution = null; } catch (Exception e) { if (!(GetService(typeof(SVsActivityLog)) is IVsActivityLog log)) return; log.LogEntry((uint)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR, "OnSolutionClosed", $"Exception raised: {e}"); } }
public HttpResponseMessage RequestTracing() { return(GetMessageWithObject(DebugInfoProvider.GetRequestTrackingForDebug(RequestManager, DatabaseName))); }
public HttpResponseMessage PrefetchingQueueStatus() { return(GetMessageWithObject(DebugInfoProvider.GetPrefetchingQueueStatusForDebug(Database))); }
public HttpResponseMessage CurrentlyIndexing() { return(GetMessageWithObject(DebugInfoProvider.GetCurrentlyIndexingForDebug(Database))); }
/// <summary> /// Checks whether the execution cycle should be stopped for debugging /// </summary> /// <param name="options">Execution options</param> /// <param name="executedInstructionCount"> /// The count of instructions already executed in this cycle /// </param> /// <returns>True, if the execution should be stopped</returns> private bool IsDebugStop(ExecuteCycleOptions options, int executedInstructionCount) { // --- No debug provider, no stop if (DebugInfoProvider == null) { return(false); } // Check if the maskable interrupt routine breakpoints should be skipped if (RunsInMaskableInterrupt) { if (options.SkipInterruptRoutine) { return(false); } } // --- In Step-Into mode we always stop when we're about to // --- execute the next instruction if (options.DebugStepMode == DebugStepMode.StepInto) { return(executedInstructionCount > 0); } // --- In Stop-At-Breakpoint mode we stop only if a predefined // --- breakpoint is reached if (options.DebugStepMode == DebugStepMode.StopAtBreakpoint && DebugInfoProvider.ShouldBreakAtAddress(Cpu.Registers.PC)) { if (executedInstructionCount > 0 || _lastBreakpoint == null || _lastBreakpoint != Cpu.Registers.PC) { // --- If we are paused at a breakpoint, we do not want // --- to pause again and again, unless we step through _lastBreakpoint = Cpu.Registers.PC; return(true); } } // --- We're in Step-Over mode if (options.DebugStepMode == DebugStepMode.StepOver) { if (DebugInfoProvider.ImminentBreakpoint != null) { // --- We also stop, if an imminent breakpoint is reached, and also remove // --- this breakpoint if (DebugInfoProvider.ImminentBreakpoint == Cpu.Registers.PC) { DebugInfoProvider.ImminentBreakpoint = null; return(true); } } else { var imminentJustCreated = false; // --- We check for a CALL-like instruction var length = Cpu.GetCallInstructionLength(); if (length > 0) { // --- Its a CALL-like instraction, create an imminent breakpoint DebugInfoProvider.ImminentBreakpoint = (ushort)(Cpu.Registers.PC + length); imminentJustCreated = true; } // --- We stop, we executed at least one instruction and if there's no imminent // --- breakpoint or we've just created one if (executedInstructionCount > 0 && (DebugInfoProvider.ImminentBreakpoint == null || imminentJustCreated)) { return(true); } } } // --- In any other case, we carry on return(false); }
public ExampleSelector(string testAssemblyPath) { this.testAssemblyPath = testAssemblyPath; debugInfoProvider = new DebugInfoProvider(testAssemblyPath); }
public HttpResponseMessage Tasks() { return(GetMessageWithObject(DebugInfoProvider.GetTasksForDebug(Database))); }
public HttpResponseMessage Config() { return(GetMessageWithObject(DebugInfoProvider.GetConfigForDebug(Database))); }