Skip to content

Commit

Permalink
Call Host_NotifyMapLoaded when clearing g_symbolDB
Browse files Browse the repository at this point in the history
Otherwise DolphinQt will have a stale symbol list and
you can get nullptr dereferences when trying to use it.
  • Loading branch information
JosJuice committed May 1, 2019
1 parent d9999f4 commit 8fd6f8f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Source/Core/Common/SymbolDB.cpp
Expand Up @@ -42,6 +42,11 @@ void SymbolDB::List()
INFO_LOG(OSHLE, "%zu functions known in this program above.", m_functions.size());
}

bool SymbolDB::IsEmpty() const
{
return m_functions.empty();
}

void SymbolDB::Clear(const char* prefix)
{
// TODO: honor prefix
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Common/SymbolDB.h
Expand Up @@ -78,6 +78,7 @@ class SymbolDB

const XFuncMap& Symbols() const { return m_functions; }
XFuncMap& AccessSymbols() { return m_functions; }
bool IsEmpty() const;
void Clear(const char* prefix = "");
void List();
void Index();
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/Core/Boot/Boot.cpp
Expand Up @@ -383,7 +383,11 @@ bool CBoot::BootUp(std::unique_ptr<BootParameters> boot)
{
SConfig& config = SConfig::GetInstance();

g_symbolDB.Clear();
if (!g_symbolDB.IsEmpty())
{
g_symbolDB.Clear();
UpdateDebugger_MapLoaded();
}

// PAL Wii uses NTSC framerate and linecount in 60Hz modes
VideoInterface::Preset(DiscIO::IsNTSC(config.m_region) ||
Expand Down
7 changes: 6 additions & 1 deletion Source/Core/Core/ConfigManager.cpp
Expand Up @@ -35,6 +35,7 @@
#include "Core/HLE/HLE.h"
#include "Core/HW/DVD/DVDInterface.h"
#include "Core/HW/SI/SI.h"
#include "Core/Host.h"
#include "Core/IOS/ES/ES.h"
#include "Core/IOS/ES/Formats.h"
#include "Core/PatchEngine.h"
Expand Down Expand Up @@ -724,7 +725,11 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
if (Core::IsRunning())
{
// TODO: have a callback mechanism for title changes?
g_symbolDB.Clear();
if (!g_symbolDB.IsEmpty())
{
g_symbolDB.Clear();
Host_NotifyMapLoaded();
}
CBoot::LoadMapFromFilename();
HLE::Reload();
PatchEngine::Reload();
Expand Down
8 changes: 7 additions & 1 deletion Source/Core/Core/IOS/MIOS.cpp
Expand Up @@ -20,6 +20,7 @@
#include "Core/HW/DVD/DVDInterface.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/SystemTimers.h"
#include "Core/Host.h"
#include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/PowerPC.h"

Expand Down Expand Up @@ -52,11 +53,16 @@ bool Load()
NOTICE_LOG(IOS, "Reinitialised hardware.");

// Load symbols for the IPL if they exist.
g_symbolDB.Clear();
if (!g_symbolDB.IsEmpty())
{
g_symbolDB.Clear();
Host_NotifyMapLoaded();
}
if (g_symbolDB.LoadMap(File::GetUserPath(D_MAPS_IDX) + "mios-ipl.map"))
{
::HLE::Clear();
::HLE::PatchFunctions();
Host_NotifyMapLoaded();
}

const PowerPC::CoreMode core_mode = PowerPC::GetMode();
Expand Down

0 comments on commit 8fd6f8f

Please sign in to comment.