private static VARIABLE GetArrayItems(ICorDebugValue value)
 {
     VARIABLE vari = new VARIABLE();
     vari.isArray = true;
     vari.isComplex = false;
     var arrayReference = value as ICorDebugReferenceValue;
     ICorDebugValue arrayDereferenced;
     try{
         arrayReference.Dereference(out arrayDereferenced);
         ICorDebugArrayValue array = arrayDereferenced as ICorDebugArrayValue;
         IList<PARAMETER> members = new List<PARAMETER>();
         if (array != null) {
             uint noOfItems = 0;
             array.GetCount(out noOfItems);
             if (noOfItems == 0) vari.innerValue = "<<Zero Elements in this array>>";
             else{
             for (int index = 0; index < noOfItems; index++) {
                 ICorDebugValue elementVal = null;
                 array.GetElementAtPosition((uint)index, out elementVal);
                 MDbgValue mdgbVal = new MDbgValue(new CorValue(value));
                 DEBUGPARAM parm = GetParamInfo(elementVal);
                 parm.name = "Item[" + index.ToString() + "]";
                 members.Add(parm);
             }
             vari.parameters = members;
             }
         }
     }
     catch (Exception) {
         vari.innerValue = "<<Not able to get the value>>";
     }
     return vari;
 }
 public IList<PARAMETER> GetParamInfo()
 {
     ICorDebugILFrame ilFrame = frame as ICorDebugILFrame;
     IList<PARAMETER> args = null;
     if (ilFrame != null){
         ICorDebugValue value = null;
         ICorDebugValueEnum values = null;
         ilFrame.EnumerateArguments(out values);
         uint val = 0;
         values.GetCount(out val);
         if (val > 0) {
             args = new List<PARAMETER>();
         }
         for (uint index = 0; index < val; index++){
             try{
                 ilFrame.GetArgument(index, out value);
                 MDbgValue mdgbVal = new MDbgValue(new CorValue(value));
                 DEBUGPARAM param = new DEBUGPARAM();
                 param.name = mdgbVal.Name;
                 param.type = mdgbVal.TypeName;
                 param.isComplex = mdgbVal.IsComplexType;
                 param.isNull = mdgbVal.IsNull;
                 param.corValue = mdgbVal;
                 args.Add(param);
             } catch (COMException e){
                 if ((uint)e.ErrorCode == 0x80131304)
                 {
                     DEBUGPARAM degParam = new DEBUGPARAM();
                     degParam.corValue = null;
                     degParam.inValid = true;
                     //degParam.corType = CorElementType.;
                     args.Add(degParam);
                     //return null;
                 }
                 else
                 {
                     throw;
                 }
             }
         }
     }
     return args;
 }
Пример #3
0
        /// <summary>
        /// Gets Array Items.  This function can be called only on one dimensional arrays.
        /// </summary>
        /// <returns>An array of the values for the Array Items.</returns>
        public MDbgValue[] GetArrayItems()
        {
            if (!IsArrayType)
                throw new Exception("Type is not array type");

            CorValue value = Dereference(CorValue, null);

            CorArrayValue av = value.CastToArrayValue();
            int[] dims = av.GetDimensions();

            ArrayList al = new ArrayList();
            for (int i = 0; i < dims[0]; i++)
            {
                MDbgValue v = new MDbgValue( "[" + i + "]", av.GetElementAtPosition(i));
                al.Add(v);
            }
            return (MDbgValue[])al.ToArray(typeof(MDbgValue));
        }
Пример #4
0
        private string PrintArray(int indentLevel, CorArrayValue av, int expandDepth, bool canDoFunceval)
        {
            StringBuilder txt = new StringBuilder();
            txt.Append("array [");
            int[] dims = av.GetDimensions();

            for (int i = 0; i < dims.Length; ++i)
            {
                if (i != 0)
                    txt.Append(",");
                txt.Append(dims[i]);
            }
            txt.Append("]");

            if (expandDepth > 0 && av.Rank == 1 && av.ElementType != CorElementType.ELEMENT_TYPE_VOID)
            {
                for (int i = 0; i < dims[0]; i++)
                {
                    MDbgValue v = new MDbgValue(av.GetElementAtPosition(i));
                    txt.Append("\n").Append(IndentedString(indentLevel + 1, "[" + i + "] = ")).
            Append(IndentedBlock(indentLevel + 2,
                           v.GetStringValue(expandDepth - 1, canDoFunceval)));
                }
            }
            return txt.ToString();
        }
Пример #5
0
        /// <summary>
        /// Gets the Array Item for the specified indexes
        /// </summary>
        /// <param name="indexes">Which indexes to get the Array Item for.</param>
        /// <returns>The Value for the given indexes.</returns>
        public MDbgValue GetArrayItem(params int[] indexes)
        {
            if (!IsArrayType)
                throw new Exception("Type is not array type");

            CorValue value = Dereference(CorValue, null);
            CorArrayValue av = value.CastToArrayValue();
            if (av.Rank != indexes.Length)
                throw new Exception("Invalid number of dimensions.");

            StringBuilder sb = new StringBuilder("[");
            for (int i = 0; i < indexes.Length; ++i)
            {
                if (i != 0)
                    sb.Append(",");
                sb.Append(indexes[i]);
            }
            sb.Append("]");

            MDbgValue v = new MDbgValue( sb.ToString(), av.GetElement(indexes));
            return v;
        }