-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,041 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,79 @@ | ||
using Heartbeat.Domain; | ||
using Heartbeat.Runtime; | ||
using Heartbeat.Runtime.Domain; | ||
using Heartbeat.Runtime.Analyzers; | ||
using Heartbeat.Runtime.Proxies; | ||
|
||
using Microsoft.Diagnostics.Runtime; | ||
using Microsoft.Diagnostics.Runtime.Interfaces; | ||
|
||
// foreach (var dumpPath in Directory.GetFiles(@"D:\dumps", "*.dmp")) | ||
// { | ||
// ProcessFile(dumpPath); | ||
// } | ||
foreach (var dumpPath in Directory.GetFiles(@"C:\Users\Ne4to\projects\local\HttpRequestDumpSamples", "*.dmp")) | ||
{ | ||
ProcessFile(dumpPath); | ||
} | ||
|
||
ProcessFile(@"D:\dbg\dump_20230507_155200.dmp"); | ||
// ProcessFile(@"D:\dbg\dump_20230507_155200.dmp"); | ||
// ProcessFile(@"D:\dbg\user-management\local\dotnet-04.DMP"); | ||
|
||
static void ProcessFile(string filePath) | ||
{ | ||
{ | ||
Console.WriteLine(); | ||
Console.WriteLine($"Processing dump: {filePath}"); | ||
|
||
var runtimeContext = new RuntimeContext(filePath); | ||
WriteDictionary(runtimeContext); | ||
// WriteDictionary(runtimeContext); | ||
// WriteWebRequests(runtimeContext); | ||
WriteHttpRequestMessage(runtimeContext); | ||
|
||
static void WriteHttpRequestMessage(RuntimeContext runtimeContext) | ||
{ | ||
var analyzer = new HttpRequestAnalyzer(runtimeContext); | ||
foreach (HttpRequestInfo httpRequest in analyzer.EnumerateHttpRequests()) | ||
{ | ||
Console.WriteLine($"{httpRequest.HttpMethod} {httpRequest.Url} {httpRequest.StatusCode}"); | ||
Console.WriteLine("\tRequest headers:"); | ||
PrintHeaders(httpRequest.RequestHeaders); | ||
Console.WriteLine("\tResponse headers:"); | ||
PrintHeaders(httpRequest.ResponseHeaders); | ||
} | ||
|
||
static void PrintHeaders(IReadOnlyList<HttpHeader> headers) | ||
{ | ||
foreach (HttpHeader header in headers) | ||
{ | ||
Console.WriteLine($"\t\t{header.Name}: {header.Value}"); | ||
} | ||
} | ||
} | ||
|
||
void WriteDictionary(RuntimeContext runtimeContext1) | ||
static void WriteDictionary(RuntimeContext runtimeContext) | ||
{ | ||
var obj = runtimeContext.EnumerateObjects(null) | ||
IClrValue obj = runtimeContext.EnumerateObjects(null) | ||
.Where(obj => !obj.IsNull && obj.Type.Name.StartsWith("System.Collections.Generic.Dictionary<System.String")) | ||
.FirstOrDefault(); | ||
|
||
DictionaryProxy dictionaryProxy = new DictionaryProxy(runtimeContext, obj); | ||
foreach (var kvp in dictionaryProxy.EnumerateItems()) | ||
{ | ||
Console.WriteLine($"{kvp.Key.Address:x16} = {kvp.Value.Address:x16}"); | ||
Console.WriteLine($"{kvp.Key.Value.Address:x16} = {kvp.Value.Value.Address:x16}"); | ||
} | ||
} | ||
// WriteWebRequests(runtimeContext); | ||
|
||
static void WriteWebRequests(RuntimeContext runtimeContext) | ||
{ | ||
var q = from clrObject in runtimeContext.EnumerateObjectsByTypeName("System.Net.HttpWebRequest", null) | ||
let webRequestProxy = new HttpWebRequestProxy(runtimeContext, clrObject) | ||
let requestContentLength = webRequestProxy.ContentLength | ||
let responseContentLength = webRequestProxy.Response?.ContentLength | ||
let totalSize = requestContentLength ?? 0L + responseContentLength ?? 0L | ||
orderby totalSize descending | ||
select $"{webRequestProxy.Method} {webRequestProxy.Address.Value} Request ContentLength: {webRequestProxy.ContentLength} Response ContentLength {webRequestProxy.Response?.ContentLength}"; | ||
var q = from IClrValue clrObject in runtimeContext.EnumerateObjectsByTypeName("System.Net.HttpWebRequest", null) | ||
let webRequestProxy = new HttpWebRequestProxy(runtimeContext, clrObject) | ||
let requestContentLength = webRequestProxy.ContentLength | ||
let responseContentLength = webRequestProxy.Response?.ContentLength | ||
let totalSize = requestContentLength ?? 0L + responseContentLength ?? 0L | ||
orderby totalSize descending | ||
select | ||
$"{webRequestProxy.Method} {webRequestProxy.Address.Value} Request ContentLength: {webRequestProxy.ContentLength} Response ContentLength {webRequestProxy.Response?.ContentLength}"; | ||
|
||
foreach (var msg in q.Take(10)) | ||
{ | ||
Console.WriteLine(msg); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.