示例#1
0
        public void LoadFromFile(string aSymbolFileName, TSynchronicity aSynchronicity)
        {
            // Check if already exists
            SymbolFileEngine engine = null;

            //
            lock (this)
            {
                engine = EngineByFileName(aSymbolFileName);
                if (engine != null)
                {
                    iFiles.Remove(engine);
                }
            }

            engine = new SymbolFileEngine(this, iActivationType, iAllowNonRomSymbols);

            lock (this)
            {
                iFiles.Add(engine);
            }

            engine.Observer += new AsyncReaderBase.Observer(SymbolEngine_ObserverProxy);
            engine.LoadFromFile(aSymbolFileName, aSynchronicity);
        }
示例#2
0
        public virtual void Read(TSynchronicity aSynchronicity)
        {
            bool isReading = this.IsReadInProgress;

            if (isReading)
            {
                // Another thread is already reading this source.
                // If the caller asked for asynchronous reading, then when the
                // other thread completes the read the caller (in this thread)
                // will be notified via the normal event callback framework - in which
                // case we need do nothing at all - just let the other thread get on with it.
                //
                // If, on the other hand, the caller requested a synchronous read, then they
                // will expect the code to be ready at the point in time which we return to them.
                //
                // In this situation, we should block this method until the code becomes ready.
                if (aSynchronicity == TSynchronicity.ESynchronous)
                {
                    while (this.IsReadInProgress)
                    {
                        System.Threading.Thread.Sleep(0);
                    }
                }
            }
            else
            {
                DoRead(aSynchronicity);
            }
        }
示例#3
0
        public void Reconstruct(TSynchronicity aSynchronicity)
        {
            iSynchronicity = aSynchronicity;
            try
            {
                PrepareForExecution();
                ExecuteHeadAlgorithm();
            }
            catch (Exception e)
            {
                // The only reason an exception should occur is if none of the algorithms indicate that
                // they are ready to process stack data (probably because symbols were not provided).
                //
                // In this situation, we must report the exception to our event handler
                if (ExceptionHandler != null && EventHandler != null)
                {
                    // Make sure we sent the 'start' and 'end' events as well - we cannot send
                    // these events twice so it's okay to try to send them (will be ignored if
                    // already sent).
                    ReportEvent(TEvent.EAlgorithmStarted);

                    // Now report the exception
                    ExceptionHandler(this, e);

                    // Indicate completion since we're not going to be able to do anything anymore
                    ReportEvent(TEvent.EAlgorithmComplete);
                }
                else
                {
                    // No exception handler so just rethrow...
                    throw e;
                }
            }
        }
        private void Timer_OpStart_Tick(object sender, EventArgs aArgs)
        {
            iTimer_OpStart.Stop();
            iTimer_OpStart.Enabled = false;
            //
            TSynchronicity syncMode = (TSynchronicity)iTimer_OpStart.Tag;

            PrimeException = null;

            // If requested to prime asynchronously then we don't need to
            // do anything because this will return immediately and the
            // prime will run in a background thread.
            //
            // On the other hand, if requesting synchronous priming then
            // we need to spawn a worker thread or else the progress dialog
            // will not redraw (since the synchronous operation runs within
            // the context of the thread in which the synchronous prime request
            // originates).
            switch (syncMode)
            {
            case TSynchronicity.EAsynchronous:
                RunPrime(TSynchronicity.EAsynchronous);
                break;

            case TSynchronicity.ESynchronous:
                ThreadPool.QueueUserWorkItem(new WaitCallback(RunSyncPrimeInWorkerThread));
                break;

            default:
                throw new NotSupportedException("Unsupported synchronicity");
            }
        }
示例#5
0
        public void Reconstruct(TSynchronicity aSynchronicity)
        {
            StackAlgorithmManager algorithmManager = new StackAlgorithmManager(this);

            algorithmManager.EventHandler     += new StackAlgorithmManager.AlgorithmEventHandler(AlgorithmManager_EventHandler);
            algorithmManager.ExceptionHandler += new StackAlgorithmManager.AlgorithmExceptionHandler(AlgorithmManager_ExceptionHandler);
            algorithmManager.Reconstruct(aSynchronicity);
        }
        public void Prime(TSynchronicity aSynchronicity)
        {
            // Timer initiates operation
            iTimer_OpStart.Tag = aSynchronicity;
            iTimer_OpStart.Start();

            // Show the dialog
            base.ShowDialog();
        }
示例#7
0
        public override void ReadSource(SymSource aSource, TSynchronicity aSynchronicity)
        {
            SymbolSource source = (SymbolSource)aSource;
            //
            SymbolFileData   data   = source.ExcavateData();
            SymbolFileReader reader = new SymbolFileReader(source, data);

            reader.Read(aSynchronicity);
        }
示例#8
0
        public void Prime(TSynchronicity aSynchronicity)
        {
            if (EngineOperation != null)
            {
                EngineOperation(this, TEvent.EPrimingStarted);
            }

            // Reset the plugins
            Code.Clear();
            Symbols.Clear();

            // Categorise the prime list by plugin
            Dictionary <DbgPluginEngine, DbgEntityList> list = new Dictionary <DbgPluginEngine, DbgEntityList>();

            foreach (DbgEntity entity in iEntityManager)
            {
                // Might be null.
                DbgPluginEngine plugin = entity.PluginEngine;
                if (plugin != null)
                {
                    // Find correct list
                    DbgEntityList pluginEntityList = null;
                    if (list.ContainsKey(plugin))
                    {
                        pluginEntityList = list[plugin];
                    }
                    else
                    {
                        pluginEntityList = new DbgEntityList(this);
                        list.Add(plugin, pluginEntityList);
                    }

                    // Now add the entry
                    pluginEntityList.Add(entity);
                }
            }

            // Finally, we can tell all the plugins about the files they are about to receive
            foreach (KeyValuePair <DbgPluginEngine, DbgEntityList> kvp in list)
            {
                kvp.Key.PrepareToPrime(kvp.Value);
            }

            // Now prime the individual entities
            foreach (DbgEntity entity in iEntityManager)
            {
                entity.Prime(aSynchronicity);
            }

            if (EngineOperation != null)
            {
                EngineOperation(this, TEvent.EPrimingComplete);
            }
        }
 public void LoadFromFile(string aSymbolFileName, TSynchronicity aSynchronicity)
 {
     iSymbolFileName = aSymbolFileName;
     //
     iParser                      = new SymbolFileParser(this, this, aSymbolFileName, this);
     iParser.Tag                  = this;
     iParser.iObserver           += new SymbianUtils.AsyncReaderBase.Observer(ParserEventHandler);
     iParser.CollectionCompleted += new SymbolLib.Sources.Symbol.Parser.SymbolFileParser.CollectionCompletedHandler(Parser_CollectionCompleted);
     iParser.SymbolCreated       += new SymbolLib.Sources.Symbol.Parser.SymbolFileParser.SymbolCreatedHandler(Parser_SymbolCreated);
     iParser.Read(aSynchronicity);
 }
 public void Start(TSynchronicity aSynchronicity)
 {
     if (aSynchronicity == TSynchronicity.EAsynchronous)
     {
         ThreadPool.QueueUserWorkItem(new WaitCallback(RunWorker));
     }
     else
     {
         RunWorker();
     }
 }
示例#11
0
 internal void LoadFromFile(string aMapFileName, TSynchronicity aSynchronicity)
 {
     iMapFileName = aMapFileName;
     iMapFile     = MapFile.NewByHostMapFileName(aMapFileName);
     //
     iParser                     = new MapFileParser(this, aMapFileName, this);
     iParser.Tag                 = this;
     iParser.iObserver          += new SymbianUtils.AsyncReaderBase.Observer(Parser_Observer);
     iParser.SymbolCreated      += new MapFileParser.SymbolCreatedHandler(Parser_SymbolCreated);
     iParser.BaseAddressHandler += new MapFileParser.MapFileBaseAddressHandler(Parser_BaseAddressHandler);
     iParser.Read(aSynchronicity);
 }
        public void Convert(TSynchronicity aSynchronicity)
        {
            switch (aSynchronicity)
            {
            default:
            case TSynchronicity.EAsynchronous:
                CreateWorkers();
                break;

            case TSynchronicity.ESynchronous:
                throw new NotSupportedException();
            }
        }
 private void RunPrime(TSynchronicity aSynchronicity)
 {
     try
     {
         iPrimer.Prime(aSynchronicity);
     }
     catch (Exception e)
     {
         OnPrimeStart();
         PrimeException = e;
         OnPrimeComplete();
     }
 }
示例#14
0
        public void Read(TSynchronicity aSynchronicity)
        {
            switch (aSynchronicity)
            {
            default:
            case TSynchronicity.EAsynchronous:
                ThreadPool.QueueUserWorkItem(new WaitCallback(InitiateReadAsync));
                break;

            case TSynchronicity.ESynchronous:
                InitiateRead();
                break;
            }
        }
示例#15
0
        protected virtual void StartRead(TSynchronicity aSynchronicity)
        {
            switch (aSynchronicity)
            {
            default:
            case TSynchronicity.EAsynchronous:
                AsyncRead();
                break;

            case TSynchronicity.ESynchronous:
                SyncRead();
                break;
            }
        }
示例#16
0
 public override void LoadFromFile(string aFileName, TSynchronicity aSynchronicity)
 {
     if (SymbolFileEngine.IsSymbolFile(aFileName))
     {
         iEngineSymbol.LoadFromFile(aFileName, aSynchronicity);
     }
     else if (MapFileEngine.IsMapFile(aFileName))
     {
         iEngineMap.LoadFromFile(aFileName, aSynchronicity);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
 public void Prime(TSynchronicity aSynchronicity)
 {
     PrimeException = null;
     //
     try
     {
         iPrimer.Prime(aSynchronicity);
     }
     catch (Exception e)
     {
         OnPrimeStart();
         PrimeException = e;
         OnPrimeComplete();
     }
 }
示例#18
0
        public override void LoadFromFile(string aFileName, TSynchronicity aSynchronicity)
        {
            string extn = Path.GetExtension(aFileName).ToLower();

            if (extn == ".symbol")
            {
                // ROM engine only supports loading a single symbol file
                // at once. First unload any old file, then load new one.
                UnloadAll();
                iEngineSymbol.LoadFromFile(aFileName, aSynchronicity);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#19
0
        public override bool LoadFromDefinition(CodeSegDefinition aDefinition, TSynchronicity aSynchronicity)
        {
            // Try Symbol file first
            bool wasActivated = false;

            lock (this)
            {
                wasActivated = iEngineSymbol.Load(aDefinition);
                if (wasActivated == false)
                {
                    wasActivated = iEngineMap.Load(aDefinition, aSynchronicity);
                }
            }

            return(wasActivated);
        }
        public virtual void Start(TSynchronicity aSynchronicity)
        {
            iSynchronicity = aSynchronicity;
            OnEvent(MultiThreadedProcessor <T> .TEvent.EEventStarting);

            int count = iQueue.Count;

            if (count == 0)
            {
                // Nothing to do!
                OnEvent(MultiThreadedProcessor <T> .TEvent.EEventCompleted);
            }
            else
            {
                // For sync mode, we need to block until the operation
                // completes.
                DestroyBlocker();
                if (aSynchronicity == TSynchronicity.ESynchronous)
                {
                    iSynchronousBlocker = new ManualResetEvent(false);
                }

                // Create worker threads to process queue items. One per
                // processor core.
                CreateThreads();

                if (aSynchronicity == TSynchronicity.ESynchronous)
                {
                    System.Diagnostics.Debug.Assert(iSynchronousBlocker != null);

                    // Now wait.
                    using ( iSynchronousBlocker )
                    {
                        iSynchronousBlocker.WaitOne();
                    }
                    iSynchronousBlocker = null;

                    // See comments in "RunThread" below for details about why
                    // we do this here - it avoids a race condition.
                    OperationComplete();
                }
            }
        }
        internal void Prime(DbgEntity aEntity, TSynchronicity aSynchronicity)
        {
            // Make a new result
            aEntity.PrimerResult = new DbgEntityPrimerResult(aEntity);

            // The primer to use
            IDbgEntityPrimer primer = null;

            // We can't sensibly prime if we don't have a plugin engine associated with the
            // entity.
            DbgPluginEngine plugin = aEntity.PluginEngine;

            if (plugin != null)
            {
                // Get primer object
                switch (UiMode)
                {
                case TDbgUiMode.EUiDisabled:
                    primer = new DbgEntityPrimerSilent(aEntity, plugin);
                    break;

                default:
                case TDbgUiMode.EUiEnabled:
                    primer = new DbgEntityPrimerUi(aEntity, plugin);
                    break;
                }
            }
            else
            {
                primer = new DbgEntityPrimerNull(aEntity);
                Engine.Trace("WARNING: Entity {0} does not supply plugin engine", aEntity.FullName);
            }

            // Make sure we indicate that we actually atttempted to prime
            // the entity.
            aEntity.PrimerResult.PrimeAttempted = true;

            // And prime away
            primer.Prime(aSynchronicity);
        }
示例#22
0
        public MapFileEngine LoadFromFile(string aMapFileName, TSynchronicity aSynchronicity)
        {
            // Check if already exists
            MapFileEngine engine = null;

            //
            lock (this)
            {
                engine = FindByMapFileName(aMapFileName);
                if (engine != null)
                {
                    iFiles.Remove(engine);
                }

                engine           = new MapFileEngine(this);
                engine.Observer += new AsyncReaderBase.Observer(MapEngine_ObserverProxy);
                engine.LoadFromFile(aMapFileName, aSynchronicity);
                iFiles.Add(engine);
            }

            return(engine);
        }
示例#23
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);
        }
示例#24
0
        public override void Prime(TSynchronicity aSynchronicity)
        {
            SymbolPlugin plugin = this.Plugin;

            // Wipe any state ready for new priming attempt
            base.OnPrepareToPrime();
            if (base.ResetEngineBeforePriming)
            {
                plugin.Clear();
            }

            // Tell the plugin which sources we are reading
            plugin.StoreSourcesThatWillBePrimed(this);

            // Listen to soure events so that we can report progress
            SourceEventsSubscribe();

            // Report the "priming started event"
            base.ReportEvent(TPrimeEvent.EEventPrimingStarted, null);

            // Now we can start the sources running.
            foreach (SymSource source in iSources)
            {
                // If the source wants to read it's data immediately, then activated
                // it right now...
                if (source.TimeToRead == SymSource.TTimeToRead.EReadWhenPriming)
                {
                    source.Read(aSynchronicity);
                }
                else
                {
                    // This source will read it's data on it's own terms so skip
                    // it to ensure that we can track when all the other sources
                    // (that do actually read their files now..) are ready.
                    Skip(source);
                }
            }
        }
示例#25
0
        public void IdentifyCrashes(TSynchronicity aSynchronicity)
        {
            // If we must operate in synchronous mode, that is, we must not
            // return until the all the crash item containers are prepared,
            // then we created a blocking object that will be signalled when
            // all the asynchronous operations are complete.
            DestroyBlocker();
            if (aSynchronicity == TSynchronicity.ESynchronous)
            {
                iSynchronousBlocker = new ManualResetEvent(false);
            }

            // Next, we start processing the source files in order to create
            // crash containers.
            DestroySourceProcessor();
            iSourceProcessor = new CIEngineSourceProcessor(iSources);
            iSourceProcessor.EventHandler += new CIEngineSourceProcessor.ProcessorEventHandler(SourceProcessor_EventHandler);
            iSourceProcessor.Start(TSynchronicity.EAsynchronous);

            // Now we operate asynchronously. When the source processor has read
            // all of the CIEngineSource objects, it will trigger and event
            // callback (SourceProcessor_EventHandler) which will cause us to start
            // the serialized operation manager.
            //
            // When the serialized operation manager completes, it will again indicate
            // this via an event callback at which point we will trigger the manual
            // reset event (blocker) and therefore resume this main thread.
            if (aSynchronicity == TSynchronicity.ESynchronous)
            {
                // Now wait.
                using ( iSynchronousBlocker )
                {
                    iSynchronousBlocker.WaitOne();
                }
                iSynchronousBlocker = null;
            }
        }
        public override void ReadSource(SymSource aSource, TSynchronicity aSynchronicity)
        {
            // Need to work out if it's a GCCE or RVCT map file.
            TMapFileType type = MapFileUtils.Type(aSource.FileName);
            //
            MapReader reader = null;

            switch (type)
            {
            case TMapFileType.ETypeRVCT:
                reader = new RVCTMapFileReader(aSource, base.Tracer);
                break;

            case TMapFileType.ETypeGCCE:
                reader = new GCCEMapFileReader(aSource, base.Tracer);
                break;

            case TMapFileType.ETypeUnknown:
            default:
                throw new NotSupportedException();
            }
            //
            reader.Read(aSynchronicity);
        }
示例#27
0
 public override void Read(TSynchronicity aSynchronicity)
 {
     // This method is typically called when the engine is primed with a list of files.
     // We've already read the OBY file content, so there's no need to do anything there
     // at all. In fact, this method is never invoked in that scenario because the OBY
     // file is never registered as a SymSource.
     //
     // The usual invocation context for this method is when a map file prime request is
     // received. Because we associated every MAP file [that we were able to locate from the
     // OBY data] with the OBY provider, we can intercept the requests to read the MAP content.
     //
     // This allows us to ignore those read requests that occur during priming, and thereby
     // allow "on demand" reading of MAP file content only when an explicit code segment
     // activation (relocation/fixup) API call is made to the SymbolView class.
     //
     // When the symbol collection is activated (relocated/fixed up) we will be notified by
     // way of the SymbolCollection's "relocated" event. This will then allow us to syncronously
     // read the MAP file content and update the collection with a list of real symbols. All of
     // this is managed by the ObeySource class.
     //
     // This therefore explains why this method is implemented, but is empty.
     // Also see Reader_EntryRead for further details.
     base.ReportEvent(TEvent.EReadingComplete);
 }
示例#28
0
        public void PrepareContent(TSynchronicity aSynchronicity)
        {
            if (CompressionType == TSymbianCompressionType.ENone)
            {
                // No content preparation required, so just indicate completion
                // immediately.
                ReportDecompressionEvent(TDecompressionEvent.EEventDecompressionStarting);
                ReportDecompressionEvent(TDecompressionEvent.EEventDecompressionComplete);
            }
            else
            {
                switch (aSynchronicity)
                {
                case TSynchronicity.ESynchronous:
                    RunDecompressor();
                    break;

                case TSynchronicity.EAsynchronous:
                    // Must take the lock to either create or destroy waiter
                    lock ( iWaiterSyncRoot )
                    {
                        if (iWaiter == null)
                        {
                            iWaiter = new AutoResetEvent(false);
                            ThreadPool.QueueUserWorkItem(new WaitCallback(RunDecompressionInBackgroundThread), null);
                            break;
                        }
                        else
                        {
                            // Wait is active, so we are presumably busy...
                            throw new Exception("Content is already in preparation");
                        }
                    }
                }
            }
        }
示例#29
0
 public void Read(TSynchronicity aSynchronicity)
 {
     base.StartRead(aSynchronicity);
 }
示例#30
0
 public void Read(TSynchronicity aSynchronicity)
 {
     iImageContent.PrepareContent(aSynchronicity);
 }