Debugger: Trace Logger - Allow logging either SPC or CPU, or both

This commit is contained in:
Sour 2019-04-07 16:10:23 -04:00
parent f0d4e6deeb
commit d7c487aadc
7 changed files with 194 additions and 93 deletions

View file

@ -46,6 +46,10 @@ void TraceLogger::WriteValue(string &output, string value, RowPart& rowPart)
void TraceLogger::SetOptions(TraceLoggerOptions options)
{
_options = options;
_logCpu[(int)CpuType::Cpu] = options.LogCpu;
_logCpu[(int)CpuType::Spc] = options.LogSpc;
string condition = _options.Condition;
string format = _options.Format;
@ -60,7 +64,7 @@ void TraceLogger::SetOptions(TraceLoggerOptions options)
}*/
ParseFormatString(_rowParts, format);
ParseFormatString(_spcRowParts, "[PC,4h] [ByteCode,15h] [Disassembly][EffectiveAddress][MemoryValue,h][Align,48] A:[A,2h] X:[X,2h] Y:[Y,2h] S:[SP,2h] P:[P,h] H:[Cycle,3] V:[Scanline,3]");
ParseFormatString(_spcRowParts, "[PC,4h] [ByteCode,15h] [Disassembly][EffectiveAddress][MemoryValue,h][Align,48] A:[A,2h] X:[X,2h] Y:[Y,2h] S:[SP,2h] P:[P,8] H:[Cycle,3] V:[Scanline,3]");
}
void TraceLogger::ParseFormatString(vector<RowPart> &rowParts, string format)
@ -165,13 +169,21 @@ void TraceLogger::LogExtraInfo(const char *log, uint32_t cycleCount)
}
}
template<CpuType cpuType>
void TraceLogger::GetStatusFlag(string &output, uint8_t ps, RowPart& part)
{
constexpr char cpuActiveStatusLetters[8] = { 'N', 'V', 'M', 'X', 'D', 'I', 'Z', 'C' };
constexpr char cpuInactiveStatusLetters[8] = { 'n', 'v', 'p', 'x', 'd', 'i', 'z', 'c' };
constexpr char spcActiveStatusLetters[8] = { 'N', 'V', 'P', 'B', 'H', 'I', 'Z', 'C' };
constexpr char spcInactiveStatusLetters[8] = { 'n', 'v', 'p', 'b', 'h', 'i', 'z', 'c' };
constexpr char activeStatusLetters[8] = cpuType == CpuType::Cpu ? cpuActiveStatusLetters : spcActiveStatusLetters;
constexpr char inactiveStatusLetters[8] = cpuType == CpuType::Cpu ? cpuInactiveStatusLetters : spcInactiveStatusLetters;
if(part.DisplayInHex) {
WriteValue(output, ps, part);
} else {
constexpr char activeStatusLetters[8] = { 'N', 'V', 'M', 'X', 'D', 'I', 'Z', 'C' };
constexpr char inactiveStatusLetters[8] = { 'n', 'v', 'm', 'x', 'd', 'i', 'z', 'c' };
string flags;
for(int i = 0; i < 8; i++) {
if(ps & 0x80) {
@ -265,7 +277,7 @@ void TraceLogger::GetTraceRow(string &output, CpuState &cpuState, PpuState &ppuS
case RowDataType::D: WriteValue(output, cpuState.D, rowPart); break;
case RowDataType::DB: WriteValue(output, cpuState.DBR, rowPart); break;
case RowDataType::SP: WriteValue(output, cpuState.SP, rowPart); break;
case RowDataType::PS: GetStatusFlag(output, cpuState.PS, rowPart); break;
case RowDataType::PS: GetStatusFlag<CpuType::Cpu>(output, cpuState.PS, rowPart); break;
case RowDataType::Cycle: WriteValue(output, ppuState.Cycle, rowPart); break;
case RowDataType::Scanline: WriteValue(output, ppuState.Scanline, rowPart); break;
case RowDataType::FrameCount: WriteValue(output, ppuState.FrameCount, rowPart); break;
@ -293,7 +305,7 @@ void TraceLogger::GetTraceRow(string &output, SpcState &cpuState, PpuState &ppuS
case RowDataType::X: WriteValue(output, cpuState.X, rowPart); break;
case RowDataType::Y: WriteValue(output, cpuState.Y, rowPart); break;
case RowDataType::SP: WriteValue(output, cpuState.SP, rowPart); break;
case RowDataType::PS: GetStatusFlag(output, cpuState.PS, rowPart); break;
case RowDataType::PS: GetStatusFlag<CpuType::Spc>(output, cpuState.PS, rowPart); break;
case RowDataType::Cycle: WriteValue(output, ppuState.Cycle, rowPart); break;
case RowDataType::Scanline: WriteValue(output, ppuState.Scanline, rowPart); break;
case RowDataType::FrameCount: WriteValue(output, ppuState.FrameCount, rowPart); break;
@ -339,7 +351,7 @@ void TraceLogger::AddRow(DisassemblyInfo &disassemblyInfo, DebugState &state)
_logCount++;
}
if(_logToFile) {
if(_logToFile && _logCpu[(int)disassemblyInfo.GetCpuType()]) {
GetTraceRow(_outputBuffer, _disassemblyCache[_currentPos], _stateCache[_currentPos]);
if(_outputBuffer.size() > 32768) {
_outputFile << _outputBuffer;
@ -381,19 +393,38 @@ const char* TraceLogger::GetExecutionTrace(uint32_t lineCount)
startPos = _currentPos + ExecutionLogSize - lineCount;
}
for(int i = 0; i < (int)lineCount; i++) {
int index = (startPos + i) % ExecutionLogSize;
switch(_disassemblyCacheCopy[index].GetCpuType()) {
case CpuType::Cpu: _executionTrace += "\x2\x1" + HexUtilities::ToHex24((_stateCacheCopy[index].Cpu.K << 16) | _stateCacheCopy[index].Cpu.PC) + "\x1"; break;
case CpuType::Spc: _executionTrace += "\x3\x1" + HexUtilities::ToHex(_stateCacheCopy[index].Spc.PC) + "\x1"; break;
}
string byteCode;
_disassemblyCacheCopy[index].GetByteCode(byteCode);
_executionTrace += byteCode + "\x1";
GetTraceRow(_executionTrace, _disassemblyCacheCopy[index], _stateCacheCopy[index]);
bool enabled = false;
for(int i = 0; i <= (int)CpuType::Spc; i++) {
enabled |= _logCpu[i];
}
if(enabled) {
for(int i = 0; i < (int)lineCount; i++) {
int index = (startPos + i) % ExecutionLogSize;
if(i > 0 && startPos == index) {
//If we're back at the start, we didn't manage to find
break;
}
CpuType cpuType = _disassemblyCacheCopy[index].GetCpuType();
if(!_logCpu[(int)cpuType]) {
//This line isn't for a CPU currently being logged, increase the line count to try and
//get the number of lines the UI requested for the CPU type currently being logged
lineCount++;
continue;
}
switch(cpuType) {
case CpuType::Cpu: _executionTrace += "\x2\x1" + HexUtilities::ToHex24((_stateCacheCopy[index].Cpu.K << 16) | _stateCacheCopy[index].Cpu.PC) + "\x1"; break;
case CpuType::Spc: _executionTrace += "\x3\x1" + HexUtilities::ToHex(_stateCacheCopy[index].Spc.PC) + "\x1"; break;
}
string byteCode;
_disassemblyCacheCopy[index].GetByteCode(byteCode);
_executionTrace += byteCode + "\x1";
GetTraceRow(_executionTrace, _disassemblyCacheCopy[index], _stateCacheCopy[index]);
}
}
return _executionTrace.c_str();
}

View file

@ -13,6 +13,9 @@ struct DebugState;
struct TraceLoggerOptions
{
bool LogCpu;
bool LogSpc;
bool ShowExtraInfo;
bool IndentCode;
bool UseLabels;
@ -56,7 +59,7 @@ struct RowPart
class TraceLogger
{
private:
static constexpr int ExecutionLogSize = 30000;
static constexpr int ExecutionLogSize = 60000;
//Must be static to be thread-safe when switching game
static string _executionTrace;
@ -71,12 +74,14 @@ private:
vector<RowPart> _rowParts;
vector<RowPart> _spcRowParts;
bool _logCpu[(int)CpuType::Spc + 1] = {};
bool _pendingLog;
//CpuState _lastState;
//DisassemblyInfo _lastDisassemblyInfo;
bool _logToFile;
uint16_t _currentPos;
uint32_t _currentPos;
uint32_t _logCount;
DebugState _stateCache[ExecutionLogSize] = {};
DisassemblyInfo _disassemblyCache[ExecutionLogSize];
@ -86,7 +91,8 @@ private:
SimpleLock _lock;
void GetStatusFlag(string &output, uint8_t ps, RowPart& part);
template<CpuType cpuType> void GetStatusFlag(string &output, uint8_t ps, RowPart& part);
void WriteByteCode(DisassemblyInfo &info, RowPart &rowPart, string &output);
void WriteDisassembly(DisassemblyInfo &info, RowPart &rowPart, uint8_t sp, uint32_t pc, string &output);
void WriteEffectiveAddress(DisassemblyInfo &info, RowPart &rowPart, void *cpuState, string &output);

View file

@ -30,22 +30,24 @@ namespace Mesen.GUI.Config
public TraceLoggerInfo()
{
LogOptions = new TraceLoggerOptions() {
LogCpu = true,
ShowByteCode = true,
ShowCpuCycles = true,
ShowEffectiveAddresses = true,
ShowExtraInfo = true,
ShowPpuFrames = false,
ShowPpuCycles = true,
ShowPpuScanline = true,
ShowRegisters = true,
UseLabels = false,
StatusFormat = StatusFlagFormat.Hexadecimal
StatusFormat = StatusFlagFormat.Text
};
}
}
public class TraceLoggerOptions
{
public bool LogCpu;
public bool LogSpc;
public bool ShowByteCode;
public bool ShowRegisters;
public bool ShowCpuCycles;

View file

@ -61,6 +61,9 @@ namespace Mesen.GUI.Debugger
this.cboStatusFlagFormat = new System.Windows.Forms.ComboBox();
this.chkUseWindowsEol = new System.Windows.Forms.CheckBox();
this.chkExtendZeroPage = new System.Windows.Forms.CheckBox();
this.chkLogCpu = new System.Windows.Forms.CheckBox();
this.chkLogSpc = new System.Windows.Forms.CheckBox();
this.lblTarget = new System.Windows.Forms.Label();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.grpExecutionLog = new System.Windows.Forms.GroupBox();
this.txtTraceLog = new Mesen.GUI.Debugger.Controls.ctrlScrollableTextbox();
@ -111,14 +114,14 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel1.Controls.Add(this.btnStopLogging, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.grpLogOptions, 0, 1);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 200);
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 226);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
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());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(778, 182);
this.tableLayoutPanel1.Size = new System.Drawing.Size(778, 195);
this.tableLayoutPanel1.TabIndex = 0;
//
// btnOpenTrace
@ -162,7 +165,7 @@ namespace Mesen.GUI.Debugger
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(772, 150);
this.grpLogOptions.Size = new System.Drawing.Size(772, 160);
this.grpLogOptions.TabIndex = 3;
this.grpLogOptions.TabStop = false;
this.grpLogOptions.Text = "Log Options";
@ -177,27 +180,32 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel5, 0, 4);
this.tableLayoutPanel2.Controls.Add(this.chkShowMemoryValues, 3, 1);
this.tableLayoutPanel2.Controls.Add(this.chkShowRegisters, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.chkShowByteCode, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.chkShowCpuCycles, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.chkShowPpuCycles, 2, 0);
this.tableLayoutPanel2.Controls.Add(this.chkShowPpuScanline, 2, 1);
this.tableLayoutPanel2.Controls.Add(this.chkShowFrameCount, 1, 1);
this.tableLayoutPanel2.Controls.Add(this.chkShowEffectiveAddresses, 3, 0);
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel4, 0, 5);
this.tableLayoutPanel2.Controls.Add(this.chkShowExtraInfo, 4, 0);
this.tableLayoutPanel2.Controls.Add(this.chkIndentCode, 0, 2);
this.tableLayoutPanel2.Controls.Add(this.chkUseLabels, 2, 2);
this.tableLayoutPanel2.Controls.Add(this.label1, 4, 2);
this.tableLayoutPanel2.Controls.Add(this.cboStatusFlagFormat, 5, 2);
this.tableLayoutPanel2.Controls.Add(this.chkUseWindowsEol, 3, 2);
this.tableLayoutPanel2.Controls.Add(this.chkExtendZeroPage, 4, 1);
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel5, 0, 6);
this.tableLayoutPanel2.Controls.Add(this.chkShowMemoryValues, 3, 3);
this.tableLayoutPanel2.Controls.Add(this.chkShowRegisters, 0, 2);
this.tableLayoutPanel2.Controls.Add(this.chkShowByteCode, 0, 3);
this.tableLayoutPanel2.Controls.Add(this.chkShowCpuCycles, 1, 2);
this.tableLayoutPanel2.Controls.Add(this.chkShowPpuCycles, 2, 2);
this.tableLayoutPanel2.Controls.Add(this.chkShowPpuScanline, 2, 3);
this.tableLayoutPanel2.Controls.Add(this.chkShowFrameCount, 1, 3);
this.tableLayoutPanel2.Controls.Add(this.chkShowEffectiveAddresses, 3, 2);
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel4, 0, 7);
this.tableLayoutPanel2.Controls.Add(this.chkShowExtraInfo, 4, 2);
this.tableLayoutPanel2.Controls.Add(this.chkIndentCode, 0, 4);
this.tableLayoutPanel2.Controls.Add(this.chkUseLabels, 2, 4);
this.tableLayoutPanel2.Controls.Add(this.label1, 4, 4);
this.tableLayoutPanel2.Controls.Add(this.cboStatusFlagFormat, 5, 4);
this.tableLayoutPanel2.Controls.Add(this.chkUseWindowsEol, 3, 4);
this.tableLayoutPanel2.Controls.Add(this.chkExtendZeroPage, 4, 3);
this.tableLayoutPanel2.Controls.Add(this.chkLogCpu, 1, 0);
this.tableLayoutPanel2.Controls.Add(this.chkLogSpc, 2, 0);
this.tableLayoutPanel2.Controls.Add(this.lblTarget, 0, 0);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 16);
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 8;
this.tableLayoutPanel2.RowCount = 9;
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 10F));
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());
@ -205,8 +213,8 @@ namespace Mesen.GUI.Debugger
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.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.Size = new System.Drawing.Size(766, 131);
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(766, 141);
this.tableLayoutPanel2.TabIndex = 0;
//
// tableLayoutPanel5
@ -223,7 +231,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel5.Controls.Add(this.lblFormat, 0, 0);
this.tableLayoutPanel5.Controls.Add(this.txtFormat, 2, 0);
this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel5.Location = new System.Drawing.Point(0, 78);
this.tableLayoutPanel5.Location = new System.Drawing.Point(0, 111);
this.tableLayoutPanel5.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel5.Name = "tableLayoutPanel5";
this.tableLayoutPanel5.RowCount = 1;
@ -279,7 +287,7 @@ namespace Mesen.GUI.Debugger
this.chkShowMemoryValues.AutoSize = true;
this.chkShowMemoryValues.Checked = true;
this.chkShowMemoryValues.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowMemoryValues.Location = new System.Drawing.Point(301, 26);
this.chkShowMemoryValues.Location = new System.Drawing.Point(301, 59);
this.chkShowMemoryValues.Name = "chkShowMemoryValues";
this.chkShowMemoryValues.Size = new System.Drawing.Size(128, 17);
this.chkShowMemoryValues.TabIndex = 17;
@ -292,7 +300,7 @@ namespace Mesen.GUI.Debugger
this.chkShowRegisters.AutoSize = true;
this.chkShowRegisters.Checked = true;
this.chkShowRegisters.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowRegisters.Location = new System.Drawing.Point(3, 3);
this.chkShowRegisters.Location = new System.Drawing.Point(3, 36);
this.chkShowRegisters.Name = "chkShowRegisters";
this.chkShowRegisters.Size = new System.Drawing.Size(70, 17);
this.chkShowRegisters.TabIndex = 2;
@ -306,7 +314,7 @@ namespace Mesen.GUI.Debugger
this.chkShowByteCode.AutoSize = true;
this.chkShowByteCode.Checked = true;
this.chkShowByteCode.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowByteCode.Location = new System.Drawing.Point(3, 26);
this.chkShowByteCode.Location = new System.Drawing.Point(3, 59);
this.chkShowByteCode.Name = "chkShowByteCode";
this.chkShowByteCode.Size = new System.Drawing.Size(75, 17);
this.chkShowByteCode.TabIndex = 4;
@ -317,14 +325,13 @@ namespace Mesen.GUI.Debugger
// chkShowCpuCycles
//
this.chkShowCpuCycles.AutoSize = true;
this.chkShowCpuCycles.Checked = true;
this.chkShowCpuCycles.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowCpuCycles.Location = new System.Drawing.Point(84, 3);
this.chkShowCpuCycles.Location = new System.Drawing.Point(84, 36);
this.chkShowCpuCycles.Name = "chkShowCpuCycles";
this.chkShowCpuCycles.Size = new System.Drawing.Size(82, 17);
this.chkShowCpuCycles.TabIndex = 3;
this.chkShowCpuCycles.Text = "CPU Cycles";
this.chkShowCpuCycles.UseVisualStyleBackColor = true;
this.chkShowCpuCycles.Visible = false;
this.chkShowCpuCycles.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged);
//
// chkShowPpuCycles
@ -332,7 +339,7 @@ namespace Mesen.GUI.Debugger
this.chkShowPpuCycles.AutoSize = true;
this.chkShowPpuCycles.Checked = true;
this.chkShowPpuCycles.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowPpuCycles.Location = new System.Drawing.Point(203, 3);
this.chkShowPpuCycles.Location = new System.Drawing.Point(203, 36);
this.chkShowPpuCycles.Name = "chkShowPpuCycles";
this.chkShowPpuCycles.Size = new System.Drawing.Size(77, 17);
this.chkShowPpuCycles.TabIndex = 5;
@ -346,7 +353,7 @@ namespace Mesen.GUI.Debugger
this.chkShowPpuScanline.AutoSize = true;
this.chkShowPpuScanline.Checked = true;
this.chkShowPpuScanline.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowPpuScanline.Location = new System.Drawing.Point(203, 26);
this.chkShowPpuScanline.Location = new System.Drawing.Point(203, 59);
this.chkShowPpuScanline.Name = "chkShowPpuScanline";
this.chkShowPpuScanline.Size = new System.Drawing.Size(92, 17);
this.chkShowPpuScanline.TabIndex = 6;
@ -358,7 +365,7 @@ namespace Mesen.GUI.Debugger
//
this.chkShowFrameCount.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.chkShowFrameCount.AutoSize = true;
this.chkShowFrameCount.Location = new System.Drawing.Point(84, 26);
this.chkShowFrameCount.Location = new System.Drawing.Point(84, 59);
this.chkShowFrameCount.Name = "chkShowFrameCount";
this.chkShowFrameCount.Size = new System.Drawing.Size(86, 17);
this.chkShowFrameCount.TabIndex = 7;
@ -371,7 +378,7 @@ namespace Mesen.GUI.Debugger
this.chkShowEffectiveAddresses.AutoSize = true;
this.chkShowEffectiveAddresses.Checked = true;
this.chkShowEffectiveAddresses.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowEffectiveAddresses.Location = new System.Drawing.Point(301, 3);
this.chkShowEffectiveAddresses.Location = new System.Drawing.Point(301, 36);
this.chkShowEffectiveAddresses.Name = "chkShowEffectiveAddresses";
this.chkShowEffectiveAddresses.Size = new System.Drawing.Size(150, 17);
this.chkShowEffectiveAddresses.TabIndex = 10;
@ -392,7 +399,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel4.Controls.Add(this.lblCondition, 0, 0);
this.tableLayoutPanel4.Controls.Add(this.txtCondition, 1, 0);
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 103);
this.tableLayoutPanel4.Location = new System.Drawing.Point(0, 136);
this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(0);
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
this.tableLayoutPanel4.RowCount = 1;
@ -409,6 +416,7 @@ namespace Mesen.GUI.Debugger
this.picHelp.Size = new System.Drawing.Size(18, 17);
this.picHelp.TabIndex = 17;
this.picHelp.TabStop = false;
this.picHelp.Visible = false;
//
// picExpressionWarning
//
@ -430,6 +438,7 @@ namespace Mesen.GUI.Debugger
this.lblCondition.Size = new System.Drawing.Size(54, 13);
this.lblCondition.TabIndex = 14;
this.lblCondition.Text = "Condition:";
this.lblCondition.Visible = false;
//
// txtCondition
//
@ -438,6 +447,7 @@ namespace Mesen.GUI.Debugger
this.txtCondition.Name = "txtCondition";
this.txtCondition.Size = new System.Drawing.Size(652, 20);
this.txtCondition.TabIndex = 15;
this.txtCondition.Visible = false;
//
// chkShowExtraInfo
//
@ -445,12 +455,13 @@ namespace Mesen.GUI.Debugger
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(462, 3);
this.chkShowExtraInfo.Location = new System.Drawing.Point(462, 36);
this.chkShowExtraInfo.Name = "chkShowExtraInfo";
this.chkShowExtraInfo.Size = new System.Drawing.Size(204, 17);
this.chkShowExtraInfo.TabIndex = 9;
this.chkShowExtraInfo.Text = "Additional information (IRQ, NMI, etc.)";
this.chkShowExtraInfo.UseVisualStyleBackColor = true;
this.chkShowExtraInfo.Visible = false;
this.chkShowExtraInfo.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged);
//
// chkIndentCode
@ -458,7 +469,7 @@ namespace Mesen.GUI.Debugger
this.chkIndentCode.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.chkIndentCode.AutoSize = true;
this.tableLayoutPanel2.SetColumnSpan(this.chkIndentCode, 2);
this.chkIndentCode.Location = new System.Drawing.Point(3, 51);
this.chkIndentCode.Location = new System.Drawing.Point(3, 84);
this.chkIndentCode.Name = "chkIndentCode";
this.chkIndentCode.Size = new System.Drawing.Size(194, 17);
this.chkIndentCode.TabIndex = 8;
@ -470,19 +481,20 @@ namespace Mesen.GUI.Debugger
//
this.chkUseLabels.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.chkUseLabels.AutoSize = true;
this.chkUseLabels.Location = new System.Drawing.Point(203, 51);
this.chkUseLabels.Location = new System.Drawing.Point(203, 84);
this.chkUseLabels.Name = "chkUseLabels";
this.chkUseLabels.Size = new System.Drawing.Size(79, 17);
this.chkUseLabels.TabIndex = 11;
this.chkUseLabels.Text = "Use Labels";
this.chkUseLabels.UseVisualStyleBackColor = true;
this.chkUseLabels.Visible = false;
this.chkUseLabels.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged);
//
// label1
//
this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(462, 53);
this.label1.Location = new System.Drawing.Point(462, 86);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(98, 13);
this.label1.TabIndex = 12;
@ -493,7 +505,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel2.SetColumnSpan(this.cboStatusFlagFormat, 2);
this.cboStatusFlagFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboStatusFlagFormat.FormattingEnabled = true;
this.cboStatusFlagFormat.Location = new System.Drawing.Point(566, 49);
this.cboStatusFlagFormat.Location = new System.Drawing.Point(566, 82);
this.cboStatusFlagFormat.Name = "cboStatusFlagFormat";
this.cboStatusFlagFormat.Size = new System.Drawing.Size(121, 21);
this.cboStatusFlagFormat.TabIndex = 13;
@ -503,7 +515,7 @@ namespace Mesen.GUI.Debugger
//
this.chkUseWindowsEol.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.chkUseWindowsEol.AutoSize = true;
this.chkUseWindowsEol.Location = new System.Drawing.Point(301, 51);
this.chkUseWindowsEol.Location = new System.Drawing.Point(301, 84);
this.chkUseWindowsEol.Name = "chkUseWindowsEol";
this.chkUseWindowsEol.Size = new System.Drawing.Size(155, 17);
this.chkUseWindowsEol.TabIndex = 19;
@ -515,7 +527,7 @@ namespace Mesen.GUI.Debugger
this.chkExtendZeroPage.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.chkExtendZeroPage.AutoSize = true;
this.tableLayoutPanel2.SetColumnSpan(this.chkExtendZeroPage, 2);
this.chkExtendZeroPage.Location = new System.Drawing.Point(462, 26);
this.chkExtendZeroPage.Location = new System.Drawing.Point(462, 59);
this.chkExtendZeroPage.Name = "chkExtendZeroPage";
this.chkExtendZeroPage.Size = new System.Drawing.Size(205, 17);
this.chkExtendZeroPage.TabIndex = 20;
@ -523,6 +535,42 @@ namespace Mesen.GUI.Debugger
this.chkExtendZeroPage.UseVisualStyleBackColor = true;
this.chkExtendZeroPage.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged);
//
// chkLogCpu
//
this.chkLogCpu.AutoSize = true;
this.chkLogCpu.Checked = true;
this.chkLogCpu.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkLogCpu.Location = new System.Drawing.Point(84, 3);
this.chkLogCpu.Name = "chkLogCpu";
this.chkLogCpu.Size = new System.Drawing.Size(87, 17);
this.chkLogCpu.TabIndex = 21;
this.chkLogCpu.Text = "CPU (65816)";
this.chkLogCpu.UseVisualStyleBackColor = true;
this.chkLogCpu.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged);
//
// chkLogSpc
//
this.chkLogSpc.AutoSize = true;
this.chkLogSpc.Checked = true;
this.chkLogSpc.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkLogSpc.Location = new System.Drawing.Point(203, 3);
this.chkLogSpc.Name = "chkLogSpc";
this.chkLogSpc.Size = new System.Drawing.Size(47, 17);
this.chkLogSpc.TabIndex = 22;
this.chkLogSpc.Text = "SPC";
this.chkLogSpc.UseVisualStyleBackColor = true;
this.chkLogSpc.CheckedChanged += new System.EventHandler(this.chkOptions_CheckedChanged);
//
// lblTarget
//
this.lblTarget.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblTarget.AutoSize = true;
this.lblTarget.Location = new System.Drawing.Point(3, 5);
this.lblTarget.Name = "lblTarget";
this.lblTarget.Size = new System.Drawing.Size(46, 13);
this.lblTarget.TabIndex = 23;
this.lblTarget.Text = "Targets:";
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 1;
@ -536,7 +584,7 @@ namespace Mesen.GUI.Debugger
this.tableLayoutPanel3.RowCount = 2;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.Size = new System.Drawing.Size(784, 385);
this.tableLayoutPanel3.Size = new System.Drawing.Size(784, 424);
this.tableLayoutPanel3.TabIndex = 1;
//
// grpExecutionLog
@ -545,7 +593,7 @@ namespace Mesen.GUI.Debugger
this.grpExecutionLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpExecutionLog.Location = new System.Drawing.Point(3, 3);
this.grpExecutionLog.Name = "grpExecutionLog";
this.grpExecutionLog.Size = new System.Drawing.Size(778, 191);
this.grpExecutionLog.Size = new System.Drawing.Size(778, 217);
this.grpExecutionLog.TabIndex = 2;
this.grpExecutionLog.TabStop = false;
this.grpExecutionLog.Text = "Execution Log";
@ -566,7 +614,7 @@ namespace Mesen.GUI.Debugger
this.txtTraceLog.ShowScrollbars = true;
this.txtTraceLog.ShowSingleContentLineNotes = true;
this.txtTraceLog.ShowSingleLineLineNumberNotes = false;
this.txtTraceLog.Size = new System.Drawing.Size(772, 172);
this.txtTraceLog.Size = new System.Drawing.Size(772, 198);
this.txtTraceLog.TabIndex = 0;
//
// ctxMenu
@ -752,7 +800,7 @@ namespace Mesen.GUI.Debugger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 409);
this.ClientSize = new System.Drawing.Size(784, 448);
this.Controls.Add(this.tableLayoutPanel3);
this.Controls.Add(this.menuStrip1);
this.MinimumSize = new System.Drawing.Size(800, 448);
@ -838,5 +886,8 @@ namespace Mesen.GUI.Debugger
private System.Windows.Forms.ContextMenuStrip ctxMenu;
private System.Windows.Forms.ToolStripMenuItem mnuCopy;
private System.Windows.Forms.ToolStripMenuItem mnuSelectAll;
private System.Windows.Forms.CheckBox chkLogCpu;
private System.Windows.Forms.CheckBox chkLogSpc;
private System.Windows.Forms.Label lblTarget;
}
}

View file

@ -44,21 +44,25 @@ namespace Mesen.GUI.Debugger
_lineCount = config.LineCount;
_entityBinder.Entity = config.LogOptions;
_entityBinder.AddBinding("ShowByteCode", chkShowByteCode);
_entityBinder.AddBinding("ShowCpuCycles", chkShowCpuCycles);
_entityBinder.AddBinding("ShowEffectiveAddresses", chkShowEffectiveAddresses);
_entityBinder.AddBinding("ShowMemoryValues", chkShowMemoryValues);
_entityBinder.AddBinding("ShowExtraInfo", chkShowExtraInfo);
_entityBinder.AddBinding("ShowPpuFrames", chkShowFrameCount);
_entityBinder.AddBinding("ShowPpuCycles", chkShowPpuCycles);
_entityBinder.AddBinding("ShowPpuScanline", chkShowPpuScanline);
_entityBinder.AddBinding("ShowRegisters", chkShowRegisters);
_entityBinder.AddBinding("IndentCode", chkIndentCode);
_entityBinder.AddBinding("UseLabels", chkUseLabels);
_entityBinder.AddBinding("ExtendZeroPage", chkExtendZeroPage);
_entityBinder.AddBinding("UseWindowsEol", chkUseWindowsEol);
_entityBinder.AddBinding("StatusFormat", cboStatusFlagFormat);
_entityBinder.AddBinding("OverrideFormat", chkOverrideFormat);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.LogCpu), chkLogCpu);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.LogSpc), chkLogSpc);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowByteCode), chkShowByteCode);
//_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowCpuCycles), chkShowCpuCycles);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowEffectiveAddresses), chkShowEffectiveAddresses);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowMemoryValues), chkShowMemoryValues);
//_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowExtraInfo), chkShowExtraInfo);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowPpuFrames), chkShowFrameCount);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowPpuCycles), chkShowPpuCycles);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowPpuScanline), chkShowPpuScanline);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ShowRegisters), chkShowRegisters);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.IndentCode), chkIndentCode);
//_entityBinder.AddBinding(nameof(TraceLoggerOptions.UseLabels), chkUseLabels);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.ExtendZeroPage), chkExtendZeroPage);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.UseWindowsEol), chkUseWindowsEol);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.StatusFormat), cboStatusFlagFormat);
_entityBinder.AddBinding(nameof(TraceLoggerOptions.OverrideFormat), chkOverrideFormat);
_entityBinder.UpdateUI();
this.toolTip.SetToolTip(this.picExpressionWarning, "Condition contains invalid syntax or symbols.");
@ -170,11 +174,11 @@ namespace Mesen.GUI.Debugger
case StatusFlagFormat.Text: format += "P:[P,8] "; break;
}
}
if(chkShowPpuCycles.Checked) {
format += "CYC:[Cycle,3] ";
}
if(chkShowPpuScanline.Checked) {
format += "SL:[Scanline,3] ";
format += "V:[Scanline,3] ";
}
if(chkShowPpuCycles.Checked) {
format += "H:[Cycle,3] ";
}
if(chkShowFrameCount.Checked) {
format += "FC:[FrameCount] ";
@ -207,6 +211,8 @@ namespace Mesen.GUI.Debugger
TraceLoggerOptions options = (TraceLoggerOptions)_entityBinder.Entity;
InteropTraceLoggerOptions interopOptions = new InteropTraceLoggerOptions();
interopOptions.LogCpu = options.LogCpu;
interopOptions.LogSpc = options.LogSpc;
interopOptions.IndentCode = options.IndentCode;
interopOptions.ShowExtraInfo = options.ShowExtraInfo;
interopOptions.UseLabels = options.UseLabels;
@ -527,6 +533,7 @@ namespace Mesen.GUI.Debugger
public class TraceLoggerStyleProvider : ctrlTextbox.ILineStyleProvider
{
private Color _spcColor = Color.FromArgb(030, 145, 030);
private Color _spcBgColor = Color.FromArgb(230, 245, 230);
private List<int> _flags;
public TraceLoggerStyleProvider(List<int> lineFlags)
@ -542,7 +549,8 @@ namespace Mesen.GUI.Debugger
public LineProperties GetLineStyle(CodeLineData lineData, int lineIndex)
{
return new LineProperties() {
FgColor = _flags[lineIndex] == 3 ? (Color?)_spcColor : null
AddressColor = _flags[lineIndex] == 3 ? (Color?)_spcColor : null,
LineBgColor = _flags[lineIndex] == 3 ? (Color?)_spcBgColor : null
};
}
}

View file

@ -121,12 +121,12 @@
<value>17, 17</value>
</metadata>
<metadata name="ctxMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 134</value>
<value>353, 17</value>
</metadata>
<metadata name="tmrUpdateLog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 56</value>
<value>107, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 95</value>
<value>238, 17</value>
</metadata>
</root>

View file

@ -423,6 +423,9 @@ namespace Mesen.GUI
[Serializable]
public struct InteropTraceLoggerOptions
{
[MarshalAs(UnmanagedType.I1)] public bool LogCpu;
[MarshalAs(UnmanagedType.I1)] public bool LogSpc;
[MarshalAs(UnmanagedType.I1)] public bool ShowExtraInfo;
[MarshalAs(UnmanagedType.I1)] public bool IndentCode;
[MarshalAs(UnmanagedType.I1)] public bool UseLabels;