internal static IList<PARAMETER> GetObjectMembers(ICorDebugValue value) { IList<PARAMETER> members = new List<PARAMETER>(); ICorDebugObjectValue objectValue = value as ICorDebugObjectValue; //incase of boxed senarion. if (objectValue == null){ ICorDebugReferenceValue refVal = value as ICorDebugReferenceValue; ICorDebugValue pDeRef = null; try{ refVal.Dereference(out pDeRef); objectValue = pDeRef as ICorDebugObjectValue; } catch (COMException e){ if ((uint)e.ErrorCode == 0x80131305) return null; } } if (objectValue != null){ ICorDebugClass _class = null; objectValue.GetClass(out _class); MetaType metatype = MetaDataUtils.MetadataMgr.GetClass(new CorClass(_class)); List<FieldInfo> metadata = metatype.GetFieldInfo(); foreach (FieldInfo fi in metadata) { DEBUGPARAM arg = new DEBUGPARAM(); ICorDebugValue exceptVal = null; try{ objectValue.GetFieldValue(_class, (uint)fi.MetadataToken, out exceptVal); arg = GetParamInfo(exceptVal); arg.name = fi.Name; members.Add(arg); }catch (COMException) { //sb.AppendLine("Value : Not able to deduce"); } } List<MetadataMethodInfo> metas = metatype.GetProperties(); ICorDebugModule module = null; _class.GetModule(out module); foreach (MetadataMethodInfo fi in metas) { DEBUGPARAM arg = new DEBUGPARAM(); try { //objectValue.GetFieldValue(_class, (uint)fi.MetadataToken, out exceptVal); //arg = GetParamInfo(exceptVal); arg.name = fi.Name; arg.isProperty = true; arg.type = fi.ReturnType; if (!fi.IsStatic) { ICorDebugReferenceValue hv = objectValue as ICorDebugReferenceValue; if (hv != null){ // arg.corValue = hv; }else{ //arg.corValue = value; } } if (arg.name.Contains(".get_Item")) { if (fi.Arguments.Count == 1 && fi.Arguments[0].name == "index") { arg.isIndexProperty = true; } } ICorDebugFunction fun = null; module.GetFunctionFromToken((uint)fi.MetadataToken, out fun); arg.property = new CorFunction(fun); members.Add(arg); } catch (COMException) { //sb.AppendLine("Value : Not able to deduce"); } } } return members; }
public static DEBUGPARAM GetParamInfo(ICorDebugValue value) { DEBUGPARAM debugParam = new DEBUGPARAM(); ICorDebugGenericValue gvalue = value as ICorDebugGenericValue; CorElementType type = CorElementType.ELEMENT_TYPE_VOID; value.GetType(out type); //debugParam.corType = type; debugParam.corValue = new MDbgValue(new CorValue(value)); debugParam.isComplex = false; if (gvalue != null){ switch (type){ case CorElementType.ELEMENT_TYPE_BOOLEAN:debugParam.type = "bool";break; case CorElementType.ELEMENT_TYPE_CHAR: debugParam.type = "char";break; case CorElementType.ELEMENT_TYPE_I1: debugParam.type = "sbyte";break; case CorElementType.ELEMENT_TYPE_U1:debugParam.type = "byte";break; case CorElementType.ELEMENT_TYPE_I2: debugParam.type = "Int16";break; case CorElementType.ELEMENT_TYPE_U2: debugParam.type = "UInt16";break; case CorElementType.ELEMENT_TYPE_I4: debugParam.type = "Int32";break; case CorElementType.ELEMENT_TYPE_U4: debugParam.type = "UInt32";break; case CorElementType.ELEMENT_TYPE_I8: debugParam.type = "Int64";break; case CorElementType.ELEMENT_TYPE_U8: debugParam.type = "UIn64";break; case CorElementType.ELEMENT_TYPE_R4: debugParam.type = "Single";break; case CorElementType.ELEMENT_TYPE_R8: debugParam.type = "Double";break; case CorElementType.ELEMENT_TYPE_PTR: debugParam.type = "IntPtr";break; case CorElementType.ELEMENT_TYPE_U: debugParam.type = "IntPtr32";break; default: debugParam.type = "***UNK***"; break; } } else if ( (type == CorElementType.ELEMENT_TYPE_CLASS) || (type == CorElementType.ELEMENT_TYPE_VALUETYPE) ){ ICorDebugObjectValue objectValue = value as ICorDebugObjectValue; ICorDebugClass _class = null; ICorDebugReferenceValue refVal = value as ICorDebugReferenceValue; ICorDebugValue pDeRef = null; try { refVal.Dereference(out pDeRef); objectValue = pDeRef as ICorDebugObjectValue; objectValue.GetClass(out _class); MetaType metatype = MetaDataUtils.MetadataMgr.GetClass(new CorClass(_class)); debugParam.type = metatype.Name; debugParam.isComplex = true; } catch (COMException e) { if ((uint)e.ErrorCode == 0x80131305){ debugParam.type = "Value Might be Null"; } } }else if (type == CorElementType.ELEMENT_TYPE_STRING){ debugParam.type = "System.String"; }else if(type == CorElementType.ELEMENT_TYPE_SZARRAY || type == CorElementType.ELEMENT_TYPE_ARRAY){ var arrayReference = value as ICorDebugReferenceValue; ICorDebugValue arrayDereferenced; arrayReference.Dereference(out arrayDereferenced); ICorDebugArrayValue array = arrayDereferenced as ICorDebugArrayValue; CorElementType arraytype = CorElementType.ELEMENT_TYPE_VOID; //array.GetElementType(out ICorDebugObjectValue objectValue = arrayDereferenced as ICorDebugObjectValue; ICorDebugClass _class = null; objectValue.GetClass(out _class); MetaType metatype = MetaDataUtils.MetadataMgr.GetClass(new CorClass(_class)); debugParam.type = metatype.Name; debugParam.isComplex = true; } else{ debugParam.type ="NotSupported for now"; } return debugParam; }
//static AutoResetEvent myResetEvent = new AutoResetEvent(false); //temp method public VARIABLE GetParamValue(DEBUGPARAM param,uint threadID) { if (!param.isProperty){ return new VARIABLE(); // return CorValue2Text.GetValue(param.corValue, param.corType); } else { CorThread corThread = null; if (liveThreads.TryGetValue(threadID, out corThread)) { corThread.GetPropertyValue(param); } ControllerStateMgr.ReleaseCallBackFlag(); TempFuncEval.mEvent.WaitOne(); //ControllerStateMgr.SetState(ControllerState.Paused); //ControllerStateMgr.RaiseCallBackFlag(); return CorValue2Text.GetValue(TempFuncEval.value, CorElementType.ELEMENT_TYPE_VOID); //return new VARIABLE(); } }
protected override void InnerExec(MProcess _process, ref Result _result) { MembersResult result = _result as MembersResult; DEBUGPARAM param = m_Param as DEBUGPARAM; result.CommadStatus = false; if(param != null){ if (!param.inValid){ result.CommadStatus = true; MDbgValue value = param.corValue; //Needs a fix for property??? result.Members = new List<PARAMETER>(); foreach (MDbgValue mdgbVal in value.GetFields()) { result.Description = mdgbVal.Name + " " + mdgbVal.TypeName; DEBUGPARAM debugParam = new DEBUGPARAM(); debugParam.name = mdgbVal.Name; debugParam.corValue = mdgbVal; debugParam.isNull = mdgbVal.IsNull; debugParam.isComplex = mdgbVal.IsComplexType; debugParam.isArray = mdgbVal.IsArrayType; debugParam.type = mdgbVal.TypeName; result.Members.Add(debugParam); } //result.Members = DebugEngine.Utilities.CorValue2Text.GetObjectMembers(param.corValue); } else { result.Description = "Value not available. Optimized by JIT/CLR"; } }else{ result.Description = "Invalid input value"; } }
public VARIABLE GetParamValue(DEBUGPARAM param) { return new VARIABLE(); //if (!param.isProperty) //{q // return CorValue2Text.GetValue(param.corValue, param.corType); //} //else { // return new VARIABLE(); //} /// }