Search code examples
.netgarbage-collectionwindbgconditional-breakpoint

WinDbg conditional breakpoint after .NET GC


I'm setting a conditional breakpoint at the end of a GC cycle.
The program breaks but it cannot evaluate the GcCondemnedGeneration variable so program breaks on every GC cycle regardless of the actual generation collected.

This is the breakpoint command:

> bp clr!ThreadSuspend::RestartEE ".if @@(clr!SVR::GCHeap::GcCondemnedGeneration==2) {kb} .else {g}"

This what I get when the breakpoint breaks:

Type information missing error for SVR::GCHeap::GcCondemnedGeneration
Couldn't resolve error at 'clr!SVR::GCHeap::GcCondemnedGeneration==2) {kb} .else {g}'
clr!ThreadSuspend::RestartEE:
00007fff`145d5dfc 488bc4          mov     rax,rsp

I tried all kind of variations but they all failed.
.Net version installed on the machine is 4.6.1.
My program runs with server gc.
clr.dll symbol was loaded successfully.

Thanks


Solution

  • I was able to make it working without using C++ expression syntax and just MASM expression (where dwo is used to derefence a DWORD-sized data such as unsigned int):

    bp clr!ThreadSuspend::RestartEE ".if (poi(clr!SVR::GCHeap::GcCondemnedGeneration)==2) {kb} .else {g}"