Psscor a soralım - Sık kullanılan Psscor komutları

Tekrar merhaba,

Önceki blog 'umuzda Windbg ve Psscor Extension' larının kurulumundan bahsetmiştik. İleriki yazılarımızda, farklı problemler için farklı debugging tekniklerini paylaşıyor olacağız. Fakat öncelikle en sık kullanacağımız komutlardan bazılarını sizinle paylaşmak istiyorum. Aşağıdaki soruları Windbg.exe 'yi çalıştırıp , psscor4 eklentisini yükledikten sonra soruyoruz:

Soru: Bu dump içerisinde .Net ‘in kullandığı tüm managed memory alanında hangi nesneler var özetleyebilir misin?

0:000> !dumpheap -stat

Statistics:
              MT Count TotalSize Class Name

..

000007ff001cd410 985,058 68,587,072 System.String
0000000002208a40 174 99,344,192 Free
Total 3,288,521 objects, Total size: 348,980,688

Soru: Şuanda bu dump içerisinde çalışan .net thread'leri nelerdir, ve ne yapıyorlar?

0:000> ~*e!clrstack
OS Thread Id: 0x17fc (0)

...

Soru: #56 numaralı thread’e gitmek istiyorum.

0:000> ~56s

Soru: Peki #56 numaralı thread’de şuan hangi .Net objeleri var?

0:056> !dso
OS Thread Id: 0x2af4 (56)
RSP/REG Object Name
rax 00000001812d0ad0 System.ServiceModel.Channels.ServiceChannel

...

Soru: Elimde objenin bulunduğu adres var, Bu objenin içeriğini görmek istiyorum.

0:056> !dumpobj 00000001812d0ad0
Name: System.ServiceModel.Channels.ServiceChannel
MethodTable: 000007ff01d8f780
EEClass: 000007ff01da94b8
Size: 264(0x108) bytes
File: C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll
Fields:
              MT Field Offset Type VT Attr Value Name
000007ff00213918 4000072 4c System.Boolean 1 instance 0 aborted

...

Soru: Bu objenin hangi obje'lere bağlı olduğunu (kökenini) nasıl bulabilirim?

0:056> !gcroot 00000001812d0ad0
...

Scan Thread 29 OSTHread 1a3c
RSP:6b5ecd0:Root: 00000001a1bf6ac8(System.Threading.Tasks.TaskExceptionHolder)->
00000001e185a620(System.Threading.Tasks.Task)->
00000001e185a788(System.Threading.ExecutionContext)->
... 

 00000001812d0bf0(System.EventHandler)->
00000001812d0ad0(System.ServiceModel.Channels.ServiceChannel)

Soru: Şuan dump içerisinde'ki tüm exception nesnelerini detayları ile görebilir miyim?

0:056> !dae
Going to dump the .NET Exceptions found in the heap.
Number of exceptions of this type: 1
Exception MethodTable: 000007ff00200038
Exception object: 00000001c0020290
Exception type: System.ExecutionEngineException
Message: <none>

...

Soru: Peki tüm aspx çağrılarını ve bunları hangi thread'ler içerisinde çalıştırıldığını nasıl görebilirim ?

0:056> !aspxpages
Going to dump the HttpContexts found in the heap.
HttpContext Timeout Completed Running ThreadId ReturnCode Verb RequestPath+QueryString
0x0000000180741338 60000 Sec no 1734 Sec XXX 200 GET /W...

Soru: ThreadPool ile ilgili özet bilgi alabilir miyim? Server'ın CPU kullanımı, timer’lar, iş istekleri?

0:056> !threadpool
CPU utilization: 81%
Worker Thread: Total: 14 Running: 2 Idle: 6 MaxLimit: 800 MinLimit: 8
Work Request in Queue: 0
--------------------------------------
Number of Timers: 30
--------------------------------------
Completion Port Thread:Total: 1 Free: 1 MaxFree: 16 CurrentLimit: 0 MaxLimit: 800 MinLimit: 8

 Soru: !dae komutu ile heap'te birçok exception nesnesi gördüm, elimde bir exception objesinin adresi var, detaylı bilgi alabilir miyim?

0:029> !PrintException 0000000261038108
Exception object: 0000000261038108
Exception type: System.AggregateException
Message: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
InnerException: System.Data.SqlClient.SqlException, Use !PrintException 00000001a1bf5828 to see more.
StackTrace (generated):
...

Soru: Dumpheap komutu ile bir nesnenin Method tablosunu buldum (MT) bu tablodan method Descriptor'ları görebilir miyim?

0:029> !dumpmt -md 0x000007ff017e2b60
..

Module: 000007ff0029d430
Name: System.Web.Configuration.XhtmlConformanceSection
...

MethodDesc Table
Entry MethodDesc JIT Name
000007ff0004c028 000007ff001c5748 JIT System.Object.ToString()
000007ff003ca068 000007ff003fad60 NONE System.Configuration.ConfigurationElement.Equals(System.Object)
...

Soru: Peki modüle ait bilgileri nasıl görebilirim?

0:029> !dumpmodule 000007ff0029d430
Name: C:\Windows\Microsoft.Net\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll
Attributes: PEFile
Assembly: 00000000013f3c60
LoaderHeap: 0000000000000000
...

 Soru: Yüklenen tüm assembly dosyalarını da görmek istiyorum.

0:065> !dumpdomain
--------------------------------------
...

Assembly: 0000000009c645a0 [C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll]
ClassLoader: 00000000022c6ed0
  Module Name
000007ff00cbeec8 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll

Soru: Dinamik olarak oluşturulan assembly dosyalarını nasıl görebilirim?

0:065> !dda
Domain: DefaultDomain
-------------------

Domain: /LM/W3SVC/1/ROOT/WebApp

-------------------

Assembly: 0x000000000c05cec0 [h2wowf5d, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null] Dynamic Module: 0x000007ff014864c8 loaded at: 0x000000000fad0000 Size: 0x000000000004f600(325,120)

Görüldüğü üzere Extension'lar dump dosyalarını yorumlamamızda bize yardımcı olacak komutlar içeriyor. Burada anlatılan bir kısım terimlere yabancı olabilirsiniz. Onlarıda bir diğer blog'da sizinle paylaşıyor olacağım.

İyi çalışmalar dilerim

Mert Öztürk.