示例#1
0
文件: diautil.cs 项目: belav/runtime
        public DiaFile(String pdbFile, String dllFile)
        {
            m_dsc = GetDiaSourceClass();
            string pdbPath = System.IO.Path.GetDirectoryName(pdbFile);

            // Open the PDB file, validating it matches the supplied DLL file
            DiaLoadCallback loadCallback = new DiaLoadCallback();

            try
            {
                m_dsc.loadDataForExe(dllFile, pdbPath, loadCallback);
            }
            catch (System.Exception diaEx)
            {
                // Provide additional diagnostics context and rethrow
                string       msg   = "ERROR from DIA loading PDB for specified DLL";
                COMException comEx = diaEx as COMException;
                if (comEx != null)
                {
                    if (Enum.IsDefined(typeof(DiaHResults), comEx.ErrorCode))
                    {
                        // This is a DIA-specific error code,
                        DiaHResults hr = (DiaHResults)comEx.ErrorCode;
                        msg += ": " + hr.ToString();

                        // Additional clarification for the common case of the DLL not matching the PDB
                        if (hr == DiaHResults.E_PDB_NOT_FOUND)
                        {
                            msg +=
                                " - The specified PDB file does not match the specified DLL file";
                        }
                    }
                }
                throw new ApplicationException(msg, diaEx);
            }

            // Save the path of the PDB file actually loaded
            Debug.Assert(loadCallback.LoadedPdbPath != null, "Didn't get PDB load callback");
            m_loadedPdbPath = loadCallback.LoadedPdbPath;

            // Also use DIA to get the debug directory entry in the DLL referring
            // to the PDB, and save it's timestamp comparison at runtime.
            m_debugTimestamp = loadCallback.DebugTimeDateStamp;
            Debug.Assert(m_debugTimestamp != 0, "Didn't find debug directory entry");

            m_dsc.openSession(out m_session);
            m_global      = new DiaSymbol(m_session.globalScope);
            m_publicsEnum = null;
        }
示例#2
0
文件: diautil.cs 项目: zpplus/runtime
        public DiaSymbol FindClassSymbol(String name, SymTagEnum tag)
        {
            DiaSymbol  res = null;
            IDiaSymbol sym = Util.FindClassSymbol(name, m_symbol, tag);

            if (sym != null)
            {
                if ((SymTagEnum)sym.symTag == SymTagEnum.SymTagData)
                {
                    res = new DiaDataSymbol(sym);
                }
                else
                {
                    res = new DiaSymbol(sym);
                }
            }

            return(res);
        }
示例#3
0
文件: diautil.cs 项目: zpplus/runtime
        public DiaSymbol FindUDTSymbol(String name)
        {
            DiaSymbol  res = null;
            IDiaSymbol sym = Util.FindSymbol(name, m_symbol, SymTagEnum.SymTagUDT);

            if (sym == null)
            {
                sym = Util.FindSymbol(name, m_symbol, SymTagEnum.SymTagTypedef);

                if (sym != null)
                {
                    sym = sym.type;
                }
            }

            if (sym != null)
            {
                res = new DiaSymbol(sym);
            }

            return(res);
        }
示例#4
0
 private UInt32 GetSymbolRva(DiaSymbol sy,
                             String symbolName,
                             String typeName)
 {
     if (sy == null)
     {
         // Ideally this would throw an exception and
         // cause the whole process to fail but
         // currently it's too complicated to get
         // all the ifdef'ing right for all the
         // mix of debug/checked/free multiplied by
         // x86/AMD64/IA64/etc.
         return UInt32.MaxValue;
     }
     if (sy.Address > UInt32.MaxValue)
     {
         throw new InvalidOperationException(typeName +
                                             " symbol " +
                                             symbolName +
                                             " overflows UInt32");
     }
     
     return (UInt32)sy.Address;
 }
示例#5
0
    public DiaSymbol FindUDTSymbol(String name)
    {
        DiaSymbol res = null;
        IDiaSymbol sym = Util.FindSymbol(name, m_symbol, SymTagEnum.SymTagUDT);

        if (sym == null)
        {
            sym = Util.FindSymbol(name, m_symbol, SymTagEnum.SymTagTypedef);

            if (sym != null)
                sym = sym.type;
        }

        if (sym != null)
            res = new DiaSymbol(sym);

        return res;
    }
示例#6
0
    public DiaSymbol FindClassSymbol(String name, SymTagEnum tag)
    {
        DiaSymbol res = null;
        IDiaSymbol sym = Util.FindClassSymbol(name, m_symbol, tag);

        if (sym != null)
        {
            if ((SymTagEnum)sym.symTag == SymTagEnum.SymTagData)
                res = new DiaDataSymbol(sym);
            else
                res = new DiaSymbol(sym);
        }

        return res;
    }
示例#7
0
    public DiaFile(String pdbFile, String dllFile)
    {
        m_dsc = new DiaSourceClass();
        string pdbPath = System.IO.Path.GetDirectoryName(pdbFile);

        // Open the PDB file, validating it matches the supplied DLL file
        DiaLoadCallback loadCallback = new DiaLoadCallback();
        try
        {
            m_dsc.loadDataForExe(dllFile, pdbPath, loadCallback);
        }
        catch (System.Exception diaEx)
        {
            // Provide additional diagnostics context and rethrow
            string msg = "ERROR from DIA loading PDB for specified DLL";
            COMException comEx = diaEx as COMException;
            if (comEx != null)
            {
                if (Enum.IsDefined(typeof(DiaHResults), comEx.ErrorCode))
                {
                    // This is a DIA-specific error code,
                    DiaHResults hr = (DiaHResults)comEx.ErrorCode;
                    msg += ": " + hr.ToString();

                    // Additional clarification for the common case of the DLL not matching the PDB
                    if (hr == DiaHResults.E_PDB_NOT_FOUND)
                    {
                        msg += " - The specified PDB file does not match the specified DLL file";
                    }
                }
            }
            throw new ApplicationException(msg, diaEx);
        }

        // Save the path of the PDB file actually loaded
        Debug.Assert(loadCallback.LoadedPdbPath != null, "Didn't get PDB load callback");
        m_loadedPdbPath = loadCallback.LoadedPdbPath;

        // Also use DIA to get the debug directory entry in the DLL referring
        // to the PDB, and save it's timestamp comparison at runtime.
        m_debugTimestamp = loadCallback.DebugTimeDateStamp;
        Debug.Assert(m_debugTimestamp != 0, "Didn't find debug directory entry");

        m_dsc.openSession(out m_session);
        m_global = new DiaSymbol(m_session.globalScope);
        m_publicsEnum = null;
    }