private static LabelManager getPrintRoomLlbManager() { if (printRoomLlbManager == null) { printRoomLlbManager = ServiceAgent.getInstance().getPrintTemplateObject(true); } return printRoomLlbManager; }
private static LabelManager getCommonLlbManager() { if (commonLlbManager == null) { commonLlbManager = ServiceAgent.getInstance().getPrintTemplateObject(false); } return commonLlbManager; }
//static void BulkChangesPs_StateChanged(object sender, PaletteSetStateEventArgs e) //{ // if (e.NewState == StateEventIndex.Hide) // { // BulkChangesCtl.Visible = false; // } // else // { // BulkChangesCtl.Visible = true; // } //} #endregion #region 标注面板 /// <summary> /// 加载标注面板 /// </summary> /// <param name="eventArgs"></param> public static void LoadLabelManager(FixEntityArgs eventArgs) { if (labelManagerPs == null && labelManager == null) { labelManager = new LabelManager { eventArgs = eventArgs }; labelManagerPs = new PaletteSet("标注") { Visible = true, Dock = DockSides.None, Size = new Size(390, 230), MinimumSize = new Size(360, 220) }; labelManagerPs.Add("标注面板", labelManager); } else { labelManager.eventArgs = eventArgs; labelManager.BindLabelSource(); labelManagerPs.Visible = true; } }
public static void EditLabel(UInt32 address, AddressType type) { CodeLabel existingLabel = LabelManager.GetLabel(address, type); CodeLabel newLabel = new CodeLabel() { Address = address, AddressType = type, Label = existingLabel?.Label, Comment = existingLabel?.Comment }; frmEditLabel frm = new frmEditLabel(newLabel, existingLabel); if (frm.ShowDialog() == DialogResult.OK) { bool empty = string.IsNullOrWhiteSpace(newLabel.Label) && string.IsNullOrWhiteSpace(newLabel.Comment); if (existingLabel != null) { LabelManager.DeleteLabel(existingLabel.Address, existingLabel.AddressType, empty); } if (!empty) { LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment); } } }
private void OnNpcAttrChangedEvent(NpcAttrChangedEvent Event) { if (Event.Master.ID != ID) { return; } switch (Event.Index) { case NpcAttrIndex.MaxHp: Bar_.SetMaxHp(CalcFinalAttr(NpcAttrIndex.MaxHp)); break; case NpcAttrIndex.MaxMp: Bar_.SetMaxMp(CalcFinalAttr(NpcAttrIndex.MaxMp)); break; case NpcAttrIndex.Speed: Action.MoveTo(Action.TargetPos); break; case NpcAttrIndex.Hp: if (Event.ChangeValue < 0) { LabelManager.AddNumberLabel(Position, NumberLabelType.Float, Event.ChangeValue); } if (CalcFinalAttr(NpcAttrIndex.Hp) <= 0) { Dead(); } break; default: break; } }
public static DebugWorkspace GetWorkspace() { string romName = EmuApi.GetRomInfo().GetRomName(); if (_workspace != null) { SaveWorkspace(); } if (_workspace == null || _romName != romName) { _romName = romName; _workspace = DebugWorkspace.GetWorkspace(); //Load watch entries WatchManager.GetWatchManager(CpuType.Cpu).WatchEntries = _workspace.WatchValues; WatchManager.GetWatchManager(CpuType.Spc).WatchEntries = _workspace.SpcWatchValues; WatchManager.GetWatchManager(CpuType.Sa1).WatchEntries = _workspace.Sa1WatchValues; WatchManager.GetWatchManager(CpuType.Gsu).WatchEntries = _workspace.GsuWatchValues; WatchManager.GetWatchManager(CpuType.NecDsp).WatchEntries = _workspace.NecDspWatchValues; LabelManager.ResetLabels(); LabelManager.SetLabels(_workspace.CpuLabels); LabelManager.SetLabels(_workspace.SpcLabels); LabelManager.SetLabels(_workspace.NecDspLabels); LabelManager.SetDefaultLabels(); AutoImportSymbols(); } //Send breakpoints & labels to emulation core (even if the same game is running) LabelManager.RefreshLabels(); BreakpointManager.SetBreakpoints(_workspace.Breakpoints); return(_workspace); }
private string GetFunctionName(ProfiledFunction func) { string functionName; if (func.Address.Address == -1) { functionName = "[Reset]"; } else { CodeLabel label = LabelManager.GetLabel((UInt32)func.Address.Address, func.Address.Type); switch (func.Address.Type) { case AddressType.PrgRom: functionName = "PRG: $"; break; case AddressType.Register: functionName = "REG: $"; break; case AddressType.SaveRam: functionName = "SRAM: $"; break; case AddressType.WorkRam: functionName = "WRAM: $"; break; case AddressType.InternalRam: functionName = "RAM: $"; break; default: throw new Exception("Unsupported type"); } functionName += func.Address.Address.ToString("X4"); if (label != null) { functionName = label.Label + " (" + functionName + ")"; } } return(functionName); }
void loadConfig(bool forDeploy = false) { log("Loading client configuration"); clientConfigManager = new ClientConfigManager(); rootPath = workingDirectory; binPath = rootPath + "bin\\" + branch + "\\"; if (!System.IO.Directory.Exists(rootPath + "bin\\")) { System.IO.Directory.CreateDirectory(rootPath + "bin\\"); } if (!System.IO.Directory.Exists(rootPath + "bin\\" + branch + "\\")) { System.IO.Directory.CreateDirectory(rootPath + "bin\\" + branch + "\\"); } string buildconf = "build"; if (rootPath.Contains("buildagent2")) { buildconf = "build2"; } clientConfigManager.load(rootPath + "config\\" + (forDeploy ? branch : buildconf) + "_" + "usp" + ".axc"); // rootPath + "config\\" + clientConfig); log("Client configuration loaded"); log("Loading server configuration"); serverConfigManager = new ServerConfigManager(); serverConfigManager.load(clientConfigManager.ServerName, clientConfigManager.PortNumber); log("Server configuration loaded"); mgr = new AOSManager() { ServerName = clientConfigManager.ServerName, ServiceId = serverConfigManager.ServerServiceIdentifier, TimeOutMinutes = 10 }; if (forDeploy) { mgr.TimeOutMinutes = 30; } client = new ClientManager(); client.AXClientBinPath = clientConfigManager.ClientBinPath; client.AXServerBinPath = serverConfigManager.ServerBinPath; client.AXConfigurationFile = rootPath + "config\\" + (forDeploy ? branch : buildconf) + "_" + "usp" + ".axc"; // rootPath + "config\\" + clientConfig; client.ModelManifest = rootPath + branch + "\\" + modelName + "\\Model.xml"; client.TimeOutMinutes = 60; model = new ModelManager() { AOSName = serverConfigManager.AOSName, SchemaName = "temp" }; sqlManager = new SQLManager(); sqlManager.DatabaseName = serverConfigManager.DatabaseName; sqlManager.Server = serverConfigManager.DatabaseServer; labelManager = new LabelManager(); }
public static void Clear() { _workspace = null; _romName = null; LabelManager.ResetLabels(); }
private void SetModel(GameObject newModel) { _labelManager = newModel.GetComponent <LabelManager>(); SetButtonText(); }
private bool UpdateContextMenu(Point mouseLocation) { _lastLocation = mouseLocation; UpdateContextMenuItemVisibility(contextMenu.Items); mnuSwitchView.Text = IsSourceView ? "Switch to Disassembly View" : "Switch to Source View"; string word = Viewer.CodeViewer.GetWordUnderLocation(mouseLocation); Ld65DbgImporter.SymbolInfo symbol = null; CodeLabel codeLabel = null; if (!word.StartsWith("$")) { Match arrayMatch = CodeTooltipManager.LabelArrayFormat.Match(word); if (arrayMatch.Success) { word = arrayMatch.Groups[1].Value; } codeLabel = LabelManager.GetLabel(word); if (Viewer.SymbolProvider != null && IsSourceView) { int rangeStart, rangeEnd; if (Viewer.CodeViewer.GetNoteRangeAtLocation(mouseLocation.Y, out rangeStart, out rangeEnd)) { symbol = Viewer.SymbolProvider.GetSymbol(word, rangeStart, rangeEnd); } } } if (word.StartsWith("$") || codeLabel != null || symbol != null) { //Cursor is on a numeric value or label _lastWord = word; if (word.StartsWith("$")) { //CPU Address _lastClickedAddress = Int32.Parse(word.Substring(1), NumberStyles.AllowHexSpecifier); _lastClickedSymbol = null; _lastClickedLabel = null; _newWatchValue = "[$" + _lastClickedAddress.ToString("X") + "]"; } else if (symbol != null) { //Symbol _lastClickedAddress = -1; _lastClickedLabel = null; _lastClickedSymbol = symbol; _newWatchValue = "[" + word + "]"; } else if (codeLabel != null) { //Label _lastClickedLabel = codeLabel; _lastClickedAddress = -1; _lastClickedSymbol = null; _newWatchValue = "[" + word + "]"; } mnuGoToLocation.Enabled = true; mnuGoToLocation.Text = $"Go to Location ({word})"; mnuShowInSplitView.Enabled = true; mnuShowInSplitView.Text = $"Show in Split View ({word})"; mnuAddToWatch.Enabled = true; mnuAddToWatch.Text = $"Add to Watch ({word})"; mnuFindOccurrences.Enabled = true; mnuFindOccurrences.Text = $"Find Occurrences ({word})"; mnuEditLabel.Enabled = true; mnuEditLabel.Text = $"Edit Label ({word})"; mnuEditInMemoryViewer.Enabled = true; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer ({word})"; return(true); } else { mnuGoToLocation.Enabled = false; mnuGoToLocation.Text = "Go to Location"; mnuShowInSplitView.Enabled = false; mnuShowInSplitView.Text = "Show in Split View"; mnuAddToWatch.Enabled = false; mnuAddToWatch.Text = "Add to Watch"; mnuFindOccurrences.Enabled = false; mnuFindOccurrences.Text = "Find Occurrences"; mnuEditLabel.Enabled = false; mnuEditLabel.Text = "Edit Label"; mnuEditInMemoryViewer.Enabled = false; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer"; _lastClickedLabel = null; _lastClickedSymbol = null; if (mouseLocation.X < Viewer.CodeViewer.CodeMargin) { _lastClickedAddress = Viewer.CodeViewer.GetLineNumberAtPosition(mouseLocation.Y); } else { _lastClickedAddress = Viewer.CodeViewer.LastSelectedLine; } if (_lastClickedAddress >= 0) { //Cursor is in the margin, over an address label string address = $"${_lastClickedAddress.ToString("X4")}"; _newWatchValue = $"[{address}]"; _lastWord = address; mnuShowInSplitView.Enabled = true; mnuShowInSplitView.Text = $"Show in Split View ({address})"; mnuAddToWatch.Enabled = true; mnuAddToWatch.Text = $"Add to Watch ({address})"; mnuFindOccurrences.Enabled = true; mnuFindOccurrences.Text = $"Find Occurrences ({address})"; mnuEditLabel.Enabled = true; mnuEditLabel.Text = $"Edit Label ({address})"; mnuEditInMemoryViewer.Enabled = true; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer ({address})"; return(true); } return(false); } }
public LabelController(LabelManager manager) { Manager = manager; }
public LocationInfo GetLocationInfo(string word, int lineIndex) { LocationInfo location = new LocationInfo(); int arraySeparatorIndex = word.IndexOf("+"); if (arraySeparatorIndex >= 0) { int index; if (int.TryParse(word.Substring(arraySeparatorIndex + 1), out index)) { location.ArrayIndex = index; } word = word.Substring(0, arraySeparatorIndex); } if (_provider is SymbolCodeDataProvider && _symbolProvider != null) { int rangeStart, rangeEnd; GetSymbolByteRange(lineIndex, out rangeStart, out rangeEnd); location.Symbol = _symbolProvider.GetSymbol(word, rangeStart, rangeEnd); } location.Label = LabelManager.GetLabel(word); int address; if (location.Label != null) { address = location.Label.GetRelativeAddress(this.CpuType).Address; if (address >= 0) { location.Address = location.Label.GetRelativeAddress(this.CpuType).Address + (location.ArrayIndex ?? 0); } else { location.Address = -1; } } else if (word.StartsWith("$")) { word = word.Replace("$", ""); if (Int32.TryParse(word, System.Globalization.NumberStyles.HexNumber, null, out address)) { location.Address = GetFullAddress(address, word.Length); } } else if (Int32.TryParse(word, out address)) { location.Address = (int)address; } else { location.Address = -1; } if (location.Label == null && location.Address >= 0) { AddressInfo relAddress = new AddressInfo() { Address = location.Address, Type = RelativeMemoryType }; CodeLabel label = LabelManager.GetLabel(relAddress); if (label != null && !string.IsNullOrWhiteSpace(label.Label)) { //ignore comment-only labels location.Label = label; } } if (location.Label != null && location.Address >= 0) { AddressInfo absAddress = location.Label.GetAbsoluteAddress(); AddressInfo absIndexedAddress = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = location.Address, Type = RelativeMemoryType }); if (absIndexedAddress.Address > absAddress.Address) { location.ArrayIndex = absIndexedAddress.Address - absAddress.Address; } } return(location); }
public void UpdateLabelList() { List <CodeLabel> labels = LabelManager.GetLabels(_cpuType); List <ListViewItem> items = new List <ListViewItem>(labels.Count); foreach (CodeLabel label in labels) { if ((label.Label.Length > 0 || ConfigManager.Config.Debug.Debugger.ShowCommentsInLabelList)) { ListViewItem item = new ListViewItem(label.Label); string prefix = string.Empty; switch (label.MemoryType) { case SnesMemoryType.PrgRom: prefix = "PRG: $"; break; case SnesMemoryType.Register: prefix = "REG: $"; break; case SnesMemoryType.SaveRam: prefix = "SRAM: $"; break; case SnesMemoryType.WorkRam: prefix = "WRAM: $"; break; case SnesMemoryType.SpcRam: prefix = "RAM: $"; break; case SnesMemoryType.SpcRom: prefix = "ROM: $"; break; case SnesMemoryType.Sa1InternalRam: prefix = "IRAM: $"; break; case SnesMemoryType.BsxPsRam: prefix = "PSRAM: $"; break; case SnesMemoryType.BsxMemoryPack: prefix = "MPACK: $"; break; case SnesMemoryType.DspProgramRom: prefix = "DSPPRG: $"; break; case SnesMemoryType.GbPrgRom: prefix = "PRG: $"; break; case SnesMemoryType.GbWorkRam: prefix = "WRAM: $"; break; case SnesMemoryType.GbCartRam: prefix = "SRAM: $"; break; case SnesMemoryType.GbHighRam: prefix = "HRAM: $"; break; case SnesMemoryType.GbBootRom: prefix = "BOOT: $"; break; case SnesMemoryType.GameboyMemory: prefix = "REG: $"; break; default: throw new Exception("Unsupported type"); } int relAddress = label.GetRelativeAddress(_cpuType).Address; item.SubItems.Add(relAddress >= 0 ? "$" + relAddress.ToString("X4") : "-"); item.SubItems.Add(prefix + label.Address.ToString("X4")); item.SubItems.Add(ConfigManager.Config.Debug.Debugger.ShowCommentsInLabelList ? label.Comment : ""); item.Tag = label; items.Add(item); } } _listItems = items; SortItems(); lstLabels.BeginUpdate(); lstLabels.VirtualMode = true; lstLabels.VirtualListSize = items.Count; lstLabels.EndUpdate(); if (items.Count > 0) //Mono: Using AutoResize when the list is empty causes a crash { colComment.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } if (!ConfigManager.Config.Debug.Debugger.ShowCommentsInLabelList) { colComment.Width = 0; } }
// Use this for initialization void Start() { FillQueue(); labelManager = GameObject.Find("Label").GetComponent <LabelManager>(); playing = true; }
private bool UpdateContextMenu(Point mouseLocation) { _lastLocation = mouseLocation; UpdateContextMenuItemVisibility(true); mnuSwitchView.Text = SourceView ? "Switch to Disassembly View" : "Switch to Source View"; string word = Viewer.CodeViewer.GetWordUnderLocation(mouseLocation); Ld65DbgImporter.SymbolInfo symbol = null; CodeLabel codeLabel = null; if (!word.StartsWith("$")) { codeLabel = LabelManager.GetLabel(word); if (Viewer.SymbolProvider != null) { int rangeStart, rangeEnd; if (Viewer.CodeViewer.GetNoteRangeAtLocation(mouseLocation.Y, out rangeStart, out rangeEnd)) { symbol = Viewer.SymbolProvider.GetSymbol(word, rangeStart, rangeEnd); if (symbol?.SegmentID == null) { symbol = null; } } } } if (word.StartsWith("$") || codeLabel != null || symbol != null) { //Cursor is on a numeric value or label _lastWord = word; if (word.StartsWith("$")) { //CPU Address _lastClickedAddress = Int32.Parse(word.Substring(1), NumberStyles.AllowHexSpecifier); _newWatchValue = "[$" + _lastClickedAddress.ToString("X") + "]"; } else if (symbol != null) { //Symbol AddressTypeInfo addressInfo = (AddressTypeInfo)Viewer.SymbolProvider.GetSymbolAddressInfo(symbol); _lastClickedAddress = (Int32)InteropEmu.DebugGetRelativeAddress((uint)addressInfo.Address, addressInfo.Type); bool matchingLabelExists = codeLabel != null && codeLabel.Label == symbol.Name; _newWatchValue = matchingLabelExists ? $"[{word}]" : $"[${_lastClickedAddress.ToString("X2")}]"; } else if (codeLabel != null) { //Label _lastClickedAddress = (Int32)InteropEmu.DebugGetRelativeAddress(codeLabel.Address, codeLabel.AddressType); _newWatchValue = "[" + word + "]"; } mnuGoToLocation.Enabled = true; mnuGoToLocation.Text = $"Go to Location ({word})"; mnuShowInSplitView.Enabled = true; mnuShowInSplitView.Text = $"Show in Split View ({word})"; mnuAddToWatch.Enabled = true; mnuAddToWatch.Text = $"Add to Watch ({word})"; mnuFindOccurrences.Enabled = true; mnuFindOccurrences.Text = $"Find Occurrences ({word})"; mnuEditLabel.Enabled = true; mnuEditLabel.Text = $"Edit Label ({word})"; mnuEditInMemoryViewer.Enabled = true; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer ({word})"; return(true); } else { mnuGoToLocation.Enabled = false; mnuGoToLocation.Text = "Go to Location"; mnuShowInSplitView.Enabled = false; mnuShowInSplitView.Text = "Show in Split View"; mnuAddToWatch.Enabled = false; mnuAddToWatch.Text = "Add to Watch"; mnuFindOccurrences.Enabled = false; mnuFindOccurrences.Text = "Find Occurrences"; mnuEditLabel.Enabled = false; mnuEditLabel.Text = "Edit Label"; mnuEditInMemoryViewer.Enabled = false; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer"; if (mouseLocation.X < Viewer.CodeViewer.CodeMargin) { _lastClickedAddress = Viewer.CodeViewer.GetLineNumberAtPosition(mouseLocation.Y); } else { _lastClickedAddress = Viewer.CodeViewer.LastSelectedLine; } if (_lastClickedAddress >= 0) { //Cursor is in the margin, over an address label string address = $"${_lastClickedAddress.ToString("X4")}"; _newWatchValue = $"[{address}]"; _lastWord = address; mnuShowInSplitView.Enabled = true; mnuShowInSplitView.Text = $"Show in Split View ({address})"; mnuAddToWatch.Enabled = true; mnuAddToWatch.Text = $"Add to Watch ({address})"; mnuFindOccurrences.Enabled = true; mnuFindOccurrences.Text = $"Find Occurrences ({address})"; mnuEditLabel.Enabled = true; mnuEditLabel.Text = $"Edit Label ({address})"; mnuEditInMemoryViewer.Enabled = true; mnuEditInMemoryViewer.Text = $"Edit in Memory Viewer ({address})"; return(true); } return(false); } }
private static LabelManager getbartenderManager() { if (bartenderManager == null) { bartenderManager = ServiceAgent.getInstance().getBartenderPrintTemplateObject(); } return bartenderManager; }
public void UpdateFunctionList(bool reset) { if (reset) { _listItems.Clear(); _functions.Clear(); } Font italicFont = null; Font regularFont = null; Int32[] entryPoints = InteropEmu.DebugGetFunctionEntryPoints(); for (int i = 0; i < entryPoints.Length && entryPoints[i] >= 0; i++) { Int32 entryPoint = entryPoints[i]; ListViewItem item; if (!_functions.TryGetValue(entryPoint, out item)) { CodeLabel label = LabelManager.GetLabel((UInt32)entryPoint, AddressType.PrgRom); item = new ListViewItem(label?.Label); item.Tag = label; item.SubItems.Add("[n/a]"); item.SubItems[1].Tag = -1; item.ForeColor = Color.Gray; if (italicFont == null) { italicFont = new Font(item.Font, FontStyle.Italic); } item.Font = italicFont; item.SubItems.Add("$" + entryPoint.ToString("X4")); item.SubItems[2].Tag = entryPoint; _listItems.Add(item); _functions[entryPoint] = item; } Int32 relativeAddress = InteropEmu.DebugGetRelativeAddress((UInt32)entryPoint, AddressType.PrgRom); if (relativeAddress != (Int32)item.SubItems[1].Tag) { if (relativeAddress >= 0) { item.SubItems[1].Text = "$" + relativeAddress.ToString("X4"); item.ForeColor = Color.Black; if (regularFont == null) { regularFont = new Font(item.Font, FontStyle.Regular); } item.Font = regularFont; } else { item.SubItems[1].Text = "[n/a]"; item.ForeColor = Color.Gray; if (italicFont == null) { italicFont = new Font(item.Font, FontStyle.Italic); } item.Font = italicFont; } item.SubItems[1].Tag = relativeAddress; } } lstFunctions.BeginUpdate(); _listItems.Sort(CompareFunctions); lstFunctions.VirtualMode = true; lstFunctions.VirtualListSize = _listItems.Count; lstFunctions.EndUpdate(); }
public void Import(string path, bool silent) { string basePath = Path.GetDirectoryName(path); string[] lines = File.ReadAllLines(path); Regex labelRegex = new Regex(@"^([0-9a-fA-F]{2}):([0-9a-fA-F]{4}) ([^\s]*)", RegexOptions.Compiled); Regex fileRegex = new Regex(@"^([0-9a-fA-F]{4}) ([0-9a-fA-F]{8}) (.*)", RegexOptions.Compiled); Regex addrRegex = new Regex(@"^([0-9a-fA-F]{2}):([0-9a-fA-F]{4}) ([0-9a-fA-F]{4}):([0-9a-fA-F]{8})", RegexOptions.Compiled); Dictionary <string, CodeLabel> labels = new Dictionary <string, CodeLabel>(); for (int i = 0; i < lines.Length; i++) { string str = lines[i].Trim(); if (str == "[labels]") { for (; i < lines.Length; i++) { if (lines[i].Length > 0) { Match m = labelRegex.Match(lines[i]); if (m.Success) { int bank = Int32.Parse(m.Groups[1].Value, System.Globalization.NumberStyles.HexNumber); int addr = (bank << 16) | Int32.Parse(m.Groups[2].Value, System.Globalization.NumberStyles.HexNumber); string label = m.Groups[3].Value; if (!LabelManager.LabelRegex.IsMatch(label)) { //ignore labels that don't respect the label naming restrictions continue; } AddressInfo relAddr = new AddressInfo() { Address = addr, Type = SnesMemoryType.CpuMemory }; AddressInfo absAddr = DebugApi.GetAbsoluteAddress(relAddr); if (absAddr.Address < 0) { continue; } string orgLabel = label; int j = 1; while (labels.ContainsKey(label)) { label = orgLabel + j.ToString(); j++; } labels[label] = new CodeLabel() { Label = label, Address = (UInt32)absAddr.Address, MemoryType = absAddr.Type, Comment = "", Flags = CodeLabelFlags.None, Length = 1 }; } } else { break; } } } else if (str == "[source files]") { for (; i < lines.Length; i++) { if (lines[i].Length > 0) { Match m = fileRegex.Match(lines[i]); if (m.Success) { int fileId = Int32.Parse(m.Groups[1].Value, System.Globalization.NumberStyles.HexNumber); //int fileCrc = Int32.Parse(m.Groups[2].Value, System.Globalization.NumberStyles.HexNumber); string filePath = m.Groups[3].Value; string fullPath = Path.Combine(basePath, filePath); _sourceFiles[fileId] = new SourceFileInfo() { Name = filePath, Data = File.Exists(fullPath) ? File.ReadAllLines(fullPath) : new string[0] }; } } else { break; } } } else if (str == "[addr-to-line mapping]") { for (; i < lines.Length; i++) { if (lines[i].Length > 0) { Match m = addrRegex.Match(lines[i]); if (m.Success) { int bank = Int32.Parse(m.Groups[1].Value, System.Globalization.NumberStyles.HexNumber); int addr = (bank << 16) | Int32.Parse(m.Groups[2].Value, System.Globalization.NumberStyles.HexNumber); int fileId = Int32.Parse(m.Groups[3].Value, System.Globalization.NumberStyles.HexNumber); int lineNumber = Int32.Parse(m.Groups[4].Value, System.Globalization.NumberStyles.HexNumber); if (lineNumber <= 1) { //Ignore line number 0 and 1, seems like bad data? continue; } AddressInfo absAddr = new AddressInfo() { Address = addr, Type = SnesMemoryType.PrgRom }; _addressByLine[_sourceFiles[fileId].Name + "_" + lineNumber.ToString()] = absAddr; _linesByAddress[absAddr.Type.ToString() + absAddr.Address.ToString()] = new SourceCodeLocation() { File = _sourceFiles[fileId], LineNumber = lineNumber }; } } else { break; } } } } LabelManager.SetLabels(labels.Values, true); }
private void RefreshList() { Int64 exclusiveTotal = _exclusiveTime.Sum(); int hexCount = GetMaxAddrHexSize(); lstFunctions.BeginUpdate(); lstFunctions.ListViewItemSorter = null; int?topItemIndex = lstFunctions.TopItem?.Index; int selectedIndex = lstFunctions.SelectedIndices.Count > 0 ? lstFunctions.SelectedIndices[0] : -1; int itemNumber = 0; for (UInt32 i = 0; i < _exclusiveTime.Length; i++) { if (_exclusiveTime[i] > 0) { string functionName; if (i == _exclusiveTime.Length - 2) { functionName = "[Reset]"; } else if (i == _exclusiveTime.Length - 1) { functionName = "[In-Memory Function]"; } else { CodeLabel label = LabelManager.GetLabel((UInt32)i, AddressType.PrgRom); functionName = "$" + i.ToString("X" + hexCount.ToString()); if (label != null) { functionName = label.Label + " (" + functionName + ")"; } } ListViewItem item; if (itemNumber >= lstFunctions.Items.Count) { item = lstFunctions.Items.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); } else { item = lstFunctions.Items[itemNumber]; } item.Text = functionName; item.Tag = i; item.Selected = false; item.Focused = false; item.SubItems[1].Text = _callCount[i].ToString(); item.SubItems[1].Tag = _callCount[i]; item.SubItems[2].Text = _inclusiveTime[i].ToString(); item.SubItems[2].Tag = _inclusiveTime[i]; double ratio = ((double)_inclusiveTime[i] / exclusiveTotal) * 100; item.SubItems[3].Text = ratio.ToString("0.00"); item.SubItems[3].Tag = (Int64)(ratio * 100); item.SubItems[4].Text = _exclusiveTime[i].ToString(); item.SubItems[4].Tag = _exclusiveTime[i]; ratio = ((double)_exclusiveTime[i] / exclusiveTotal) * 100; item.SubItems[5].Text = ratio.ToString("0.00"); item.SubItems[5].Tag = (Int64)(ratio * 100); itemNumber++; } } lstFunctions.ListViewItemSorter = new ListComparer(_sortColumn, _sortOrder); lstFunctions.EndUpdate(); if (topItemIndex.HasValue) { lstFunctions.TopItem = lstFunctions.Items[topItemIndex.Value]; } if (selectedIndex >= 0) { lstFunctions.Items[selectedIndex].Selected = true; lstFunctions.Items[selectedIndex].Focused = true; } }
public void Import(string path, bool silent = false) { DbgFileStamp = File.GetLastWriteTime(path); string[] fileRows = File.ReadAllLines(path); string basePath = Path.GetDirectoryName(path); DbgPath = basePath; foreach (string row in fileRows) { try { if (LoadLines(row) || LoadSpans(row) || LoadSymbols(row) || LoadCSymbols(row) || LoadScopes(row) || LoadFiles(row, basePath) || LoadSegments(row)) { continue; } } catch { _errorCount++; } } LoadFileData(basePath); BuildCdlData(); foreach (LineInfo line in _lines.Values) { foreach (int spanID in line.SpanIDs) { SpanInfo span; if (_spans.TryGetValue(spanID, out span)) { SegmentInfo segment; if (_segments.TryGetValue(span.SegmentID, out segment) && !segment.IsRam) { for (int i = 0; i < span.Size; i++) { int prgAddress = segment.FileOffset - _headerSize + span.Offset + i; LineInfo existingLine; if (_linesByPrgAddress.TryGetValue(prgAddress, out existingLine) && existingLine.Type == LineType.External) { //Give priority to lines that come from C files continue; } _linesByPrgAddress[prgAddress] = line; if (i == 0 && spanID == line.SpanIDs[0]) { //Mark the first byte of the first span representing this line as the PRG address for this line of code FileInfo file = _files[line.FileID]; _prgAddressByLine[file.ID.ToString() + "_" + line.LineNumber.ToString()] = prgAddress; } } } } } } LoadLabels(); int labelCount = 0; DbgIntegrationConfig config = ConfigManager.Config.Debug.DbgIntegration; if (config.ImportCpuComments || config.ImportSpcComments) { LoadComments(); } List <CodeLabel> labels = new List <CodeLabel>(_romLabels.Count + _ramLabels.Count + _workRamLabels.Count + _saveRamLabels.Count); if (config.ImportCpuPrgRomLabels) { labels.AddRange(_romLabels.Values); labelCount += _romLabels.Count; } if (config.ImportCpuWorkRamLabels) { labels.AddRange(_workRamLabels.Values); labelCount += _workRamLabels.Count; } if (config.ImportCpuSaveRamLabels) { labels.AddRange(_saveRamLabels.Values); labelCount += _saveRamLabels.Count; } if (config.ImportSpcRamLabels) { labels.AddRange(_spcRamLabels.Values); labelCount += _spcRamLabels.Count; } if (ConfigManager.Config.Debug.DbgIntegration.ResetLabelsOnImport) { DebugWorkspaceManager.ResetLabels(); } LabelManager.SetLabels(labels, true); if (!silent) { if (_errorCount > 0) { _errorCount -= _filesNotFound.Count; string message = $"Import completed with {labelCount} labels imported"; if (_errorCount > 0) { message += $"and {_errorCount} errors - please file a bug report and attach the DBG file you tried to import."; } if (_filesNotFound.Count > 0) { message += Environment.NewLine + Environment.NewLine + "The following files could not be found:"; foreach (string file in _filesNotFound) { message += Environment.NewLine + file; } } MessageBox.Show(message, "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show($"Import completed with {labelCount} labels imported.", "Mesen", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public void UpdateLabelList() { List <CodeLabel> labels = LabelManager.GetLabels(); List <ListViewItem> items = new List <ListViewItem>(labels.Count); Font italicFont = null; foreach (CodeLabel label in labels) { if ((label.Label.Length > 0 || ConfigManager.Config.DebugInfo.ShowCommentsInLabelList) && (!label.Flags.HasFlag(CodeLabelFlags.AutoJumpLabel) || ConfigManager.Config.DebugInfo.ShowJumpLabels)) { ListViewItem item = new ListViewItem(label.Label); Int32 relativeAddress = label.GetRelativeAddress(); if (relativeAddress >= 0) { item.SubItems.Add("$" + relativeAddress.ToString("X4")); } else { item.SubItems.Add("[n/a]"); item.ForeColor = ThemeHelper.Theme.LabelDisabledForeColor; if (italicFont == null) { italicFont = new Font(item.Font, FontStyle.Italic); } item.Font = italicFont; } string prefix = string.Empty; switch (label.AddressType) { case AddressType.InternalRam: prefix = "RAM: $"; break; case AddressType.PrgRom: prefix = "PRG: $"; break; case AddressType.Register: prefix = "REG: $"; break; case AddressType.SaveRam: prefix = "SRAM: $"; break; case AddressType.WorkRam: prefix = "WRAM: $"; break; } item.SubItems.Add(prefix + label.Address.ToString("X4")); item.SubItems.Add(ConfigManager.Config.DebugInfo.ShowCommentsInLabelList ? label.Comment : ""); item.SubItems[1].Tag = label; item.Tag = relativeAddress; items.Add(item); } } _listItems = items; SortItems(); lstLabels.BeginUpdate(); lstLabels.VirtualMode = true; lstLabels.VirtualListSize = items.Count; lstLabels.EndUpdate(); colComment.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); if (!ConfigManager.Config.DebugInfo.ShowCommentsInLabelList) { colComment.Width = 0; } }
internal ILData(ILInstructionsAttribute atrib, FieldBinder fields, MethodBinder methods, LocalBinder locals, ArgBinder args, Pass pass) { //int ct = 0; this.canEmit = false; this.localDatas = new(); this.instructionEmitters = new(); foreach (var v in locals.arr) { this.localDatas.Add(v); } var stream = new InstrStream(atrib); var bindContext = new BindContext(fields, methods, locals, args); var labelManager = this.lblMgr = new LabelManager(); labelManager.logger = pass.logger; var currentLabels = new List <String>(); while (!stream.IsFinished()) { while (stream.Read(out LabelToken tok)) { stream.Advance(1); currentLabels.Add(tok.name); } if (stream.Read(out Op op)) { stream.Advance(1); var emitter = pass.OpToEmitter(op, stream, labelManager.AddCallback, bindContext); if (emitter is null) { //pass.logger.Error("No emitter produced"); return; } //pass.logger.Message($"Successfully got emitter"); var ctx = new EmitterContext(emitter); //pass.logger.Message($"Successfully got emitcontext"); this.instructionEmitters.Add(ctx); //pass.logger.Message($"Successfully added emitcontext, handling labels"); foreach (var l in currentLabels) { //pass.logger.Message($"Applying label {l}"); if (!labelManager.LabelCreated(l, ctx)) { pass.logger.Error("Duplicate label"); return; } } currentLabels.Clear(); } else { pass.logger.Error("Expected Op or Label"); return; } } //pass.logger.Message($"{ct++}"); pass.logger.Message($"Building emit data successful"); this.canEmit = true; }