public static void DeleteLabel(CodeLabel label, bool raiseEvent)
        {
            bool needEvent = false;

            _labels.Remove(label);
            for (UInt32 i = label.Address; i < label.Address + label.Length; i++)
            {
                UInt32 key = GetKey(i, label.AddressType);
                if (_labelsByKey.ContainsKey(key))
                {
                    _reverseLookup.Remove(_labelsByKey[key].Label);
                }

                if (_labelsByKey.Remove(key))
                {
                    InteropEmu.DebugSetLabel(i, label.AddressType, string.Empty, string.Empty);
                    if (raiseEvent)
                    {
                        needEvent = true;
                    }
                }
            }

            if (needEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
            }
        }
Example #2
0
        public static bool SetLabel(UInt32 address, AddressType type, string label, string comment, bool raiseEvent = true, CodeLabelFlags flags = CodeLabelFlags.None)
        {
            if (_reverseLookup.ContainsKey(label))
            {
                //Another identical label exists, we need to remove it
                CodeLabel existingLabel = _reverseLookup[label];
                DeleteLabel(existingLabel.Address, existingLabel.AddressType, false);
            }

            UInt32 key = GetKey(address, type);

            if (_labels.ContainsKey(key))
            {
                _reverseLookup.Remove(_labels[key].Label);
            }

            _labels[key] = new CodeLabel()
            {
                Address = address, AddressType = type, Label = label, Comment = comment, Flags = flags
            };
            if (label.Length > 0)
            {
                _reverseLookup[label] = _labels[key];
            }

            InteropEmu.DebugSetLabel(address, type, label, comment.Replace(Environment.NewLine, "\n"));
            if (raiseEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
            }

            return(true);
        }
Example #3
0
        public static void DeleteLabel(CodeLabel label, bool raiseEvent)
        {
            bool needEvent = false;

            _labels.Remove(label);
            for (UInt32 i = label.Address; i < label.Address + label.Length; i++)
            {
                UInt64 key = GetKey(i, label.MemoryType);
                if (_labelsByKey.ContainsKey(key))
                {
                    _reverseLookup.Remove(_labelsByKey[key].Label);
                }

                if (_labelsByKey.Remove(key))
                {
                    DebugApi.SetLabel(i, label.MemoryType, string.Empty, string.Empty);
                    if (raiseEvent)
                    {
                        needEvent = true;
                    }
                }
            }

            if (needEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
                DebugApi.RefreshDisassembly(label.MemoryType.ToCpuType());
            }
        }
Example #4
0
        public static bool SetLabel(UInt32 address, AddressType type, string label, string comment, bool raiseEvent = true)
        {
            string key = GetKey(address, type);

            if (_labels.ContainsKey(key))
            {
                _reverseLookup.Remove(_labels[key].Label);
            }

            _labels[key] = new CodeLabel()
            {
                Address = address, AddressType = type, Label = label, Comment = comment
            };
            if (label.Length > 0)
            {
                _reverseLookup[label] = _labels[key];
            }

            InteropEmu.DebugSetLabel(address, type, label, comment.Replace(Environment.NewLine, "\n"));
            if (raiseEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
            }

            return(true);
        }
Example #5
0
 public static void SetLabels(IEnumerable <CodeLabel> labels, bool raiseEvents = true)
 {
     foreach (CodeLabel label in labels)
     {
         SetLabel(label.Address, label.AddressType, label.Label, label.Comment, false);
     }
     if (raiseEvents)
     {
         OnLabelUpdated?.Invoke(null, null);
     }
 }
Example #6
0
        public static bool SetLabel(UInt32 address, AddressType type, string label, string comment, bool raiseEvent = true, CodeLabelFlags flags = CodeLabelFlags.None, UInt32 labelLength = 1)
        {
            if (_reverseLookup.ContainsKey(label))
            {
                //Another identical label exists, we need to remove it
                CodeLabel existingLabel = _reverseLookup[label];
                DeleteLabel(existingLabel, false);
            }

            CodeLabel newLabel = new CodeLabel()
            {
                Address = address, AddressType = type, Label = label, Comment = comment, Flags = flags, Length = labelLength
            };

            for (UInt32 i = address; i < address + labelLength; i++)
            {
                UInt32    key = GetKey(i, type);
                CodeLabel existingLabel;
                if (_labelsByKey.TryGetValue(key, out existingLabel))
                {
                    DeleteLabel(existingLabel, false);
                    _reverseLookup.Remove(existingLabel.Label);
                }

                _labelsByKey[key] = newLabel;

                if (labelLength == 1)
                {
                    InteropEmu.DebugSetLabel(i, type, label, comment.Replace(Environment.NewLine, "\n"));
                }
                else
                {
                    InteropEmu.DebugSetLabel(i, type, label + "+" + (i - address).ToString(), comment.Replace(Environment.NewLine, "\n"));

                    //Only set the comment on the first byte of multi-byte comments
                    comment = "";
                }
            }

            _labels.Add(newLabel);
            if (label.Length > 0)
            {
                _reverseLookup[label] = newLabel;
            }

            if (raiseEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
            }

            return(true);
        }
Example #7
0
        public static bool SetLabel(CodeLabel label, bool raiseEvent)
        {
            if (_reverseLookup.ContainsKey(label.Label))
            {
                //Another identical label exists, we need to remove it
                DeleteLabel(_reverseLookup[label.Label], false);
            }

            string comment = label.Comment;

            for (UInt32 i = label.Address; i < label.Address + label.Length; i++)
            {
                UInt64    key = GetKey(i, label.MemoryType);
                CodeLabel existingLabel;
                if (_labelsByKey.TryGetValue(key, out existingLabel))
                {
                    DeleteLabel(existingLabel, false);
                    _reverseLookup.Remove(existingLabel.Label);
                }

                _labelsByKey[key] = label;

                if (label.Length == 1)
                {
                    DebugApi.SetLabel(i, label.MemoryType, label.Label, comment.Replace(Environment.NewLine, "\n"));
                }
                else
                {
                    DebugApi.SetLabel(i, label.MemoryType, label.Label + "+" + (i - label.Address).ToString(), comment.Replace(Environment.NewLine, "\n"));

                    //Only set the comment on the first byte of multi-byte comments
                    comment = "";
                }
            }

            _labels.Add(label);
            if (label.Label.Length > 0)
            {
                _reverseLookup[label.Label] = label;
            }

            if (raiseEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
                DebugApi.RefreshDisassembly(label.MemoryType.ToCpuType());
            }

            return(true);
        }
Example #8
0
 public static void DeleteLabel(UInt32 address, AddressType type, bool raiseEvent)
 {
     if (_labels.ContainsKey(GetKey(address, type)))
     {
         _reverseLookup.Remove(_labels[GetKey(address, type)].Label);
     }
     if (_labels.Remove(GetKey(address, type)))
     {
         InteropEmu.DebugSetLabel(address, type, string.Empty, string.Empty);
         if (raiseEvent)
         {
             OnLabelUpdated?.Invoke(null, null);
         }
     }
 }
Example #9
0
 private static void ProcessLabelUpdate()
 {
     OnLabelUpdated?.Invoke(null, null);
     UpdateAssertBreakpoints();
 }