Example #1
0
        private object TryAddInternal(
            RegistryChangedEventHandler handler,
            RegistryChangedEventArgs args,
            out bool needNewThread
            )
        {
            WatchEntry newEntry;

            needNewThread = false;

            lock (_eventsLock) {
                if (_entries.Count >= MAXIMUM_WAIT_OBJECTS)
                {
                    needNewThread = true;
                    return(null);
                }
                newEntry = WatchEntry.TryCreate(handler, args);
                if (newEntry == null)
                {
                    return(null);
                }
                _entries.Add(newEntry);
            }

            _itemAdded.Set();

            return(newEntry);
        }
        private void moveDownToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listWatch.SelectedItems.Count == 0)
            {
                return;
            }
            if (listWatch.SelectedIndices[0] + 1 == listWatch.Items.Count)
            {
                return;
            }
            int index = listWatch.SelectedIndices[0];

            WatchEntry entry = (WatchEntry)listWatch.SelectedItems[0].Tag;
            var        item  = listWatch.Items[index];

            listWatch.Items.RemoveAt(index);
            listWatch.Items.Insert(index + 1, item);

            // also exchange in project settings!
            if (m_WatchEntries.Count != listWatch.Items.Count)
            {
                Debug.Log("Watch Entry count mismatch!!");
            }
            var oldItem = m_WatchEntries[index];

            m_WatchEntries[index]     = m_WatchEntries[index + 1];
            m_WatchEntries[index + 1] = oldItem;

            /*
             * m_WatchEntries.RemoveAt( index );
             * m_WatchEntries.Insert( index + 1, oldItem );*/
        }
        private void contextDebugItem_Opening(object sender, CancelEventArgs e)
        {
            if (listWatch.SelectedItems.Count == 0)
            {
                e.Cancel = true;
                return;
            }
            WatchEntry entry = (WatchEntry)listWatch.SelectedItems[0].Tag;

            watchReadFromMemoryToolStripMenuItem.Checked = entry.DisplayMemory;
            displayBoundsToolStripMenuItem.Visible       = entry.DisplayMemory;
            toggleEndiannessToolStripMenuItem.Checked    = !entry.BigEndian;

            moveDownToolStripMenuItem.Enabled = (listWatch.SelectedIndices[0] + 1 < listWatch.Items.Count);
            moveUpToolStripMenuItem.Enabled   = (listWatch.SelectedIndices[0] > 0);

            if (displayBoundsToolStripMenuItem.Visible)
            {
                bytes1ToolStripMenuItem.Checked  = (entry.SizeInBytes == 1);
                bytes2ToolStripMenuItem.Checked  = (entry.SizeInBytes == 2);
                bytes4ToolStripMenuItem.Checked  = (entry.SizeInBytes == 4);
                bytes8ToolStripMenuItem.Checked  = (entry.SizeInBytes == 8);
                bytes16ToolStripMenuItem.Checked = (entry.SizeInBytes == 16);
                bytes32ToolStripMenuItem.Checked = (entry.SizeInBytes == 32);
            }
        }
Example #4
0
        /// <summary>
        /// Adds a watch item to the listview. Displays a dialog allowing the user to
        /// specify the watchentry to create.
        /// </summary>
        public void AddWatchItem()
        {
            //create an instance of the add watch dialog
            AddWatch aw = new AddWatch();

            //set the code label resolver delegate
            aw.CodeLabels = _codeLabelsHandler();

            //show the dialog. If OK was pressed, then add watch entry
            if (aw.ShowDialog(this) == DialogResult.OK)
            {
                string lab = aw.Label;
                if (!string.IsNullOrEmpty(lab))
                {
                    //resolve the label name to an address in memory. If we cannot resolve it, just exit
                    uint address = 0;
                    if (_resolveSymbolHandler(lab, ref address))
                    {
                        //create a new watch entry and set the resolved address
                        WatchEntry we = new WatchEntry(lab, aw.WatchType, aw.Signed, aw.DisplayHex, _JM);
                        we.Address = address;

                        //add watch entry to listview
                        ListViewItem lvi = new ListViewItem(new string[2] {
                            we.Label, we.ToString()
                        });
                        lvi.Tag = we;
                        listView1.Items.Add(lvi);
                    }
                }
            }
        }//AddWatchItem
Example #5
0
        public void AddWatch(string name, ulong address, uint size, bool signed)
        {
            var watch      = new Watch(name, address, size, signed);
            var watchEntry = new WatchEntry(watch);

            Watches.Add(watchEntry);
        }
        private string TypeToString(WatchEntry Entry)
        {
            string result = Entry.Type.ToString();

            if (!Entry.BigEndian)
            {
                result += ", LE";
            }
            return(result);
        }
        private void binaryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in listWatch.SelectedItems)
            {
                WatchEntry entry = (WatchEntry)item.Tag;

                entry.Type            = WatchEntry.DisplayType.BINARY;
                item.SubItems[1].Text = TypeToString(entry);
                UpdateValue(entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue);
            }
        }
Example #8
0
        }     //resetView

        /// <summary>
        /// This is called when the view needs to be updated. When the simulator hits a breakpoint or
        /// the program terminates are examples.
        /// Evaluate all the watch entries and update their values in the listview.
        /// </summary>
        public void updateView()
        {
            if (_JM == null || !_JM.ValidLoadedProgram)
            {
                return;
            }
            foreach (ListViewItem lvi in listView1.Items)
            {
                WatchEntry we = (lvi.Tag as WatchEntry);
                lvi.SubItems[1].Text = we.ToString();
            }
        }//updateView
        private void toggleEndiannessToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toggleEndiannessToolStripMenuItem.Checked = !toggleEndiannessToolStripMenuItem.Checked;
            foreach (ListViewItem item in listWatch.SelectedItems)
            {
                WatchEntry entry = (WatchEntry)item.Tag;

                entry.BigEndian       = !toggleEndiannessToolStripMenuItem.Checked;
                item.SubItems[1].Text = TypeToString(entry);

                UpdateValue(entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue);
            }
        }
        private void copySelectedValuesToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var sb = new StringBuilder();

            foreach (ListViewItem item in listWatch.SelectedItems)
            {
                WatchEntry entry = (WatchEntry)item.Tag;

                sb.AppendLine(item.SubItems[2].Text);
            }

            Clipboard.SetText(sb.ToString());
        }
        private void bytes4ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in listWatch.SelectedItems)
            {
                WatchEntry entry = (WatchEntry)item.Tag;

                entry.SizeInBytes = 4;
                UpdateValue(entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue);
                if (Core.MainForm.AppState == Types.StudioState.DEBUGGING_BROKEN)
                {
                    Core.Debugging.Debugger.RefreshRegistersAndWatches();
                }
            }
        }
        private void watchReadFromMemoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            watchReadFromMemoryToolStripMenuItem.Checked = !watchReadFromMemoryToolStripMenuItem.Checked;
            displayBoundsToolStripMenuItem.Visible       = watchReadFromMemoryToolStripMenuItem.Checked;
            foreach (ListViewItem item in listWatch.SelectedItems)
            {
                WatchEntry entry = (WatchEntry)item.Tag;

                entry.DisplayMemory = watchReadFromMemoryToolStripMenuItem.Checked;
                UpdateValue(entry.Name, entry.IndexedX, entry.IndexedY, entry.CurrentValue);
            }
            if (watchReadFromMemoryToolStripMenuItem.Checked)
            {
                Core.Debugging.Debugger.RefreshRegistersAndWatches();
            }
        }
        public void AddWatchEntry(WatchEntry Watch)
        {
            ListViewItem item = new ListViewItem();

            item.Text = Watch.Name;
            if (Watch.IndexedX)
            {
                item.Text += ",x";
            }
            if (Watch.IndexedY)
            {
                item.Text += ",y";
            }
            item.SubItems.Add(TypeToString(Watch));
            if (Watch.DisplayMemory)
            {
                item.SubItems.Add("(unread)");
                m_WatchEntries.Add(Watch);
            }
            else if (!Watch.DisplayMemory)
            {
                if (Watch.SizeInBytes == 1)
                {
                    GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(Watch.Address.ToString("x02"));
                    Watch.CurrentValue = data;
                    item.SubItems.Add(data.ToString());
                }
                else if (Watch.SizeInBytes == 2)
                {
                    GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(Watch.Address.ToString("x04"));
                    Watch.CurrentValue = data;
                    item.SubItems.Add(data.ToString());
                }
                else
                {
                    item.SubItems.Add("(unread)");
                }
            }
            else
            {
                item.SubItems.Add("(unread)");
                m_WatchEntries.Add(Watch);
            }
            item.Tag = Watch;

            listWatch.Items.Add(item);
        }
Example #14
0
        private object AddInternal(RegistryChangedEventHandler handler, RegistryChangedEventArgs args)
        {
            WatchEntry newEntry;

            lock (_eventsLock) {
                if (_entries.Count >= NativeMethods.MAXIMUM_WAIT_OBJECTS)
                {
                    return(null);
                }
                newEntry = new WatchEntry(handler, args);
                _entries.Add(newEntry);
            }

            _itemAdded.Set();

            return(newEntry);
        }
        public void RemoveWatchEntry(WatchEntry Watch)
        {
            m_WatchEntries.Remove(Watch);
            foreach (ListViewItem item in listWatch.Items)
            {
                WatchEntry watchEntry = (WatchEntry)item.Tag;

                if (watchEntry == Watch)
                {
                    listWatch.Items.Remove(item);
                    if (DebuggedProject != null)
                    {
                        DebuggedProject.SetModified();
                    }
                    return;
                }
            }
        }
Example #16
0
        }//LoadFromXML

        /// <summary>
        /// Called when the application is shutting down. Save all the view settings
        /// to the xml document.
        /// </summary>
        /// <param name="xmlOut"></param>
        public void saveState(XmlWriter xmlOut)
        {
            xmlOut.WriteStartElement(WatchView.ViewName);
            //_graphicElements.savetoXML(xmlOut);

            foreach (ListViewItem lvi in listView1.Items)
            {
                WatchEntry we = (lvi.Tag as WatchEntry);
                xmlOut.WriteStartElement("WatchItem");
                xmlOut.WriteAttributeString("Label", we.Label);
                xmlOut.WriteAttributeString("WatchType", Enum.GetName(typeof(WatchType), we.WatchType));
                xmlOut.WriteAttributeString("Signed", we.Signed.ToString());
                xmlOut.WriteAttributeString("DisplayHex", we.DisplayHex.ToString());
                xmlOut.WriteEndElement();
            }//foreach

            _graphicElements.SaveToXML(xmlOut);
            xmlOut.WriteEndElement();
        }
        public void UpdateValue(string WatchVar, bool IndexedX, bool IndexedY, GR.Memory.ByteBuffer Data)
        {
            foreach (ListViewItem item in listWatch.Items)
            {
                WatchEntry watchEntry = (WatchEntry)item.Tag;

                if ((watchEntry.Name == WatchVar) &&
                    (watchEntry.IndexedX == IndexedX) &&
                    (watchEntry.IndexedY == IndexedY))
                {
                    watchEntry.CurrentValue = Data;

                    if (watchEntry.SizeInBytes != watchEntry.CurrentValue.Length)
                    {
                        Debug.Log("Watch entry received different size than expected!");
                    }

                    if (watchEntry.CurrentValue.Length == 0)
                    {
                        item.SubItems[2].Text = "(unread)";
                        continue;
                    }

                    switch (watchEntry.Type)
                    {
                    case WatchEntry.DisplayType.HEX:
                        if (watchEntry.DisplayMemory)
                        {
                            StringBuilder sb = new StringBuilder();

                            sb.Append("$");
                            if (watchEntry.BigEndian)
                            {
                                for (int i = 0; i < Data.Length; ++i)
                                {
                                    sb.Append(Data.ByteAt(i).ToString("x2"));
                                    if (i + 1 < Data.Length)
                                    {
                                        sb.Append(" ");
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 0; i < Data.Length; ++i)
                                {
                                    sb.Append(Data.ByteAt((int)Data.Length - 1 - i).ToString("x2"));
                                    if (i + 1 < Data.Length)
                                    {
                                        sb.Append(" ");
                                    }
                                }
                            }
                            item.SubItems[2].Text = sb.ToString();
                        }
                        else
                        {
                            item.SubItems[2].Text = "$" + watchEntry.Address.ToString("x4");
                        }
                        break;

                    case WatchEntry.DisplayType.DEZ:
                        if (!watchEntry.DisplayMemory)
                        {
                            item.SubItems[2].Text = watchEntry.Address.ToString();
                        }
                        else if (watchEntry.SizeInBytes == 1)
                        {
                            item.SubItems[2].Text = Data.ByteAt(0).ToString();
                        }
                        else if (watchEntry.BigEndian)
                        {
                            string totalText = "";
                            for (uint i = 0; i < Data.Length; ++i)
                            {
                                totalText += Data.ByteAt((int)i).ToString("d") + " ";
                            }
                            item.SubItems[2].Text = totalText;
                        }
                        else
                        {
                            string totalText = "";
                            for (uint i = 0; i < Data.Length; ++i)
                            {
                                totalText += Data.ByteAt((int)Data.Length - 1 - (int)i).ToString("d") + " ";
                            }
                            item.SubItems[2].Text = totalText;
                        }
                        break;

                    case WatchEntry.DisplayType.BINARY:
                        if (!watchEntry.DisplayMemory)
                        {
                            item.SubItems[2].Text = "%" + Convert.ToString(watchEntry.Address, 2);
                        }
                        else if (watchEntry.SizeInBytes == 1)
                        {
                            item.SubItems[2].Text = "%" + Convert.ToString(Data.ByteAt(0), 2);
                        }
                        else if (watchEntry.SizeInBytes == 2)
                        {
                            item.SubItems[2].Text = "%" + Convert.ToString(Data.UInt16At(0), 2);
                        }
                        else
                        {
                            item.SubItems[2].Text = Data.ToString();
                        }
                        break;

                    default:
                        if (watchEntry.DisplayMemory)
                        {
                            item.SubItems[2].Text = Data.ByteAt(0).ToString();
                        }
                        else
                        {
                            item.SubItems[2].Text = watchEntry.Address.ToString("x4");
                        }
                        break;
                    }
                }
            }
        }
        public void UpdateValues()
        {
            if (InvokeRequired)
            {
                Invoke(new MainForm.ParameterLessCallback(UpdateValues));
                return;
            }

            foreach (var watchEntry in m_WatchEntries)
            {
                ListViewItem itemToModify = null;
                foreach (ListViewItem item in listWatch.Items)
                {
                    WatchEntry oldWatchEntry = (WatchEntry)item.Tag;

                    if (oldWatchEntry == watchEntry)
                    {
                        itemToModify = item;
                        break;
                    }
                }
                if (itemToModify == null)
                {
                    itemToModify = new ListViewItem();

                    itemToModify.Text = watchEntry.Name;
                    if (watchEntry.IndexedX)
                    {
                        itemToModify.Text += ",x";
                    }
                    if (watchEntry.IndexedY)
                    {
                        itemToModify.Text += ",y";
                    }
                    itemToModify.SubItems.Add(TypeToString(watchEntry));
                    if (watchEntry.DisplayMemory)
                    {
                        itemToModify.SubItems.Add("(unread)");
                    }
                    else if (!watchEntry.DisplayMemory)
                    {
                        if (watchEntry.SizeInBytes == 1)
                        {
                            GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(watchEntry.Address.ToString("x02"));
                            watchEntry.CurrentValue = data;
                            itemToModify.SubItems.Add(data.ToString());
                        }
                        else if (watchEntry.SizeInBytes == 2)
                        {
                            GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(watchEntry.Address.ToString("x04"));
                            watchEntry.CurrentValue = data;
                            itemToModify.SubItems.Add(data.ToString());
                        }
                        else
                        {
                            itemToModify.SubItems.Add("(unread)");
                        }
                    }
                    else
                    {
                        itemToModify.SubItems.Add("(unread)");
                    }
                    itemToModify.Tag = watchEntry;
                    listWatch.Items.Add(itemToModify);
                }

                if (!watchEntry.DisplayMemory)
                {
                    switch (watchEntry.Type)
                    {
                    case WatchEntry.DisplayType.HEX:
                        itemToModify.SubItems[2].Text = "$" + watchEntry.Address.ToString("x4");
                        break;

                    case WatchEntry.DisplayType.DEZ:
                        itemToModify.SubItems[2].Text = watchEntry.Address.ToString();
                        break;

                    case WatchEntry.DisplayType.BINARY:
                        itemToModify.SubItems[2].Text = "%" + Convert.ToString(watchEntry.Address, 2);
                        break;

                    default:
                        itemToModify.SubItems[2].Text = watchEntry.Address.ToString("x4");
                        break;
                    }
                }
            }
        }
Example #19
0
        public void AddWatch(string name, ulong address, int size, bool signed)
        {
            var watch = new WatchEntry(name, address, size, signed, MainForm.Display32);

            watches.Add(watch);
        }
Example #20
0
        private object AddInternal(RegistryChangedEventHandler handler, RegistryChangedEventArgs args) {
            WatchEntry newEntry;

            lock (_eventsLock) {
                if (_entries.Count >= NativeMethods.MAXIMUM_WAIT_OBJECTS) {
                    return null;
                }
                newEntry = new WatchEntry(handler, args);
                _entries.Add(newEntry);
            }

            _itemAdded.Set();

            return newEntry;
        }
Example #21
0
        public void AddWatch(string name, ulong address, int size, bool signed)
        {
            var watch = new WatchEntry(name, address, size, signed, MainForm.Display32);

            watches.Add(watch);
        }