private void mnuEditLabel_Click(object sender, EventArgs e) { if (UpdateContextMenu(_lastLocation)) { if (_lastClickedAddress >= 0) { AddressTypeInfo info = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((UInt32)_lastClickedAddress, info); if (info.Address >= 0) { ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); } } else if (_lastClickedLabel != null) { ctrlLabelList.EditLabel(_lastClickedLabel.Address, _lastClickedLabel.AddressType); } else if (_lastClickedSymbol != null) { AddressTypeInfo info = Viewer.SymbolProvider.GetSymbolAddressInfo(_lastClickedSymbol); if (info != null && info.Address >= 0) { ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); } } } }
public AddressTypeInfo GetAddressInfo(int lineNumber) { AddressTypeInfo info = new AddressTypeInfo(); SetAddressInfo(info, lineNumber); return(info); }
public void ScrollToLineNumber(int lineNumber, bool scrollToTop = false) { AddressTypeInfo addressInfo = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((uint)lineNumber, addressInfo); ScrollToAddress(addressInfo, scrollToTop); }
public void ToggleBreakpoint(bool toggleEnabledFlag) { int relativeAddress = Viewer.CodeViewer.CurrentLine; AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine); BreakpointManager.ToggleBreakpoint(relativeAddress, info, toggleEnabledFlag); }
public ScrollbarColorProvider(ctrlSourceViewer viewer) { _viewer = viewer; DebugInfo info = ConfigManager.Config.DebugInfo; int len = viewer.ctrlCodeViewer.LineCount; int[] relativeAddresses = new int[len]; AddressTypeInfo[] addressInfo = new AddressTypeInfo[len]; for (int i = 0; i < len; i++) { addressInfo[i] = _viewer.GetAddressInfo(i); if (addressInfo[i].Address >= 0) { relativeAddresses[i] = InteropEmu.DebugGetRelativeAddress((uint)addressInfo[i].Address, AddressType.PrgRom); } else { relativeAddresses[i] = -1; } } foreach (Breakpoint breakpoint in BreakpointManager.Breakpoints) { for (int i = 0; i < len; i++) { if (breakpoint.Matches(relativeAddresses[i], addressInfo[i])) { Color bpColor = breakpoint.BreakOnExec ? info.CodeExecBreakpointColor : (breakpoint.BreakOnWrite ? info.CodeWriteBreakpointColor : info.CodeReadBreakpointColor); _breakpointColors[i] = bpColor; } } } }
public void ScrollToAddress(AddressTypeInfo addressInfo, bool scrollToTop = false) { int relativeAddress = InteropEmu.DebugGetRelativeAddress((uint)addressInfo.Address, addressInfo.Type); if (relativeAddress >= 0) { this.ctrlCodeViewer.ScrollToLineNumber(relativeAddress, eHistoryType.Always, scrollToTop); } }
public void ToggleBreakpoint() { AddressTypeInfo info = GetAddressInfo(ctrlCodeViewer.SelectedLine); if (info.Address >= 0) { BreakpointManager.ToggleBreakpoint(-1, info, false); } }
private void mnuViewInMemoryType_Click(object sender, EventArgs e) { AddressTypeInfo addressInfo = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((UInt32)SelectionStartAddress, addressInfo); if (addressInfo.Address >= 0 && (addressInfo.Type == AddressType.PrgRom || addressInfo.Type == AddressType.WorkRam || addressInfo.Type == AddressType.SaveRam)) { MemoryViewer.ShowAddress(addressInfo.Address, addressInfo.Type.ToMemoryType()); } }
private void ctrlCodeViewer_MouseDown(object sender, MouseEventArgs e) { _tooltipManager.Close(); if (e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) { int relativeAddress = ctrlCodeViewer.GetLineNumberAtPosition(e.Y); AddressTypeInfo info = GetAddressInfo(ctrlCodeViewer.GetLineIndexAtPosition(e.Y)); BreakpointManager.ToggleBreakpoint(relativeAddress, info, false); } }
private Breakpoint GetCurrentLineBreakpoint() { AddressTypeInfo addressInfo = GetAddressInfo(ctrlCodeViewer.SelectedLine); if (addressInfo.Address >= 0) { int relativeAddress = InteropEmu.DebugGetRelativeAddress((uint)addressInfo.Address, addressInfo.Type); return(BreakpointManager.GetMatchingBreakpoint(relativeAddress, addressInfo)); } return(null); }
public static CodeLabel GetLabel(UInt16 relativeAddress) { AddressTypeInfo info = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((UInt32)relativeAddress, ref info); if (info.Address >= 0) { return(GetLabel((UInt32)info.Address, info.Type)); } return(null); }
public frmCodeTooltip(Form parent, Dictionary <string, string> values, AddressTypeInfo previewAddress = null, CodeInfo code = null, Ld65DbgImporter symbolProvider = null) { _parentForm = parent; _values = values; _previewAddress = previewAddress; _code = code; _symbolProvider = symbolProvider; InitializeComponent(); this.TopLevel = false; this.Parent = _parentForm; _parentForm.Controls.Add(this); }
private void mnuEditLabel_Click(object sender, EventArgs e) { if (UpdateContextMenu(_lastLocation)) { AddressTypeInfo info = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((UInt32)_lastClickedAddress, ref info); if (info.Address >= 0) { ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); } } }
public string GetLineComment(int lineNumber) { if (_code.SymbolProvider != null && _code._config?.ShowSourceAsComments == true) { AddressTypeInfo addressInfo = _code.GetAddressInfo(lineNumber); if (addressInfo.Type == AddressType.PrgRom) { return(_code.SymbolProvider.GetSourceCodeLine(addressInfo.Address)); } } return(null); }
private void lstFunctions_DoubleClick(object sender, EventArgs e) { if (lstFunctions.SelectedIndices.Count > 0) { AddressTypeInfo addr = _functions[lstFunctions.SelectedIndices[0]].Address; int relativeAddress = InteropEmu.DebugGetRelativeAddress((uint)addr.Address, addr.Type); if (relativeAddress >= 0) { OnFunctionSelected?.Invoke(relativeAddress, EventArgs.Empty); } } }
public static void ToggleBreakpoint(int relativeAddress, AddressTypeInfo info, bool toggleEnabled) { if (relativeAddress >= 0 || info.Address >= 0) { Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(relativeAddress, info); if (breakpoint != null) { if (toggleEnabled) { breakpoint.SetEnabled(!breakpoint.Enabled); } else { BreakpointManager.RemoveBreakpoint(breakpoint); } } else { if (info.Address < 0 || info.Type == AddressType.InternalRam) { breakpoint = new Breakpoint() { MemoryType = DebugMemoryType.CpuMemory, BreakOnExec = true, BreakOnRead = true, BreakOnWrite = true, Address = (UInt32)relativeAddress, Enabled = true }; } else { breakpoint = new Breakpoint() { Enabled = true, BreakOnExec = true, Address = (UInt32)info.Address }; if (info.Type != AddressType.PrgRom) { breakpoint.BreakOnRead = true; breakpoint.BreakOnWrite = true; } breakpoint.MemoryType = info.Type.ToMemoryType(); } BreakpointManager.AddBreakpoint(breakpoint); } } }
public bool Matches(int relativeAddress, ref AddressTypeInfo info) { if (this.IsCpuBreakpoint && this.AddressType == BreakpointAddressType.SingleAddress) { if (this.MemoryType == DebugMemoryType.CpuMemory) { return(relativeAddress == this.Address); } else { return(_equivalentAddressType == info.Type && info.Address == this.Address); } } return(false); }
private void mnuEditLabel_Click(object sender, EventArgs e) { UInt32 address = (UInt32)ctrlHexBox.SelectionStart; if (this._memoryType == DebugMemoryType.CpuMemory) { AddressTypeInfo info = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType(address, info); ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); } else { ctrlLabelList.EditLabel(address, GetAddressType().Value); } }
private GoToDestination GetDestination() { Ld65DbgImporter.ReferenceInfo definitionInfo = _lastClickedSymbol != null?Viewer.SymbolProvider?.GetSymbolDefinition(_lastClickedSymbol) : null; AddressTypeInfo addressInfo = _lastClickedSymbol != null?Viewer.SymbolProvider?.GetSymbolAddressInfo(_lastClickedSymbol) : null; return(new GoToDestination() { CpuAddress = _lastClickedAddress >= 0 ? _lastClickedAddress : (addressInfo != null ? InteropEmu.DebugGetRelativeAddress((UInt32)addressInfo.Address, addressInfo.Type) : -1), Label = _lastClickedLabel, AddressInfo = addressInfo, File = definitionInfo?.FileName, Line = definitionInfo?.LineNumber ?? 0 }); }
private void ctrlCodeViewer_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Location.X > this.ctrlCodeViewer.CodeMargin / 2 && e.Location.X < this.ctrlCodeViewer.CodeMargin) { AddressTypeInfo info = GetAddressInfo(ctrlCodeViewer.GetLineIndexAtPosition(e.Y)); if (info.Address >= 0) { ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); } } else { _codeViewerActions.ProcessMouseDoubleClick(e.Location); } }
public void DisplayAddressTooltip(string word, UInt32 address) { byte byteValue = InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, address); UInt16 wordValue = (UInt16)(byteValue | (InteropEmu.DebugGetMemoryValue(DebugMemoryType.CpuMemory, address + 1) << 8)); var values = new Dictionary <string, string>() { { "Address", "$" + address.ToString("X4") }, { "Value", $"${byteValue.ToString("X2")} (byte){Environment.NewLine}${wordValue.ToString("X4")} (word)" } }; AddressTypeInfo addressInfo = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType(address, addressInfo); this.ShowTooltip(word, values, -1, addressInfo); }
public void ToggleBreakpoint(bool toggleEnabledFlag) { AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine); if (info.Address < 0) { //Current line has no address, try using the next line instead. //(Used when trying to set a breakpoint on a row containing only a label) info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine + 1); } if (info.Address >= 0) { BreakpointManager.ToggleBreakpoint(info, toggleEnabledFlag); } }
public AddressTypeInfo GetAddressInfo(int lineNumber) { AddressTypeInfo info = new AddressTypeInfo(); info.Address = this._absoluteLineNumbers[lineNumber]; switch (this._lineMemoryType[lineNumber]) { case 'P': info.Type = AddressType.PrgRom; break; case 'W': info.Type = AddressType.WorkRam; break; case 'S': info.Type = AddressType.SaveRam; break; case 'N': info.Type = AddressType.InternalRam; break; } return(info); }
private void LoadLabels() { foreach (KeyValuePair <int, SymbolInfo> kvp in _symbols) { try { SymbolInfo symbol = kvp.Value; if (symbol.SegmentID == null) { continue; } if (_segments.ContainsKey(symbol.SegmentID.Value)) { SegmentInfo segment = _segments[symbol.SegmentID.Value]; int count = 2; string orgSymbolName = symbol.Name; if (!LabelManager.LabelRegex.IsMatch(orgSymbolName)) { //ignore labels that don't respect the label naming restrictions continue; } string newName = symbol.Name; while (!_usedLabels.Add(newName)) { //Ensure labels are unique newName = orgSymbolName + "_" + count.ToString(); count++; } AddressTypeInfo addressInfo = GetSymbolAddressInfo(symbol); if (symbol.Address != null && symbol.Address >= 0) { CodeLabel label = this.CreateLabel(addressInfo.Address, addressInfo.Type, (uint)GetSymbolSize(symbol)); if (label != null) { label.Label = newName; } } } } catch { _errorCount++; } } }
private void SetAddressInfo(AddressTypeInfo info, int lineNumber) { if (lineNumber < this._code.AbsoluteLineNumbers.Length) { info.Address = this._code.AbsoluteLineNumbers[lineNumber]; switch (this._code.LineMemoryType[lineNumber]) { case 'P': info.Type = AddressType.PrgRom; break; case 'W': info.Type = AddressType.WorkRam; break; case 'S': info.Type = AddressType.SaveRam; break; case 'N': info.Type = AddressType.InternalRam; break; } } }
private bool CurrentFileContainsAddress(int cpuAddress) { if (CurrentFile == null) { return(false); } AddressTypeInfo addressInfo = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((uint)cpuAddress, addressInfo); if (addressInfo.Address >= 0 && addressInfo.Type == AddressType.PrgRom) { LineInfo line = _symbolProvider.GetSourceCodeLineInfo(addressInfo.Address); return(CurrentFile.ID == line?.FileID); } return(false); }
public void UpdateContextMenuItemVisibility(ToolStripItemCollection items) { items[nameof(mnuUndoPrgChrEdit)].Enabled = InteropEmu.DebugHasUndoHistory(); items[nameof(mnuShowNextStatement)].Enabled = Viewer.ActiveAddress.HasValue; items[nameof(mnuSetNextStatement)].Enabled = Viewer.ActiveAddress.HasValue; items[nameof(mnuEditSelectedCode)].Enabled = items[nameof(mnuEditSubroutine)].Enabled = InteropEmu.DebugIsExecutionStopped() && Viewer.CodeViewer.CurrentLine >= 0; bool hasSymbolProvider = Viewer.SymbolProvider != null; items[nameof(mnuShowSourceAsComments)].Visible = hasSymbolProvider; items[nameof(mnuSwitchView)].Visible = hasSymbolProvider; items[nameof(sepSwitchView)].Visible = hasSymbolProvider; if (IsSourceView) { items[nameof(mnuMarkSelectionAs)].Visible = false; items[nameof(mnuEditSubroutine)].Visible = false; items[nameof(mnuEditSelectedCode)].Visible = false; items[nameof(mnuNavigateForward)].Visible = false; items[nameof(mnuNavigateBackward)].Visible = false; items[nameof(mnuEditLabel)].Visible = false; items[nameof(sepNavigation)].Visible = false; items[nameof(mnuShowSourceAsComments)].Visible = false; items[nameof(sepMarkSelectionAs)].Visible = false; } else { items[nameof(mnuEditSourceFile)].Visible = false; } AddressTypeInfo addressInfo = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine); if (addressInfo.Address >= 0) { int relAddress = InteropEmu.DebugGetRelativeAddress((uint)addressInfo.Address, addressInfo.Type); items[nameof(mnuPerfTracker)].Text = "Performance Tracker ($" + relAddress.ToString("X4") + ")"; items[nameof(mnuPerfTracker)].Enabled = true; } else { items[nameof(mnuPerfTracker)].Text = "Performance Tracker"; items[nameof(mnuPerfTracker)].Enabled = false; } }
public bool Matches(int relativeAddress) { if (this.IsCpuBreakpoint) { if (this.IsAbsoluteAddress) { AddressTypeInfo addressTypeInfo = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((uint)relativeAddress, ref addressTypeInfo); return(addressTypeInfo.Type == GUI.AddressType.PrgRom && addressTypeInfo.Address == this.Address); } else { return(relativeAddress == this.Address); } } return(false); }
private void mnuEditLabel_Click(object sender, EventArgs e) { if (UpdateContextMenu(_lastLocation)) { if (_lastClickedAddress >= 0) { //get selected adress of debugger text window int startAddress, endAddress; string rangeString; GetSelectedAddressRange(out startAddress, out endAddress, out rangeString); AddressTypeInfo info = new AddressTypeInfo(); InteropEmu.DebugGetAbsoluteAddressAndType((UInt32)_lastClickedAddress, info); if (info.Address >= 0) { ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); //if that is the same as the address we just edited, restore selected line if (startAddress == info.Address) { GoToDestination(new GoToDestination() { AddressInfo = info }); } } else { ctrlLabelList.EditLabel((UInt32)_lastClickedAddress, AddressType.Register); } } else if (_lastClickedLabel != null) { ctrlLabelList.EditLabel(_lastClickedLabel.Address, _lastClickedLabel.AddressType); } else if (_lastClickedSymbol != null) { AddressTypeInfo info = Viewer.SymbolProvider.GetSymbolAddressInfo(_lastClickedSymbol); if (info != null && info.Address >= 0) { ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); } } } }
public void ScrollToAddress(AddressTypeInfo addressInfo, bool scrollToTop = false) { if (addressInfo.Address >= 0 && addressInfo.Type == AddressType.PrgRom) { LineInfo line = _symbolProvider.GetSourceCodeLineInfo(addressInfo.Address); if (line != null) { foreach (Ld65DbgImporter.FileInfo fileInfo in cboFile.Items) { if (fileInfo.ID == line.FileID) { cboFile.SelectedItem = fileInfo; break; } } ctrlCodeViewer.ScrollToLineIndex(line.LineNumber, eHistoryType.Always, scrollToTop); } } }