LmT*_*oon 1 c# debugging clr windbg sos
我有简单的控制台应用程序(目标框架4.5.2):
using System;
public class SosTest
{
public class Foo
{
public Foo()
{
Console.WriteLine("Creation of foo");
}
}
static void Main(string[] args)
{
var n1 = new Foo();
var n2 = new Foo();
Console.WriteLine("Allocated objects");
Console.WriteLine("Press any key to invoke GC");
Console.ReadKey();
n2 = n1;
n1 = null;
GC.Collect();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
Run Code Online (Sandbox Code Playgroud)
我想看看托管堆的状态.我做了以下步骤:
.load MicrosoftNet\Framework\v4.0.30319\sos.dll!eeheap -gc但在最后一个命令中我得到以下消息:
无法找到运行时DLL(clr.dll),0x80004005扩展命令需要clr.dll才能执行某些操作.
为什么命令!eeheap -gc失败?
如果它会帮助它是lm命令的结果:
0:000> lm
start end module name
00be0000 00be8000 ConsoleApplication1 (deferred)
734c0000 73519000 MSCOREE (deferred)
74c20000 74d00000 KERNEL32 (deferred)
753d0000 75571000 KERNELBASE (deferred)
77d80000 77f03000 ntdll (pdb symbols)
Run Code Online (Sandbox Code Playgroud)
我不确定你是否正确行事,但我过去常常使用以下命令:
sxe ld clrjit; g
Run Code Online (Sandbox Code Playgroud)
之后写:
.loadby sos clr
Run Code Online (Sandbox Code Playgroud)
的sxe ld clrjit时通知调试器clrjit模块被装载时,g标志是用于继续执行和.loadby sos clr将加载SOS调试器,其中它发现从位置clr.dll
我曾经看过以下的以下两个复数视线上的课程C#塔内由巴特迪斯,我发现他们非常适合于理解C#和CLR的见解: