public bool Unload(CodeSegDefinition aDefinition)
        {
            bool   suspended    = false;
            string searchingFor = aDefinition.EnvironmentFileName.ToLower();

            // Try to promote a symbol
            foreach (SymbolsForBinary file in iActivatedSymbols)
            {
                string entryName = System.IO.Path.GetFileName(file.HostBinaryFileName).ToLower();
                if (entryName == searchingFor)
                {
#if DEBUG
                    System.Diagnostics.Debug.WriteLine(" UNLOAD {S}: " + aDefinition.ToString());
#endif
                    //
                    iActivatedSymbols.Remove(file);
                    iIdleSymbols.Add(file);
                    //
                    iRange.UpdateMin(file.AddressRangeStart);
                    iRange.UpdateMax(file.AddressRangeEnd);
                    //
                    suspended = true;

                    // NB: We don't untag the file since it was obviously needed at
                    // some point.
                    break;
                }
            }

            return(suspended);
        }
        public bool Load(CodeSegDefinition aDefinition)
        {
            bool   activated    = false;
            string searchingFor = aDefinition.EnvironmentFileName.ToLower();

            if (string.IsNullOrEmpty(searchingFor))
            {
                // Try to use on-target name instead, if valid
                searchingFor = aDefinition.ImageFileName.ToLower();
            }

            // Try to promote a symbol
            foreach (SymbolsForBinary file in iIdleSymbols)
            {
                string entryName = System.IO.Path.GetFileName(file.HostBinaryFileName).ToLower();
                if (entryName == searchingFor)
                {
#if DEBUG
                    System.Diagnostics.Debug.WriteLine("   LOAD {S}: " + aDefinition.ToString());
#endif

                    // Fix up the symbols in this collection
                    file.Fixup(aDefinition.AddressStart);

                    // Update ranges
                    iRange.UpdateMin(file.AddressRangeStart);
                    iRange.UpdateMax(file.AddressRangeEnd);

                    // Housekeeping
                    iActivatedSymbols.Add(file);
                    iIdleSymbols.Remove(file);
                    iActivatedSymbols.Sort();

                    // Even though the symbols for this binary may not be explicitly referenced
                    // they are definitely required by the callee, therefore we tag them
                    // immediately.
                    file.Tagged = true;

                    // Indicate we loaded the code seg from a symbol file
                    aDefinition.Source = CodeSegDefinition.TSourceType.ESourceWasSymbolFile;

                    activated = true;
                    break;
                }
            }

            return(activated);
        }
Example #3
0
        public bool Load(CodeSegDefinition aDefinition, TSynchronicity aSynchronicity)
        {
            bool ret = false;

            //
            if (string.IsNullOrEmpty(aDefinition.MapFileName) || !aDefinition.MapFileExists)
            {
            }
            else
            {
                // First pass - try to find map engine that matches the specified
                // PC file name.
                string mapFileName = aDefinition.MapFileName;
                if (aDefinition.MapFileExists)
                {
                    System.Diagnostics.Debug.WriteLine("   LOAD {M}: " + aDefinition.ToString());

                    MapFileEngine engine = FindByMapFileName(mapFileName);
                    if (engine != null)
                    {
                        engine.Load(aDefinition);
                        ret = true;
                    }
                    else
                    {
                        // Map file engine doesn't exist for the specified code segment.
                        // Can we load it from file?
                        engine = LoadFromFile(aDefinition.MapFileName, aSynchronicity);
                        if (engine != null)
                        {
                            engine.Load(aDefinition);
                            ret = true;
                        }
                    }
                }
            }
            //
            return(ret);
        }