public async Task InvokeAsync(HttpContext context)
        {
            ClrInfo    runtimeInfo = _dataTargetProvider.GetDataTarget().ClrVersions[0];
            ClrRuntime runtime     = runtimeInfo.CreateRuntime();
            var        stats       = from o in runtime.Heap.EnumerateObjects()
                                     let t = o.Type
                                             group o by t into g
                                             let size = g.Sum(o => (uint)o.Size)
                                                        select new
            {
                Name  = g.Key.Name,
                Size  = size,
                Count = g.Count()
            };

            var content = TableBuilder.CreateDataTable("Heap", stats.OrderByDescending(f => f.Size).Select(f => new
            {
                Size  = f.Size,
                Count = f.Count.ToString(),
                Name  = f.Name
            }));

            await _next(context);

            await context.Response.WriteAsync(content);
        }
        public async Task InvokeAsync(HttpContext context)
        {
            await _next(context);

            ClrInfo    runtimeInfo = _dataTargetProvider.GetDataTarget().ClrVersions[0];
            ClrRuntime runtime     = runtimeInfo.CreateRuntime();

            if (context.Request.Query.TryGetValue("id", out StringValues value))
            {
                var       threadId = value.ToString();
                ClrThread thread   = runtime.Threads.FirstOrDefault(f => f.OSThreadId.ToString() == threadId);
                if (thread != null)
                {
                    string content = TableBuilder.CreateDataTable($"Stack for Thread {threadId}", thread.StackTrace.Select(f => new
                    {
                        InstructionPointer = TableColumn.Wrap(f.InstructionPointer).Format("{0,12:X}"),
                        StackPointer       = TableColumn.Wrap(f.StackPointer).Format("{0,12:X}"),
                        DisplayString      = f.DisplayString,
                        Method             = f.Method,
                        ModuleName         = f.ModuleName,
                    }));

                    await context.Response.WriteAsync(content);
                }
            }
        }
        public async Task InvokeAsync(HttpContext context)
        {
            ClrInfo    runtimeInfo = _dataTargetProvider.GetDataTarget().ClrVersions[0];
            ClrRuntime runtime     = runtimeInfo.CreateRuntime();
            var        content     = TableBuilder.CreateDataTable("Threads", runtime.Threads.Select(f => new
            {
                ThreadId   = TableColumn.Wrap(f.OSThreadId).Link($"{context.Request.PathBase.Value}/stacks?id={f.OSThreadId}"),
                GcMode     = f.GcMode,
                Runtime    = f.Runtime.ToString(),
                AppDomains = string.Join(",", f.Runtime.AppDomains.Select(a => a.Name))
            }));

            await _next(context);

            await context.Response.WriteAsync(content);
        }
Ejemplo n.º 4
0
        public async Task InvokeAsync(HttpContext context)
        {
            await _next(context);

            var versions = _dataTargetProvider.GetDataTarget().ClrVersions;

            string content = TableBuilder.CreateDataTable("Clr Info", versions.Select(f => new {
                ClrVersion       = f.Version.ToString(),
                Flavor           = f.Flavor,
                LocalMatchingDac = f.LocalMatchingDac,
                DacInfoFileName  = f.DacInfo.FileName,
                DacInfoFileSize  = f.DacInfo.FileSize,
                Architecture     = f.DacInfo.TargetArchitecture,
            }));

            await context.Response.WriteAsync(content);
        }
Ejemplo n.º 5
0
        public async Task InvokeAsync(HttpContext context)
        {
            ClrInfo    runtimeInfo = _dataTargetProvider.GetDataTarget().ClrVersions[0];
            ClrRuntime runtime     = runtimeInfo.CreateRuntime();
            var        content     = TableBuilder.CreateDataTable("Modules", runtime.Modules.Select(f => new
            {
                AssemblyId      = f.AssemblyId,
                AssemblyName    = f.AssemblyName,
                DebuggingMode   = f.DebuggingMode,
                FileName        = f.FileName,
                ImageBase       = f.ImageBase,
                MetadataAddress = f.MetadataAddress,
                Name            = f.Name,
                Runtime         = f.Runtime,
            }));

            await _next(context);

            await context.Response.WriteAsync(content);
        }