dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.95k stars 4.65k forks source link

How to unbox dynamic var via ICorDebug interface #45481

Open pavel-orekhov opened 3 years ago

pavel-orekhov commented 3 years ago

Hello! I work on netcoredbg. My goal is to eval/print dynamic from ICorDebugManagedCallback::Breakpoint of ICorDebugValue (frame_var) of code

int ii = 41;
dynamic di=42;

ICorDebugValue ("ii")->GetType() returns ELEMENT_TYPE_I4 and allright. Over attrs are ii: size=4 CorElementType=8 ExactCorElementType=8 CORTypeId=(7ffa4f7cb1e8,0) isRef=0 isBoxed=0 isValueClass=0 type="System.Int32"

for dynamic var a ref returns (at amd64):

di: size=8 CorElementType=12 ExactCorElementType=11 CORTypeId=(7ffa4f7cb1e8,0) isRef=1 i
    sBoxed=0 isValueClass=0 type="System.Int32"

after dereference (ICorDebugReferenceValue::Dereference) CorElementType=ELEMENT_TYPE_VALUETYPE

 *di: size=4 CorElementType=11 ExactCorElementType=11 CORTypeId=(7ffa4f7cb1e8,0) isRef=0
    isBoxed=0 isValueClass=0 type="System.Int32"

How to dereference/unbox di till ELEMENT_TYPE_I4 to get raw numeric value?

cc @alpencolt @viewizard

Dotnet-GitSync-Bot commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

pavel-orekhov commented 3 years ago

Most exact area is "ICorDebug interface using". Maybe intersection of following area-Debugger-mono, area-TypeSystem-coreclr, area-VM-coreclr

ghost commented 3 years ago

Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.

Issue Details
Hello! I work on `netcoredbg`. My goal is to eval/print dynamic from `ICorDebugManagedCallback::Breakpoint` of `ICorDebugValue (frame_var)` of code ```c# int ii = 41; dynamic di=42; ``` `ICorDebugValue ("ii")->GetType()` returns `ELEMENT_TYPE_I4` and allright. Over attrs are ii: size=4 CorElementType=8 ExactCorElementType=8 CORTypeId=(7ffa4f7cb1e8,0) isRef=0 isBoxed=0 isValueClass=0 type="System.Int32" for dynamic var a ref returns (at amd64): ``` di: size=8 CorElementType=12 ExactCorElementType=11 CORTypeId=(7ffa4f7cb1e8,0) isRef=1 i sBoxed=0 isValueClass=0 type="System.Int32" ``` after dereference (`ICorDebugReferenceValue::Dereference`) `CorElementType=ELEMENT_TYPE_VALUETYPE` ``` *di: size=4 CorElementType=11 ExactCorElementType=11 CORTypeId=(7ffa4f7cb1e8,0) isRef=0 isBoxed=0 isValueClass=0 type="System.Int32" ``` How to dereference/unbox `di` till `ELEMENT_TYPE_I4` to get raw numeric value? cc @alpencolt @viewizard
Author: pavel-orekhov
Assignees: -
Labels: `area-Diagnostics-coreclr`, `untriaged`
Milestone: -
tommcdon commented 3 years ago

@hoyosjs @sdmaclea