コード例 #1
0
ファイル: DiaSymbolField.cs プロジェクト: sdmaclea/SharpDebug
        /// <summary>
        /// Initializes a new instance of the <see cref="DiaSymbolField"/> class.
        /// </summary>
        /// <param name="parentType">The parent type.</param>
        /// <param name="symbol">The DIA symbol.</param>
        public DiaSymbolField(DiaSymbol parentType, IDiaSymbol symbol)
            : base(parentType)
        {
            this.symbol  = symbol;
            Name         = symbol.name;
            LocationType = symbol.locationType;
            DataKind     = symbol.dataKind;
            Offset       = symbol.offset;
            Value        = symbol.value;

            ulong size = symbol.length;

            if (size > int.MaxValue)
            {
                throw new ArgumentException("Symbol size is unexpected");
            }
            Size = (int)size;
            if (LocationType == LocationType.BitField)
            {
                BitSize = Size;
            }
            else
            {
                BitSize = Size * 8;
            }

            uint bitPosition = symbol.bitPosition;

            if (bitPosition > int.MaxValue)
            {
                throw new ArgumentException("Symbol bit position is unexpected");
            }
            BitPosition = (int)bitPosition;

            IDiaSymbol type = symbol.type;

            if (type != null)
            {
                Type = ((DiaModule)Module).GetSymbol(type);
            }
        }
コード例 #2
0
ファイル: DiaModule.cs プロジェクト: sdmaclea/SharpDebug
        /// <summary>
        /// Gets the symbol from the cache or adds new entry in the cache if symbol wasn't previously found.
        /// </summary>
        /// <param name="symbol">The symbol.</param>
        internal Symbol GetSymbol(IDiaSymbol symbol)
        {
            if (symbol == null)
            {
                return(null);
            }

            Symbol s;
            uint   symbolId = symbol.symIndexId;

            if (!symbolById.TryGetValue(symbolId, out s))
            {
                s = new DiaSymbol(this, symbol);
                lock (this)
                {
                    Symbol previousSymbol = null;

                    symbolById.TryAdd(symbolId, s);
                    if (s.Tag != CodeTypeTag.ModuleGlobals)
                    {
                        if (!symbolByName.TryGetValue(s.Name, out previousSymbol))
                        {
                            symbolByName.TryAdd(s.Name, s);
                        }
                        else
                        {
                            previousSymbol.LinkSymbols(s);
                        }
                    }
                }

                s.InitializeCache();
            }

            return(s);
        }