Esempio n. 1
0
        public Profiler(DebugView view)
            : base(view)
        {
            _window = new Window(30, 30, 60, 25, "Profiler");
            _window.Visible = false;
            View.Desktop.Add(_window);

            _profilerView = new ListView<ProfilerItem>(1, 1, 56, 19);
            _profilerView.Columns.Add(new ListView<ProfilerItem>.Column("Function", 43, p => p.Function));
            _profilerView.Columns.Add(new ListView<ProfilerItem>.Column("Samples", 11, p => p.Samples, true, p => string.Format("{0,11:P}", p.Samples / (float)_totalSamples)));
            _window.Add(_profilerView);

            _start = new Button(1, 21, 10, "Start");
            _start.Clicked += () =>
            {
                if (Target == null)
                    return;

                if (!_profiling)
                    Reset();

                _profiling = !_profiling;
            };

            _window.Add(_start);

            _message = new Label(13, 21, 40, 1, "Profiling requires debug information");
            _window.Add(_message);

            _profiling = false;
            _items = new Dictionary<string, ProfilerItem>();
            _totalSamples = 0;
        }
Esempio n. 2
0
        public Target(DebugView view)
            : base(view)
        {
            _window = new Window(10, 10, 30, 7, "Target");
            _window.Visible = false;
            View.Desktop.Add(_window);

            var codeError = new Label(1, 1, 26, 2, "");
            _window.Add(codeError);

            _codeText = new TextBox(1, 3, 18);
            _window.Add(_codeText);

            var codeButton = new Button(20, 3, 7, "Load");
            codeButton.Clicked += () =>
            {
                if (Target == null || _codeText.Value.Length == 0)
                    return;

                try
                {
                    Target.Load(Assets.ReloadCode(_codeText.Value));
                    codeError.Caption = "";
                    _needUpdate = true;
                }
                catch
                {
                    codeError.Caption = "Failed to load code";
                }
            };
            _window.Add(codeButton);

            // TODO: put target stats in this window

            _needUpdate = true;
        }
Esempio n. 3
0
        public Cpu(DebugView view)
            : base(view)
        {
            #region Widget Creation
            _window = new Window(10, 10, 110, 41, "CPU");
            View.Desktop.Add(_window);

            _disassembly = new Disassembly(1, 1, 79, 37);
            _disassembly.Clicked += (addr, button) =>
            {
                if (Target == null)
                    return;

                if (button == Mouse.Button.Left)
                    Target.AddBreakpoint(addr);
                else if (button == Mouse.Button.Right)
                    Target.RemoveBreakpoint(addr);
            };
            _window.Add(_disassembly);

            var y = 1;

            _registers = new Label[RegisterNames.Length];
            for (var i = 0; i < _registers.Length; i++, y++)
            {
                _registers[i] = new Label(82, y, 25, 1, "");
                _window.Add(_registers[i]);
            }

            y++;

            _flags = new Label[FlagNames.Length];
            for (var i = 0; i < _flags.Length; i++, y++)
            {
                _flags[i] = new Label(82, y, 25, 1, "");
                _window.Add(_flags[i]);
            }

            y++;
            _ivt = new Label(82, y++, 25, 1, "");
            _window.Add(_ivt);

            _error = new Label(82, ++y, 25, 4, "");
            _window.Add(_error);

            _skipInterrupt = new Checkbox(82, 29, 25, "Skip Interrupts");
            _skipInterrupt.Changed += () =>
            {
                if (Target != null)
                    Target.SkipInterrupts = _skipInterrupt.Checked;
            };
            _window.Add(_skipInterrupt);

            _step = new Button(82, 31, 25, "Step");
            _step.Clicked += () =>
            {
                if (Target == null || !Target.Paused)
                    return;

                Target.Step = true;
                _autoMove = true;
            };
            _window.Add(_step);

            _pause = new Button(82, 34, 25, "Pause");
            _pause.Clicked += () =>
            {
                if (Target == null)
                    return;

                if (!Target.Paused)
                    _autoMove = true;

                Target.Paused = !Target.Paused;
                Target.Step = true;
            };
            _window.Add(_pause);

            var gotoInput = new TextBox(82, 37, 17);
            _window.Add(gotoInput);

            var gotoButton = new Button(100, 37, 7, "Goto");
            gotoButton.Clicked += () =>
            {
                if (Target == null || gotoInput.Value.Length == 0)
                    return;

                try
                {
                    _gotoError = null;
                    var expr = WatchExpression.Compile(gotoInput.Value);
                    Goto(expr(Target));
                }
                catch (Exception e)
                {
                    _gotoError = string.Format("Goto: {0}", e.Message);
                }
            };
            _window.Add(gotoButton);
            #endregion
        }
Esempio n. 4
0
        public Watch(DebugView view)
            : base(view)
        {
            _window = new Window(25, 25, 80, 25, "Watch");
            _window.Visible = false;
            View.Desktop.Add(_window);

            _watchView = new ListView<WatchItem>(1, 1, 76, 19);
            _watchView.Columns.Add(new ListView<WatchItem>.Column("Name", 14, w => w.Name));
            _watchView.Columns.Add(new ListView<WatchItem>.Column("Expression", 40, w => w.Expression, false));
            _watchView.Columns.Add(new ListView<WatchItem>.Column("Value", 20, null, false, w =>
            {
                if (Target == null)
                    return "No Target";

                if (w.Error != null)
                    return w.Error;

                try
                {
                    var value = w.Function(Target);
                    return string.Format("{0:X8} {0,11}", value);
                }
                catch (WatchException e)
                {
                    return e.Message;
                }
                catch
                {
                    return "Error";
                }
            }));

            _watchView.Clicked += (item, button) =>
            {
                if (button == Mouse.Button.Right)
                {
                    _watchView.Items.Remove(item);
                }
                else if (button == Mouse.Button.Middle)
                {
                    _editing = item;
                    _name.Value = _editing.Name;
                    _expression.Value = _editing.Expression;
                }
            };

            _window.Add(_watchView);

            _name = new TextBox(1, 21, 13);
            _window.Add(_name);

            _expression = new TextBox(15, 21, 50);
            _window.Add(_expression);

            _button = new Button(66, 21, 11, "Add");
            _button.Clicked += () =>
            {
                if (_expression.Value.Length == 0)
                    return;

                WatchItem item;

                if (_editing == null)
                {
                    item = new WatchItem();
                    _watchView.Items.Add(item);
                }
                else
                {
                    item = _editing;
                }

                item.Name = _name.Value;
                item.Expression = _expression.Value;

                try
                {
                    item.Function = WatchExpression.Compile(item.Expression);
                    item.Error = null;
                }
                catch (WatchException e)
                {
                    item.Error = e.Message;
                }

                _name.Value = "";
                _expression.Value = "";
                _editing = null;
            };
            _window.Add(_button);
        }