From 147a5f0e7588d0ab1fcee7470f8b236b74b4e499 Mon Sep 17 00:00:00 2001
From: alyosha-tas <alexei.f.k@gmail.com>
Date: Mon, 31 May 2021 21:58:01 -0400
Subject: [PATCH] Debugger: full update on restart, remove breakpoints before
 closing

---
 src/BizHawk.Client.EmuHawk/MainForm.cs                       | 5 +++++
 .../tools/Debugger/GenericDebugger.IToolForm.cs              | 1 +
 src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs | 1 +
 3 files changed, 7 insertions(+)

diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs
index 209596a8e4..1b2e1a8eab 100644
--- a/src/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/src/BizHawk.Client.EmuHawk/MainForm.cs
@@ -3729,6 +3729,11 @@ namespace BizHawk.Client.EmuHawk
 				loader.OnLoadSettings += CoreSettings;
 				loader.OnLoadSyncSettings += CoreSyncSettings;
 
+				if (Tools.IsLoaded<GenericDebugger>())
+				{
+					Tools.Restart<GenericDebugger>();
+				}
+
 				// this also happens in CloseGame(). But it needs to happen here since if we're restarting with the same core,
 				// any settings changes that we made need to make it back to config before we try to instantiate that core with
 				// the new settings objects
diff --git a/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs b/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs
index 52d48379d4..37f76484e4 100644
--- a/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.IToolForm.cs
@@ -138,6 +138,7 @@ namespace BizHawk.Client.EmuHawk
 		{
 			DisengageDebugger();
 			EngageDebugger();
+			FullUpdate();
 		}
 	}
 }
diff --git a/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs b/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs
index d89f0d469a..85703a43d6 100644
--- a/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs
@@ -89,6 +89,7 @@ namespace BizHawk.Client.EmuHawk
 
 				_pcRegisterSize = Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].BitSize / 4;
 				SetDisassemblerItemCount();
+				UpdatePC();
 				UpdateDisassembler();
 			}
 			else