mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
Debugger: Fixed crashes when switching between games from different consoles (in AOT build)
Caused by what looks like slight differences between how AOT treats an empty array (vs JIT builds) when it marshals the array (AOT sends a null pointer, JIT sends a pointer to an empty array) This was causing issues in both builds (AOT crashed immediately because of the null pointer, JIT read from out-of-bounds memory)
This commit is contained in:
parent
acbe931ba0
commit
1975ab958c
6 changed files with 20 additions and 7 deletions
|
@ -588,7 +588,9 @@ void Debugger::ProcessEvent(EventType type, std::optional<CpuType> cpuTypeOpt)
|
|||
break;
|
||||
|
||||
case EventType::StartFrame: {
|
||||
_emu->GetNotificationManager()->SendNotification(ConsoleNotificationType::EventViewerRefresh, (void*)evtCpuType);
|
||||
if(!_emu->IsDebuggerBlocked()) {
|
||||
_emu->GetNotificationManager()->SendNotification(ConsoleNotificationType::EventViewerRefresh, (void*)evtCpuType);
|
||||
}
|
||||
BaseEventManager* evtMgr = GetEventManager(evtCpuType);
|
||||
if(evtMgr) {
|
||||
evtMgr->ClearFrameEvents();
|
||||
|
|
|
@ -403,7 +403,9 @@ void PpuTools::UpdateViewers(uint16_t scanline, uint16_t cycle)
|
|||
for(auto updateTiming : _updateTimings) {
|
||||
ViewerRefreshConfig cfg = updateTiming.second;
|
||||
if(cfg.Cycle == cycle && cfg.Scanline == scanline) {
|
||||
_emu->GetNotificationManager()->SendNotification(ConsoleNotificationType::ViewerRefresh, (void*)(uint64_t)updateTiming.first);
|
||||
if(!_emu->IsDebuggerBlocked()) {
|
||||
_emu->GetNotificationManager()->SendNotification(ConsoleNotificationType::ViewerRefresh, (void*)(uint64_t)updateTiming.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ public:
|
|||
void Unlock();
|
||||
bool IsThreadPaused();
|
||||
|
||||
bool IsDebuggerBlocked() { return _blockDebuggerRequestCount > 0; }
|
||||
void SuspendDebugger(bool release);
|
||||
|
||||
void Serialize(ostream& out, bool includeSettings, int compressionLevel = 1);
|
||||
|
|
|
@ -528,7 +528,8 @@ namespace Mesen.Debugger.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
_coreData.Palette = DebugApi.GetPaletteInfo(CpuType);
|
||||
DebugPaletteInfo palette = DebugApi.GetPaletteInfo(CpuType);
|
||||
_coreData.Palette = palette.ColorCount > 0 ? palette : null;
|
||||
}
|
||||
RefreshTab();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace Mesen.Debugger.ViewModels
|
|||
private byte[] _coreSourceData = Array.Empty<byte>();
|
||||
private byte[] _sourceData = Array.Empty<byte>();
|
||||
private bool _refreshPending;
|
||||
private bool _inGameLoaded;
|
||||
|
||||
[Obsolete("For designer only")]
|
||||
public TileViewerViewModel() : this(CpuType.Snes, new PictureViewer(), null) { }
|
||||
|
@ -409,7 +410,9 @@ namespace Mesen.Debugger.ViewModels
|
|||
|
||||
private void Config_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
RefreshTab();
|
||||
if(!_inGameLoaded) {
|
||||
RefreshTab();
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshData()
|
||||
|
@ -460,7 +463,7 @@ namespace Mesen.Debugger.ViewModels
|
|||
|
||||
private void InternalRefreshTab()
|
||||
{
|
||||
if(Disposed) {
|
||||
if(Disposed || PaletteColors.Length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -650,8 +653,10 @@ namespace Mesen.Debugger.ViewModels
|
|||
public void OnGameLoaded()
|
||||
{
|
||||
Dispatcher.UIThread.Post(() => {
|
||||
_inGameLoaded = true;
|
||||
InitForCpuType();
|
||||
RefreshData();
|
||||
_inGameLoaded = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -415,7 +415,9 @@ namespace Mesen.Debugger.ViewModels
|
|||
|
||||
private void Config_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
RefreshTab();
|
||||
if(!_inGameLoaded) {
|
||||
RefreshTab();
|
||||
}
|
||||
}
|
||||
|
||||
[MemberNotNull(nameof(ViewerBitmap))]
|
||||
|
@ -487,7 +489,7 @@ namespace Mesen.Debugger.ViewModels
|
|||
_coreData.CopyTo(_data);
|
||||
}
|
||||
|
||||
if(_data.PpuState == null || _data.PpuToolsState == null) {
|
||||
if(_data.PpuState == null || _data.PpuToolsState == null || _data.RgbPalette.Length == 0) {
|
||||
_refreshPending = false;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue