Exemplo n.º 1
0
        // called by WebSocketManager
        public void StartSession(string socketId, string bundleId, string dumpId, string initialCommand)
        {
            try {
                System.Console.WriteLine($"StartSession ({socketId}): {bundleId}, {dumpId}");
                if (string.IsNullOrEmpty(bundleId) || string.IsNullOrEmpty(dumpId))
                {
                    return;
                }
                var dumpInfo         = dumpRepo.Get(bundleId, dumpId);
                var dumpFilePath     = dumpRepo.GetDumpFilePath(bundleId, dumpId);
                var dumpFilePathInfo = dumpFilePath != null ? new FileInfo(dumpFilePath) : null;
                var workingDirectory = dumpFilePathInfo?.Directory;

                var  sdResult         = dumpRepo.GetResult(bundleId, dumpId).Result;
                bool is64bit          = sdResult?.SystemContext.ProcessArchitecture.Contains("64") ?? true;        // default to 64 bit in case it's not known
                ConsoleAppManager mgr = null;
                var initialCommands   = new List <string>();
                if (dumpInfo.DumpFileName.EndsWith(".dmp", StringComparison.OrdinalIgnoreCase))
                {
                    mgr = StartCdb(socketId, workingDirectory, dumpFilePathInfo, is64bit, bundleId, dumpId);
                    initialCommands.Add(".cordll -ve -u -l");                     // load DAC and SOS
                }
                else
                {
                    throw new NotSupportedException($"file extension of '{dumpInfo.DumpFileName}' not supported for interactive mode.");
                }
                if (mgr != null && !string.IsNullOrEmpty(initialCommand))
                {
                    initialCommands.Add(WebUtility.UrlDecode(initialCommand));
                }
                RunInitialCommandsAsync(socketId, mgr, initialCommands);
            } catch (Exception e) {
                Console.WriteLine($"Error in StartSession: {e}");
            }
        }
Exemplo n.º 2
0
        public override async Task <AnalyzerState> AnalyzeDump(DumpMetainfo dumpInfo, string analysisWorkingDir, AnalyzerState previousState)
        {
            if (dumpInfo.DumpType != DumpType.WindowsDump && dumpInfo.DumpType != DumpType.LinuxCoreDump)
            {
                return(previousState);
            }

            try {
                string dumpFilePath = dumpRepo.GetDumpFilePath(dumpInfo.Id);
                if (!File.Exists(dumpFilePath))
                {
                    dumpRepo.SetErrorMessage(dumpInfo.Id, $"Primary dump file not found (id: {dumpInfo.Id}, path: {dumpFilePath})");
                    return(AnalyzerState.Failed);
                }

                if (new FileInfo(dumpFilePath).Length == 0)
                {
                    dumpRepo.SetErrorMessage(dumpInfo.Id, "The primary dump file is empty!");
                    return(AnalyzerState.Failed);
                }

                if (dumpInfo.DumpType == DumpType.WindowsDump)
                {
                    await AnalyzeWindows(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }
                else if (dumpInfo.DumpType == DumpType.LinuxCoreDump)
                {
                    await LinuxAnalyzationAsync(dumpInfo, new DirectoryInfo(analysisWorkingDir), dumpFilePath);
                }

                // Re-fetch dump info as it was updated
                dumpInfo = dumpRepo.Get(dumpInfo.Id);

                SDResult result = await dumpRepo.GetResultAndThrow(dumpInfo.Id);

                if (result != null)
                {
                    return(AnalyzerState.Succeeded);
                }
                else
                {
                    return(AnalyzerState.Failed);
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                dumpRepo.SetErrorMessage(dumpInfo.Id, e.ToString());
                return(AnalyzerState.Failed);
            } finally {
                dumpInfo = dumpRepo.Get(dumpInfo.Id);
                if (settings.Value.DeleteDumpAfterAnalysis)
                {
                    dumpRepo.DeleteDumpFile(dumpInfo.Id);
                }
            }
        }
Exemplo n.º 3
0
 public void StartSession(string socketId, string bundleId, string dumpId)
 {
     try {
         System.Console.WriteLine($"StartSession ({socketId}): {bundleId}, {dumpId}");
         if (string.IsNullOrEmpty(bundleId) || string.IsNullOrEmpty(dumpId))
         {
             return;
         }
         var  dumpInfo = dumpRepo.Get(bundleId, dumpId);
         bool is64bit  = dumpInfo.Is64Bit.HasValue ? dumpInfo.Is64Bit.Value : true;                // default to 64 bit in case it's not known.
         StartCdb(socketId, dumpRepo.GetDumpFilePath(bundleId, dumpId), is64bit);
     } catch (Exception e) {
         Console.WriteLine($"Error in StartSession: {e}");
     }
 }