microsoft / clrmd

Microsoft.Diagnostics.Runtime is a set of APIs for introspecting processes and dumps.
MIT License
1.05k stars 256 forks source link

Enumerate over a ClrType that implements IEnumerable #1258

Closed richardfencel closed 5 months ago

richardfencel commented 5 months ago

I attach ClrMd to a target process and create a ClrType from an ArrayList in the target process. The ClrType object is:

Snap81

One of the methods in this type is GetEnumerator():

Snap81 url)

Is there anyway to use the GetEnumerate() method in the ClrType object to do a foreach loop and enumerate over all the objects in the ArrayList?

weltkante commented 5 months ago

Is there anyway to use the GetEnumerate() method in the ClrType object to do a foreach loop and enumerate over all the objects in the ArrayList?

unlikely, as that requires executing code and is what a debugger is for, as far as I know clrmd doesn't cover debugger features, you probably have to write your own

since ArrayList is a builtin object with known behaviour you could of course hardcode the knowledge and code required for iteration and inspect the fields via clrmd and implement the iteration yourself

richardfencel commented 5 months ago

Thanks for your explanation. This is what I needed to know.