Пример #1
0
        private List <StackInfo> GetStackInfo()
        {
            int nmiHandler = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFA) | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFB) << 8);
            int irqHandler = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFE) | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFF) << 8);

            InteropEmu.DebugGetCallstack(out _absoluteCallstack, out _relativeCallstack);
            DebugState state = new DebugState();

            InteropEmu.DebugGetState(ref state);
            _programCounter = state.CPU.DebugPC;

            int relDestinationAddr = -1, absDestinationAddr = -1;

            List <StackInfo> stack = new List <StackInfo>();

            for (int i = 0, len = _relativeCallstack.Length; i < len; i += 2)
            {
                if (_relativeCallstack[i] == -2)
                {
                    break;
                }

                int relSubEntryAddr = i == 0 ? -1 : _relativeCallstack[i - 1] & 0xFFFF;
                int absSubEntryAddr = i == 0 ? -1 : _absoluteCallstack[i - 1];

                stack.Add(new StackInfo()
                {
                    SubName             = this.GetFunctionName(relSubEntryAddr, absSubEntryAddr, nmiHandler, irqHandler),
                    IsMapped            = (_relativeCallstack[i] & 0x10000) != 0x10000,
                    CurrentRelativeAddr = _relativeCallstack[i] & 0xFFFF,
                    CurrentAbsoluteAddr = _absoluteCallstack[i]
                });

                relDestinationAddr = _relativeCallstack[i + 1] & 0xFFFF;
                absDestinationAddr = _absoluteCallstack[i + 1];
            }

            //Add current location
            stack.Add(new StackInfo()
            {
                SubName             = this.GetFunctionName(relDestinationAddr, absDestinationAddr, nmiHandler, irqHandler),
                IsMapped            = true,
                CurrentRelativeAddr = _programCounter,
                CurrentAbsoluteAddr = InteropEmu.DebugGetAbsoluteAddress((UInt32)_programCounter)
            });

            return(stack);
        }
Пример #2
0
        public void UpdateCallstack()
        {
            InteropEmu.DebugGetCallstack(out _absoluteCallstack, out _relativeCallstack);
            DebugState state = new DebugState();

            InteropEmu.DebugGetState(ref state);
            _programCounter = state.CPU.DebugPC;

            this.lstCallstack.Items.Clear();
            int          subStartAddr = -1;
            ListViewItem item;

            for (int i = 0, len = _relativeCallstack.Length; i < len; i += 2)
            {
                int  jsrAddr         = _relativeCallstack[i];
                bool unmappedAddress = false;
                if (subStartAddr >= 0)
                {
                    unmappedAddress = ((subStartAddr & 0x10000) == 0x10000);
                    if (unmappedAddress)
                    {
                        subStartAddr &= 0xFFFF;
                        jsrAddr      &= 0xFFFF;
                    }
                }

                string startAddr = subStartAddr >= 0 ? subStartAddr.ToString("X4") : "--------";
                if (_relativeCallstack[i] == -2)
                {
                    break;
                }
                subStartAddr = _relativeCallstack[i + 1];
                item         = this.lstCallstack.Items.Insert(0, "$" + startAddr);
                item.SubItems.Add("@ $" + jsrAddr.ToString("X4"));
                item.SubItems.Add("[$" + _absoluteCallstack[i].ToString("X4") + "]");

                if (unmappedAddress)
                {
                    item.ForeColor = Color.Gray;
                    item.Font      = new Font(item.Font, FontStyle.Italic);
                }
            }
            item = this.lstCallstack.Items.Insert(0, "$" + (subStartAddr >= 0 ? subStartAddr.ToString("X4") : "--------"));
            item.SubItems.Add("@ $" + _programCounter.ToString("X4"));
        }
Пример #3
0
        private List <StackInfo> GetStackInfo()
        {
            int nmiHandler = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFA) | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFB) << 8);
            int irqHandler = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFE) | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, 0xFFFF) << 8);

            _stackFrames = InteropEmu.DebugGetCallstack();
            DebugState state = new DebugState();

            InteropEmu.DebugGetState(ref state);
            _programCounter = state.CPU.DebugPC;

            int relDestinationAddr = -1, absDestinationAddr = -1;

            List <StackInfo> stack = new List <StackInfo>();

            for (int i = 0, len = _stackFrames.Length; i < len; i++)
            {
                int relSubEntryAddr = i == 0 ? -1 : _stackFrames[i - 1].JumpTarget;
                int absSubEntryAddr = i == 0 ? -1 : _stackFrames[i - 1].JumpTargetAbsolute;

                stack.Add(new StackInfo()
                {
                    SubName             = this.GetFunctionName(relSubEntryAddr, absSubEntryAddr, nmiHandler, irqHandler),
                    IsMapped            = _stackFrames[i].JumpSourceAbsolute < 0 ? false : InteropEmu.DebugGetRelativeAddress((uint)_stackFrames[i].JumpSourceAbsolute, AddressType.PrgRom) >= 0,
                    CurrentRelativeAddr = _stackFrames[i].JumpSource,
                    CurrentAbsoluteAddr = _stackFrames[i].JumpSourceAbsolute
                });

                relDestinationAddr = _stackFrames[i].JumpTarget;
                absDestinationAddr = _stackFrames[i].JumpTargetAbsolute;
            }

            //Add current location
            stack.Add(new StackInfo()
            {
                SubName             = this.GetFunctionName(relDestinationAddr, absDestinationAddr, nmiHandler, irqHandler),
                IsMapped            = true,
                CurrentRelativeAddr = _programCounter,
                CurrentAbsoluteAddr = InteropEmu.DebugGetAbsoluteAddress((UInt32)_programCounter)
            });

            return(stack);
        }