public static uint GetLocalCount(this ISymUnmanagedScope instance)
 {
     return(instance.__GetLocalCount());
 }
Esempio n. 2
0
        /// <summary>
        /// Emits scope debugging symbols based on <c>ISymUnmanagedScope</c> insatnce, representing
        /// scope from new assembly.
        /// </summary>
        /// <param name="smScope">Scope from new version of changed assembly.</param>
        /// <param name="placeholder">Placeholder translation for local variables.</param>
        public void EmitScope(ISymUnmanagedScope smScope, Dictionary <int, int> placeholder)
        {
            if (State != WriterState.Building)
            {
                throw new TranslatingException("ISym* interfaces were not initialized.");
            }
            uint scStartOffset = smScope.__GetStartOffset();
            uint scEndOffset   = smScope.__GetEndOffset();

            mWriter.OpenScope(scStartOffset);

            uint localsCount = smScope.__GetLocalCount();

            if (localsCount > 0)
            {
                uint read;
                ISymUnmanagedVariable[] variables = new ISymUnmanagedVariable[localsCount];
                smScope.__GetLocals(localsCount, out read, variables);
                for (int i = 0; i < localsCount; i++)
                {
                    byte[]    signature = variables[i].GetSignature();
                    Signature sig       = new Signature(signature);
                    sig.Migrate(translator);
                    signature = sig.Compress();

                    string name     = variables[i].GetName();
                    uint   addr1    = 0;                             //variables[i].GetAddressField1();
                    uint   addr2    = 0;                             //variables[i].GetAddressField2();
                    uint   addr3    = 0;                             //variables[i].GetAddressField3();
                    uint   addrKind = variables[i].GetAddressKind(); //variables[i].GetAddressKind();
                    if ((variables[i].GetAttributes() & 1) != 1)
                    {
                        addr1    = variables[i].GetAddressField1();
                        addrKind = variables[i].GetAddressKind();
                        if (placeholder != null && placeholder.ContainsKey((int)addr1))
                        {
                            addr1 = (uint)placeholder[(int)addr1];
                        }
                    }
                    uint varStartOffset = scStartOffset;
                    uint varEndOffset   = scEndOffset;
                    uint attributes     = variables[i].GetAttributes();

                    IntPtr pName = Marshal.StringToCoTaskMemUni(name);
                    IntPtr pSig  = Marshal.AllocCoTaskMem(signature.Length);
                    Marshal.Copy(signature, 0, pSig, signature.Length);

                    try{
                        mWriter.DefineLocalVariable(pName, attributes, (uint)signature.Length, pSig, addrKind,
                                                    addr1, addr2, addr3, varStartOffset, varEndOffset);
                    } finally {
                        Marshal.FreeCoTaskMem(pSig);
                        Marshal.FreeCoTaskMem(pName);
                    }
                }
            }
            ISymUnmanagedScope[] subScopes = smScope.GetChildren();
            foreach (ISymUnmanagedScope subScope in subScopes)
            {
                EmitScope(subScope, placeholder);
            }
            mWriter.CloseScope(scEndOffset);
        }
Esempio n. 3
0
        /// <summary>
        /// Emits scope debugging symbols based on <c>ISymUnmanagedScope</c> insatnce, representing
        /// scope from new assembly.
        /// </summary>
        /// <param name="smScope">Scope from new version of changed assembly.</param>
        /// <param name="placeholder">Placeholder translation for local variables.</param>
        public void EmitScope(ISymUnmanagedScope smScope, Dictionary<int, int> placeholder)
        {
            if(State != WriterState.Building){
                throw new TranslatingException("ISym* interfaces were not initialized.");
            }
            uint scStartOffset = smScope.__GetStartOffset();
            uint scEndOffset = smScope.__GetEndOffset();
            mWriter.OpenScope(scStartOffset);

            uint localsCount = smScope.__GetLocalCount();
            if(localsCount > 0){
                uint read;
                ISymUnmanagedVariable[] variables = new ISymUnmanagedVariable[localsCount];
                smScope.__GetLocals(localsCount,out read,variables);
                for (int i = 0; i < localsCount; i++) {
                    byte[] signature = variables[i].GetSignature();
                    Signature sig = new Signature(signature);
                    sig.Migrate(translator);
                    signature = sig.Compress();

                    string name = variables[i].GetName();
                    uint addr1 = 0;//variables[i].GetAddressField1();
                    uint addr2 = 0;//variables[i].GetAddressField2();
                    uint addr3 = 0;//variables[i].GetAddressField3();
                    uint addrKind = variables[i].GetAddressKind();//variables[i].GetAddressKind();
                    if((variables[i].GetAttributes() & 1) != 1)
                    {
                        addr1 = variables[i].GetAddressField1();
                        addrKind = variables[i].GetAddressKind();
                        if (placeholder != null && placeholder.ContainsKey((int)addr1))
                        {
                            addr1 = (uint)placeholder[(int)addr1];
                        }
                    }
                    uint varStartOffset = scStartOffset;
                    uint varEndOffset = scEndOffset;
                    uint attributes = variables[i].GetAttributes();

                    IntPtr pName = Marshal.StringToCoTaskMemUni(name);
                    IntPtr pSig = Marshal.AllocCoTaskMem(signature.Length);
                    Marshal.Copy(signature,0,pSig,signature.Length);

                    try{
                        mWriter.DefineLocalVariable(pName,attributes,(uint)signature.Length,pSig,addrKind,
                                                    addr1,addr2,addr3,varStartOffset,varEndOffset);
                    } finally {
                        Marshal.FreeCoTaskMem(pSig);
                        Marshal.FreeCoTaskMem(pName);
                    }
                }
            }
            ISymUnmanagedScope[] subScopes = smScope.GetChildren();
            foreach(ISymUnmanagedScope subScope in subScopes){
                EmitScope(subScope,placeholder);
            }
            mWriter.CloseScope(scEndOffset);
        }