mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-30 20:40:54 +00:00
Debugger: Added "Break on Crash" option
This commit is contained in:
parent
89c5eab317
commit
3bb760703e
@ -241,7 +241,8 @@ uint16_t CPU::FetchOperand()
|
||||
//Don't stop emulation on CPU crash when playing NSFs, reset cpu instead
|
||||
Console::Reset(true);
|
||||
return 0;
|
||||
} else {
|
||||
} else if(!Debugger::IsEnabled()) {
|
||||
//Throw an error and stop emulation core (if debugger is not enabled)
|
||||
throw std::runtime_error("Invalid OP code - CPU crashed");
|
||||
}
|
||||
#else
|
||||
|
@ -153,6 +153,11 @@ void Debugger::BreakIfDebugging()
|
||||
if(Debugger::Instance != nullptr) {
|
||||
Debugger::Instance->Step(1);
|
||||
Debugger::Instance->SleepUntilResume();
|
||||
} else if(EmulationSettings::CheckFlag(EmulationFlags::BreakOnCrash)) {
|
||||
//When "Break on Crash" is enabled, open the debugger and break immediately if a crash occurs
|
||||
Console::GetInstance()->GetDebugger(true);
|
||||
Debugger::Instance->Step(1);
|
||||
Debugger::Instance->SleepUntilResume();
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,9 +165,14 @@ bool Debugger::LoadCdlFile(string cdlFilepath)
|
||||
{
|
||||
if(_codeDataLogger->LoadCdlFile(cdlFilepath)) {
|
||||
//Can't use DebugBreakHelper due to the fact this is called in the constructor
|
||||
Console::Pause();
|
||||
bool isEmulationThread = Console::GetEmulationThreadId() == std::this_thread::get_id();
|
||||
if(!isEmulationThread) {
|
||||
Console::Pause();
|
||||
}
|
||||
UpdateCdlCache();
|
||||
Console::Resume();
|
||||
if(!isEmulationThread) {
|
||||
Console::Resume();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -76,6 +76,7 @@ enum EmulationFlags : uint64_t
|
||||
IntegerFpsMode = 0x2000000000000,
|
||||
|
||||
DebuggerWindowEnabled = 0x4000000000000,
|
||||
BreakOnCrash = 0x8000000000000,
|
||||
|
||||
ForceMaxSpeed = 0x4000000000000000,
|
||||
ConsoleMode = 0x8000000000000000,
|
||||
|
@ -81,6 +81,7 @@ namespace Mesen.GUI.Config
|
||||
AudioInfo.ApplyConfig();
|
||||
PreferenceInfo.ApplyConfig();
|
||||
EmulationInfo.ApplyConfig();
|
||||
DebugInfo.ApplyConfig();
|
||||
|
||||
InteropEmu.SetNesModel(Region);
|
||||
}
|
||||
|
@ -218,6 +218,7 @@ namespace Mesen.GUI.Config
|
||||
public bool BreakOnUnofficialOpcodes = true;
|
||||
public bool BreakOnBrk = false;
|
||||
public bool BreakOnDebuggerFocus = false;
|
||||
public bool BreakOnCrash = false;
|
||||
|
||||
public TraceLoggerOptions TraceLoggerOptions;
|
||||
public bool TraceAutoRefresh = true;
|
||||
@ -260,6 +261,11 @@ namespace Mesen.GUI.Config
|
||||
};
|
||||
}
|
||||
|
||||
static public void ApplyConfig()
|
||||
{
|
||||
InteropEmu.SetFlag(EmulationFlags.BreakOnCrash, ConfigManager.Config.DebugInfo.BreakOnCrash);
|
||||
}
|
||||
|
||||
public void AddRecentScript(string scriptFile)
|
||||
{
|
||||
string existingItem = RecentScripts.Where((file) => file == scriptFile).FirstOrDefault();
|
||||
|
55
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
55
GUI.NET/Debugger/frmDebugger.Designer.cs
generated
@ -170,6 +170,7 @@ namespace Mesen.GUI.Debugger
|
||||
this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
|
||||
this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping();
|
||||
this.tsToolbar = new System.Windows.Forms.ToolStrip();
|
||||
this.mnuBreakOnCrash = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
@ -215,7 +216,7 @@ namespace Mesen.GUI.Debugger
|
||||
this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel10);
|
||||
this.splitContainer.Panel2MinSize = 100;
|
||||
this.splitContainer.Size = new System.Drawing.Size(1172, 573);
|
||||
this.splitContainer.SplitterDistance = 404;
|
||||
this.splitContainer.SplitterDistance = 401;
|
||||
this.splitContainer.SplitterWidth = 7;
|
||||
this.splitContainer.TabIndex = 1;
|
||||
this.splitContainer.TabStop = false;
|
||||
@ -238,8 +239,8 @@ namespace Mesen.GUI.Debugger
|
||||
//
|
||||
this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists);
|
||||
this.ctrlSplitContainerTop.Panel2MinSize = 150;
|
||||
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 404);
|
||||
this.ctrlSplitContainerTop.SplitterDistance = 767;
|
||||
this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 401);
|
||||
this.ctrlSplitContainerTop.SplitterDistance = 764;
|
||||
this.ctrlSplitContainerTop.SplitterWidth = 7;
|
||||
this.ctrlSplitContainerTop.TabIndex = 3;
|
||||
this.ctrlSplitContainerTop.PanelCollapsed += new System.EventHandler(this.ctrlSplitContainerTop_PanelCollapsed);
|
||||
@ -260,7 +261,7 @@ 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.Size = new System.Drawing.Size(767, 404);
|
||||
this.tlpTop.Size = new System.Drawing.Size(764, 401);
|
||||
this.tlpTop.TabIndex = 2;
|
||||
//
|
||||
// ctrlDebuggerCode
|
||||
@ -272,7 +273,7 @@ namespace Mesen.GUI.Debugger
|
||||
this.ctrlDebuggerCode.Name = "ctrlDebuggerCode";
|
||||
this.ctrlDebuggerCode.ShowMemoryValues = false;
|
||||
this.ctrlDebuggerCode.ShowScrollbars = true;
|
||||
this.ctrlDebuggerCode.Size = new System.Drawing.Size(303, 398);
|
||||
this.ctrlDebuggerCode.Size = new System.Drawing.Size(300, 395);
|
||||
this.ctrlDebuggerCode.TabIndex = 2;
|
||||
this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
|
||||
this.ctrlDebuggerCode.OnSetNextStatement += new Mesen.GUI.Debugger.ctrlDebuggerCode.AddressEventHandler(this.ctrlDebuggerCode_OnSetNextStatement);
|
||||
@ -282,10 +283,10 @@ namespace Mesen.GUI.Debugger
|
||||
// ctrlConsoleStatus
|
||||
//
|
||||
this.ctrlConsoleStatus.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlConsoleStatus.Location = new System.Drawing.Point(309, 0);
|
||||
this.ctrlConsoleStatus.Location = new System.Drawing.Point(306, 0);
|
||||
this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.ctrlConsoleStatus.Name = "ctrlConsoleStatus";
|
||||
this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 404);
|
||||
this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 401);
|
||||
this.ctrlConsoleStatus.TabIndex = 3;
|
||||
this.ctrlConsoleStatus.OnGotoLocation += new System.EventHandler(this.ctrlConsoleStatus_OnGotoLocation);
|
||||
//
|
||||
@ -294,11 +295,11 @@ namespace Mesen.GUI.Debugger
|
||||
this.ctrlDebuggerCodeSplit.Code = null;
|
||||
this.ctrlDebuggerCodeSplit.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlDebuggerCodeSplit.HideSelection = false;
|
||||
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(312, 3);
|
||||
this.ctrlDebuggerCodeSplit.Location = new System.Drawing.Point(309, 3);
|
||||
this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit";
|
||||
this.ctrlDebuggerCodeSplit.ShowMemoryValues = false;
|
||||
this.ctrlDebuggerCodeSplit.ShowScrollbars = true;
|
||||
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 398);
|
||||
this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 395);
|
||||
this.ctrlDebuggerCodeSplit.TabIndex = 4;
|
||||
this.ctrlDebuggerCodeSplit.Visible = false;
|
||||
this.ctrlDebuggerCodeSplit.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode);
|
||||
@ -319,16 +320,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(398, 404);
|
||||
this.tlpFunctionLabelLists.Size = new System.Drawing.Size(401, 401);
|
||||
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, 205);
|
||||
this.grpLabels.Location = new System.Drawing.Point(3, 203);
|
||||
this.grpLabels.Name = "grpLabels";
|
||||
this.grpLabels.Size = new System.Drawing.Size(392, 196);
|
||||
this.grpLabels.Size = new System.Drawing.Size(395, 195);
|
||||
this.grpLabels.TabIndex = 6;
|
||||
this.grpLabels.TabStop = false;
|
||||
this.grpLabels.Text = "Labels";
|
||||
@ -338,7 +339,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(386, 177);
|
||||
this.ctrlLabelList.Size = new System.Drawing.Size(389, 176);
|
||||
this.ctrlLabelList.TabIndex = 0;
|
||||
this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence);
|
||||
this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected);
|
||||
@ -349,7 +350,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(392, 196);
|
||||
this.grpFunctions.Size = new System.Drawing.Size(395, 194);
|
||||
this.grpFunctions.TabIndex = 5;
|
||||
this.grpFunctions.TabStop = false;
|
||||
this.grpFunctions.Text = "Functions";
|
||||
@ -359,7 +360,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(386, 177);
|
||||
this.ctrlFunctionList.Size = new System.Drawing.Size(389, 175);
|
||||
this.ctrlFunctionList.TabIndex = 0;
|
||||
this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence);
|
||||
this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected);
|
||||
@ -390,7 +391,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(1172, 162);
|
||||
this.tableLayoutPanel10.Size = new System.Drawing.Size(1172, 165);
|
||||
this.tableLayoutPanel10.TabIndex = 0;
|
||||
//
|
||||
// grpWatch
|
||||
@ -399,7 +400,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(384, 156);
|
||||
this.grpWatch.Size = new System.Drawing.Size(384, 159);
|
||||
this.grpWatch.TabIndex = 2;
|
||||
this.grpWatch.TabStop = false;
|
||||
this.grpWatch.Text = "Watch";
|
||||
@ -409,7 +410,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(378, 137);
|
||||
this.ctrlWatch.Size = new System.Drawing.Size(378, 140);
|
||||
this.ctrlWatch.TabIndex = 0;
|
||||
//
|
||||
// grpBreakpoints
|
||||
@ -418,7 +419,7 @@ namespace Mesen.GUI.Debugger
|
||||
this.grpBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grpBreakpoints.Location = new System.Drawing.Point(393, 3);
|
||||
this.grpBreakpoints.Name = "grpBreakpoints";
|
||||
this.grpBreakpoints.Size = new System.Drawing.Size(384, 156);
|
||||
this.grpBreakpoints.Size = new System.Drawing.Size(384, 159);
|
||||
this.grpBreakpoints.TabIndex = 3;
|
||||
this.grpBreakpoints.TabStop = false;
|
||||
this.grpBreakpoints.Text = "Breakpoints";
|
||||
@ -428,7 +429,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(378, 137);
|
||||
this.ctrlBreakpoints.Size = new System.Drawing.Size(378, 140);
|
||||
this.ctrlBreakpoints.TabIndex = 0;
|
||||
this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation);
|
||||
//
|
||||
@ -438,7 +439,7 @@ namespace Mesen.GUI.Debugger
|
||||
this.grpCallstack.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grpCallstack.Location = new System.Drawing.Point(783, 3);
|
||||
this.grpCallstack.Name = "grpCallstack";
|
||||
this.grpCallstack.Size = new System.Drawing.Size(386, 156);
|
||||
this.grpCallstack.Size = new System.Drawing.Size(386, 159);
|
||||
this.grpCallstack.TabIndex = 4;
|
||||
this.grpCallstack.TabStop = false;
|
||||
this.grpCallstack.Text = "Call Stack";
|
||||
@ -448,7 +449,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(380, 137);
|
||||
this.ctrlCallstack.Size = new System.Drawing.Size(380, 140);
|
||||
this.ctrlCallstack.TabIndex = 0;
|
||||
this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected);
|
||||
//
|
||||
@ -992,6 +993,7 @@ namespace Mesen.GUI.Debugger
|
||||
this.mnuBreakOnReset,
|
||||
this.mnuBreakOnUnofficialOpcodes,
|
||||
this.mnuBreakOnBrk,
|
||||
this.mnuBreakOnCrash,
|
||||
this.toolStripMenuItem15,
|
||||
this.mnuBreakOnOpen,
|
||||
this.mnuBreakOnDebuggerFocus});
|
||||
@ -1483,6 +1485,14 @@ namespace Mesen.GUI.Debugger
|
||||
this.tsToolbar.Text = "toolStrip1";
|
||||
this.tsToolbar.Visible = false;
|
||||
//
|
||||
// mnuBreakOnCrash
|
||||
//
|
||||
this.mnuBreakOnCrash.CheckOnClick = true;
|
||||
this.mnuBreakOnCrash.Name = "mnuBreakOnCrash";
|
||||
this.mnuBreakOnCrash.Size = new System.Drawing.Size(243, 22);
|
||||
this.mnuBreakOnCrash.Text = "Break on CPU crash";
|
||||
this.mnuBreakOnCrash.Click += new System.EventHandler(this.mnuBreakOnCrash_Click);
|
||||
//
|
||||
// frmDebugger
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -1666,5 +1676,6 @@ namespace Mesen.GUI.Debugger
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPpuShowPreviousFrame;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem19;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuEventViewer;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuBreakOnCrash;
|
||||
}
|
||||
}
|
@ -69,6 +69,7 @@ namespace Mesen.GUI.Debugger
|
||||
this.mnuBreakOnOpen.Checked = ConfigManager.Config.DebugInfo.BreakOnOpen;
|
||||
this.mnuBreakOnUnofficialOpcodes.Checked = ConfigManager.Config.DebugInfo.BreakOnUnofficialOpcodes;
|
||||
this.mnuBreakOnBrk.Checked = ConfigManager.Config.DebugInfo.BreakOnBrk;
|
||||
this.mnuBreakOnCrash.Checked = ConfigManager.Config.DebugInfo.BreakOnCrash;
|
||||
this.mnuBreakOnDebuggerFocus.Checked = ConfigManager.Config.DebugInfo.BreakOnDebuggerFocus;
|
||||
this.mnuDisplayOpCodesInLowerCase.Checked = ConfigManager.Config.DebugInfo.DisplayOpCodesInLowerCase;
|
||||
|
||||
@ -803,7 +804,14 @@ namespace Mesen.GUI.Debugger
|
||||
ConfigManager.Config.DebugInfo.BreakOnBrk = mnuBreakOnBrk.Checked;
|
||||
ConfigManager.ApplyChanges();
|
||||
}
|
||||
|
||||
|
||||
private void mnuBreakOnCrash_Click(object sender, EventArgs e)
|
||||
{
|
||||
ConfigManager.Config.DebugInfo.BreakOnCrash = mnuBreakOnCrash.Checked;
|
||||
ConfigManager.ApplyChanges();
|
||||
DebugInfo.ApplyConfig();
|
||||
}
|
||||
|
||||
private void mnuBreakOnDebuggerFocus_Click(object sender, EventArgs e)
|
||||
{
|
||||
ConfigManager.Config.DebugInfo.BreakOnDebuggerFocus = mnuBreakOnDebuggerFocus.Checked;
|
||||
|
@ -1491,6 +1491,7 @@ namespace Mesen.GUI
|
||||
IntegerFpsMode = 0x2000000000000,
|
||||
|
||||
DebuggerWindowEnabled = 0x4000000000000,
|
||||
BreakOnCrash = 0x8000000000000,
|
||||
|
||||
ForceMaxSpeed = 0x4000000000000000,
|
||||
ConsoleMode = 0x8000000000000000,
|
||||
|
Loading…
Reference in New Issue
Block a user