Debugger: Trace Logger - Added clear log button

This commit is contained in:
Sour 2019-05-20 17:14:50 -04:00
parent 9cae20c527
commit 79aa90f60b
6 changed files with 34 additions and 5 deletions

View file

@ -392,6 +392,11 @@ void TraceLogger::Log(DebugState &state, DisassemblyInfo &disassemblyInfo)
//}
}
void TraceLogger::Clear()
{
_logCount = 0;
}
const char* TraceLogger::GetExecutionTrace(uint32_t lineCount)
{
int startPos;
@ -410,7 +415,7 @@ const char* TraceLogger::GetExecutionTrace(uint32_t lineCount)
enabled |= _logCpu[i];
}
if(enabled) {
if(enabled && lineCount > 0) {
for(int i = 0; i < TraceLogger::ExecutionLogSize; i++) {
int index = (startPos - i);
if(index < 0) {

View file

@ -115,6 +115,7 @@ public:
~TraceLogger();
void Log(DebugState &state, DisassemblyInfo &disassemblyInfo);
void Clear();
//void LogNonExec(OperationInfo& operationInfo);
void SetOptions(TraceLoggerOptions options);
void StartLogging(string filename);

View file

@ -53,6 +53,7 @@ extern "C"
DllExport void __stdcall SetTraceOptions(TraceLoggerOptions options) { GetDebugger()->GetTraceLogger()->SetOptions(options); }
DllExport void __stdcall StartTraceLogger(char* filename) { GetDebugger()->GetTraceLogger()->StartLogging(filename); }
DllExport void __stdcall StopTraceLogger() { GetDebugger()->GetTraceLogger()->StopLogging(); }
DllExport void __stdcall ClearTraceLog() { GetDebugger()->GetTraceLogger()->Clear(); }
DllExport const char* GetExecutionTrace(uint32_t lineCount) { return GetDebugger()->GetTraceLogger()->GetExecutionTrace(lineCount); }
DllExport void __stdcall SetBreakpoints(Breakpoint breakpoints[], uint32_t length) { GetDebugger()->GetBreakpointManager()->SetBreakpoints(breakpoints, length); }

View file

@ -64,6 +64,7 @@ namespace Mesen.GUI.Debugger
this.chkLogCpu = new System.Windows.Forms.CheckBox();
this.chkLogSpc = new System.Windows.Forms.CheckBox();
this.lblTarget = new System.Windows.Forms.Label();
this.btnClearLog = new System.Windows.Forms.Button();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.grpExecutionLog = new System.Windows.Forms.GroupBox();
this.txtTraceLog = new Mesen.GUI.Debugger.Controls.ctrlScrollableTextbox();
@ -105,14 +106,16 @@ namespace Mesen.GUI.Debugger
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnCount = 4;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.btnOpenTrace, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.btnOpenTrace, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.btnStartLogging, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.btnStopLogging, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.grpLogOptions, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.btnClearLog, 2, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 226);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
@ -120,7 +123,6 @@ namespace Mesen.GUI.Debugger
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, 195);
this.tableLayoutPanel1.TabIndex = 0;
//
@ -160,7 +162,7 @@ namespace Mesen.GUI.Debugger
//
// grpLogOptions
//
this.tableLayoutPanel1.SetColumnSpan(this.grpLogOptions, 3);
this.tableLayoutPanel1.SetColumnSpan(this.grpLogOptions, 4);
this.grpLogOptions.Controls.Add(this.tableLayoutPanel2);
this.grpLogOptions.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpLogOptions.Location = new System.Drawing.Point(3, 32);
@ -572,6 +574,16 @@ namespace Mesen.GUI.Debugger
this.lblTarget.TabIndex = 23;
this.lblTarget.Text = "Targets:";
//
// btnClearLog
//
this.btnClearLog.Location = new System.Drawing.Point(205, 3);
this.btnClearLog.Name = "btnClearLog";
this.btnClearLog.Size = new System.Drawing.Size(81, 23);
this.btnClearLog.TabIndex = 4;
this.btnClearLog.Text = "Clear Log";
this.btnClearLog.UseVisualStyleBackColor = true;
this.btnClearLog.Click += new System.EventHandler(this.btnClearLog_Click);
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 1;
@ -808,6 +820,8 @@ namespace Mesen.GUI.Debugger
this.Name = "frmTraceLogger";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Trace Logger";
this.Controls.SetChildIndex(this.menuStrip1, 0);
this.Controls.SetChildIndex(this.tableLayoutPanel3, 0);
this.tableLayoutPanel1.ResumeLayout(false);
this.grpLogOptions.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
@ -890,5 +904,6 @@ namespace Mesen.GUI.Debugger
private System.Windows.Forms.CheckBox chkLogCpu;
private System.Windows.Forms.CheckBox chkLogSpc;
private System.Windows.Forms.Label lblTarget;
private System.Windows.Forms.Button btnClearLog;
}
}

View file

@ -482,6 +482,12 @@ namespace Mesen.GUI.Debugger
{
txtTraceLog.SelectAll();
}
private void btnClearLog_Click(object sender, EventArgs e)
{
DebugApi.ClearTraceLog();
RefreshLog(true, true);
}
}
public class TraceLoggerCodeDataProvider : ICodeDataProvider

View file

@ -25,6 +25,7 @@ namespace Mesen.GUI
[DllImport(DllPath)] public static extern void StartTraceLogger([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string filename);
[DllImport(DllPath)] public static extern void StopTraceLogger();
[DllImport(DllPath)] public static extern void SetTraceOptions(InteropTraceLoggerOptions options);
[DllImport(DllPath)] public static extern void ClearTraceLog();
[DllImport(DllPath, EntryPoint = "GetDisassemblyLineData")] private static extern void GetDisassemblyLineDataWrapper(CpuType type, UInt32 lineIndex, ref InteropCodeLineData lineData);
public static CodeLineData GetDisassemblyLineData(CpuType type, UInt32 lineIndex)