public virtual StringBuilder DoProcessing(MDFileConnection memoryDumpFileConnection) { var dump = DataTarget.LoadCrashDump(fileName: memoryDumpFileConnection.PathToDump); // dump.SymbolLocator = new DefaultSymbolLocator // { // SymbolCache = @"C:\symbols" // }; // TODO: NMI test. Migration to newer clrMD /* * dump.SetSymbolPath(@"http://msdl.microsoft.com/download/symbols/"); * * if (string.IsNullOrEmpty(pathToMscord)) * pathToMscord = dump.ClrVersions[0].TryDownloadDac(); */ var runtime = dump.ClrVersions[0].CreateRuntime(memoryDumpFileConnection.PathToMsCorDacwks, ignoreMismatch: true); var dynamicModules = from module in runtime.Modules where module.IsDynamic where !module.IsFile select module; var sb = new StringBuilder(); foreach (var module in dynamicModules) { Console.WriteLine(module); sb.AppendLine(ProduceModuleInfo(module)); } return(sb); }
public virtual StringBuilder DoProcessing(MDFileConnection memoryDumpFileConnection) { var sb = new StringBuilder(); var map = ModelMapperManager.NewMapperFactory; var runtime = MDClrRuntimeFactory.Instance.BuildClrRuntime(memoryDumpFileConnection); var messages = from fileAppender in map.ExtractFromHeap <SitecoreLogFileAppenderModel>(memoryDumpFileConnection) let textWriterModel = fileAppender.TextWritter as QuietTextWriterModel let innerWriter = textWriterModel?.InnerWritter as StreamWriterModel let lastLogEntry = innerWriter?.InMemoryContent where !string.IsNullOrEmpty(lastLogEntry) select new { loggerName = fileAppender.LogAppenderName, file = fileAppender.m_fileName, logTime = fileAppender.m_currentDate, bufferAddress = innerWriter.HexAddress, lastLogEntry }; messages.ToArray().ForEach(message => sb.AppendLine(message.ToString())); return(sb); }
public virtual IOrderedEnumerable <ContactInfo> ExtractRequestsByContact(MDFileConnection instance) { var runtime = MDClrRuntimeFactory.Instance.BuildClrRuntime(instance); var modelMapperFactory = ModelMapperManager.NewMapperFactory; return(ExtractRequestsByContact(runtime, modelMapperFactory)); }
public static IEnumerable <IClrObjMappingModel> ExtractFromHeap(this IModelMapperFactory factory, IFilteredObjectsProvider clrObjectFilter, string pathToDumpFile, string pathToMsCord = null) { if (string.IsNullOrEmpty(pathToMsCord)) { MDClrRuntimeFactory.TryGetMscordacPath(pathToDumpFile, out pathToMsCord); } var connectionDetails = new MDFileConnection(pathToDumpFile, pathToMsCord); return(ExtractFromHeap(factory, clrObjectFilter, connectionDetails)); }
public virtual StringBuilder DoProcessing(MDFileConnection memoryDumpFileConnection) { var runtime = MDClrRuntimeFactory.Instance.BuildClrRuntime(memoryDumpFileConnection); var modelMapperFactory = ModelMapperManager.NewMapperFactory; var requests = ObjectFilter.EnumerateObjectsFromHeap <HttpWebRequestMappingModel>(memoryDumpFileConnection, modelMapperFactory) .Where(r => r.ContainUrl && !r.m_BodyStarted).OrderByDescending(r => r.StartTime); var sb = new StringBuilder(); foreach (var request in requests) { sb.AppendLine($"Request: {request.Url}{Environment.NewLine}Started: {request.StartTime} Submited: {request.m_RequestSubmitted} OnceFailed: {request.m_OnceFailed}{Environment.NewLine} Body started:{request.m_BodyStarted} Hex: {request.HexAddress}"); } return(sb); }
public virtual StringBuilder DoProcessing(MDFileConnection memoryDumpFileConnection) { var contacts = ExtractRequestsByContact(memoryDumpFileConnection); var sb = new StringBuilder(); foreach (var contact in contacts) { sb.AppendLine(new string(Enumerable.Repeat('*', 40).ToArray())); sb.AppendLine($"{contact.ContactId} has {contact.Count} requests with {contact.DistinctAspNet} asp.Net sessions:"); foreach (var request in contact.Requests) { sb.AppendLine(request.ToString()); } sb.AppendLine(); } return(sb); }
public virtual StringBuilder DoProcessing(MDFileConnection memoryDumpFileConnection) { var modelMapperFactory = ModelMapperManager.NewMapperFactory; var renderRenderingStreams = ObjectFilter.EnumerateObjectsFromHeap <MVCRenderRenderingArgsMapping>(memoryDumpFileConnection, modelMapperFactory); var sb = new StringBuilder(); var gold = from args in renderRenderingStreams where args.Rendered where args.UsedCache == false let pageContext = args.Obj.GetRefFld("_pageContext") where !pageContext.IsNullObj let innerHttpContext = pageContext.GetRefFldChained(new[] { "requestContext", "<HttpContext>k__BackingField", "_context" }, false) where innerHttpContext.HasValue let context = modelMapperFactory.BuildOfType <HttpContextMappingModel>(innerHttpContext.Value) where context?.HasURL == true let renderingPointer = args.Obj.GetRefFldChained(new[] { "<Rendering>k__BackingField", "renderer" }, false) where renderingPointer.HasValue let controllerRendered = modelMapperFactory.BuildOfType <ControllerRendererMapping>(renderingPointer.Value) where controllerRendered != null select new { args.HexAddress, url = context.URL, executed = context.ExecutionDuration.TotalSeconds, controller = controllerRendered.ControllerName, action = controllerRendered.ActionName, }; foreach (var tile in gold) { sb.Append(tile); } return(sb); }
public virtual StringBuilder DoProcessing(MDFileConnection memoryDumpFileConnection) { var runtime = MDClrRuntimeFactory.Instance.BuildClrRuntime(memoryDumpFileConnection); var modelMapperFactory = ModelMapperManager.NewMapperFactory; var allThreadContext = ObjectFilter.ExtractFromRuntime(runtime, ObjectEnumerator); var gold = from threadContext in allThreadContext let model = modelMapperFactory.BuildModel(threadContext) as ThreadContextMappingModel where model != null where model._setCurrentThreadOnHttpContext = true let context = model.AssignedHttpContext where context != null where !context._finishPipelineRequestCalled /* NOT YET OVER */ let request = context._request as HttpRequestMappingModel where request != null let cookies = request._cookies.Value as HashtableMappingModel where cookies != null where cookies.Elements.ContainsKey(TextConstants.CookieNames.SitecoreAnalyticsGlobal) // where cookies.Elements.ContainsKey(TextConstants.CookieNames.AspNetSession) let analyticsCookie = cookies[TextConstants.CookieNames.SitecoreAnalyticsGlobal] as HttpCookieModel let sessionCookie = cookies[TextConstants.CookieNames.AspNetSession] as HttpCookieModel where !string.IsNullOrEmpty(analyticsCookie.Value) // where !string.IsNullOrEmpty(sessionCookie.Value) let workerRequest = context._wr as IIS7WorkerRequestModel where workerRequest != null let metadata = new { context.URL, TotalSeconds = Math.Round(context.ExecutionDuration.TotalSeconds, 2), analyticsId = analyticsCookie.Value, aspSession = sessionCookie?.Value ?? "[NoSession]", context = context.HexAddress, request = request.HexAddress, threadId = context.ManagedThreadId } where metadata.TotalSeconds > 0 orderby metadata.TotalSeconds descending select metadata; var sb = new StringBuilder(); foreach (var request in gold) { sb.AppendLine(new string(Enumerable.Repeat('*', 40).ToArray())); sb.AppendLine(request.ToString()); sb.AppendLine(); } return(sb); }
public static IEnumerable <ClrObject> EnumerateObjectsFromHeap(this IFilteredObjectsProvider filteredObjectProvider, string pathToMemoryDump, string pathToMsCord) { var connection = new MDFileConnection(pathToMemoryDump, pathToMsCord); return(EnumerateObjectsFromHeap(filteredObjectProvider, connection)); }