Debugger: Added support for bass .sym files
This commit is contained in:
parent
3a41275575
commit
7a313572a5
4 changed files with 68 additions and 2 deletions
58
UI/Debugger/Labels/BassLabelFile.cs
Normal file
58
UI/Debugger/Labels/BassLabelFile.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using Mesen.GUI.Config;
|
||||
using Mesen.GUI.Debugger.Labels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Mesen.GUI.Debugger
|
||||
{
|
||||
public class BassLabelFile
|
||||
{
|
||||
public static void Import(string path, bool silent = false)
|
||||
{
|
||||
List<CodeLabel> labels = new List<CodeLabel>(1000);
|
||||
|
||||
int errorCount = 0;
|
||||
foreach(string row in File.ReadAllLines(path, Encoding.UTF8)) {
|
||||
string lineData = row.Trim();
|
||||
int splitIndex = lineData.IndexOf(' ');
|
||||
UInt32 address;
|
||||
|
||||
if(!UInt32.TryParse(lineData.Substring(0, splitIndex), NumberStyles.HexNumber, null, out address)) {
|
||||
errorCount++;
|
||||
}
|
||||
|
||||
AddressInfo absAddress = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = (int)address, Type = SnesMemoryType.CpuMemory });
|
||||
|
||||
if(absAddress.Address >= 0) {
|
||||
CodeLabel label = new CodeLabel();
|
||||
label.Address = (UInt32)absAddress.Address;
|
||||
label.MemoryType = absAddress.Type;
|
||||
label.Comment = "";
|
||||
string labelName = lineData.Substring(splitIndex + 1).Replace('.', '_');
|
||||
if(string.IsNullOrEmpty(labelName) || !LabelManager.LabelRegex.IsMatch(labelName)) {
|
||||
errorCount++;
|
||||
} else {
|
||||
label.Label = labelName;
|
||||
labels.Add(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LabelManager.SetLabels(labels);
|
||||
|
||||
if(!silent) {
|
||||
string message = $"Import completed with {labels.Count} labels imported";
|
||||
if(errorCount > 0) {
|
||||
message += $" and {errorCount} error(s)";
|
||||
}
|
||||
MessageBox.Show(message, "Mesen-S", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -148,7 +148,14 @@ namespace Mesen.GUI.Debugger.Workspace
|
|||
if(ConfigManager.Config.Debug.DbgIntegration.ResetLabelsOnImport) {
|
||||
ResetLabels();
|
||||
}
|
||||
new WlaDxImporter().Import(symPath, silent);
|
||||
|
||||
string symContent = File.ReadAllText(symPath);
|
||||
if(symContent.Contains("[labels]")) {
|
||||
//Assume WLA-DX symbol files
|
||||
new WlaDxImporter().Import(symPath, silent);
|
||||
} else {
|
||||
BassLabelFile.Import(symPath, silent);
|
||||
}
|
||||
LabelManager.RefreshLabels();
|
||||
}
|
||||
|
||||
|
|
|
@ -298,6 +298,7 @@
|
|||
<Compile Include="Debugger\Controls\ctrlMemoryType.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\Labels\BassLabelFile.cs" />
|
||||
<Compile Include="Debugger\MemoryTools\ctrlMemoryAccessCounters.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -396,7 +397,7 @@
|
|||
<DependentUpon>frmEditLabel.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Debugger\Labels\LabelManager.cs" />
|
||||
<Compile Include="Debugger\MslLabelFile.cs" />
|
||||
<Compile Include="Debugger\Labels\MslLabelFile.cs" />
|
||||
<Compile Include="Debugger\PpuViewer\ctrlImagePanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
|
Loading…
Add table
Reference in a new issue