Debugger: Added option to view the result of the addressing logic for indirect/absolute addressing modes

This commit is contained in:
Souryo 2016-11-19 19:21:28 -05:00
parent d38c7bd735
commit ebd5fd318c
15 changed files with 237 additions and 108 deletions

View file

@ -435,10 +435,12 @@ bool Debugger::IsCodeChanged()
string Debugger::GenerateOutput()
{
State cpuState = _cpu->GetState();
std::ostringstream output;
bool showEffectiveAddresses = CheckFlag(DebuggerFlags::ShowEffectiveAddresses);
//Get code in internal RAM
output << _disassembler->GetCode(0x0000, 0x1FFF, 0x0000, PrgMemoryType::PrgRom);
output << _disassembler->GetCode(0x0000, 0x1FFF, 0x0000, PrgMemoryType::PrgRom, showEffectiveAddresses, cpuState, _memoryManager);
output << "2000:::--END OF INTERNAL RAM--\n";
for(uint32_t i = 0x2000; i < 0x10000; i += 0x100) {
@ -456,7 +458,7 @@ string Debugger::GenerateOutput()
romAddr += 0x100;
i+=0x100;
}
output << _disassembler->GetCode(startAddr, endAddr, startMemoryAddr, PrgMemoryType::PrgRom);
output << _disassembler->GetCode(startAddr, endAddr, startMemoryAddr, PrgMemoryType::PrgRom, showEffectiveAddresses, cpuState, _memoryManager);
} else if(ramAddr >= 0) {
startAddr = ramAddr;
endAddr = startAddr + 0xFF;
@ -465,7 +467,7 @@ string Debugger::GenerateOutput()
ramAddr += 0x100;
i += 0x100;
}
output << _disassembler->GetCode(startAddr, endAddr, startMemoryAddr, PrgMemoryType::WorkRam);
output << _disassembler->GetCode(startAddr, endAddr, startMemoryAddr, PrgMemoryType::WorkRam, showEffectiveAddresses, cpuState, _memoryManager);
}
}
@ -504,7 +506,7 @@ void Debugger::SetNextStatement(uint16_t addr)
void Debugger::StartTraceLogger(TraceLoggerOptions options)
{
string traceFilepath = FolderUtilities::CombinePath(FolderUtilities::GetDebuggerFolder(), "Trace - " + FolderUtilities::GetFilename(_romName, false) + ".log");
_traceLogger.reset(new TraceLogger(traceFilepath, options));
_traceLogger.reset(new TraceLogger(traceFilepath, _memoryManager, options));
}
void Debugger::StopTraceLogger()

View file

@ -21,7 +21,8 @@ class Disassembler;
enum class DebuggerFlags
{
PpuPartialDraw = 1
PpuPartialDraw = 1,
ShowEffectiveAddresses = 2,
};
class Debugger

View file

@ -2,6 +2,8 @@
#include "Disassembler.h"
#include "DisassemblyInfo.h"
#include "BaseMapper.h"
#include "MemoryManager.h"
#include "CPU.h"
Disassembler::Disassembler(uint8_t* internalRam, uint8_t* prgRom, uint32_t prgSize, uint8_t* prgRam, uint32_t prgRamSize)
{
@ -172,7 +174,7 @@ void Disassembler::InvalidateCache(uint16_t memoryAddr, int32_t absoluteRamAddr)
}
}
string Disassembler::GetCode(uint32_t startAddr, uint32_t endAddr, uint16_t memoryAddr, PrgMemoryType memoryType)
string Disassembler::GetCode(uint32_t startAddr, uint32_t endAddr, uint16_t memoryAddr, PrgMemoryType memoryType, bool showEffectiveAddresses, State& cpuState, shared_ptr<MemoryManager> memoryManager)
{
std::ostringstream output;
vector<shared_ptr<DisassemblyInfo>> *cache;
@ -199,7 +201,8 @@ string Disassembler::GetCode(uint32_t startAddr, uint32_t endAddr, uint16_t memo
output << "\n";
byteCount = 0;
}
output << std::hex << std::uppercase << memoryAddr << ":" << addr << ":" << info->ToString(memoryAddr) << "\n";
string effectiveAddress = showEffectiveAddresses ? info->GetEffectiveAddress(cpuState, memoryManager) : "";
output << std::hex << std::uppercase << memoryAddr << ":" << addr << ":" << info->ToString(memoryAddr) << "||" << effectiveAddress << "\n";
addr += info->GetSize();
memoryAddr += info->GetSize();
} else {

View file

@ -2,6 +2,8 @@
#include "stdafx.h"
#include "BaseMapper.h"
struct State;
class MemoryManager;
class DisassemblyInfo;
class Disassembler
@ -24,7 +26,7 @@ public:
uint32_t BuildCache(int32_t absoluteAddr, int32_t absoluteRamAddr, uint16_t memoryAddr, bool isSubEntryPoint);
void InvalidateCache(uint16_t memoryAddr, int32_t absoluteRamAddr);
string GetCode(uint32_t startAddr, uint32_t endAddr, uint16_t memoryAddr, PrgMemoryType memoryType);
string GetCode(uint32_t startAddr, uint32_t endAddr, uint16_t memoryAddr, PrgMemoryType memoryType, bool showEffectiveAddresses, State& cpuState, shared_ptr<MemoryManager> memoryManager);
shared_ptr<DisassemblyInfo> GetDisassemblyInfo(int32_t absoluteAddress, int32_t absoluteRamAddress, uint16_t memoryAddress);
};

View file

@ -125,6 +125,55 @@ void DisassemblyInfo::SetSubEntryPoint()
Initialize();
}
}
string DisassemblyInfo::GetEffectiveAddress(State& cpuState, shared_ptr<MemoryManager> memoryManager)
{
std::stringstream ss;
ss << std::uppercase << std::setfill('0');
switch(_opMode) {
case AddrMode::ZeroX: ss << " @ $" << std::setw(2) << std::hex << (short)(uint8_t)(*(_opPointer + 1) + cpuState.X); break;
case AddrMode::ZeroY: ss << " @ $" << std::setw(2) << std::hex << (short)(uint8_t)(*(_opPointer + 1) + cpuState.Y); break;
case AddrMode::IndX: {
uint8_t zeroAddr = *(_opPointer + 1) + cpuState.X;
uint16_t addr = memoryManager->DebugRead(zeroAddr) | memoryManager->DebugRead((uint8_t)(zeroAddr + 1)) << 8;
ss << " @ $" << std::setw(4) << std::hex << addr;
break;
}
case AddrMode::IndY:
case AddrMode::IndYW: {
uint8_t zeroAddr = *(_opPointer + 1);
uint16_t addr = memoryManager->DebugRead(zeroAddr) | memoryManager->DebugRead((uint8_t)(zeroAddr + 1)) << 8;
addr += cpuState.Y;
ss << " @ $" << std::setw(4) << std::hex << addr;
break;
}
case AddrMode::Ind: {
uint8_t zeroAddr = *(_opPointer + 1);
uint16_t addr = memoryManager->DebugRead(zeroAddr) | memoryManager->DebugRead((uint8_t)(zeroAddr + 1)) << 8;
ss << " @ $" << std::setw(4) << std::hex << addr;
break;
}
case AddrMode::AbsX:
case AddrMode::AbsXW: {
uint16_t addr = (*(_opPointer + 1) | (*(_opPointer + 2) << 8)) + cpuState.X;
ss << " @ $" << std::setw(4) << std::hex << addr;
break;
}
case AddrMode::AbsY:
case AddrMode::AbsYW: {
uint16_t addr = (*(_opPointer + 1) | (*(_opPointer + 2) << 8)) + cpuState.Y;
ss << " @ $" << std::setfill('0') << std::setw(4) << std::hex << addr;
break;
}
}
return ss.str();
}
string DisassemblyInfo::ToString(uint32_t memoryAddr)
{

View file

@ -24,6 +24,7 @@ public:
DisassemblyInfo(uint8_t* opPointer, bool isSubEntryPoint);
void SetSubEntryPoint();
string GetEffectiveAddress(State& cpuState, shared_ptr<MemoryManager> memoryManager);
string ToString(uint32_t memoryAddr);
uint32_t GetSize();
};

View file

@ -3,11 +3,13 @@
#include "DisassemblyInfo.h"
#include "DebugState.h"
#include "Console.h"
#include "MemoryManager.h"
TraceLogger *TraceLogger::_instance = nullptr;
TraceLogger::TraceLogger(string outputFilepath, TraceLoggerOptions options)
TraceLogger::TraceLogger(string outputFilepath, shared_ptr<MemoryManager> memoryManager, TraceLoggerOptions options)
{
_memoryManager = memoryManager;
_outputFile.open(outputFilepath, ios::out | ios::binary);
_options = options;
_firstLine = true;
@ -73,7 +75,8 @@ void TraceLogger::Log(DebugState &state, shared_ptr<DisassemblyInfo> disassembly
_outputFile << std::string(indentLevel, ' ');
}
_outputFile << std::setfill(' ') << std::setw(32 - indentLevel) << std::left << assemblyCode;
string codeString = assemblyCode + (_options.ShowEffectiveAddresses ? disassemblyInfo->GetEffectiveAddress(state.CPU, _memoryManager) : "");
_outputFile << std::setfill(' ') << std::setw(32 - indentLevel) << std::left << codeString;
if(_options.ShowRegisters) {
_outputFile << std::setfill('0')
@ -101,7 +104,7 @@ void TraceLogger::Log(DebugState &state, shared_ptr<DisassemblyInfo> disassembly
if(_options.ShowCpuCycles) {
_outputFile << " CPU Cycle:" << cpuState.CycleCount;
}
_firstLine = false;
}
}

View file

@ -2,6 +2,7 @@
#include "stdafx.h"
class DisassemblyInfo;
class MemoryManager;
struct DebugState;
struct TraceLoggerOptions
@ -14,6 +15,7 @@ struct TraceLoggerOptions
bool ShowPpuFrames;
bool ShowExtraInfo;
bool IndentCode;
bool ShowEffectiveAddresses;
};
class TraceLogger
@ -24,9 +26,10 @@ private:
string _outputFilepath;
ofstream _outputFile;
bool _firstLine;
shared_ptr<MemoryManager> _memoryManager;
public:
TraceLogger(string outputFilepath, TraceLoggerOptions options);
TraceLogger(string outputFilepath, shared_ptr<MemoryManager> memoryManager, TraceLoggerOptions options);
~TraceLogger();
void Log(DebugState &state, shared_ptr<DisassemblyInfo> disassemblyInfo);

View file

@ -28,6 +28,8 @@ namespace Mesen.GUI.Config
public bool PpuAutoRefresh = true;
public bool PpuPartialDraw = false;
public bool ShowEffectiveAddresses = true;
public bool ShowCpuMemoryMapping = true;
public bool ShowPpuMemoryMapping = true;

View file

@ -338,7 +338,7 @@ namespace Mesen.GUI.Debugger
int lineIndex;
if(this.GetCharIndex(position, out charIndex, out lineIndex)) {
string text = (useCompareText && _compareContents != null) ? _compareContents[lineIndex] : _contents[lineIndex];
List<char> wordDelimiters = new List<char>(new char[] { ' ', ',' });
List<char> wordDelimiters = new List<char>(new char[] { ' ', ',', '|', ';', '(', ')' });
if(wordDelimiters.Contains(text[charIndex])) {
return string.Empty;
} else {
@ -444,6 +444,14 @@ namespace Mesen.GUI.Debugger
private void DrawLine(Graphics g, int currentLine, int marginLeft, int positionY)
{
string[] lineContent = _contents[currentLine].Split(new string[] { "||" }, StringSplitOptions.None);
string codeString = lineContent.Length > 0 ? lineContent[0] : "";
string addressString = lineContent.Length > 1 ? lineContent[1] : "";
string commentString = lineContent.Length > 2 ? lineContent[2] : "";
float codeStringLength = g.MeasureString(codeString, this.Font).Width;
float addressStringLength = g.MeasureString(addressString, this.Font).Width;
if(this.ShowLineNumbers) {
//Show line number
string lineNumber = _lineNumbers[currentLine] >= 0 ? _lineNumbers[currentLine].ToString(_showLineInHex ? "X4" : "") : "..";
@ -466,16 +474,14 @@ namespace Mesen.GUI.Debugger
LineProperties lineProperties = _lineProperties[currentLine];
textColor = lineProperties.FgColor ?? Color.Black;
float stringLength = g.MeasureString(_contents[currentLine], this.Font).Width;
if(lineProperties.BgColor.HasValue) {
using(Brush bgBrush = new SolidBrush(lineProperties.BgColor.Value)) {
g.FillRectangle(bgBrush, marginLeft + 1, positionY + 1, stringLength, this.LineHeight-1);
g.FillRectangle(bgBrush, marginLeft + 1, positionY + 1, codeStringLength, this.LineHeight-1);
}
}
if(lineProperties.OutlineColor.HasValue) {
using(Pen outlinePen = new Pen(lineProperties.OutlineColor.Value, 1)) {
g.DrawRectangle(outlinePen, marginLeft + 1, positionY + 1, stringLength, this.LineHeight-1);
g.DrawRectangle(outlinePen, marginLeft + 1, positionY + 1, codeStringLength, this.LineHeight-1);
}
}
@ -508,14 +514,21 @@ namespace Mesen.GUI.Debugger
}
}
string lineText = _contents[currentLine];
using(Brush fgBrush = new SolidBrush(textColor)) {
g.DrawString(lineText, this.Font, fgBrush, marginLeft, positionY);
g.DrawString(codeString, this.Font, fgBrush, marginLeft, positionY);
using(Brush addressBrush = new SolidBrush(Color.SteelBlue)) {
g.DrawString(addressString, this.Font, addressBrush, marginLeft + codeStringLength, positionY);
}
using(Brush commentBrush = new SolidBrush(Color.DarkGreen)) {
g.DrawString(commentString, this.Font, commentBrush, Math.Max(marginLeft + 220, marginLeft + codeStringLength + addressStringLength), positionY);
}
if(this.ShowContentNotes) {
g.DrawString(_contentNotes[currentLine], _noteFont, Brushes.Gray, marginLeft, positionY + this.Font.Size+3);
}
this.DrawHighlightedSearchString(g, lineText, marginLeft, positionY);
this.DrawHighlightedCompareString(g, lineText, currentLine, marginLeft, positionY);
this.DrawHighlightedSearchString(g, codeString, marginLeft, positionY);
this.DrawHighlightedCompareString(g, codeString, currentLine, marginLeft, positionY);
}
}

View file

@ -38,11 +38,17 @@
this.tmrCdlRatios = new System.Windows.Forms.Timer(this.components);
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.tlpTop = new System.Windows.Forms.TableLayoutPanel();
this.ctrlDebuggerCode = new Mesen.GUI.Debugger.ctrlDebuggerCode();
this.ctrlConsoleStatus = new Mesen.GUI.Debugger.ctrlConsoleStatus();
this.ctrlDebuggerCodeSplit = new Mesen.GUI.Debugger.ctrlDebuggerCode();
this.tableLayoutPanel10 = new System.Windows.Forms.TableLayoutPanel();
this.grpWatch = new System.Windows.Forms.GroupBox();
this.picWatchHelp = new System.Windows.Forms.PictureBox();
this.ctrlWatch = new Mesen.GUI.Debugger.ctrlWatch();
this.grpBreakpoints = new System.Windows.Forms.GroupBox();
this.ctrlBreakpoints = new Mesen.GUI.Debugger.Controls.ctrlBreakpoints();
this.grpCallstack = new System.Windows.Forms.GroupBox();
this.ctrlCallstack = new Mesen.GUI.Debugger.Controls.ctrlCallstack();
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
@ -80,6 +86,7 @@
this.mnuShowPpuMemoryMapping = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
this.mnuPpuPartialDraw = new System.Windows.Forms.ToolStripMenuItem();
this.mnuShowEffectiveAddresses = new System.Windows.Forms.ToolStripMenuItem();
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mnuPpuViewer = new System.Windows.Forms.ToolStripMenuItem();
this.mnuMemoryViewer = new System.Windows.Forms.ToolStripMenuItem();
@ -98,12 +105,6 @@
this.lblPrgAnalysisResult = new System.Windows.Forms.ToolStripStatusLabel();
this.lblChrAnalysis = new System.Windows.Forms.ToolStripStatusLabel();
this.lblChrAnalysisResult = new System.Windows.Forms.ToolStripStatusLabel();
this.ctrlDebuggerCode = new Mesen.GUI.Debugger.ctrlDebuggerCode();
this.ctrlConsoleStatus = new Mesen.GUI.Debugger.ctrlConsoleStatus();
this.ctrlDebuggerCodeSplit = new Mesen.GUI.Debugger.ctrlDebuggerCode();
this.ctrlWatch = new Mesen.GUI.Debugger.ctrlWatch();
this.ctrlBreakpoints = new Mesen.GUI.Debugger.Controls.ctrlBreakpoints();
this.ctrlCallstack = new Mesen.GUI.Debugger.Controls.ctrlCallstack();
this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
this.contextMenuCode.SuspendLayout();
@ -188,6 +189,41 @@
this.tlpTop.Size = new System.Drawing.Size(984, 387);
this.tlpTop.TabIndex = 2;
//
// ctrlDebuggerCode
//
this.ctrlDebuggerCode.Code = null;
this.ctrlDebuggerCode.ContextMenuStrip = this.contextMenuCode;
this.ctrlDebuggerCode.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlDebuggerCode.Location = new System.Drawing.Point(3, 3);
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
this.ctrlDebuggerCode.Size = new System.Drawing.Size(546, 381);
this.ctrlDebuggerCode.TabIndex = 2;
this.ctrlDebuggerCode.OnWatchAdded += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnWatchAdded);
this.ctrlDebuggerCode.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
this.ctrlDebuggerCode.Enter += new System.EventHandler(this.ctrlDebuggerCode_Enter);
//
// ctrlConsoleStatus
//
this.ctrlConsoleStatus.Dock = System.Windows.Forms.DockStyle.Top;
this.ctrlConsoleStatus.Location = new System.Drawing.Point(552, 0);
this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0);
this.ctrlConsoleStatus.Name = "ctrlConsoleStatus";
this.ctrlConsoleStatus.Size = new System.Drawing.Size(432, 362);
this.ctrlConsoleStatus.TabIndex = 3;
//
// ctrlDebuggerCodeSplit
//
this.ctrlDebuggerCodeSplit.Code = null;
this.ctrlDebuggerCodeSplit.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(555, 3);
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 381);
this.ctrlDebuggerCodeSplit.TabIndex = 4;
this.ctrlDebuggerCodeSplit.Visible = false;
this.ctrlDebuggerCodeSplit.OnWatchAdded += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnWatchAdded);
this.ctrlDebuggerCodeSplit.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
this.ctrlDebuggerCodeSplit.Enter += new System.EventHandler(this.ctrlDebuggerCodeSplit_Enter);
//
// tableLayoutPanel10
//
this.tableLayoutPanel10.ColumnCount = 3;
@ -229,6 +265,14 @@
this.picWatchHelp.TabIndex = 1;
this.picWatchHelp.TabStop = false;
//
// ctrlWatch
//
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(315, 118);
this.ctrlWatch.TabIndex = 0;
//
// grpBreakpoints
//
this.grpBreakpoints.Controls.Add(this.ctrlBreakpoints);
@ -240,6 +284,15 @@
this.grpBreakpoints.TabStop = false;
this.grpBreakpoints.Text = "Breakpoints";
//
// ctrlBreakpoints
//
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(316, 118);
this.ctrlBreakpoints.TabIndex = 0;
this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation);
//
// grpCallstack
//
this.grpCallstack.Controls.Add(this.ctrlCallstack);
@ -251,6 +304,15 @@
this.grpCallstack.TabStop = false;
this.grpCallstack.Text = "Callstack";
//
// ctrlCallstack
//
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(317, 118);
this.ctrlCallstack.TabIndex = 0;
this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected);
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -481,7 +543,8 @@
this.mnuShowCpuMemoryMapping,
this.mnuShowPpuMemoryMapping,
this.toolStripMenuItem6,
this.mnuPpuPartialDraw});
this.mnuPpuPartialDraw,
this.mnuShowEffectiveAddresses});
this.mnuOptions.Name = "mnuOptions";
this.mnuOptions.Size = new System.Drawing.Size(61, 20);
this.mnuOptions.Text = "Options";
@ -562,9 +625,17 @@
this.mnuPpuPartialDraw.CheckOnClick = true;
this.mnuPpuPartialDraw.Name = "mnuPpuPartialDraw";
this.mnuPpuPartialDraw.Size = new System.Drawing.Size(228, 22);
this.mnuPpuPartialDraw.Text = "Draw partial frame";
this.mnuPpuPartialDraw.Text = "Draw Partial Frame";
this.mnuPpuPartialDraw.Click += new System.EventHandler(this.mnuPpuPartialDraw_Click);
//
// mnuShowEffectiveAddresses
//
this.mnuShowEffectiveAddresses.CheckOnClick = true;
this.mnuShowEffectiveAddresses.Name = "mnuShowEffectiveAddresses";
this.mnuShowEffectiveAddresses.Size = new System.Drawing.Size(228, 22);
this.mnuShowEffectiveAddresses.Text = "Show Effective Addresses";
this.mnuShowEffectiveAddresses.Click += new System.EventHandler(this.mnuShowEffectiveAddresses_Click);
//
// toolsToolStripMenuItem
//
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -707,67 +778,6 @@
this.lblChrAnalysisResult.Size = new System.Drawing.Size(239, 19);
this.lblChrAnalysisResult.Text = "xx% (Drawn: xx%, Read: xx%, Unknown: xx%)";
//
// ctrlDebuggerCode
//
this.ctrlDebuggerCode.Code = null;
this.ctrlDebuggerCode.ContextMenuStrip = this.contextMenuCode;
this.ctrlDebuggerCode.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlDebuggerCode.Location = new System.Drawing.Point(3, 3);
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
this.ctrlDebuggerCode.Size = new System.Drawing.Size(546, 381);
this.ctrlDebuggerCode.TabIndex = 2;
this.ctrlDebuggerCode.OnWatchAdded += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnWatchAdded);
this.ctrlDebuggerCode.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
this.ctrlDebuggerCode.Enter += new System.EventHandler(this.ctrlDebuggerCode_Enter);
//
// ctrlConsoleStatus
//
this.ctrlConsoleStatus.Dock = System.Windows.Forms.DockStyle.Top;
this.ctrlConsoleStatus.Location = new System.Drawing.Point(552, 0);
this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0);
this.ctrlConsoleStatus.Name = "ctrlConsoleStatus";
this.ctrlConsoleStatus.Size = new System.Drawing.Size(432, 362);
this.ctrlConsoleStatus.TabIndex = 3;
//
// ctrlDebuggerCodeSplit
//
this.ctrlDebuggerCodeSplit.Code = null;
this.ctrlDebuggerCodeSplit.Dock = System.Windows.Forms.DockStyle.Fill;
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(555, 3);
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 381);
this.ctrlDebuggerCodeSplit.TabIndex = 4;
this.ctrlDebuggerCodeSplit.Visible = false;
this.ctrlDebuggerCodeSplit.OnWatchAdded += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnWatchAdded);
this.ctrlDebuggerCodeSplit.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
this.ctrlDebuggerCodeSplit.Enter += new System.EventHandler(this.ctrlDebuggerCodeSplit_Enter);
//
// ctrlWatch
//
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(315, 118);
this.ctrlWatch.TabIndex = 0;
//
// ctrlBreakpoints
//
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(316, 118);
this.ctrlBreakpoints.TabIndex = 0;
this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation);
//
// ctrlCallstack
//
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(317, 118);
this.ctrlCallstack.TabIndex = 0;
this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected);
//
// ctrlPpuMemoryMapping
//
this.ctrlPpuMemoryMapping.Dock = System.Windows.Forms.DockStyle.Bottom;
@ -900,5 +910,6 @@
private System.Windows.Forms.ToolStripMenuItem mnuShowCpuMemoryMapping;
private System.Windows.Forms.ToolStripMenuItem mnuShowPpuMemoryMapping;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem6;
private System.Windows.Forms.ToolStripMenuItem mnuShowEffectiveAddresses;
}
}

View file

@ -32,6 +32,7 @@ namespace Mesen.GUI.Debugger
this.mnuSplitView.Checked = ConfigManager.Config.DebugInfo.SplitView;
this.mnuPpuPartialDraw.Checked = ConfigManager.Config.DebugInfo.PpuPartialDraw;
this.mnuShowEffectiveAddresses.Checked = ConfigManager.Config.DebugInfo.ShowEffectiveAddresses;
this.mnuShowCpuMemoryMapping.Checked = ConfigManager.Config.DebugInfo.ShowCpuMemoryMapping;
this.mnuShowPpuMemoryMapping.Checked = ConfigManager.Config.DebugInfo.ShowPpuMemoryMapping;
@ -87,13 +88,21 @@ namespace Mesen.GUI.Debugger
}
}
private void UpdateDebuggerFlags()
{
DebuggerFlags flags = mnuPpuPartialDraw.Checked ? DebuggerFlags.PpuPartialDraw : DebuggerFlags.None;
if(mnuShowEffectiveAddresses.Checked) {
flags |= DebuggerFlags.ShowEffectiveAddresses;
}
InteropEmu.DebugSetFlags(flags);
}
private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e)
{
switch(e.NotificationType) {
case InteropEmu.ConsoleNotificationType.CodeBreak:
this.BeginInvoke((MethodInvoker)(() => UpdateDebugger()));
BreakpointManager.SetBreakpoints();
InteropEmu.DebugSetFlags(mnuPpuPartialDraw.Checked ? DebuggerFlags.PpuPartialDraw : DebuggerFlags.None);
break;
case InteropEmu.ConsoleNotificationType.GameReset:
@ -122,6 +131,8 @@ namespace Mesen.GUI.Debugger
private void UpdateDebugger()
{
UpdateDebuggerFlags();
if(InteropEmu.DebugIsCodeChanged()) {
string code = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(InteropEmu.DebugGetCode());
ctrlDebuggerCode.Code = code;
@ -410,6 +421,13 @@ namespace Mesen.GUI.Debugger
ConfigManager.Config.DebugInfo.PpuPartialDraw = mnuPpuPartialDraw.Checked;
ConfigManager.ApplyChanges();
}
private void mnuShowEffectiveAddresses_Click(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.ShowEffectiveAddresses = mnuShowEffectiveAddresses.Checked;
ConfigManager.ApplyChanges();
UpdateDebugger();
}
private void mnuShowCpuMemoryMapping_CheckedChanged(object sender, EventArgs e)
{

View file

@ -41,6 +41,7 @@
this.chkShowExtraInfo = new System.Windows.Forms.CheckBox();
this.chkShowByteCode = new System.Windows.Forms.CheckBox();
this.chkIndentCode = new System.Windows.Forms.CheckBox();
this.chkShowEffectiveAddresses = new System.Windows.Forms.CheckBox();
this.tableLayoutPanel1.SuspendLayout();
this.grpLogOptions.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
@ -65,7 +66,7 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(339, 150);
this.tableLayoutPanel1.Size = new System.Drawing.Size(339, 193);
this.tableLayoutPanel1.TabIndex = 0;
//
// btnOpenTrace
@ -109,7 +110,7 @@
this.grpLogOptions.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpLogOptions.Location = new System.Drawing.Point(3, 32);
this.grpLogOptions.Name = "grpLogOptions";
this.grpLogOptions.Size = new System.Drawing.Size(333, 90);
this.grpLogOptions.Size = new System.Drawing.Size(333, 132);
this.grpLogOptions.TabIndex = 3;
this.grpLogOptions.TabStop = false;
this.grpLogOptions.Text = "Log Contents";
@ -118,24 +119,27 @@
//
this.tableLayoutPanel2.ColumnCount = 3;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.tableLayoutPanel2.Controls.Add(this.chkShowEffectiveAddresses, 0, 3);
this.tableLayoutPanel2.Controls.Add(this.chkShowCpuCycles, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.chkShowPpuCycles, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.chkShowRegisters, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.chkShowPpuScanline, 1, 1);
this.tableLayoutPanel2.Controls.Add(this.chkShowFrameCount, 2, 1);
this.tableLayoutPanel2.Controls.Add(this.chkShowExtraInfo, 0, 2);
this.tableLayoutPanel2.Controls.Add(this.chkShowByteCode, 2, 2);
this.tableLayoutPanel2.Controls.Add(this.chkShowExtraInfo, 0, 4);
this.tableLayoutPanel2.Controls.Add(this.chkShowByteCode, 0, 2);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 16);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 4;
this.tableLayoutPanel2.RowCount = 6;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(327, 71);
this.tableLayoutPanel2.Size = new System.Drawing.Size(327, 113);
this.tableLayoutPanel2.TabIndex = 0;
//
// chkShowCpuCycles
@ -143,7 +147,7 @@
this.chkShowCpuCycles.AutoSize = true;
this.chkShowCpuCycles.Checked = true;
this.chkShowCpuCycles.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowCpuCycles.Location = new System.Drawing.Point(112, 3);
this.chkShowCpuCycles.Location = new System.Drawing.Point(111, 3);
this.chkShowCpuCycles.Name = "chkShowCpuCycles";
this.chkShowCpuCycles.Size = new System.Drawing.Size(82, 17);
this.chkShowCpuCycles.TabIndex = 3;
@ -179,7 +183,7 @@
this.chkShowPpuScanline.AutoSize = true;
this.chkShowPpuScanline.Checked = true;
this.chkShowPpuScanline.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowPpuScanline.Location = new System.Drawing.Point(112, 26);
this.chkShowPpuScanline.Location = new System.Drawing.Point(111, 26);
this.chkShowPpuScanline.Name = "chkShowPpuScanline";
this.chkShowPpuScanline.Size = new System.Drawing.Size(92, 17);
this.chkShowPpuScanline.TabIndex = 6;
@ -189,7 +193,7 @@
// chkShowFrameCount
//
this.chkShowFrameCount.AutoSize = true;
this.chkShowFrameCount.Location = new System.Drawing.Point(221, 26);
this.chkShowFrameCount.Location = new System.Drawing.Point(220, 26);
this.chkShowFrameCount.Name = "chkShowFrameCount";
this.chkShowFrameCount.Size = new System.Drawing.Size(86, 17);
this.chkShowFrameCount.TabIndex = 7;
@ -202,7 +206,7 @@
this.chkShowExtraInfo.Checked = true;
this.chkShowExtraInfo.CheckState = System.Windows.Forms.CheckState.Checked;
this.tableLayoutPanel2.SetColumnSpan(this.chkShowExtraInfo, 2);
this.chkShowExtraInfo.Location = new System.Drawing.Point(3, 49);
this.chkShowExtraInfo.Location = new System.Drawing.Point(3, 95);
this.chkShowExtraInfo.Name = "chkShowExtraInfo";
this.chkShowExtraInfo.Size = new System.Drawing.Size(204, 17);
this.chkShowExtraInfo.TabIndex = 9;
@ -214,7 +218,7 @@
this.chkShowByteCode.AutoSize = true;
this.chkShowByteCode.Checked = true;
this.chkShowByteCode.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowByteCode.Location = new System.Drawing.Point(221, 49);
this.chkShowByteCode.Location = new System.Drawing.Point(3, 49);
this.chkShowByteCode.Name = "chkShowByteCode";
this.chkShowByteCode.Size = new System.Drawing.Size(75, 17);
this.chkShowByteCode.TabIndex = 4;
@ -225,18 +229,31 @@
//
this.chkIndentCode.AutoSize = true;
this.tableLayoutPanel1.SetColumnSpan(this.chkIndentCode, 3);
this.chkIndentCode.Location = new System.Drawing.Point(3, 128);
this.chkIndentCode.Location = new System.Drawing.Point(3, 170);
this.chkIndentCode.Name = "chkIndentCode";
this.chkIndentCode.Size = new System.Drawing.Size(194, 17);
this.chkIndentCode.TabIndex = 8;
this.chkIndentCode.Text = "Indent code based on stack pointer";
this.chkIndentCode.UseVisualStyleBackColor = true;
//
// chkShowEffectiveAddresses
//
this.chkShowEffectiveAddresses.AutoSize = true;
this.chkShowEffectiveAddresses.Checked = true;
this.chkShowEffectiveAddresses.CheckState = System.Windows.Forms.CheckState.Checked;
this.tableLayoutPanel2.SetColumnSpan(this.chkShowEffectiveAddresses, 2);
this.chkShowEffectiveAddresses.Location = new System.Drawing.Point(3, 72);
this.chkShowEffectiveAddresses.Name = "chkShowEffectiveAddresses";
this.chkShowEffectiveAddresses.Size = new System.Drawing.Size(150, 17);
this.chkShowEffectiveAddresses.TabIndex = 10;
this.chkShowEffectiveAddresses.Text = "Show Effective Addresses";
this.chkShowEffectiveAddresses.UseVisualStyleBackColor = true;
//
// frmTraceLogger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(339, 150);
this.ClientSize = new System.Drawing.Size(339, 193);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
@ -269,5 +286,6 @@
private System.Windows.Forms.CheckBox chkShowExtraInfo;
private System.Windows.Forms.CheckBox chkIndentCode;
private System.Windows.Forms.Button btnOpenTrace;
private System.Windows.Forms.CheckBox chkShowEffectiveAddresses;
}
}

View file

@ -41,7 +41,8 @@ namespace Mesen.GUI.Debugger
ShowPpuFrames = chkShowFrameCount.Checked,
ShowPpuScanline = chkShowPpuScanline.Checked,
ShowRegisters = chkShowRegisters.Checked,
IndentCode = chkIndentCode.Checked
IndentCode = chkIndentCode.Checked,
ShowEffectiveAddresses = chkShowEffectiveAddresses.Checked
};
InteropEmu.DebugStartTraceLogger(options);

View file

@ -652,6 +652,7 @@ namespace Mesen.GUI
[MarshalAs(UnmanagedType.I1)] public bool ShowPpuFrames;
[MarshalAs(UnmanagedType.I1)] public bool ShowExtraInfo;
[MarshalAs(UnmanagedType.I1)] public bool IndentCode;
[MarshalAs(UnmanagedType.I1)] public bool ShowEffectiveAddresses;
}
[Flags]
@ -717,7 +718,8 @@ namespace Mesen.GUI
public enum DebuggerFlags
{
None = 0,
PpuPartialDraw = 1
PpuPartialDraw = 1,
ShowEffectiveAddresses = 2
}
public struct InteropRomInfo