Пример #1
0
        DmdType CreateTypeSig(IList <TSpec> tspecs, DmdType currentType)
        {
            foreach (var tspec in tspecs)
            {
                switch (tspec.etype)
                {
                case DMD.ElementType.SZArray:
                    currentType = currentType.MakeArrayType();
                    break;

                case DMD.ElementType.Array:
                    var arraySpec = (ArraySpec)tspec;
                    currentType = currentType.MakeArrayType(arraySpec.rank, arraySpec.sizes, arraySpec.lowerBounds);
                    break;

                case DMD.ElementType.GenericInst:
                    var ginstSpec = (GenericInstSpec)tspec;
                    currentType = currentType.MakeGenericType(ginstSpec.args.ToArray());
                    break;

                case DMD.ElementType.ByRef:
                    currentType = currentType.MakeByRefType();
                    break;

                case DMD.ElementType.Ptr:
                    currentType = currentType.MakePointerType();
                    break;

                default:
                    Verify(false, "Unknown TSpec");
                    break;
                }
            }
            return(currentType);
        }
Пример #2
0
        unsafe EvalArgumentResult ConvertSZArray(void *array, int length, int elementSize, DmdType elementType, out DmdType type)
        {
            type = elementType.MakeArrayType();
            var corElementType = GetType(elementType);
            var res            = dnEval.CreateSZArray(corElementType, length, out int hr);

            if (res is null || !res.Value.NormalResult)
            {
                return(EvalArgumentResult.Create(res, hr));
            }
            if (!IsInitialized(array, length * elementSize))
            {
                return(EvalArgumentResult.Create(res, hr));
            }

            bool error = true;

            try {
                Debug.Assert(length > 0);
                CorValue?arrayValue = res.Value.ResultOrException !;
                if (arrayValue.IsReference)
                {
                    arrayValue = arrayValue.GetDereferencedValue(out hr);
                    if (!(arrayValue is null))
                    {
                        return(new EvalArgumentResult(CordbgErrorHelper.GetErrorMessage(hr)));
                    }
                }
                Debug.Assert(arrayValue?.IsArray == true);
                if (arrayValue?.IsArray != true)
                {
                    return(new EvalArgumentResult(PredefinedEvaluationErrorMessages.InternalDebuggerError));
                }
                var addr = DbgDotNetValueImpl.GetArrayAddress(arrayValue);
                if (addr is null)
                {
                    return(new EvalArgumentResult(PredefinedEvaluationErrorMessages.InternalDebuggerError));
                }

                if (!(appDomain.Process is CorProcess process))
                {
                    return(new EvalArgumentResult(PredefinedEvaluationErrorMessages.InternalDebuggerError));
                }
                hr = process.WriteMemory(addr.Value.Address, array, length * elementSize, out int sizeWritten);
                if (hr < 0 || sizeWritten != length * elementSize)
                {
                    return(new EvalArgumentResult(PredefinedEvaluationErrorMessages.InternalDebuggerError));
                }

                var eaRes = new EvalArgumentResult(AddValue(type, res.Value.ResultOrException));
                error = false;
                return(eaRes);
            }
            finally {
                if (error)
                {
                    engine.DisposeHandle_CorDebug(res.Value.ResultOrException);
                }
            }
        }
Пример #3
0
        unsafe EvalArgumentResult ConvertSZArray(void *array, int length, int elementSize, DmdType elementType, out DmdType type)
        {
            type = elementType.MakeArrayType();
            var res = CreateSZArray(elementType, length);

            if (res.ErrorMessage != null)
            {
                return(res);
            }
            if (!IsInitialized(array, length * elementSize))
            {
                return(res);
            }

            Debug.Assert(length > 0);
            var arrayValue = (ArrayMirror)res.Value;
            var addr       = DbgDotNetValueImpl.GetArrayAddress(arrayValue, elementType, engine);

            if (addr == null)
            {
                return(new EvalArgumentResult(PredefinedEvaluationErrorMessages.InternalDebuggerError));
            }

            engine.DbgRuntime.Process.WriteMemory(addr.Value.Address, array, length * elementSize);
            return(new EvalArgumentResult(arrayValue));
        }