Search code examples
clrwindbgvalue-typesosdbghelp

Efficient way to get name/MT of ValueTypes not listed in !dumpheap -stat


I'm working my way around the SOS commands and their output, but I noticed there doesn't seem to be a way to get really all types that are currently in use somehow. The best way so far is !dumpheap -stat, but it only lists types for which there are instances. However, when a ValueType is never boxed, that type will not show up on !dumpheap -stat. (Which isn't surprising, as they aren't allocated on the heap.)

So my question is: Are there any efficient ways to figure out which additional ValueTypes currently exist? I mean, I could load them on-demand when inspecting individual heap objects (something like !dumpvc <mt> <address> based on !do <address> output), but for displayed statistics it would be nice to find the types through some simpler means than looking at (instances/class definitions of) all known classes to figure out whether they use any additional ValueTypes.


Solution

  • There doesn't seem to be any efficient way to do this. In other words, I ended up checking each type !DumpHeap -stat returned for whether it is a struct array or contains struct fields. In both cases I need to recursively check if the new-found struct type contains any struct fields as well. In that case recursion is required, unless I've already seen the struct type.

    !DumpModule -mt is not option, btw. For example, I see System.Collections.Generic.List`1, but nothing that would represent e.g. the List class.