Debugger: Trace Logger - Fixed dead lock on power cycle when trace logger is opened

This commit is contained in:
Sour 2020-07-03 16:12:24 -04:00
parent b17fdc49c6
commit eb89559f4f
2 changed files with 38 additions and 32 deletions

View file

@ -153,7 +153,8 @@ namespace Mesen.GUI.Debugger
_entityBinder.UpdateObject(); _entityBinder.UpdateObject();
//Disable logging when we close the trace logger //Disable logging when we close the trace logger
SetOptions(true); _interopOptions = GetInteropOptions(true);
SetCoreOptions();
ConfigManager.ApplyChanges(); ConfigManager.ApplyChanges();
@ -243,34 +244,34 @@ namespace Mesen.GUI.Debugger
} }
} }
private void SetOptions(bool disableLogging = false) private InteropTraceLoggerOptions GetInteropOptions(bool disableLogging = false)
{ {
_entityBinder.UpdateObject(); _entityBinder.UpdateObject();
TraceLoggerOptions options = (TraceLoggerOptions)_entityBinder.Entity; TraceLoggerOptions options = (TraceLoggerOptions)_entityBinder.Entity;
CoprocessorType coproc = EmuApi.GetRomInfo().CoprocessorType; CoprocessorType coproc = EmuApi.GetRomInfo().CoprocessorType;
_interopOptions = new InteropTraceLoggerOptions(); InteropTraceLoggerOptions interopOptions = new InteropTraceLoggerOptions();
_interopOptions.LogCpu = !disableLogging && options.LogCpu && coproc != CoprocessorType.Gameboy; interopOptions.LogCpu = !disableLogging && options.LogCpu && coproc != CoprocessorType.Gameboy;
_interopOptions.LogSpc = !disableLogging && options.LogSpc && coproc != CoprocessorType.Gameboy; interopOptions.LogSpc = !disableLogging && options.LogSpc && coproc != CoprocessorType.Gameboy;
_interopOptions.LogNecDsp = !disableLogging && options.LogNecDsp; interopOptions.LogNecDsp = !disableLogging && options.LogNecDsp;
_interopOptions.LogSa1 = !disableLogging && options.LogSa1; interopOptions.LogSa1 = !disableLogging && options.LogSa1;
_interopOptions.LogGsu = !disableLogging && options.LogGsu; interopOptions.LogGsu = !disableLogging && options.LogGsu;
_interopOptions.LogCx4 = !disableLogging && options.LogCx4; interopOptions.LogCx4 = !disableLogging && options.LogCx4;
_interopOptions.LogGameboy = !disableLogging && options.LogGameboy; interopOptions.LogGameboy = !disableLogging && options.LogGameboy;
_interopOptions.IndentCode = options.IndentCode; interopOptions.IndentCode = options.IndentCode;
_interopOptions.ShowExtraInfo = options.ShowExtraInfo; interopOptions.ShowExtraInfo = options.ShowExtraInfo;
_interopOptions.UseLabels = options.UseLabels; interopOptions.UseLabels = options.UseLabels;
_interopOptions.UseWindowsEol = options.UseWindowsEol; interopOptions.UseWindowsEol = options.UseWindowsEol;
_interopOptions.ExtendZeroPage = options.ExtendZeroPage; interopOptions.ExtendZeroPage = options.ExtendZeroPage;
_interopOptions.Condition = Encoding.UTF8.GetBytes(txtCondition.Text); interopOptions.Condition = Encoding.UTF8.GetBytes(txtCondition.Text);
Array.Resize(ref _interopOptions.Condition, 1000); Array.Resize(ref interopOptions.Condition, 1000);
_interopOptions.Format = Encoding.UTF8.GetBytes(txtFormat.Text.Replace("\t", "\\t")); interopOptions.Format = Encoding.UTF8.GetBytes(txtFormat.Text.Replace("\t", "\\t"));
Array.Resize(ref _interopOptions.Format, 1000); Array.Resize(ref interopOptions.Format, 1000);
DebugApi.SetTraceOptions(_interopOptions); return interopOptions;
} }
private void SetCoreOptions() private void SetCoreOptions()
@ -286,7 +287,8 @@ namespace Mesen.GUI.Debugger
sfd.InitialDirectory = ConfigManager.DebuggerFolder; sfd.InitialDirectory = ConfigManager.DebuggerFolder;
if(sfd.ShowDialog() == DialogResult.OK) { if(sfd.ShowDialog() == DialogResult.OK) {
_lastFilename = sfd.FileName; _lastFilename = sfd.FileName;
SetOptions(); _interopOptions = GetInteropOptions();
SetCoreOptions();
DebugApi.StartTraceLogger(sfd.FileName); DebugApi.StartTraceLogger(sfd.FileName);
btnStartLogging.Enabled = false; btnStartLogging.Enabled = false;
@ -320,8 +322,10 @@ namespace Mesen.GUI.Debugger
} }
_refreshRunning = true; _refreshRunning = true;
SetOptions(); _interopOptions = GetInteropOptions();
Task.Run(() => { Task.Run(() => {
SetCoreOptions();
//Update trace log in another thread for performance //Update trace log in another thread for performance
DebugState state = DebugApi.GetState(); DebugState state = DebugApi.GetState();
if(_previousMasterClock != state.MasterClock || forceUpdate) { if(_previousMasterClock != state.MasterClock || forceUpdate) {

View file

@ -167,18 +167,20 @@ namespace Mesen.GUI.Forms
} }
})); }));
this.BeginInvoke((Action)(() => { Task.Run(() => {
UpdateDebuggerMenu(); this.BeginInvoke((Action)(() => {
ctrlRecentGames.Visible = false; UpdateDebuggerMenu();
SaveStateManager.UpdateStateMenu(mnuLoadState, false); ctrlRecentGames.Visible = false;
SaveStateManager.UpdateStateMenu(mnuSaveState, true); SaveStateManager.UpdateStateMenu(mnuLoadState, false);
SaveStateManager.UpdateStateMenu(mnuSaveState, true);
this.Text = "Mesen-S - " + romInfo.GetRomName(); this.Text = "Mesen-S - " + romInfo.GetRomName();
if(DebugWindowManager.HasOpenedWindow) { if(DebugWindowManager.HasOpenedWindow) {
DebugWorkspaceManager.GetWorkspace(); DebugWorkspaceManager.GetWorkspace();
} }
})); }));
});
break; break;
case ConsoleNotificationType.BeforeEmulationStop: case ConsoleNotificationType.BeforeEmulationStop: