Esempio n. 1
0
        internal RegisterCollection(CrashDebuggerInfo aCrashDebugger, TType aType, DProcess aProcess, RegisterCollection aLinkedWith)
            : base(aCrashDebugger)
        {
            iType    = aType;
            iProcess = aProcess;

            iEntries = new ArmRegisterCollection();
            iEntries.BackingStore = this as IARCBackingStore;

            iLinkedWith = aLinkedWith;
        }
Esempio n. 2
0
        /// <summary>
        /// Internal constructor called by CIRegisterListForThread which sets a thread up as a parent
        /// of the register list.
        /// </summary>
        internal CIRegisterList(CIContainer aContainer, CIElement aParent, TArmRegisterBank aBank)
            : base(aContainer, aParent)
        {
            iCollection              = new ArmRegisterCollection(aBank);
            iCollection.Tag          = this;
            iCollection.BackingStore = this;

            // Restrict children
            base.AddSupportedChildType(typeof(CIRegister));
            base.AddSupportedChildType(typeof(CrashItemLib.Crash.Messages.CIMessage));
        }
Esempio n. 3
0
        private void CheckRequiredRegistersAvailable()
        {
            ArmRegisterCollection regs = CPU.Registers;

            // We need SP, LR, PC, CPSR
            bool sp   = regs.Contains(TArmRegisterType.EArmReg_SP);
            bool lr   = regs.Contains(TArmRegisterType.EArmReg_LR);
            bool pc   = regs.Contains(TArmRegisterType.EArmReg_PC);
            bool cpsr = regs.Contains(TArmRegisterType.EArmReg_CPSR);
            //
            bool available = (sp && lr && pc && cpsr);

            if (!available)
            {
                SymbianUtils.SymDebug.SymDebugger.Break();
                throw new ArgumentException("One or more registers is unavailable");
            }
        }
Esempio n. 4
0
        private void MakeInitialSeedStackFramesFromRegisterValues()
        {
            if (!iAlreadySavedInitialRegisterFrames)
            {
                ArmRegisterCollection regs = CPU.Registers;

                // Make PC stack frame
                ArmStackFrame framePC = new ArmStackFrame(TArmRegisterType.EArmReg_PC);
                framePC.Data = regs[TArmRegisterType.EArmReg_PC].Value;

                // Make LR stack frame
                ArmStackFrame frameLR = new ArmStackFrame(TArmRegisterType.EArmReg_LR);
                frameLR.Data = regs[TArmRegisterType.EArmReg_LR].Value;

                // Save 'em
                SaveStackFrames(framePC, frameLR);

                // Don't do this again
                iAlreadySavedInitialRegisterFrames = true;
            }
        }
Esempio n. 5
0
        private bool AddLRAndPC()
        {
            bool addedLRandPC = false;
            //
            ArmRegisterCollection regs = base.Engine.Registers;

            // If we're inside the stack address range, then poke in the PC and LR values
            if (regs.Count > 0)
            {
                // Working bottom up, so LR should go on the stack first
                if (regs.Contains(TArmRegisterType.EArmReg_LR))
                {
                    ArmRegister regLR = regs[TArmRegisterType.EArmReg_LR];

                    StackOutputEntry entryLR = new StackOutputEntry(0, regLR.Value, base.DebugEngineView);
                    entryLR.IsRegisterBasedEntry       = true;
                    entryLR.IsOutsideCurrentStackRange = true;
                    entryLR.AssociatedRegister         = regLR.RegType;
                    EmitElement(entryLR);
                }

                // Then the PC...
                if (regs.Contains(TArmRegisterType.EArmReg_PC))
                {
                    ArmRegister regPC = regs[TArmRegisterType.EArmReg_PC];

                    StackOutputEntry entryPC = new StackOutputEntry(0, regPC.Value, base.DebugEngineView);
                    entryPC.IsRegisterBasedEntry       = true;
                    entryPC.IsOutsideCurrentStackRange = true;
                    entryPC.AssociatedRegister         = regPC.RegType;
                    EmitElement(entryPC);
                }

                // Even if they weren't added, we at least attempted to addd them
                addedLRandPC = true;
            }

            return(addedLRandPC);
        }
Esempio n. 6
0
        private void GetNewLRValue(uint aLinkRegOffsetInWords, ArmPrologueHelper aPrologue)
        {
            uint sp = CPU[TArmRegisterType.EArmReg_SP];

            Trace(string.Format("GetNewLRValue - stack DWORD offset to LR: 0x{0:x8}, sp: 0x{1:x8}", aLinkRegOffsetInWords, sp));

            // If the link register was pushed onto the stack, then get the new value
            // now...
            if (aLinkRegOffsetInWords != uint.MaxValue)
            {
                ArmRegisterCollection regs = aPrologue.OffsetValues;
                foreach (ArmRegister reg in regs)
                {
                    Trace("GetNewLRValue - reg offsets - " + reg.ToString());
                }

                long offsetOnStackToLR = aLinkRegOffsetInWords * 4;
                long stackBase         = iStackInterface.StackBase;
                long stackOffsetToLR   = sp - 4 - stackBase - offsetOnStackToLR;
                iLastLinkRegisterStackAddress = stackBase + stackOffsetToLR;
                uint newLRValue = iStackInterface.StackValueAtAddress((uint)iLastLinkRegisterStackAddress);
                Trace(string.Format("GetNewLRValue - Fetching LR from stack address: 0x{0:x8} (0x{1:x8})", iLastLinkRegisterStackAddress, newLRValue));

                uint   temp;
                string sym;
                SymbolViewText.Lookup(newLRValue, out temp, out sym);
                Trace("GetNewLRValue - LR changed to: 0x" + newLRValue.ToString("x8") + " => [ " + sym + " ]");

                CPU[TArmRegisterType.EArmReg_LR].Value = newLRValue;
            }
            else
            {
                iLastLinkRegisterStackAddress = KLinkRegisterWasNotPushedOnStack;
                Trace("GetNewLRValue - LR not pushed on stack!");
            }
        }
Esempio n. 7
0
        protected override void PerformOperation()
        {
            // Get the source data we need to reconstruct and signal we're about to start
            StackSourceData sourceData = base.SourceData;

            // Get the output data sink
            StackOutputData outputData = base.OutputData;

            outputData.Clear();
            outputData.AlgorithmName = Name;

            // Get the address range of the stack pointer data
            AddressRange pointerRange         = base.Engine.AddressInfo.StackPointerRange;
            AddressRange pointerRangeExtended = base.Engine.AddressInfo.StackPointerRangeWithExtensionArea;

            // Indicates if we added LR and PC to the call stack
            bool addedLRandPC = false;

            // Get registers
            ArmRegisterCollection regs = base.Engine.Registers;

            foreach (DataBufferUint sourceEntry in sourceData.GetUintEnumerator())
            {
                // Check if it is within the stack domain, taking into account
                // our extended range
                if (pointerRangeExtended.Contains(sourceEntry.Address))
                {
                    StackOutputEntry outputEntry = new StackOutputEntry(sourceEntry.Address, sourceEntry.Uint, base.DebugEngineView);

                    // Is it the element tht corresponds to the current value of SP?
                    bool isCurrentSPEntry = (outputEntry.AddressRange.Contains(base.Engine.AddressInfo.Pointer));
                    outputEntry.IsCurrentStackPointerEntry = isCurrentSPEntry;

                    // Is it within the pure 'stack pointer' address range?
                    bool outsidePureStackPointerRange = !pointerRange.Contains(sourceEntry.Address);
                    outputEntry.IsOutsideCurrentStackRange = outsidePureStackPointerRange;

                    // These are never accurate, but neither are they ghosts
                    outputEntry.IsAccurate = false;
                    outputEntry.IsGhost    = false;

                    // Save entry
                    EmitElement(outputEntry);

                    // If we're inside the stack address range, then poke in the PC and LR values
                    if (isCurrentSPEntry)
                    {
                        System.Diagnostics.Debug.Assert(!addedLRandPC);
                        addedLRandPC = AddLRAndPC();
                    }
                }
                else
                {
                    // Nope, ignore it...
                }

                NotifyEvent(TEvent.EReadingProgress);
                ++iDWordIndex;
            }

            // If the stack overflowed, then SP might be outside of the stack range. Therefore
            // LR and PC will not be added yet.
            if (!addedLRandPC)
            {
                AddLRAndPC();
            }
        }
Esempio n. 8
0
 public void Add(ArmRegisterCollection aArmRegisterCollection)
 {
     // Will cause a call back to create the entries in iRegisters...
     iCollection.Copy(aArmRegisterCollection);
     System.Diagnostics.Debug.Assert(iCollection.Count == base.Count);
 }