Beispiel #1
0
        public bool HandleMessage(MessageBase message)
        {
            DebugMessage debugMessage = (DebugMessage)message;

            switch (message.Name)
            {
            case MessageNames.BreakPointHitName:
                Thread.VolatileWrite(ref _debugHitSession, debugMessage.Id);
                DebugEventInfo debugEvent = new DebugEventInfo(debugMessage);
                _globalInfo.EventQueue.Enqueue(debugEvent);
                break;

            case MessageNames.AddBreakPointName:

                break;

            case MessageNames.DelBreakPointName:
                break;

            case MessageNames.RequestValueName:
                break;

            default:
                throw new ArgumentOutOfRangeException();
                break;
            }
            return(true);
        }
        private DebugEventInfo?GetEventAtPosition(Point location)
        {
            Point pos = GetHClockAndScanline(location);

            EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions();
            DebugEventInfo            evt     = new DebugEventInfo();

            DebugApi.GetEventViewerEvent(this.CpuType, ref evt, (UInt16)pos.Y, (UInt16)pos.X, options);
            if (evt.ProgramCounter == 0xFFFFFFFF)
            {
                int[] xOffsets = new int[] { 0, 1, -1, 2, -2, 3 };
                int[] yOffsets = new int[] { 0, -1, 1 };

                //Check for other events near the current mouse position
                for (int j = 0; j < yOffsets.Length; j++)
                {
                    for (int i = 0; i < xOffsets.Length; i++)
                    {
                        DebugApi.GetEventViewerEvent(this.CpuType, ref evt, (UInt16)(pos.Y + yOffsets[j]), (UInt16)(pos.X + xOffsets[i] * _xRatio), options);
                        if (evt.ProgramCounter != 0xFFFFFFFF)
                        {
                            return(evt);
                        }
                    }
                }
                return(null);
            }
            else
            {
                return(evt);
            }
        }
Beispiel #3
0
        public static bool ShowEvent(DebugEventInfo evt)
        {
            DebugInfo cfg = ConfigManager.Config.DebugInfo;

            switch (evt.Type)
            {
            case DebugEventType.PpuRegisterWrite: {
                int register = evt.Address & 0x07;
                switch (register)
                {
                case 0: return(cfg.EventViewerShowPpuWrite2000);

                case 1: return(cfg.EventViewerShowPpuWrite2001);

                case 3: return(cfg.EventViewerShowPpuWrite2003);

                case 4: return(cfg.EventViewerShowPpuWrite2004);

                case 5: return(cfg.EventViewerShowPpuWrite2005);

                case 6: return(cfg.EventViewerShowPpuWrite2006);

                case 7: return(cfg.EventViewerShowPpuWrite2007);

                default: return(false);
                }
            }

            case DebugEventType.PpuRegisterRead: {
                int register = evt.Address & 0x07;
                switch (register)
                {
                case 2: return(cfg.EventViewerShowPpuRead2002);

                case 4: return(cfg.EventViewerShowPpuRead2004);

                case 7: return(cfg.EventViewerShowPpuRead2007);

                default: return(false);
                }
            }

            case DebugEventType.MapperRegisterWrite: return(cfg.EventViewerShowMapperRegisterWrites);

            case DebugEventType.MapperRegisterRead: return(cfg.EventViewerShowMapperRegisterReads);

            case DebugEventType.Nmi: return(cfg.EventViewerShowNmi);

            case DebugEventType.Irq: return(cfg.EventViewerShowIrq);

            case DebugEventType.SpriteZeroHit: return(cfg.EventViewerShowSpriteZeroHit);

            case DebugEventType.Breakpoint: return(cfg.EventViewerShowMarkedBreakpoints);

            case DebugEventType.DmcDmaRead: return(cfg.EventViewerShowDmcDmaReads);
            }
            return(false);
        }
Beispiel #4
0
        public void GetLastEventInfo()
        {
            DebugEventInfo lastEvent = DebugEventInfo.LastEvent;

            Assert.NotNull(lastEvent);
            Assert.True(lastEvent.Type.HasFlag(DebugEvent.Exception));
            Assert.Equal("Access violation - code c0000005 (first/second chance not available)", lastEvent.Description);
            Assert.Equal(Process.Current, lastEvent.Process);
            Assert.Equal(Thread.Current, lastEvent.Thread);
        }
 public DebugInformation(DebugEventInfo eventInfo, ISequenceFlowContainer parentSequenceData)
 {
     this.BreakPoint = eventInfo.BreakPoint;
     this.WatchDatas = new Dictionary <IVariable, string>(eventInfo.WatchData.Count);
     for (int i = 0; i < eventInfo.WatchData.Count; i++)
     {
         IVariable variable = CoreUtils.GetVariable(parentSequenceData, eventInfo.WatchData.Names[i]);
         WatchDatas.Add(variable, eventInfo.WatchData.Values[i]);
     }
 }
Beispiel #6
0
        static int Main(string[] args)
        {
            DebugClient  cli  = null;
            DebugControl ctrl = null;

            try
            {
                cli  = new DebugClient();
                ctrl = new DebugControl(cli);

                // ctrl.Execute(OutputControl.ToAllClients, "sxe ibp", ExecuteOptions.Default);
                ctrl.EngineOptions |= EngineOptions.InitialBreak;

                //cli.OnExceptionDebugEvent += new ExceptionEventHandler(HandleException);
                //cli.OnExitProcessDebugEvent += new ExitProcessEventHandler(HandleExitProcess);
                //cli.OnBreakpointDebugEvent += new BreakpointEventHandler(HandleBp);
                //cli.CreateProcess(0, "notepad.exe", CreateProcessOptions.DebugOnlyThisProcess);

                cli.CreateProcessAndAttach(0,
                                           @"notepad.exe",
                                           CreateProcessOptions.DebugOnlyThisProcess,
                                           0,
                                           ProcessAttachMode.InvasiveResumeProcess);

                Console.WriteLine(cli.ToString());      //Identity.ToString());

                Console.WriteLine(ctrl.WaitForEvent()); // <-- BREAKS HERE!!!

                DebugEventInfo lastEvent = ctrl.GetLastEventInformation();

                Console.WriteLine("Last event: {0}", lastEvent.Description);

                /*for (int i = 0; i < 200; i++)
                 *  Console.WriteLine(cli.ToString()); */
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Exception thrown: {0}", e);
                return(1);
            }
            finally
            {
                if (cli != null)
                {
                    cli.Dispose();
                }
                if (ctrl != null)
                {
                    ctrl.Dispose();
                }
            }

            return(0);
        }
Beispiel #7
0
        public void GetData()
        {
            DebugState state = new DebugState();

            InteropEmu.DebugGetState(ref state);

            DebugEventInfo[] eventInfoArray;
            DebugEventInfo[] prevEventInfoArray = new DebugEventInfo[0];

            InteropEmu.DebugGetDebugEvents(false, out _pictureData, out eventInfoArray);
            if (ConfigManager.Config.DebugInfo.EventViewerShowPreviousFrameEvents && (state.PPU.Scanline != -1 || state.PPU.Cycle != 0))
            {
                //Get the previous frame's data, too
                InteropEmu.DebugGetDebugEvents(true, out _pictureData, out prevEventInfoArray);
            }

            int currentCycle = (int)((state.PPU.Scanline + 1) * 341 + state.PPU.Cycle);
            var debugEvents  = new Dictionary <int, List <DebugEventInfo> >();

            List <DebugEventInfo>   eventList = new List <DebugEventInfo>(eventInfoArray.Length + prevEventInfoArray.Length);
            Action <DebugEventInfo> addEvent  = (DebugEventInfo eventInfo) => {
                int frameCycle = (eventInfo.Scanline + 1) * 341 + eventInfo.Cycle;

                List <DebugEventInfo> infoList;
                if (!debugEvents.TryGetValue(frameCycle, out infoList))
                {
                    infoList = new List <DebugEventInfo>();
                    debugEvents[frameCycle] = infoList;
                }
                infoList.Add(eventInfo);
                eventList.Add(eventInfo);
            };

            for (int i = 0; i < eventInfoArray.Length; i++)
            {
                addEvent(eventInfoArray[i]);
            }

            //Show events from the previous frame, too
            for (int i = 0; i < prevEventInfoArray.Length; i++)
            {
                int frameCycle = (prevEventInfoArray[i].Scanline + 1) * 341 + prevEventInfoArray[i].Cycle;
                if (frameCycle > currentCycle)
                {
                    addEvent(prevEventInfoArray[i]);
                }
            }

            _debugEvents        = eventList;
            _debugEventsByCycle = debugEvents;
            _state = state;
        }
        public void DebugEventProcess(DebugEventInfo eventInfo, ISequenceFlowContainer parentSequenceData)
        {
            if (eventInfo.IsDebugHit)
            {
                RefreshCommonStatus(eventInfo, RuntimeState.DebugBlocked, StepResult.NotAvailable);

                DebugInformation debugInformation = new DebugInformation(eventInfo, parentSequenceData);
                _stateManageContext.EventDispatcher.RaiseEvent(Constants.BreakPointHitted, Session,
                                                               _stateManageContext.GlobalInfo.DebugHandle, debugInformation);
            }
            else
            {
                RefreshCommonStatus(eventInfo, RuntimeState.Running, StepResult.NotAvailable);
            }
        }
Beispiel #9
0
        private void SendRunDebugStepMessage(string messageName)
        {
            if (_debugHitSession == Constants.NoDebugHitSession)
            {
                return;
            }
            int          debugSession = Interlocked.Exchange(ref _debugHitSession, Constants.NoDebugHitSession);
            DebugMessage debugMessage = new DebugMessage(messageName, debugSession, true);

            _globalInfo.MessageTransceiver.Send(debugMessage);

            DebugEventInfo debugEvent = new DebugEventInfo(debugMessage);

            _globalInfo.EventQueue.Enqueue(debugEvent);
        }
Beispiel #10
0
        public void Continue()
        {
            if (_debugHitSession == Constants.NoDebugHitSession)
            {
                return;
            }
            DebugMessage debugMessage = new DebugMessage(MessageNames.DownDebugMsgName, _debugHitSession,
                                                         DebugMessageType.FreeDebugBlock);

            _globalInfo.MessageTransceiver.Send(debugMessage);

            DebugEventInfo debugEvent = new DebugEventInfo(debugMessage);

            _globalInfo.EventQueue.Enqueue(debugEvent);
            this._debugHitSession = Constants.NoDebugHitSession;
        }
Beispiel #11
0
        public bool HandleMessage(MessageBase message)
        {
            DebugMessage     debugMessage = (DebugMessage)message;
            DebugMessageType messageType  = debugMessage.DebugMsgType;

            switch (messageType)
            {
            case DebugMessageType.BreakPointHitted:
                Thread.VolatileWrite(ref _debugHitSession, debugMessage.Id);
                DebugEventInfo debugEvent = new DebugEventInfo(debugMessage);
                _globalInfo.EventQueue.Enqueue(debugEvent);
                break;

            default:
                throw new ArgumentException();
            }
            return(true);
        }
        private ListViewItem CreateListViewItem(int index)
        {
            DebugEventInfo eventInfo = _debugEvents[index];

            string details = "";

            if (eventInfo.PpuLatch >= 1)
            {
                details += "2nd Write";
            }

            bool isReadWrite = (
                eventInfo.Type == DebugEventType.MapperRegisterRead ||
                eventInfo.Type == DebugEventType.MapperRegisterWrite ||
                eventInfo.Type == DebugEventType.PpuRegisterRead ||
                eventInfo.Type == DebugEventType.PpuRegisterWrite
                );

            if (eventInfo.Type == DebugEventType.Breakpoint)
            {
                if (eventInfo.BreakpointId >= 0 && eventInfo.BreakpointId < _breakpoints.Count)
                {
                    Breakpoint bp = _breakpoints[eventInfo.BreakpointId];
                    details += " Type: " + bp.ToReadableType();
                    details += " Addresses: " + bp.GetAddressString(true);
                    if (bp.Condition.Length > 0)
                    {
                        details += " Condition: " + bp.Condition;
                    }
                }
            }

            return(new ListViewItem(new string[] {
                eventInfo.ProgramCounter.ToString("X4"),
                eventInfo.Scanline.ToString(),
                eventInfo.Cycle.ToString(),
                ResourceHelper.GetEnumText(eventInfo.Type),
                isReadWrite ? ("$" + eventInfo.Address.ToString("X4")) : "",
                isReadWrite ? ("$" + eventInfo.Value.ToString("X2")) : "",
                details
            }));
        }
Beispiel #13
0
        private void picViewer_MouseMove(object sender, MouseEventArgs e)
        {
            Point pos = GetCycleScanline(e.Location);

            if (_lastPos == pos)
            {
                return;
            }

            EventViewerDisplayOptions options    = GetInteropOptions();
            DebugEventInfo            debugEvent = new DebugEventInfo();

            InteropEmu.GetEventViewerEvent(ref debugEvent, (Int16)(pos.Y - 1), (UInt16)pos.X, options);
            if (debugEvent.ProgramCounter == 0xFFFFFFFF)
            {
                ResetTooltip();
                UpdateOverlay(e.Location);
                return;
            }

            Dictionary <string, string> values = new Dictionary <string, string>()
            {
                { "Type", ResourceHelper.GetEnumText(debugEvent.Type) },
                { "Scanline", debugEvent.Scanline.ToString() },
                { "Cycle", debugEvent.Cycle.ToString() },
                { "PC", "$" + debugEvent.ProgramCounter.ToString("X4") },
            };

            switch (debugEvent.Type)
            {
            case DebugEventType.MapperRegisterRead:
            case DebugEventType.MapperRegisterWrite:
            case DebugEventType.PpuRegisterRead:
            case DebugEventType.PpuRegisterWrite:
                values["Register"] = "$" + debugEvent.Address.ToString("X4");
                values["Value"]    = "$" + debugEvent.Value.ToString("X2");

                if (debugEvent.PpuLatch >= 0)
                {
                    values["2nd Write"] = debugEvent.PpuLatch == 0 ? "false" : "true";
                }
                break;

            case DebugEventType.DmcDmaRead:
                values["Address"] = "$" + debugEvent.Address.ToString("X4");
                values["Value"]   = "$" + debugEvent.Value.ToString("X2");
                break;

            case DebugEventType.Breakpoint:
                ReadOnlyCollection <Breakpoint> breakpoints = BreakpointManager.Breakpoints;
                if (debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count)
                {
                    Breakpoint bp = breakpoints[debugEvent.BreakpointId];
                    values["BP Type"]      = bp.ToReadableType();
                    values["BP Addresses"] = bp.GetAddressString(true);
                    if (bp.Condition.Length > 0)
                    {
                        values["BP Condition"] = bp.Condition;
                    }
                }
                break;
            }

            ResetTooltip();
            UpdateOverlay(new Point((int)(debugEvent.Cycle * 2 * picViewer.ImageScale), (int)((debugEvent.Scanline + 1) * 2 * picViewer.ImageScale)));

            Form parentForm = this.FindForm();

            _tooltip             = new frmCodeTooltip(parentForm, values, null, null, null, 10);
            _tooltip.FormClosed += (s, evt) => { _tooltip = null; };
            Point location = Control.MousePosition;

            location.Offset(10, 10);
            _tooltip.SetFormLocation(location, this);
        }
Beispiel #14
0
        private void picPicture_MouseMove(object sender, MouseEventArgs e)
        {
            int cycle    = ((e.X & ~0x01) / (_zoomed ? 2 : 1)) / 2;
            int scanline = ((e.Y & ~0x01) / (_zoomed ? 2 : 1)) / 2;

            EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions();
            DebugEventInfo            evt     = DebugApi.GetEventViewerEvent((UInt16)scanline, (UInt16)cycle, options);

            if (evt.ProgramCounter == 0xFFFFFFFF)
            {
                ResetTooltip();
                UpdateOverlay(e.Location);
                return;
            }

            Dictionary <string, string> values = new Dictionary <string, string>()
            {
                { "Type", ResourceHelper.GetEnumText(evt.Type) },
                { "Scanline", evt.Scanline.ToString() },
                { "Cycle", evt.Cycle.ToString() },
                { "PC", "$" + evt.ProgramCounter.ToString("X6") },
            };

            switch (evt.Type)
            {
            case DebugEventType.Register:
                bool isWrite = evt.Operation.Type == MemoryOperationType.Write || evt.Operation.Type == MemoryOperationType.DmaWrite;
                bool isDma   = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead;
                values["Register"] = "$" + evt.Operation.Address.ToString("X4") + (isWrite ? " (Write)" : " (Read)") + (isDma ? " (DMA)" : "");
                values["Value"]    = "$" + evt.Operation.Value.ToString("X2");
                break;

            case DebugEventType.Breakpoint:
                //TODO

                /*ReadOnlyCollection<Breakpoint> breakpoints = BreakpointManager.Breakpoints;
                 * if(debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count) {
                 *      Breakpoint bp = breakpoints[debugEvent.BreakpointId];
                 *      values["BP Type"] = bp.ToReadableType();
                 *      values["BP Addresses"] = bp.GetAddressString(true);
                 *      if(bp.Condition.Length > 0) {
                 *              values["BP Condition"] = bp.Condition;
                 *      }
                 * }*/
                break;
            }

            double scale = _zoomed ? 2 : 1;

            UpdateOverlay(new Point((int)(evt.Cycle * 2 * scale), (int)(evt.Scanline * 2 * scale)));

            ResetTooltip();
            Form parentForm = this.FindForm();

            _tooltip             = new frmInfoTooltip(parentForm, values, 10);
            _tooltip.FormClosed += (s, ev) => { _tooltip = null; };
            Point location = picViewer.PointToScreen(e.Location);

            location.Offset(10, 10);
            _tooltip.SetFormLocation(location, this);
        }
        private void picPicture_MouseMove(object sender, MouseEventArgs e)
        {
            DebugEventInfo?result = GetEventAtPosition(e.Location);

            if (result == null)
            {
                ResetTooltip();
                UpdateOverlay(e.Location);
                return;
            }

            DebugEventInfo evt    = result.Value;
            Point          newPos = new Point(evt.Cycle, evt.Scanline);

            if (_lastPos == newPos)
            {
                return;
            }

            Dictionary <string, string> values;

            if (this.CpuType == CpuType.Gameboy)
            {
                values = new Dictionary <string, string>()
                {
                    { "Type", ResourceHelper.GetEnumText(evt.Type) },
                    { "Scanline", evt.Scanline.ToString() },
                    { "Cycle", evt.Cycle.ToString() },
                    { "PC", "$" + evt.ProgramCounter.ToString("X4") },
                };
            }
            else
            {
                values = new Dictionary <string, string>()
                {
                    { "Type", ResourceHelper.GetEnumText(evt.Type) },
                    { "Scanline", evt.Scanline.ToString() },
                    { "H-Clock", evt.Cycle.ToString() + " (" + GetCycle(evt.Cycle) + ")" },
                    { "PC", "$" + evt.ProgramCounter.ToString("X6") },
                };
            }

            switch (evt.Type)
            {
            case DebugEventType.Register:
                bool isWrite = evt.Operation.Type == MemoryOperationType.Write || evt.Operation.Type == MemoryOperationType.DmaWrite;
                bool isDma   = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead;

                CodeLabel label = LabelManager.GetLabel(new AddressInfo()
                {
                    Address = (int)evt.Operation.Address, Type = SnesMemoryType.CpuMemory
                });
                string registerText = "$" + evt.Operation.Address.ToString("X4");
                if (label != null)
                {
                    registerText = label.Label + " (" + registerText + ")";
                }

                values["Register"] = registerText + (isWrite ? " (Write)" : " (Read)") + (isDma ? " (DMA)" : "");
                values["Value"]    = "$" + evt.Operation.Value.ToString("X2");

                if (isDma && this.CpuType != CpuType.Gameboy)
                {
                    bool indirectHdma = false;
                    values["Channel"] = (evt.DmaChannel & 0x07).ToString();

                    if ((evt.DmaChannel & ctrlEventViewerPpuView.HdmaChannelFlag) != 0)
                    {
                        indirectHdma           = evt.DmaChannelInfo.HdmaIndirectAddressing;
                        values["Channel"]     += indirectHdma ? " (Indirect HDMA)" : " (HDMA)";
                        values["Line Counter"] = "$" + evt.DmaChannelInfo.HdmaLineCounterAndRepeat.ToString("X2");
                    }

                    values["Mode"] = evt.DmaChannelInfo.TransferMode.ToString();

                    int aBusAddress;
                    if (indirectHdma)
                    {
                        aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.TransferSize;
                    }
                    else
                    {
                        aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.SrcAddress;
                    }

                    if (!evt.DmaChannelInfo.InvertDirection)
                    {
                        values["Transfer"] = "$" + aBusAddress.ToString("X4") + " -> $" + evt.DmaChannelInfo.DestAddress.ToString("X2");
                    }
                    else
                    {
                        values["Transfer"] = "$" + aBusAddress.ToString("X4") + " <- $" + evt.DmaChannelInfo.DestAddress.ToString("X2");
                    }
                }
                break;

            case DebugEventType.Breakpoint:
                ReadOnlyCollection <Breakpoint> breakpoints = BreakpointManager.Breakpoints;
                if (evt.BreakpointId >= 0 && evt.BreakpointId < breakpoints.Count)
                {
                    Breakpoint bp = breakpoints[evt.BreakpointId];
                    values["CPU Type"]     = ResourceHelper.GetEnumText(bp.CpuType);
                    values["BP Type"]      = bp.ToReadableType();
                    values["BP Addresses"] = bp.GetAddressString(true);
                    if (bp.Condition.Length > 0)
                    {
                        values["BP Condition"] = bp.Condition;
                    }
                }
                break;
            }

            UpdateOverlay(new Point((int)(evt.Cycle / _xRatio * this.ImageScale), (int)(evt.Scanline * 2 * this.ImageScale)));

            Form  parentForm = this.FindForm();
            Point location   = parentForm.PointToClient(Control.MousePosition);

            BaseForm.GetPopupTooltip(parentForm).SetTooltip(location, values);
        }
        private ListViewItem CreateListViewItem(int index)
        {
            DebugEventInfo evt   = _debugEvents[index];
            bool           isDma = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead;

            string details = "";

            if (evt.Type == DebugEventType.Breakpoint)
            {
                if (evt.BreakpointId >= 0 && evt.BreakpointId < _breakpoints.Count)
                {
                    Breakpoint bp = _breakpoints[evt.BreakpointId];
                    details += " Type: " + bp.ToReadableType();
                    details += " Addresses: " + bp.GetAddressString(true);
                    if (bp.Condition.Length > 0)
                    {
                        details += " Condition: " + bp.Condition;
                    }
                }
            }

            if (isDma)
            {
                bool indirectHdma = false;
                if ((evt.DmaChannel & ctrlEventViewerPpuView.HdmaChannelFlag) != 0)
                {
                    indirectHdma = evt.DmaChannelInfo.HdmaIndirectAddressing;
                    details     += "HDMA #" + (evt.DmaChannel & 0x07).ToString();
                    details     += indirectHdma ? " (indirect)" : "";
                }
                else
                {
                    details += "DMA #" + (evt.DmaChannel & 0x07).ToString();
                }

                int aBusAddress;
                if (indirectHdma)
                {
                    aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.TransferSize;
                }
                else
                {
                    aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.SrcAddress;
                }

                if (!evt.DmaChannelInfo.InvertDirection)
                {
                    details += " - $" + aBusAddress.ToString("X4") + " -> $" + (0x2100 | evt.DmaChannelInfo.DestAddress).ToString("X4");
                }
                else
                {
                    details += " - $" + aBusAddress.ToString("X4") + " <- $" + (0x2100 | evt.DmaChannelInfo.DestAddress).ToString("X4");
                }
            }

            return(new ListViewItem(new string[] {
                evt.ProgramCounter.ToString("X4"),
                evt.Scanline.ToString(),
                evt.Cycle.ToString(),
                evt.Type.ToString(),
                evt.Type == DebugEventType.Register ? ("$" + evt.Operation.Address.ToString("X4")) : "",
                evt.Type == DebugEventType.Register ? ("$" + evt.Operation.Value.ToString("X2")) : "",
                details
            }));
        }
Beispiel #17
0
    private void SendTextToUI(string name)
    {
        DebugEventInfo dei = new DebugEventInfo(gameObject, name, 0);

        EventCoordinator.ActivateEvent(dei);
    }
 public void DebugEventProcess(DebugEventInfo eventInfo)
 {
     _sequenceHandles[eventInfo.BreakPoint.Session].DebugEventProcess(eventInfo, this.SequenceData);
 }
        private void DebugEventProcess(EventInfoBase eventInfo)
        {
            DebugEventInfo debugEvent = (DebugEventInfo)eventInfo;

            _sessionStateHandles[debugEvent.Session].DebugEventProcess(debugEvent);
        }
Beispiel #20
0
        private void picPicture_MouseMove(object sender, MouseEventArgs e)
        {
            Point pos = GetCycleScanline(e.Location);

            if (_lastPos == pos)
            {
                return;
            }

            EventViewerDisplayOptions options = ConfigManager.Config.Debug.EventViewer.GetInteropOptions();
            DebugEventInfo            evt     = DebugApi.GetEventViewerEvent((UInt16)pos.Y, (UInt16)pos.X, options);

            if (evt.ProgramCounter == 0xFFFFFFFF)
            {
                ResetTooltip();
                UpdateOverlay(e.Location);
                return;
            }

            Dictionary <string, string> values = new Dictionary <string, string>()
            {
                { "Type", ResourceHelper.GetEnumText(evt.Type) },
                { "Scanline", evt.Scanline.ToString() },
                { "Cycle", evt.Cycle.ToString() },
                { "PC", "$" + evt.ProgramCounter.ToString("X6") },
            };

            switch (evt.Type)
            {
            case DebugEventType.Register:
                bool isWrite = evt.Operation.Type == MemoryOperationType.Write || evt.Operation.Type == MemoryOperationType.DmaWrite;
                bool isDma   = evt.Operation.Type == MemoryOperationType.DmaWrite || evt.Operation.Type == MemoryOperationType.DmaRead;
                values["Register"] = "$" + evt.Operation.Address.ToString("X4") + (isWrite ? " (Write)" : " (Read)") + (isDma ? " (DMA)" : "");
                values["Value"]    = "$" + evt.Operation.Value.ToString("X2");

                if (isDma)
                {
                    bool indirectHdma = false;
                    values["Channel"] = evt.DmaChannel.ToString();
                    if (evt.DmaChannelInfo.InterruptedByHdma != 0)
                    {
                        indirectHdma           = evt.DmaChannelInfo.HdmaIndirectAddressing != 0;
                        values["Channel"]     += indirectHdma ? " (Indirect HDMA)" : " (HDMA)";
                        values["Line Counter"] = "$" + evt.DmaChannelInfo.HdmaLineCounterAndRepeat.ToString("X2");
                    }
                    values["Mode"] = evt.DmaChannelInfo.TransferMode.ToString();

                    int aBusAddress;
                    if (indirectHdma)
                    {
                        aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.TransferSize;
                    }
                    else
                    {
                        aBusAddress = (evt.DmaChannelInfo.SrcBank << 16) | evt.DmaChannelInfo.SrcAddress;
                    }

                    if (evt.DmaChannelInfo.InvertDirection == 0)
                    {
                        values["Transfer"] = "$" + aBusAddress.ToString("X4") + " -> $" + evt.DmaChannelInfo.DestAddress.ToString("X2");
                    }
                    else
                    {
                        values["Transfer"] = "$" + aBusAddress.ToString("X4") + " <- $" + evt.DmaChannelInfo.DestAddress.ToString("X2");
                    }
                }
                break;

            case DebugEventType.Breakpoint:
                //TODO

                /*ReadOnlyCollection<Breakpoint> breakpoints = BreakpointManager.Breakpoints;
                 * if(debugEvent.BreakpointId >= 0 && debugEvent.BreakpointId < breakpoints.Count) {
                 *      Breakpoint bp = breakpoints[debugEvent.BreakpointId];
                 *      values["BP Type"] = bp.ToReadableType();
                 *      values["BP Addresses"] = bp.GetAddressString(true);
                 *      if(bp.Condition.Length > 0) {
                 *              values["BP Condition"] = bp.Condition;
                 *      }
                 * }*/
                break;
            }

            UpdateOverlay(new Point((int)(evt.Cycle * 2 * this.ImageScale), (int)(evt.Scanline * 2 * this.ImageScale)));

            Form  parentForm = this.FindForm();
            Point location   = parentForm.PointToClient(this.PointToScreen(new Point(e.Location.X - picViewer.ScrollOffsets.X, e.Location.Y - picViewer.ScrollOffsets.Y)));

            BaseForm.GetPopupTooltip(parentForm).SetTooltip(location, values);
        }