private string ExecIfValid(string exec) { if (exec != null && filesystem.GetFile(exec).Exists) { return(exec); } return(null); }
private string GetLocalPathFromPath(string filepath) { if (filesystem.GetFile("." + filepath).Exists) { return("." + filepath); } else if (filesystem.GetFile(filepath).Exists) { return(filepath); } return(null); }
/// <summary> /// Overrides the original *.so with the unstripped binary /// </summary> private async Task UnstripLibrary(SDCDModule module, string hash) { if (IsDebugFileAvailable(module, hash)) { string tempBinary = module.LocalPath + ".old"; if (filesystem.GetFile(tempBinary).Exists) { filesystem.Delete(tempBinary); } filesystem.Move(module.LocalPath, tempBinary); await processHandler.ExecuteProcessAndGetOutputAsync("eu-unstrip", $"-o {module.LocalPath} {tempBinary} {DebugFilePath(module.LocalPath, hash)}"); filesystem.Delete(tempBinary); } }
public void ProvideSourceFiles(string directory) { IList <Task> tasks = new List <Task>(); IList <string> files = new List <string>(); if (result.ThreadInformation == null) { return; } string repoUrl = Environment.GetEnvironmentVariable(EnvironmentName.REPOSITORY_URL.Name); string repoAuth = Environment.GetEnvironmentVariable(EnvironmentName.REPOSITORY_AUTHENTICATION.Name); if (string.IsNullOrEmpty(repoUrl)) { return; } foreach (var thread in result.ThreadInformation) { if (thread.Value.StackTrace == null) { continue; } foreach (var stackframe in thread.Value.StackTrace) { string file = stackframe.SourceInfo?.File; if (file == null) { // no source info continue; } string repoPath = DynatraceSourceLink.GetRepoPathIfAvailable(file); if (repoPath == null) { // source not available continue; } string url = repoUrl + repoPath; // GDB requires paths beginning with /src. Therefore, all source files must be merged into a common /src directory. string shortPath = file.Substring(1); if (shortPath.Contains("/src/")) { shortPath = shortPath.Substring(shortPath.IndexOf("/src/") + 1); } IFileInfo targetFile = filesystem.GetFile(Path.Combine(directory, shortPath)); if (files.Contains(targetFile.FullName)) { continue; } files.Add(targetFile.FullName); tasks.Add(requestHandler.DownloadFromUrlAsync(url, targetFile.FullName, repoAuth)); } } foreach (Task t in tasks) { t.Wait(); } }
private void LinkDebugFile(string localPath, string debugPath) { IFileInfo targetDebugFile = filesystem.GetFile(Path.Combine(Path.GetDirectoryName(localPath), DebugSymbolResolver.DebugFileName(localPath))); if (targetDebugFile.Exists) { return; } Console.WriteLine($"Creating symbolic link: {debugPath}, {targetDebugFile}"); filesystem.CreateSymbolicLink(debugPath, targetDebugFile.FullName); }
public void Analyze() { string logPath = $"{Path.Combine(coredump.Directory.FullName, Path.GetFileNameWithoutExtension(coredump.FullName))}.log"; var logFile = filesystem.GetFile(logPath); if (!logFile.Exists) { Console.WriteLine($"No coredump log available ({logPath}). Skipping."); return; } SetVersionsIfAvailable(logFile); }
private void ExtractModules(string gdbOut, IList <SDModule> modules) { foreach (string line in gdbOut.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { Match match = GdbLibraryRegex.Match(line); if (match.Success) { string startAddr = match.Groups[1].Value; string endAddr = match.Groups[2].Value; string library = match.Groups[3].Value; Console.WriteLine("Shared Library: 0x" + startAddr + " - 0x" + endAddr + ": " + library); modules.Add(new SDCDModule() { StartAddress = Convert.ToUInt64(startAddr, 16), EndAddress = Convert.ToUInt64(endAddr, 16), FilePath = library, FileName = Path.GetFileName(library), LocalPath = filesystem.GetFile(library).FullName, FileSize = (uint)GetFileSizeForLibrary(library) }); } } }
private IFileInfo GetCoreDumpFile(string inputFile) { IFileInfo file = filesystem.GetFile(inputFile); if (file.Exists) { if (file.Extension == ".core") { return(file); } else if (file.Extension == ".tar" || file.Extension == ".gz" || file.Extension == ".tgz" || file.Extension == ".tar" || file.Extension == ".zip") { IDirectoryInfo directory = file.Directory; Console.WriteLine($"Extracting archives in directory {directory.FullName}"); ExtractArchivesInDir(directory); return(FindCoredumpOrNull(directory)); } else { Console.WriteLine($"Could not identify input file {inputFile}. Assuming it is a core dump."); return(file); } } else { IDirectoryInfo directory = filesystem.GetDirectory(inputFile); if (directory.Exists) { Console.WriteLine($"Extracting archives in directory {directory.FullName}"); ExtractArchivesInDir(directory); return(FindCoredumpOrNull(directory)); } else { Console.WriteLine("Input file does not exist!"); return(null); } } }
private bool IsDebugFileAvailable(SDCDModule module, string hash) { return(filesystem.GetFile(DebugFilePath(module.LocalPath, hash)).Exists); }