Debugger: Added "Auto-create jump labels" option

This commit is contained in:
Sour 2018-09-08 13:16:17 -04:00
parent f25d680e32
commit 7ec7512fde
15 changed files with 193 additions and 60 deletions

View file

@ -44,5 +44,5 @@ void CodeRunner::WriteRAM(uint16_t addr, uint8_t value)
DisassemblyInfo CodeRunner::GetDisassemblyInfo(uint16_t cpuAddress)
{
return DisassemblyInfo(_byteCode.data() + cpuAddress - CodeRunner::BaseAddress, false);
return DisassemblyInfo(_byteCode.data() + cpuAddress - CodeRunner::BaseAddress, false, false);
}

View file

@ -208,7 +208,7 @@ void Debugger::UpdateCdlCache()
for(int i = 0, len = _mapper->GetMemorySize(DebugMemoryType::PrgRom); i < len; i++) {
if(_codeDataLogger->IsCode(i)) {
AddressTypeInfo info = { i, AddressType::PrgRom };
i = _disassembler->BuildCache(info, 0, _codeDataLogger->IsSubEntryPoint(i)) - 1;
i = _disassembler->BuildCache(info, 0, _codeDataLogger->IsSubEntryPoint(i), false) - 1;
}
}
@ -601,7 +601,7 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
}
}
_disassembler->BuildCache(addressInfo, addr, isSubEntryPoint);
_disassembler->BuildCache(addressInfo, addr, isSubEntryPoint, false);
ProcessStepConditions(addr);
@ -929,6 +929,11 @@ const char* Debugger::GetCode(uint32_t &length)
}
}
void Debugger::GetJumpTargets(bool* jumpTargets)
{
_disassembler->GetJumpTargets(jumpTargets);
}
int32_t Debugger::GetRelativeAddress(uint32_t addr, AddressType type)
{
switch(type) {

View file

@ -203,6 +203,8 @@ public:
void GenerateCodeOutput();
const char* GetCode(uint32_t &length);
void GetJumpTargets(bool* jumpTargets);
int32_t GetRelativeAddress(uint32_t addr, AddressType type);
int32_t GetAbsoluteAddress(uint32_t addr);

View file

@ -188,7 +188,7 @@ void Disassembler::GetInfo(AddressTypeInfo &info, uint8_t** source, uint32_t &si
}
uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bool isSubEntryPoint)
uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bool isSubEntryPoint, bool isJumpTarget)
{
uint32_t mask = info.Type == AddressType::InternalRam ? 0x7FF : 0xFFFFFFFF;
@ -203,8 +203,9 @@ uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bo
if(!disInfo) {
while(absoluteAddr < (int32_t)size && !(*cache)[absoluteAddr]) {
bool isJump = IsUnconditionalJump(source[absoluteAddr]);
disInfo = new DisassemblyInfo(source+absoluteAddr, isSubEntryPoint);
disInfo = new DisassemblyInfo(source+absoluteAddr, isSubEntryPoint, isJumpTarget);
isSubEntryPoint = false;
isJumpTarget = false;
(*cache)[absoluteAddr] = shared_ptr<DisassemblyInfo>(disInfo);
@ -218,6 +219,9 @@ uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bo
if(isSubEntryPoint) {
disInfo->SetSubEntryPoint();
}
if(isJumpTarget) {
disInfo->SetJumpTarget();
}
uint8_t opCode = source[absoluteAddr];
if(IsJump(opCode)) {
@ -228,7 +232,9 @@ uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bo
const uint8_t jsrCode = 0x20;
if(addressInfo.Address >= 0) {
BuildCache(addressInfo, jumpDest, opCode == jsrCode);
BuildCache(addressInfo, jumpDest, opCode == jsrCode, true);
} else {
disInfo->SetJumpTarget();
}
}
}
@ -306,7 +312,7 @@ void Disassembler::RebuildPrgRomCache(uint32_t absoluteAddr, int32_t length)
uint16_t memoryAddr = _debugger->GetRelativeAddress(absoluteAddr, AddressType::PrgRom);
AddressTypeInfo info = { (int32_t)absoluteAddr, AddressType::PrgRom };
BuildCache(info, memoryAddr, isSubEntryPoint);
BuildCache(info, memoryAddr, isSubEntryPoint, false);
}
static const char* hexTable[256] = {
@ -533,7 +539,7 @@ string Disassembler::GetCode(AddressTypeInfo &addressInfo, uint32_t endAddr, uin
isVerifiedData = addressInfo.Type == AddressType::PrgRom && cdl->IsData(addr&mask);
if(!info && ((disassembleUnidentifiedData && !isVerifiedData) || (disassembleVerifiedData && isVerifiedData))) {
dataType = isVerifiedData ? DataType::VerifiedData : DataType::UnidentifiedData;
tmpInfo->Initialize(source + (addr & mask), false);
tmpInfo->Initialize(source + (addr & mask), false, false);
info = tmpInfo;
} else if(info) {
dataType = DataType::VerifiedCode;
@ -673,4 +679,15 @@ DisassemblyInfo Disassembler::GetDisassemblyInfo(AddressTypeInfo &info)
} else {
return DisassemblyInfo();
}
}
void Disassembler::GetJumpTargets(bool* jumpTargets)
{
memset(jumpTargets, 0, _disassembleCache.size());
for(size_t i = 0, len = _disassembleCache.size(); i < len; i++) {
shared_ptr<DisassemblyInfo> disInfo = _disassembleCache[i];
if(disInfo && disInfo->IsJumpTarget()) {
jumpTargets[i] = true;
}
}
}

View file

@ -43,7 +43,7 @@ public:
void BuildOpCodeTables(bool useLowerCase);
void Reset();
uint32_t BuildCache(AddressTypeInfo &info, uint16_t memoryAddr, bool isSubEntryPoint);
uint32_t BuildCache(AddressTypeInfo &info, uint16_t memoryAddr, bool isSubEntryPoint, bool isJumpTarget);
void InvalidateCache(AddressTypeInfo &info);
bool IsUnofficialOpCode(uint8_t opCode);
@ -52,5 +52,7 @@ public:
DisassemblyInfo GetDisassemblyInfo(AddressTypeInfo &info);
void GetJumpTargets(bool* jumpTargets);
void RebuildPrgRomCache(uint32_t absoluteAddr, int32_t length);
};

View file

@ -33,9 +33,9 @@ DisassemblyInfo::DisassemblyInfo()
{
}
DisassemblyInfo::DisassemblyInfo(uint8_t* opPointer, bool isSubEntryPoint)
DisassemblyInfo::DisassemblyInfo(uint8_t* opPointer, bool isSubEntryPoint, bool isJumpTarget)
{
Initialize(opPointer, isSubEntryPoint);
Initialize(opPointer, isSubEntryPoint, isJumpTarget);
}
void DisassemblyInfo::ToString(string &out, uint32_t memoryAddr, MemoryManager* memoryManager, LabelManager* labelManager, bool extendZeroPage)
@ -148,9 +148,10 @@ uint16_t DisassemblyInfo::GetOpAddr(uint16_t memoryAddr)
return opAddr;
}
void DisassemblyInfo::Initialize(uint8_t* opPointer, bool isSubEntryPoint)
void DisassemblyInfo::Initialize(uint8_t* opPointer, bool isSubEntryPoint, bool isJumpTarget)
{
_isSubEntryPoint = isSubEntryPoint;
_isJumpTarget = isJumpTarget;
uint8_t opCode = *opPointer;
_opSize = DisassemblyInfo::OPSize[opCode];
@ -168,6 +169,11 @@ void DisassemblyInfo::SetSubEntryPoint()
_isSubEntryPoint = true;
}
void DisassemblyInfo::SetJumpTarget()
{
_isJumpTarget = true;
}
int32_t DisassemblyInfo::GetMemoryValue(State& cpuState, MemoryManager* memoryManager)
{
int32_t address = -1;
@ -300,4 +306,9 @@ bool DisassemblyInfo::IsSubEntryPoint()
bool DisassemblyInfo::IsSubExitPoint()
{
return _isSubExitPoint;
}
}
bool DisassemblyInfo::IsJumpTarget()
{
return _isJumpTarget;
}

View file

@ -17,6 +17,7 @@ public:
private:
uint8_t _byteCode[3];
bool _isJumpTarget = false;
bool _isSubEntryPoint = false;
bool _isSubExitPoint = false;
uint32_t _opSize = 0;
@ -24,12 +25,14 @@ private:
public:
DisassemblyInfo();
DisassemblyInfo(uint8_t* opPointer, bool isSubEntryPoint);
DisassemblyInfo(uint8_t* opPointer, bool isSubEntryPoint, bool isJumpTarget);
void Initialize(uint8_t * opPointer, bool isSubEntryPoint);
void Initialize(uint8_t * opPointer, bool isSubEntryPoint, bool isJumpTarget);
void SetSubEntryPoint();
void SetJumpTarget();
int32_t GetEffectiveAddress(State& cpuState, MemoryManager* memoryManager);
void GetEffectiveAddressString(string &out, State& cpuState, MemoryManager* memoryManager, LabelManager* labelManager);
@ -41,5 +44,6 @@ public:
bool IsSubEntryPoint();
bool IsSubExitPoint();
bool IsJumpTarget();
};

View file

@ -129,6 +129,9 @@ namespace Mesen.GUI.Config
public bool DisplayOpCodesInLowerCase = false;
public bool ShowEffectiveAddresses = true;
public bool AutoCreateJumpLabels = false;
public bool ShowJumpLabels = false;
public bool DisassembleVerifiedData = false;
public bool DisassembleUnidentifiedData = false;

View file

@ -41,6 +41,7 @@
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
this.mnuShowComments = new System.Windows.Forms.ToolStripMenuItem();
this.mnuShowJumpLabels = new System.Windows.Forms.ToolStripMenuItem();
this.lstLabels = new Mesen.GUI.Controls.DoubleBufferedListView();
this.colFunctionLabel = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colFunctionAddress = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@ -63,15 +64,16 @@
this.mnuAddToWatch,
this.mnuFindOccurrences,
this.toolStripMenuItem2,
this.mnuShowComments});
this.mnuShowComments,
this.mnuShowJumpLabels});
this.contextMenu.Name = "contextMenu";
this.contextMenu.Size = new System.Drawing.Size(187, 242);
this.contextMenu.Size = new System.Drawing.Size(231, 264);
//
// mnuAdd
//
this.mnuAdd.Image = global::Mesen.GUI.Properties.Resources.Add;
this.mnuAdd.Name = "mnuAdd";
this.mnuAdd.Size = new System.Drawing.Size(186, 22);
this.mnuAdd.Size = new System.Drawing.Size(230, 22);
this.mnuAdd.Text = "Add";
this.mnuAdd.Click += new System.EventHandler(this.mnuAdd_Click);
//
@ -79,7 +81,7 @@
//
this.mnuEdit.Image = global::Mesen.GUI.Properties.Resources.EditLabel;
this.mnuEdit.Name = "mnuEdit";
this.mnuEdit.Size = new System.Drawing.Size(186, 22);
this.mnuEdit.Size = new System.Drawing.Size(230, 22);
this.mnuEdit.Text = "Edit";
this.mnuEdit.Click += new System.EventHandler(this.mnuEdit_Click);
//
@ -87,20 +89,20 @@
//
this.mnuDelete.Image = global::Mesen.GUI.Properties.Resources.Close;
this.mnuDelete.Name = "mnuDelete";
this.mnuDelete.Size = new System.Drawing.Size(186, 22);
this.mnuDelete.Size = new System.Drawing.Size(230, 22);
this.mnuDelete.Text = "Delete";
this.mnuDelete.Click += new System.EventHandler(this.mnuDelete_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(183, 6);
this.toolStripMenuItem1.Size = new System.Drawing.Size(227, 6);
//
// mnuViewInCpuMemory
//
this.mnuViewInCpuMemory.Image = global::Mesen.GUI.Properties.Resources.Chip;
this.mnuViewInCpuMemory.Name = "mnuViewInCpuMemory";
this.mnuViewInCpuMemory.Size = new System.Drawing.Size(186, 22);
this.mnuViewInCpuMemory.Size = new System.Drawing.Size(230, 22);
this.mnuViewInCpuMemory.Text = "View in CPU memory";
this.mnuViewInCpuMemory.Click += new System.EventHandler(this.mnuViewInCpuMemory_Click);
//
@ -108,20 +110,20 @@
//
this.mnuViewInMemoryType.Image = global::Mesen.GUI.Properties.Resources.CheatCode;
this.mnuViewInMemoryType.Name = "mnuViewInMemoryType";
this.mnuViewInMemoryType.Size = new System.Drawing.Size(186, 22);
this.mnuViewInMemoryType.Size = new System.Drawing.Size(230, 22);
this.mnuViewInMemoryType.Text = "View in {0} memory";
this.mnuViewInMemoryType.Click += new System.EventHandler(this.mnuViewInMemoryType_Click);
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(183, 6);
this.toolStripMenuItem3.Size = new System.Drawing.Size(227, 6);
//
// mnuAddBreakpoint
//
this.mnuAddBreakpoint.Image = global::Mesen.GUI.Properties.Resources.Breakpoint;
this.mnuAddBreakpoint.Name = "mnuAddBreakpoint";
this.mnuAddBreakpoint.Size = new System.Drawing.Size(186, 22);
this.mnuAddBreakpoint.Size = new System.Drawing.Size(230, 22);
this.mnuAddBreakpoint.Text = "Add breakpoint";
this.mnuAddBreakpoint.Click += new System.EventHandler(this.mnuAddBreakpoint_Click);
//
@ -129,7 +131,7 @@
//
this.mnuAddToWatch.Image = global::Mesen.GUI.Properties.Resources.Add;
this.mnuAddToWatch.Name = "mnuAddToWatch";
this.mnuAddToWatch.Size = new System.Drawing.Size(186, 22);
this.mnuAddToWatch.Size = new System.Drawing.Size(230, 22);
this.mnuAddToWatch.Text = "Add to watch";
this.mnuAddToWatch.Click += new System.EventHandler(this.mnuAddToWatch_Click);
//
@ -137,23 +139,31 @@
//
this.mnuFindOccurrences.Image = global::Mesen.GUI.Properties.Resources.Find;
this.mnuFindOccurrences.Name = "mnuFindOccurrences";
this.mnuFindOccurrences.Size = new System.Drawing.Size(186, 22);
this.mnuFindOccurrences.Size = new System.Drawing.Size(230, 22);
this.mnuFindOccurrences.Text = "Find Occurrences";
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(183, 6);
this.toolStripMenuItem2.Size = new System.Drawing.Size(227, 6);
//
// mnuShowComments
//
this.mnuShowComments.CheckOnClick = true;
this.mnuShowComments.Name = "mnuShowComments";
this.mnuShowComments.Size = new System.Drawing.Size(186, 22);
this.mnuShowComments.Size = new System.Drawing.Size(230, 22);
this.mnuShowComments.Text = "Show Comments";
this.mnuShowComments.Click += new System.EventHandler(this.mnuShowComments_Click);
//
// mnuShowJumpLabels
//
this.mnuShowJumpLabels.CheckOnClick = true;
this.mnuShowJumpLabels.Name = "mnuShowJumpLabels";
this.mnuShowJumpLabels.Size = new System.Drawing.Size(230, 22);
this.mnuShowJumpLabels.Text = "Show Automatic Jump Labels";
this.mnuShowJumpLabels.Click += new System.EventHandler(this.mnuShowJumpLabels_Click);
//
// lstLabels
//
this.lstLabels.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
@ -229,5 +239,6 @@
private System.Windows.Forms.ToolStripMenuItem mnuViewInCpuMemory;
private System.Windows.Forms.ToolStripMenuItem mnuViewInMemoryType;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
private System.Windows.Forms.ToolStripMenuItem mnuShowJumpLabels;
}
}

View file

@ -33,6 +33,7 @@ namespace Mesen.GUI.Debugger.Controls
base.OnLoad(e);
if(!IsDesignMode) {
mnuShowComments.Checked = ConfigManager.Config.DebugInfo.ShowCommentsInLabelList;
mnuShowJumpLabels.Checked = ConfigManager.Config.DebugInfo.ShowJumpLabels;
InitShortcuts();
}
}
@ -123,7 +124,7 @@ namespace Mesen.GUI.Debugger.Controls
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) {
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();
@ -216,8 +217,9 @@ namespace Mesen.GUI.Debugger.Controls
if(lstLabels.SelectedIndices.Count > 0) {
int topIndex = lstLabels.TopItem.Index;
int lastSelectedIndex = lstLabels.SelectedIndices[lstLabels.SelectedIndices.Count - 1];
for(int i = lstLabels.SelectedIndices.Count - 1; i >= 0; i--) {
CodeLabel label = (CodeLabel)_listItems[lstLabels.SelectedIndices[i]].SubItems[1].Tag;
List<int> selectedIndexes = new List<int>(lstLabels.SelectedIndices.Cast<int>().ToList());
for(int i = selectedIndexes.Count - 1; i >= 0; i--) {
CodeLabel label = (CodeLabel)_listItems[selectedIndexes[i]].SubItems[1].Tag;
LabelManager.DeleteLabel(label.Address, label.AddressType, i == 0);
}
@ -318,6 +320,13 @@ namespace Mesen.GUI.Debugger.Controls
ConfigManager.ApplyChanges();
this.UpdateLabelList();
}
private void mnuShowJumpLabels_Click(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.ShowJumpLabels = mnuShowJumpLabels.Checked;
ConfigManager.ApplyChanges();
this.UpdateLabelList();
}
private void lstLabels_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{

View file

@ -14,6 +14,7 @@ namespace Mesen.GUI.Debugger
public AddressType AddressType;
public string Label;
public string Comment;
public CodeLabelFlags Flags;
public override string ToString()
{
@ -80,7 +81,7 @@ namespace Mesen.GUI.Debugger
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);
SetLabel(label.Address, label.AddressType, label.Label, label.Comment, false, label.Flags);
}
if(raiseEvents) {
OnLabelUpdated?.Invoke(null, null);
@ -97,7 +98,7 @@ namespace Mesen.GUI.Debugger
return address.ToString() + addressType.ToString();
}
public static bool SetLabel(UInt32 address, AddressType type, string label, string comment, bool raiseEvent = true)
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
@ -110,7 +111,7 @@ namespace Mesen.GUI.Debugger
_reverseLookup.Remove(_labels[key].Label);
}
_labels[key] = new CodeLabel() { Address = address, AddressType = type, Label = label, Comment = comment };
_labels[key] = new CodeLabel() { Address = address, AddressType = type, Label = label, Comment = comment, Flags = flags };
if(label.Length > 0) {
_reverseLookup[label] = _labels[key];
}
@ -137,6 +138,20 @@ namespace Mesen.GUI.Debugger
}
}
public static void CreateAutomaticJumpLabels()
{
bool[] jumpTargets = InteropEmu.DebugGetJumpTargets();
List<CodeLabel> labelsToAdd = new List<CodeLabel>();
for(int i = 0; i < jumpTargets.Length; i++) {
if(jumpTargets[i] && LabelManager.GetLabel((uint)i, AddressType.PrgRom) == null) {
labelsToAdd.Add(new CodeLabel() { Flags = CodeLabelFlags.AutoJumpLabel, Address = (uint)i, AddressType = AddressType.PrgRom, Label = "L" + i.ToString("X4"), Comment = "" });
}
}
if(labelsToAdd.Count > 0) {
LabelManager.SetLabels(labelsToAdd, true);
}
}
private const int FdsMapperID = 65535;
private const int NsfMapperID = 65534;
@ -258,4 +273,11 @@ namespace Mesen.GUI.Debugger
}
}
}
[Flags]
public enum CodeLabelFlags
{
None = 0,
AutoJumpLabel = 1
}
}

View file

@ -208,6 +208,8 @@ namespace Mesen.GUI.Debugger
this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip();
this.mnuAutoCreateJumpLabels = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem25 = new System.Windows.Forms.ToolStripSeparator();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
@ -252,7 +254,7 @@ namespace Mesen.GUI.Debugger
this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel10);
this.splitContainer.Panel2MinSize = 100;
this.splitContainer.Size = new System.Drawing.Size(1075, 570);
this.splitContainer.SplitterDistance = 414;
this.splitContainer.SplitterDistance = 411;
this.splitContainer.SplitterWidth = 7;
this.splitContainer.TabIndex = 1;
this.splitContainer.TabStop = false;
@ -276,7 +278,7 @@ namespace Mesen.GUI.Debugger
//
this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists);
this.ctrlSplitContainerTop.Panel2MinSize = 150;
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1075, 414);
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1075, 411);
this.ctrlSplitContainerTop.SplitterDistance = 750;
this.ctrlSplitContainerTop.SplitterWidth = 7;
this.ctrlSplitContainerTop.TabIndex = 3;
@ -297,8 +299,8 @@ namespace Mesen.GUI.Debugger
this.tlpTop.Name = "tlpTop";
this.tlpTop.RowCount = 1;
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 414F));
this.tlpTop.Size = new System.Drawing.Size(750, 414);
this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 411F));
this.tlpTop.Size = new System.Drawing.Size(750, 411);
this.tlpTop.TabIndex = 2;
//
// panel1
@ -309,7 +311,7 @@ namespace Mesen.GUI.Debugger
this.panel1.Location = new System.Drawing.Point(3, 0);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(286, 414);
this.panel1.Size = new System.Drawing.Size(286, 411);
this.panel1.TabIndex = 5;
//
// ctrlSourceViewer
@ -318,7 +320,7 @@ namespace Mesen.GUI.Debugger
this.ctrlSourceViewer.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlSourceViewer.Location = new System.Drawing.Point(0, 0);
this.ctrlSourceViewer.Name = "ctrlSourceViewer";
this.ctrlSourceViewer.Size = new System.Drawing.Size(286, 414);
this.ctrlSourceViewer.Size = new System.Drawing.Size(286, 411);
this.ctrlSourceViewer.SymbolProvider = null;
this.ctrlSourceViewer.TabIndex = 7;
this.ctrlSourceViewer.Visible = false;
@ -331,7 +333,7 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCode.Location = new System.Drawing.Point(0, 0);
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
this.ctrlDebuggerCode.ShowMemoryValues = false;
this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 414);
this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 411);
this.ctrlDebuggerCode.SymbolProvider = null;
this.ctrlDebuggerCode.TabIndex = 2;
this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
@ -345,7 +347,7 @@ namespace Mesen.GUI.Debugger
this.panel2.Location = new System.Drawing.Point(292, 0);
this.panel2.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(1, 414);
this.panel2.Size = new System.Drawing.Size(1, 411);
this.panel2.TabIndex = 6;
//
// ctrlSourceViewerSplit
@ -354,7 +356,7 @@ namespace Mesen.GUI.Debugger
this.ctrlSourceViewerSplit.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlSourceViewerSplit.Location = new System.Drawing.Point(0, 0);
this.ctrlSourceViewerSplit.Name = "ctrlSourceViewerSplit";
this.ctrlSourceViewerSplit.Size = new System.Drawing.Size(1, 414);
this.ctrlSourceViewerSplit.Size = new System.Drawing.Size(1, 411);
this.ctrlSourceViewerSplit.SymbolProvider = null;
this.ctrlSourceViewerSplit.TabIndex = 8;
this.ctrlSourceViewerSplit.Visible = false;
@ -367,7 +369,7 @@ namespace Mesen.GUI.Debugger
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(0, 0);
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
this.ctrlDebuggerCodeSplit.ShowMemoryValues = false;
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 414);
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 411);
this.ctrlDebuggerCodeSplit.SymbolProvider = null;
this.ctrlDebuggerCodeSplit.TabIndex = 4;
this.ctrlDebuggerCodeSplit.Visible = false;
@ -387,7 +389,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 414);
this.tableLayoutPanel1.Size = new System.Drawing.Size(458, 411);
this.tableLayoutPanel1.TabIndex = 7;
//
// ctrlConsoleStatus
@ -411,7 +413,7 @@ namespace Mesen.GUI.Debugger
this.tlpVerticalLayout.Name = "tlpVerticalLayout";
this.tlpVerticalLayout.RowCount = 1;
this.tlpVerticalLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpVerticalLayout.Size = new System.Drawing.Size(458, 14);
this.tlpVerticalLayout.Size = new System.Drawing.Size(458, 11);
this.tlpVerticalLayout.TabIndex = 4;
//
// tlpFunctionLabelLists
@ -427,16 +429,16 @@ namespace Mesen.GUI.Debugger
this.tlpFunctionLabelLists.RowCount = 2;
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(318, 414);
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(318, 411);
this.tlpFunctionLabelLists.TabIndex = 5;
//
// grpLabels
//
this.grpLabels.Controls.Add(this.ctrlLabelList);
this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpLabels.Location = new System.Drawing.Point(3, 210);
this.grpLabels.Location = new System.Drawing.Point(3, 208);
this.grpLabels.Name = "grpLabels";
this.grpLabels.Size = new System.Drawing.Size(312, 201);
this.grpLabels.Size = new System.Drawing.Size(312, 200);
this.grpLabels.TabIndex = 6;
this.grpLabels.TabStop = false;
this.grpLabels.Text = "Labels";
@ -446,7 +448,7 @@ namespace Mesen.GUI.Debugger
this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlLabelList.Location = new System.Drawing.Point(3, 16);
this.ctrlLabelList.Name = "ctrlLabelList";
this.ctrlLabelList.Size = new System.Drawing.Size(306, 182);
this.ctrlLabelList.Size = new System.Drawing.Size(306, 181);
this.ctrlLabelList.TabIndex = 0;
this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence);
this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected);
@ -457,7 +459,7 @@ namespace Mesen.GUI.Debugger
this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpFunctions.Location = new System.Drawing.Point(3, 3);
this.grpFunctions.Name = "grpFunctions";
this.grpFunctions.Size = new System.Drawing.Size(312, 201);
this.grpFunctions.Size = new System.Drawing.Size(312, 199);
this.grpFunctions.TabIndex = 5;
this.grpFunctions.TabStop = false;
this.grpFunctions.Text = "Functions";
@ -467,7 +469,7 @@ namespace Mesen.GUI.Debugger
this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16);
this.ctrlFunctionList.Name = "ctrlFunctionList";
this.ctrlFunctionList.Size = new System.Drawing.Size(306, 182);
this.ctrlFunctionList.Size = new System.Drawing.Size(306, 180);
this.ctrlFunctionList.TabIndex = 0;
this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence);
this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected);
@ -498,7 +500,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel10.Size = new System.Drawing.Size(1075, 149);
this.tableLayoutPanel10.Size = new System.Drawing.Size(1075, 152);
this.tableLayoutPanel10.TabIndex = 0;
//
// grpWatch
@ -507,7 +509,7 @@ namespace Mesen.GUI.Debugger
this.grpWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpWatch.Location = new System.Drawing.Point(3, 3);
this.grpWatch.Name = "grpWatch";
this.grpWatch.Size = new System.Drawing.Size(352, 143);
this.grpWatch.Size = new System.Drawing.Size(352, 146);
this.grpWatch.TabIndex = 2;
this.grpWatch.TabStop = false;
this.grpWatch.Text = "Watch";
@ -517,7 +519,7 @@ namespace Mesen.GUI.Debugger
this.ctrlWatch.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlWatch.Location = new System.Drawing.Point(3, 16);
this.ctrlWatch.Name = "ctrlWatch";
this.ctrlWatch.Size = new System.Drawing.Size(346, 124);
this.ctrlWatch.Size = new System.Drawing.Size(346, 127);
this.ctrlWatch.TabIndex = 0;
//
// grpBreakpoints
@ -526,7 +528,7 @@ namespace Mesen.GUI.Debugger
this.grpBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpBreakpoints.Location = new System.Drawing.Point(361, 3);
this.grpBreakpoints.Name = "grpBreakpoints";
this.grpBreakpoints.Size = new System.Drawing.Size(352, 143);
this.grpBreakpoints.Size = new System.Drawing.Size(352, 146);
this.grpBreakpoints.TabIndex = 3;
this.grpBreakpoints.TabStop = false;
this.grpBreakpoints.Text = "Breakpoints";
@ -536,7 +538,7 @@ namespace Mesen.GUI.Debugger
this.ctrlBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlBreakpoints.Location = new System.Drawing.Point(3, 16);
this.ctrlBreakpoints.Name = "ctrlBreakpoints";
this.ctrlBreakpoints.Size = new System.Drawing.Size(346, 124);
this.ctrlBreakpoints.Size = new System.Drawing.Size(346, 127);
this.ctrlBreakpoints.TabIndex = 0;
this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation);
//
@ -546,7 +548,7 @@ namespace Mesen.GUI.Debugger
this.grpCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpCallstack.Location = new System.Drawing.Point(719, 3);
this.grpCallstack.Name = "grpCallstack";
this.grpCallstack.Size = new System.Drawing.Size(353, 143);
this.grpCallstack.Size = new System.Drawing.Size(353, 146);
this.grpCallstack.TabIndex = 4;
this.grpCallstack.TabStop = false;
this.grpCallstack.Text = "Call Stack";
@ -556,7 +558,7 @@ namespace Mesen.GUI.Debugger
this.ctrlCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlCallstack.Location = new System.Drawing.Point(3, 16);
this.ctrlCallstack.Name = "ctrlCallstack";
this.ctrlCallstack.Size = new System.Drawing.Size(347, 124);
this.ctrlCallstack.Size = new System.Drawing.Size(347, 127);
this.ctrlCallstack.TabIndex = 0;
this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected);
//
@ -1028,6 +1030,8 @@ namespace Mesen.GUI.Debugger
this.mnuSplitView,
this.mnuUseVerticalLayout,
this.toolStripMenuItem11,
this.mnuAutoCreateJumpLabels,
this.toolStripMenuItem25,
this.mnuHidePauseIcon,
this.mnuPpuPartialDraw,
this.mnuPpuShowPreviousFrame,
@ -1844,6 +1848,19 @@ namespace Mesen.GUI.Debugger
this.tsToolbar.Text = "toolStrip1";
this.tsToolbar.Visible = false;
//
// mnuAutoCreateJumpLabels
//
this.mnuAutoCreateJumpLabels.CheckOnClick = true;
this.mnuAutoCreateJumpLabels.Name = "mnuAutoCreateJumpLabels";
this.mnuAutoCreateJumpLabels.Size = new System.Drawing.Size(266, 22);
this.mnuAutoCreateJumpLabels.Text = "Auto-create jump labels";
this.mnuAutoCreateJumpLabels.Click += new System.EventHandler(this.mnuAutoCreateJumpLabels_Click);
//
// toolStripMenuItem25
//
this.toolStripMenuItem25.Name = "toolStripMenuItem25";
this.toolStripMenuItem25.Size = new System.Drawing.Size(263, 6);
//
// frmDebugger
//
this.AllowDrop = true;
@ -2072,5 +2089,7 @@ namespace Mesen.GUI.Debugger
private System.Windows.Forms.ToolStripMenuItem mnuBreakOnInit;
private System.Windows.Forms.ToolStripMenuItem mnuBreakOnPlay;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem26;
private System.Windows.Forms.ToolStripMenuItem mnuAutoCreateJumpLabels;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem25;
}
}

View file

@ -80,6 +80,7 @@ namespace Mesen.GUI.Debugger
}));
});
}
this.mnuAutoCreateJumpLabels.Checked = ConfigManager.Config.DebugInfo.AutoCreateJumpLabels;
this.mnuCopyAddresses.Checked = ConfigManager.Config.DebugInfo.CopyAddresses;
this.mnuCopyByteCode.Checked = ConfigManager.Config.DebugInfo.CopyByteCode;
this.mnuCopyComments.Checked = ConfigManager.Config.DebugInfo.CopyComments;
@ -583,6 +584,10 @@ namespace Mesen.GUI.Debugger
return;
}
if(ConfigManager.Config.DebugInfo.AutoCreateJumpLabels) {
LabelManager.CreateAutomaticJumpLabels();
}
ctrlBreakpoints.RefreshListAddresses();
ctrlLabelList.UpdateLabelListAddresses();
ctrlFunctionList.UpdateFunctionList(false);
@ -1026,6 +1031,12 @@ namespace Mesen.GUI.Debugger
{
DebugWindowManager.OpenDebugWindow(DebugWindow.TraceLogger);
}
private void mnuAutoCreateJumpLabels_Click(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.AutoCreateJumpLabels = mnuAutoCreateJumpLabels.Checked;
ConfigManager.ApplyChanges();
}
private void mnuCopyAddresses_Click(object sender, EventArgs e)
{

View file

@ -365,6 +365,21 @@ namespace Mesen.GUI
return assembledCode;
}
[DllImport(DLLPath, EntryPoint = "DebugGetJumpTargets")] private static extern void DebugGetJumpTargetsWrapper(IntPtr isJumpTargets);
public static bool[] DebugGetJumpTargets()
{
bool[] isJumpTarget = new bool[InteropEmu.DebugGetMemorySize(DebugMemoryType.PrgRom)];
GCHandle hJumpTarget = GCHandle.Alloc(isJumpTarget, GCHandleType.Pinned);
try {
InteropEmu.DebugGetJumpTargetsWrapper(hJumpTarget.AddrOfPinnedObject());
} finally {
hJumpTarget.Free();
}
return isJumpTarget;
}
[DllImport(DLLPath, EntryPoint = "DebugGetMemoryState")] private static extern UInt32 DebugGetMemoryStateWrapper(DebugMemoryType type, IntPtr buffer);
public static byte[] DebugGetMemoryState(DebugMemoryType type)
{

View file

@ -65,6 +65,8 @@ extern "C"
DllExport void __stdcall DebugPpuStep(uint32_t count) { GetDebugger()->PpuStep(count); }
DllExport void __stdcall DebugBreakOnScanline(int32_t scanline) { GetDebugger()->BreakOnScanline(scanline); }
DllExport const char* __stdcall DebugGetCode(uint32_t &length) { return GetDebugger()->GetCode(length); }
DllExport void __stdcall DebugGetJumpTargets(bool* isJumpTarget) { GetDebugger()->GetJumpTargets(isJumpTarget); }
DllExport void __stdcall DebugSetPpuViewerScanlineCycle(int32_t ppuViewerId, int32_t scanline, int32_t cycle) { return GetDebugger()->SetPpuViewerScanlineCycle(ppuViewerId, scanline, cycle); }
DllExport void __stdcall DebugClearPpuViewerSettings(int32_t ppuViewerId) { return GetDebugger()->ClearPpuViewerSettings(ppuViewerId); }