Exemplo n.º 1
0
 private void OnCollectionCreated(SymbolsForBinary aCollection)
 {
     if (CollectionCreated != null && aCollection != null)
     {
         CollectionCreated(aCollection);
     }
 }
Exemplo n.º 2
0
        public static TFileType IsSupported(string aFileName)
        {
            TFileType ret = TFileType.EFileNotSupported;

            //
            try
            {
                string extension = Path.GetExtension(aFileName).ToLower();
                if (extension == ".symbol")
                {
                    SymbolFileEngine tempEngine = new SymbolFileEngine(null, SymbolFileEngine.TActivationType.EOnDemand, false);
                    SymbolsForBinary symbols    = tempEngine.ReadFirstCollection(aFileName);

                    // For a valid ROFS symbol file, the first symbol should have an address of zero.
                    bool containedNonZeroFirstSymbolCollection = (symbols != null && symbols.Count > 0 && symbols[0].Address != 0);
                    if (containedNonZeroFirstSymbolCollection)
                    {
                        ret = TFileType.EFileRomSymbol;
                    }
                }
            }
            catch (Exception)
            {
            }
            //
            return(ret);
        }
Exemplo n.º 3
0
        private bool Parser_CollectionCompleted(SymbolsForBinary aCollection)
        {
            // Check whether the collection contains any item. If it doesn't, ditch it.
            // Remove empty collections or sort completed ones.
            bool takeCollection = false;
            int  count          = aCollection.Count;

            if (count > 0)
            {
                // Check whether the collection contains at least 2 symbols, and if not
                // does the one and only symbol just have a length of zero?
                if (count == 1)
                {
                    GenericSymbol symbol = aCollection.FirstSymbol;
                    takeCollection = (symbol.Size > 0) || symbol.IsUnknownSymbol;
                }
                else
                {
                    takeCollection = true;
                }
            }

            // If its okay to take the collection, let's sort it and activate if necessary.
            if (takeCollection)
            {
#if INSPECT_SYMBOL_DATA
                using (StreamWriter writer = new StreamWriter(@"C:\Temp\OldSymbols\" + Path.GetFileName(aCollection.HostBinaryFileName) + ".symbol"))
                {
                    aCollection.WriteToStream(writer);
                }
#endif
                // All the symbol collections - whether they are loaded or idle.
                iAllSymbols.Add(aCollection);

                // Then put the collection in the correct container depending on
                // activation type.
                if (iActivationType == TActivationType.EImmediate)
                {
                    aCollection.Sort();
                    iActivatedSymbols.Add(aCollection);
                    //
                    iRange.UpdateMin(aCollection.AddressRangeStart);
                    iRange.UpdateMax(aCollection.AddressRangeEnd);
                }
                else if (iActivationType == TActivationType.EOnDemand)
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(SortCollection), aCollection);
                    iIdleSymbols.Add(aCollection);
                }
            }
            else
            {
                //System.Diagnostics.Debug.WriteLine( "Discarded Symbol Collection: " + aCollection.TargetBinary );
                //System.Diagnostics.Debug.WriteLine( " " );
            }

            iCurrentBinary = null;
            return(SymbolFileParser.KCollectionCompletedAndContinueParsing);
        }
Exemplo n.º 4
0
        private void SortCollection(object aCollection)
        {
            SymbolsForBinary symbols = aCollection as SymbolsForBinary;

            if (symbols != null)
            {
                symbols.Sort();
            }
        }
Exemplo n.º 5
0
 private void OnCollectionCompleted(SymbolsForBinary aCollection)
 {
     if (CollectionCompleted != null && aCollection != null)
     {
         // If returns immediate abort then we will stop parsing
         // straight away.
         iImmediateAbort = (CollectionCompleted(aCollection) == KCollectionCompletedAndAbortParsing);
     }
 }
Exemplo n.º 6
0
        public static TFileType IsSupported(string aFileName)
        {
            TFileType ret = TFileType.EFileNotSupported;

            //
            try
            {
                string extension = Path.GetExtension(aFileName).ToLower();
                if (extension == ".symbol")
                {
                    bool sawSomeValidContent = false;
                    //
                    SymbolFileEngine tempEngine = new SymbolFileEngine(null, SymbolFileEngine.TActivationType.EOnDemand, true);
                    SymbolsForBinary symbols    = tempEngine.ReadFirstCollection(aFileName, out sawSomeValidContent);

                    // For a valid ROFS symbol file, the first symbol should have an address of zero.
                    bool valid = (symbols != null && symbols.Count > 0 && symbols[0].Address == 0);
                    if (valid)
                    {
                        ret = TFileType.EFileRofsSymbol;
                    }
                    else if (sawSomeValidContent)
                    {
                        // Probably just a file containing data files rather than code, but that's okay.
                        ret = TFileType.EFileRofsSymbol;
                    }
                }
                else if (extension == ".map")
                {
                    ret = MapFileEngineCollection.IsSupported(aFileName);
                }
            }
            catch (Exception)
            {
            }
            //
            return(ret);
        }
Exemplo n.º 7
0
        public SymbolsForBinary ReadFirstCollection(string aFileName, out bool aIsSymbolFile)
        {
            iCurrentBinary  = null;
            iSymbolFileName = aFileName;
            //
            iParser = new SymbolFileParser(this, this, aFileName, this);
            iParser.CollectionCompleted += new SymbolLib.Sources.Symbol.Parser.SymbolFileParser.CollectionCompletedHandler(Parser_CollectionCompletedSingleOnly);
            iParser.SymbolCreated       += new SymbolLib.Sources.Symbol.Parser.SymbolFileParser.SymbolCreatedHandler(Parser_SymbolCreated);
            iParser.Read(TSynchronicity.ESynchronous);
            //
            SymbolsForBinary ret = null;

            if (iAllSymbols.Count > 0)
            {
                ret           = iAllSymbols[0];
                aIsSymbolFile = true;
            }

            // Did we see any collections whatsoever (all be they data or code?)
            aIsSymbolFile = iParser.ContainedAtLeastOneCollectionFileName;

            return(ret);
        }
Exemplo n.º 8
0
 public SymbolsForBinary CreateCollection(string aHostFileName)
 {
     iCurrentBinary            = new SymbolsForBinary(aHostFileName);
     iCurrentBinary.SourceFile = SymbolFileName;
     return(iCurrentBinary);
 }