microsoft / clrmd

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

Missing methods in ClrMd 2.0 #1257

Closed richardfencel closed 2 months ago

richardfencel commented 3 months ago

I recently upgraded via NuGet to ClrMd 2.0 from 1.0 and got a large number of compile errors in my existing 1.0 ClrMd code. Can someone tell me exactly what methods have been eliminated and how that functionality is now implemented? For example, ClrType no longer as GetValue() method as well as a Heap.Runtime.ReadMemory(). Another example, ClrInstanceField no longer has a GetValue() method. Am I supposed to reason out what the replacements might be or is this documented somewhere? Thanks for your help.

richardfencel commented 3 months ago

I found this useful link from a prior incident that answers most of my questions. If anybody has anything else to contribute, please add.

richardfencel commented 3 months ago

What I really need is a link to some ClrMd 2.0 sample code.

timcassell commented 3 months ago

What I really need is a link to some ClrMd 2.0 sample code.

You could take a look at BenchmarkDotNet's usage. Though it might not use all the features you're trying to use.

richardfencel commented 3 months ago

Thanks for the recommendation.

I still have one problem I cannot solve. I am trying to get the value of a ClrObject when the object type is not known, i.e. I want to convert a ClrObject to an object. I was able to do that in ClrMd 1.0 at least for primitives. That is, the following worked:

object myObj = someClrType.Getalue(someAddress);

In ClrMd 2.0 I tried:

ClrObject test = someClrType.Heap.GetObject(someAddress);

This works as well in that it returns a ClrObject (the type is a Double which is correct). However, I need the actual value of the double. The debug data for the ClrObject is shown in the attached image. Snap6

richardfencel commented 3 months ago

Sorry, Getalue() should be GetValue()

richardfencel commented 2 months ago

I think the way for me to fix this is to determine first the Clrmd ElementType (e.g. "int") and then call one of the Clrmd generic "read" methods using that type, e.g. if the "read" method had the signature Readxxxx<>(), then we would call Readxxxx().

I am going to close this incident now. Thanks to all those who participated.