mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Merge pull request #12630 from mitaclaw/ppc-symbols-global
PPCSymbolDB: Move instance to PowerPCManager
This commit is contained in:
@ -376,11 +376,11 @@ bool CBoot::FindMapFile(std::string* existing_map_file, std::string* writable_ma
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBoot::LoadMapFromFilename(const Core::CPUThreadGuard& guard)
|
||||
bool CBoot::LoadMapFromFilename(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db)
|
||||
{
|
||||
std::string strMapFilename;
|
||||
bool found = FindMapFile(&strMapFilename, nullptr);
|
||||
if (found && g_symbolDB.LoadMap(guard, strMapFilename))
|
||||
if (found && ppc_symbol_db.LoadMap(guard, strMapFilename))
|
||||
{
|
||||
UpdateDebugger_MapLoaded();
|
||||
return true;
|
||||
@ -514,9 +514,9 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
||||
{
|
||||
SConfig& config = SConfig::GetInstance();
|
||||
|
||||
if (!g_symbolDB.IsEmpty())
|
||||
if (auto& ppc_symbol_db = system.GetPPCSymbolDB(); !ppc_symbol_db.IsEmpty())
|
||||
{
|
||||
g_symbolDB.Clear();
|
||||
ppc_symbol_db.Clear();
|
||||
UpdateDebugger_MapLoaded();
|
||||
}
|
||||
|
||||
@ -595,7 +595,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
||||
|
||||
ppc_state.pc = executable.reader->GetEntryPoint();
|
||||
|
||||
if (executable.reader->LoadSymbols(guard))
|
||||
if (executable.reader->LoadSymbols(guard, system.GetPPCSymbolDB()))
|
||||
{
|
||||
UpdateDebugger_MapLoaded();
|
||||
HLE::PatchFunctions(system);
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "DiscIO/VolumeDisc.h"
|
||||
#include "DiscIO/VolumeWad.h"
|
||||
|
||||
class PPCSymbolDB;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class CPUThreadGuard;
|
||||
@ -168,7 +170,7 @@ public:
|
||||
//
|
||||
// Returns true if a map file exists, false if none could be found.
|
||||
static bool FindMapFile(std::string* existing_map_file, std::string* writable_map_file);
|
||||
static bool LoadMapFromFilename(const Core::CPUThreadGuard& guard);
|
||||
static bool LoadMapFromFilename(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db);
|
||||
|
||||
private:
|
||||
static bool DVDRead(Core::System& system, const DiscIO::VolumeDisc& disc, u64 dvd_offset,
|
||||
@ -215,7 +217,7 @@ public:
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual bool IsWii() const = 0;
|
||||
virtual bool LoadIntoMemory(Core::System& system, bool only_in_mem1 = false) const = 0;
|
||||
virtual bool LoadSymbols(const Core::CPUThreadGuard& guard) const = 0;
|
||||
virtual bool LoadSymbols(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db) const = 0;
|
||||
|
||||
protected:
|
||||
std::vector<u8> m_bytes;
|
||||
|
@ -27,7 +27,10 @@ public:
|
||||
bool IsAncast() const { return m_is_ancast; };
|
||||
u32 GetEntryPoint() const override { return m_dolheader.entryPoint; }
|
||||
bool LoadIntoMemory(Core::System& system, bool only_in_mem1 = false) const override;
|
||||
bool LoadSymbols(const Core::CPUThreadGuard& guard) const override { return false; }
|
||||
bool LoadSymbols(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db) const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
enum
|
||||
|
@ -180,7 +180,7 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool ElfReader::LoadSymbols(const Core::CPUThreadGuard& guard) const
|
||||
bool ElfReader::LoadSymbols(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db) const
|
||||
{
|
||||
bool hasSymbols = false;
|
||||
SectionID sec = GetSectionByName(".symtab");
|
||||
@ -218,11 +218,11 @@ bool ElfReader::LoadSymbols(const Core::CPUThreadGuard& guard) const
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
g_symbolDB.AddKnownSymbol(guard, value, size, name, symtype);
|
||||
ppc_symbol_db.AddKnownSymbol(guard, value, size, name, symtype);
|
||||
hasSymbols = true;
|
||||
}
|
||||
}
|
||||
g_symbolDB.Index();
|
||||
ppc_symbol_db.Index();
|
||||
return hasSymbols;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
u32 GetEntryPoint() const override { return entryPoint; }
|
||||
u32 GetFlags() const { return (u32)(header->e_flags); }
|
||||
bool LoadIntoMemory(Core::System& system, bool only_in_mem1 = false) const override;
|
||||
bool LoadSymbols(const Core::CPUThreadGuard& guard) const override;
|
||||
bool LoadSymbols(const Core::CPUThreadGuard& guard, PPCSymbolDB& ppc_symbol_db) const override;
|
||||
// TODO: actually check for validity.
|
||||
bool IsValid() const override { return true; }
|
||||
bool IsWii() const override;
|
||||
|
@ -205,13 +205,14 @@ void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard)
|
||||
if (!Core::IsRunning())
|
||||
return;
|
||||
|
||||
if (!g_symbolDB.IsEmpty())
|
||||
auto& system = guard.GetSystem();
|
||||
auto& ppc_symbol_db = system.GetPPCSymbolDB();
|
||||
if (!ppc_symbol_db.IsEmpty())
|
||||
{
|
||||
g_symbolDB.Clear();
|
||||
ppc_symbol_db.Clear();
|
||||
Host_NotifyMapLoaded();
|
||||
}
|
||||
CBoot::LoadMapFromFilename(guard);
|
||||
auto& system = Core::System::GetInstance();
|
||||
CBoot::LoadMapFromFilename(guard, ppc_symbol_db);
|
||||
HLE::Reload(system);
|
||||
PatchEngine::Reload();
|
||||
HiresTexture::Update();
|
||||
|
@ -54,7 +54,8 @@ static void WalkTheStack(const Core::CPUThreadGuard& guard,
|
||||
// instead of "pointing ahead"
|
||||
bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>& output)
|
||||
{
|
||||
const auto& ppc_state = guard.GetSystem().GetPPCState();
|
||||
auto& power_pc = guard.GetSystem().GetPowerPC();
|
||||
const auto& ppc_state = power_pc.GetPPCState();
|
||||
|
||||
if (!Core::IsRunning() || !PowerPC::MMU::HostIsRAMAddress(guard, ppc_state.gpr[1]))
|
||||
return false;
|
||||
@ -68,14 +69,16 @@ bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
|
||||
output.push_back({
|
||||
.Name = fmt::format(" * {} [ LR = {:08x} ]\n", g_symbolDB.GetDescription(LR(ppc_state)),
|
||||
.Name = fmt::format(" * {} [ LR = {:08x} ]\n", ppc_symbol_db.GetDescription(LR(ppc_state)),
|
||||
LR(ppc_state) - 4),
|
||||
.vAddress = LR(ppc_state) - 4,
|
||||
});
|
||||
|
||||
WalkTheStack(guard, [&output](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
WalkTheStack(guard, [&output, &ppc_symbol_db](u32 func_addr) {
|
||||
std::string func_desc = ppc_symbol_db.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
|
||||
@ -91,7 +94,9 @@ bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>
|
||||
void PrintCallstack(const Core::CPUThreadGuard& guard, Common::Log::LogType type,
|
||||
Common::Log::LogLevel level)
|
||||
{
|
||||
const auto& ppc_state = guard.GetSystem().GetPPCState();
|
||||
auto& power_pc = guard.GetSystem().GetPowerPC();
|
||||
const auto& ppc_state = power_pc.GetPPCState();
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
|
||||
GENERIC_LOG_FMT(type, level, "== STACK TRACE - SP = {:08x} ==", ppc_state.gpr[1]);
|
||||
|
||||
@ -100,14 +105,14 @@ void PrintCallstack(const Core::CPUThreadGuard& guard, Common::Log::LogType type
|
||||
GENERIC_LOG_FMT(type, level, " LR = 0 - this is bad");
|
||||
}
|
||||
|
||||
if (g_symbolDB.GetDescription(ppc_state.pc) != g_symbolDB.GetDescription(LR(ppc_state)))
|
||||
if (ppc_symbol_db.GetDescription(ppc_state.pc) != ppc_symbol_db.GetDescription(LR(ppc_state)))
|
||||
{
|
||||
GENERIC_LOG_FMT(type, level, " * {} [ LR = {:08x} ]", g_symbolDB.GetDescription(LR(ppc_state)),
|
||||
LR(ppc_state));
|
||||
GENERIC_LOG_FMT(type, level, " * {} [ LR = {:08x} ]",
|
||||
ppc_symbol_db.GetDescription(LR(ppc_state)), LR(ppc_state));
|
||||
}
|
||||
|
||||
WalkTheStack(guard, [type, level](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
WalkTheStack(guard, [type, level, &ppc_symbol_db](u32 func_addr) {
|
||||
std::string func_desc = ppc_symbol_db.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
GENERIC_LOG_FMT(type, level, " * {} [ addr = {:08x} ]", func_desc, func_addr);
|
||||
|
@ -90,7 +90,8 @@ void PPCPatches::UnPatch(std::size_t index)
|
||||
PatchEngine::RemoveMemoryPatch(index);
|
||||
}
|
||||
|
||||
PPCDebugInterface::PPCDebugInterface(Core::System& system) : m_system(system)
|
||||
PPCDebugInterface::PPCDebugInterface(Core::System& system, PPCSymbolDB& ppc_symbol_db)
|
||||
: m_system(system), m_ppc_symbol_db(ppc_symbol_db)
|
||||
{
|
||||
}
|
||||
|
||||
@ -423,7 +424,7 @@ u32 PPCDebugInterface::GetColor(const Core::CPUThreadGuard* guard, u32 address)
|
||||
if (!PowerPC::MMU::HostIsRAMAddress(*guard, address))
|
||||
return 0xeeeeee;
|
||||
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
const Common::Symbol* const symbol = m_ppc_symbol_db.GetSymbolFromAddr(address);
|
||||
if (!symbol)
|
||||
return 0xFFFFFF;
|
||||
if (symbol->type != Common::Symbol::Type::Function)
|
||||
@ -443,7 +444,7 @@ u32 PPCDebugInterface::GetColor(const Core::CPUThreadGuard* guard, u32 address)
|
||||
|
||||
std::string PPCDebugInterface::GetDescription(u32 address) const
|
||||
{
|
||||
return g_symbolDB.GetDescription(address);
|
||||
return m_ppc_symbol_db.GetDescription(address);
|
||||
}
|
||||
|
||||
std::optional<u32>
|
||||
|
@ -17,6 +17,7 @@ namespace Core
|
||||
class CPUThreadGuard;
|
||||
class System;
|
||||
} // namespace Core
|
||||
class PPCSymbolDB;
|
||||
|
||||
void ApplyMemoryPatch(const Core::CPUThreadGuard&, Common::Debug::MemoryPatch& patch,
|
||||
bool store_existing_value = true);
|
||||
@ -36,7 +37,7 @@ private:
|
||||
class PPCDebugInterface final : public Core::DebugInterface
|
||||
{
|
||||
public:
|
||||
explicit PPCDebugInterface(Core::System& system);
|
||||
explicit PPCDebugInterface(Core::System& system, PPCSymbolDB& ppc_symbol_db);
|
||||
~PPCDebugInterface() override;
|
||||
|
||||
// Watches
|
||||
@ -112,4 +113,5 @@ private:
|
||||
PPCPatches m_patches;
|
||||
std::shared_ptr<Core::NetworkCaptureLogger> m_network_logger;
|
||||
Core::System& m_system;
|
||||
PPCSymbolDB& m_ppc_symbol_db;
|
||||
};
|
||||
|
@ -106,7 +106,9 @@ void PatchFixedFunctions(Core::System& system)
|
||||
|
||||
void PatchFunctions(Core::System& system)
|
||||
{
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_state = power_pc.GetPPCState();
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
|
||||
// Remove all hooks that aren't fixed address hooks
|
||||
for (auto i = s_hooked_addresses.begin(); i != s_hooked_addresses.end();)
|
||||
@ -128,7 +130,7 @@ void PatchFunctions(Core::System& system)
|
||||
if (os_patches[i].flags == HookFlag::Fixed)
|
||||
continue;
|
||||
|
||||
for (const auto& symbol : g_symbolDB.GetSymbolsFromName(os_patches[i].name))
|
||||
for (const auto& symbol : ppc_symbol_db.GetSymbolsFromName(os_patches[i].name))
|
||||
{
|
||||
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
|
||||
{
|
||||
@ -178,14 +180,14 @@ u32 GetHookByAddress(u32 address)
|
||||
return (iter != s_hooked_addresses.end()) ? iter->second : 0;
|
||||
}
|
||||
|
||||
u32 GetHookByFunctionAddress(u32 address)
|
||||
u32 GetHookByFunctionAddress(PPCSymbolDB& ppc_symbol_db, u32 address)
|
||||
{
|
||||
const u32 index = GetHookByAddress(address);
|
||||
// Fixed hooks use a fixed address and don't patch the whole function
|
||||
if (index == 0 || os_patches[index].flags == HookFlag::Fixed)
|
||||
return index;
|
||||
|
||||
const auto symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
const Common::Symbol* const symbol = ppc_symbol_db.GetSymbolFromAddr(address);
|
||||
return (symbol && symbol->address == address) ? index : 0;
|
||||
}
|
||||
|
||||
@ -199,9 +201,10 @@ HookFlag GetHookFlagsByIndex(u32 index)
|
||||
return os_patches[index].flags;
|
||||
}
|
||||
|
||||
TryReplaceFunctionResult TryReplaceFunction(u32 address, PowerPC::CoreMode mode)
|
||||
TryReplaceFunctionResult TryReplaceFunction(PPCSymbolDB& ppc_symbol_db, u32 address,
|
||||
PowerPC::CoreMode mode)
|
||||
{
|
||||
const u32 hook_index = GetHookByFunctionAddress(address);
|
||||
const u32 hook_index = GetHookByFunctionAddress(ppc_symbol_db, address);
|
||||
if (hook_index == 0)
|
||||
return {};
|
||||
|
||||
@ -229,7 +232,8 @@ u32 UnPatch(Core::System& system, std::string_view patch_name)
|
||||
if (patch == std::end(os_patches))
|
||||
return 0;
|
||||
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_state = power_pc.GetPPCState();
|
||||
|
||||
if (patch->flags == HookFlag::Fixed)
|
||||
{
|
||||
@ -252,10 +256,10 @@ u32 UnPatch(Core::System& system, std::string_view patch_name)
|
||||
return addr;
|
||||
}
|
||||
|
||||
const auto& symbols = g_symbolDB.GetSymbolsFromName(patch_name);
|
||||
const auto symbols = power_pc.GetSymbolDB().GetSymbolsFromName(patch_name);
|
||||
if (!symbols.empty())
|
||||
{
|
||||
const auto& symbol = symbols[0];
|
||||
const Common::Symbol* const symbol = symbols.front();
|
||||
for (u32 addr = symbol->address; addr < symbol->address + symbol->size; addr += 4)
|
||||
{
|
||||
s_hooked_addresses.erase(addr);
|
||||
|
@ -18,6 +18,8 @@ namespace PowerPC
|
||||
enum class CoreMode;
|
||||
}
|
||||
|
||||
class PPCSymbolDB;
|
||||
|
||||
namespace HLE
|
||||
{
|
||||
using HookFunction = void (*)(const Core::CPUThreadGuard&);
|
||||
@ -66,7 +68,7 @@ void ExecuteFromJIT(u32 current_pc, u32 hook_index, Core::System& system);
|
||||
// Returns the HLE hook index of the address
|
||||
u32 GetHookByAddress(u32 address);
|
||||
// Returns the HLE hook index if the address matches the function start
|
||||
u32 GetHookByFunctionAddress(u32 address);
|
||||
u32 GetHookByFunctionAddress(PPCSymbolDB& ppc_symbol_db, u32 address);
|
||||
HookType GetHookTypeByIndex(u32 index);
|
||||
HookFlag GetHookFlagsByIndex(u32 index);
|
||||
|
||||
@ -74,6 +76,7 @@ bool IsEnabled(HookFlag flag, PowerPC::CoreMode mode);
|
||||
|
||||
// Performs the backend-independent preliminary checking for whether a function
|
||||
// can be HLEd. If it can be, the information needed for HLEing it is returned.
|
||||
TryReplaceFunctionResult TryReplaceFunction(u32 address, PowerPC::CoreMode mode);
|
||||
TryReplaceFunctionResult TryReplaceFunction(PPCSymbolDB& ppc_symbol_db, u32 address,
|
||||
PowerPC::CoreMode mode);
|
||||
|
||||
} // namespace HLE
|
||||
|
@ -67,21 +67,22 @@ bool Load(Core::System& system)
|
||||
ReinitHardware(system);
|
||||
NOTICE_LOG_FMT(IOS, "Reinitialised hardware.");
|
||||
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
|
||||
// Load symbols for the IPL if they exist.
|
||||
if (!g_symbolDB.IsEmpty())
|
||||
if (!ppc_symbol_db.IsEmpty())
|
||||
{
|
||||
g_symbolDB.Clear();
|
||||
ppc_symbol_db.Clear();
|
||||
Host_NotifyMapLoaded();
|
||||
}
|
||||
if (g_symbolDB.LoadMap(guard, File::GetUserPath(D_MAPS_IDX) + "mios-ipl.map"))
|
||||
if (ppc_symbol_db.LoadMap(guard, File::GetUserPath(D_MAPS_IDX) + "mios-ipl.map"))
|
||||
{
|
||||
::HLE::Clear();
|
||||
::HLE::PatchFunctions(system);
|
||||
Host_NotifyMapLoaded();
|
||||
}
|
||||
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
|
||||
const PowerPC::CoreMode core_mode = power_pc.GetMode();
|
||||
power_pc.SetMode(PowerPC::CoreMode::Interpreter);
|
||||
|
||||
|
@ -365,8 +365,7 @@ bool MemChecks::OverlapsMemcheck(u32 address, u32 length) const
|
||||
});
|
||||
}
|
||||
|
||||
bool TMemCheck::Action(Core::System& system, Core::DebugInterface* debug_interface, u64 value,
|
||||
u32 addr, bool write, size_t size, u32 pc)
|
||||
bool TMemCheck::Action(Core::System& system, u64 value, u32 addr, bool write, size_t size, u32 pc)
|
||||
{
|
||||
if (!is_enabled)
|
||||
return false;
|
||||
@ -376,9 +375,10 @@ bool TMemCheck::Action(Core::System& system, Core::DebugInterface* debug_interfa
|
||||
{
|
||||
if (log_on_hit)
|
||||
{
|
||||
auto& ppc_symbol_db = system.GetPPCSymbolDB();
|
||||
NOTICE_LOG_FMT(MEMMAP, "MBP {:08x} ({}) {}{} {:x} at {:08x} ({})", pc,
|
||||
debug_interface->GetDescription(pc), write ? "Write" : "Read", size * 8, value,
|
||||
addr, debug_interface->GetDescription(addr));
|
||||
ppc_symbol_db.GetDescription(pc), write ? "Write" : "Read", size * 8, value,
|
||||
addr, ppc_symbol_db.GetDescription(addr));
|
||||
}
|
||||
if (break_on_hit)
|
||||
return true;
|
||||
|
@ -11,10 +11,6 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/PowerPC/Expression.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class DebugInterface;
|
||||
}
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
@ -49,8 +45,7 @@ struct TMemCheck
|
||||
std::optional<Expression> condition;
|
||||
|
||||
// returns whether to break
|
||||
bool Action(Core::System& system, Core::DebugInterface* debug_interface, u64 value, u32 addr,
|
||||
bool write, size_t size, u32 pc);
|
||||
bool Action(Core::System& system, u64 value, u32 addr, bool write, size_t size, u32 pc);
|
||||
};
|
||||
|
||||
// Code breakpoints.
|
||||
|
@ -271,7 +271,7 @@ bool CachedInterpreter::HandleFunctionHooking(u32 address)
|
||||
{
|
||||
// CachedInterpreter inherits from JitBase and is considered a JIT by relevant code.
|
||||
// (see JitInterface and how m_mode is set within PowerPC.cpp)
|
||||
const auto result = HLE::TryReplaceFunction(address, PowerPC::CoreMode::JIT);
|
||||
const auto result = HLE::TryReplaceFunction(m_ppc_symbol_db, address, PowerPC::CoreMode::JIT);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
|
@ -65,8 +65,9 @@ void Interpreter::UpdatePC()
|
||||
}
|
||||
|
||||
Interpreter::Interpreter(Core::System& system, PowerPC::PowerPCState& ppc_state, PowerPC::MMU& mmu,
|
||||
Core::BranchWatch& branch_watch)
|
||||
: m_system(system), m_ppc_state(ppc_state), m_mmu(mmu), m_branch_watch(branch_watch)
|
||||
Core::BranchWatch& branch_watch, PPCSymbolDB& ppc_symbol_db)
|
||||
: m_system(system), m_ppc_state(ppc_state), m_mmu(mmu), m_branch_watch(branch_watch),
|
||||
m_ppc_symbol_db(ppc_symbol_db)
|
||||
{
|
||||
}
|
||||
|
||||
@ -107,7 +108,8 @@ void Interpreter::Trace(const UGeckoInstruction& inst)
|
||||
|
||||
bool Interpreter::HandleFunctionHooking(u32 address)
|
||||
{
|
||||
const auto result = HLE::TryReplaceFunction(address, PowerPC::CoreMode::Interpreter);
|
||||
const auto result =
|
||||
HLE::TryReplaceFunction(m_ppc_symbol_db, address, PowerPC::CoreMode::Interpreter);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
|
@ -19,12 +19,13 @@ namespace PowerPC
|
||||
class MMU;
|
||||
struct PowerPCState;
|
||||
} // namespace PowerPC
|
||||
class PPCSymbolDB;
|
||||
|
||||
class Interpreter : public CPUCoreBase
|
||||
{
|
||||
public:
|
||||
Interpreter(Core::System& system, PowerPC::PowerPCState& ppc_state, PowerPC::MMU& mmu,
|
||||
Core::BranchWatch& branch_watch);
|
||||
Core::BranchWatch& branch_watch, PPCSymbolDB& ppc_symbol_db);
|
||||
Interpreter(const Interpreter&) = delete;
|
||||
Interpreter(Interpreter&&) = delete;
|
||||
Interpreter& operator=(const Interpreter&) = delete;
|
||||
@ -317,6 +318,7 @@ private:
|
||||
PowerPC::PowerPCState& m_ppc_state;
|
||||
PowerPC::MMU& m_mmu;
|
||||
Core::BranchWatch& m_branch_watch;
|
||||
PPCSymbolDB& m_ppc_symbol_db;
|
||||
|
||||
UGeckoInstruction m_prev_inst{};
|
||||
u32 m_last_pc = 0;
|
||||
|
@ -1285,7 +1285,7 @@ void Jit64::IntializeSpeculativeConstants()
|
||||
|
||||
bool Jit64::HandleFunctionHooking(u32 address)
|
||||
{
|
||||
const auto result = HLE::TryReplaceFunction(address, PowerPC::CoreMode::JIT);
|
||||
const auto result = HLE::TryReplaceFunction(m_ppc_symbol_db, address, PowerPC::CoreMode::JIT);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
|
@ -781,7 +781,7 @@ void JitArm64::WriteConditionalExceptionExit(int exception, ARM64Reg temp_gpr, A
|
||||
|
||||
bool JitArm64::HandleFunctionHooking(u32 address)
|
||||
{
|
||||
const auto result = HLE::TryReplaceFunction(address, PowerPC::CoreMode::JIT);
|
||||
const auto result = HLE::TryReplaceFunction(m_ppc_symbol_db, address, PowerPC::CoreMode::JIT);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
|
@ -94,7 +94,8 @@ void JitTrampoline(JitBase& jit, u32 em_address)
|
||||
|
||||
JitBase::JitBase(Core::System& system)
|
||||
: m_code_buffer(code_buffer_size), m_system(system), m_ppc_state(system.GetPPCState()),
|
||||
m_mmu(system.GetMMU()), m_branch_watch(system.GetPowerPC().GetBranchWatch())
|
||||
m_mmu(system.GetMMU()), m_branch_watch(system.GetPowerPC().GetBranchWatch()),
|
||||
m_ppc_symbol_db(system.GetPPCSymbolDB())
|
||||
{
|
||||
m_registered_config_callback_id = CPUThreadConfigCallback::AddConfigChangedCallback([this] {
|
||||
if (DoesConfigNeedRefresh())
|
||||
|
@ -31,6 +31,7 @@ namespace PowerPC
|
||||
class MMU;
|
||||
struct PowerPCState;
|
||||
} // namespace PowerPC
|
||||
class PPCSymbolDB;
|
||||
|
||||
//#define JIT_LOG_GENERATED_CODE // Enables logging of generated code
|
||||
//#define JIT_LOG_GPR // Enables logging of the PPC general purpose regs
|
||||
@ -208,6 +209,7 @@ public:
|
||||
PowerPC::PowerPCState& m_ppc_state;
|
||||
PowerPC::MMU& m_mmu;
|
||||
Core::BranchWatch& m_branch_watch;
|
||||
PPCSymbolDB& m_ppc_symbol_db;
|
||||
};
|
||||
|
||||
void JitTrampoline(JitBase& jit, u32 em_address);
|
||||
|
@ -152,7 +152,7 @@ void JitBaseBlockCache::FinalizeBlock(JitBlock& block, bool block_link,
|
||||
|
||||
Common::Symbol* symbol = nullptr;
|
||||
if (Common::JitRegister::IsEnabled() &&
|
||||
(symbol = g_symbolDB.GetSymbolFromAddr(block.effectiveAddress)) != nullptr)
|
||||
(symbol = m_jit.m_ppc_symbol_db.GetSymbolFromAddr(block.effectiveAddress)) != nullptr)
|
||||
{
|
||||
Common::JitRegister::Register(block.normalEntry, block.codeSize, "JIT_PPC_{}_{:08x}",
|
||||
symbol->function_name.c_str(), block.physicalAddress);
|
||||
|
@ -138,7 +138,7 @@ void JitInterface::WriteProfileResults(const std::string& filename) const
|
||||
"ms)\tblkCodeSize\n");
|
||||
for (auto& stat : prof_stats.block_stats)
|
||||
{
|
||||
std::string name = g_symbolDB.GetDescription(stat.addr);
|
||||
std::string name = m_system.GetPPCSymbolDB().GetDescription(stat.addr);
|
||||
double percent = 100.0 * (double)stat.cost / (double)prof_stats.cost_sum;
|
||||
double timePercent = 100.0 * (double)stat.tick_counter / (double)prof_stats.timecost_sum;
|
||||
f.WriteString(fmt::format("{0:08x}\t{1}\t{2}\t{3}\t{4}\t{5:.2f}\t{6:.2f}\t{7:.2f}\t{8}\n",
|
||||
|
@ -558,8 +558,7 @@ void MMU::Memcheck(u32 address, u64 var, bool write, size_t size)
|
||||
|
||||
mc->num_hits++;
|
||||
|
||||
const bool pause = mc->Action(m_system, &m_power_pc.GetDebugInterface(), var, address, write,
|
||||
size, m_ppc_state.pc);
|
||||
const bool pause = mc->Action(m_system, var, address, write, size, m_ppc_state.pc);
|
||||
if (!pause)
|
||||
return;
|
||||
|
||||
|
@ -187,12 +187,12 @@ bool ReanalyzeFunction(const Core::CPUThreadGuard& guard, u32 start_addr, Common
|
||||
|
||||
// Second pass analysis, done after the first pass is done for all functions
|
||||
// so we have more information to work with
|
||||
static void AnalyzeFunction2(Common::Symbol* func)
|
||||
static void AnalyzeFunction2(PPCSymbolDB* func_db, Common::Symbol* func)
|
||||
{
|
||||
u32 flags = func->flags;
|
||||
|
||||
bool nonleafcall = std::any_of(func->calls.begin(), func->calls.end(), [](const auto& call) {
|
||||
const Common::Symbol* called_func = g_symbolDB.GetSymbolFromAddr(call.function);
|
||||
bool nonleafcall = std::any_of(func->calls.begin(), func->calls.end(), [&](const auto& call) {
|
||||
const Common::Symbol* const called_func = func_db->GetSymbolFromAddr(call.function);
|
||||
return called_func && (called_func->flags & Common::FFLAG_LEAF) == 0;
|
||||
});
|
||||
|
||||
@ -408,7 +408,7 @@ void FindFunctions(const Core::CPUThreadGuard& guard, u32 startAddr, u32 endAddr
|
||||
WARN_LOG_FMT(SYMBOLS, "Weird function");
|
||||
continue;
|
||||
}
|
||||
AnalyzeFunction2(&(func.second));
|
||||
AnalyzeFunction2(func_db, &(func.second));
|
||||
Common::Symbol& f = func.second;
|
||||
if (f.name.substr(0, 3) == "zzz")
|
||||
{
|
||||
@ -824,7 +824,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
|
||||
|
||||
const bool enable_follow = m_enable_branch_following;
|
||||
|
||||
auto& mmu = Core::System::GetInstance().GetMMU();
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& mmu = system.GetMMU();
|
||||
for (std::size_t i = 0; i < block_size; ++i)
|
||||
{
|
||||
auto result = mmu.TryReadInstruction(address);
|
||||
@ -979,6 +980,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
|
||||
block->m_broken = true;
|
||||
}
|
||||
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_symbol_db = power_pc.GetSymbolDB();
|
||||
// Scan for flag dependencies; assume the next block (or any branch that can leave the block)
|
||||
// wants flags, to be safe.
|
||||
bool wantsFPRF = true;
|
||||
@ -998,8 +1001,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer,
|
||||
crDiscardable = BitSet8{};
|
||||
}
|
||||
|
||||
const auto ppc_mode = Core::System::GetInstance().GetPowerPC().GetMode();
|
||||
const bool hle = !!HLE::TryReplaceFunction(op.address, ppc_mode);
|
||||
const auto ppc_mode = power_pc.GetMode();
|
||||
const bool hle = !!HLE::TryReplaceFunction(ppc_symbol_db, op.address, ppc_mode);
|
||||
const bool may_exit_block = hle || op.canEndBlock || op.canCauseException;
|
||||
|
||||
const bool opWantsFPRF = op.wantsFPRF;
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include "Core/PowerPC/SignatureDB/SignatureDB.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
PPCSymbolDB g_symbolDB;
|
||||
|
||||
PPCSymbolDB::PPCSymbolDB() = default;
|
||||
|
||||
PPCSymbolDB::~PPCSymbolDB() = default;
|
||||
|
@ -39,5 +39,3 @@ public:
|
||||
void PrintCallers(u32 funcAddr) const;
|
||||
void LogFunctionCall(u32 addr);
|
||||
};
|
||||
|
||||
extern PPCSymbolDB g_symbolDB;
|
||||
|
@ -85,7 +85,8 @@ std::ostream& operator<<(std::ostream& os, CPUCore core)
|
||||
}
|
||||
|
||||
PowerPCManager::PowerPCManager(Core::System& system)
|
||||
: m_breakpoints(system), m_memchecks(system), m_debug_interface(system), m_system(system)
|
||||
: m_breakpoints(system), m_memchecks(system), m_debug_interface(system, m_symbol_db),
|
||||
m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
@ -668,7 +669,7 @@ void PowerPCManager::CheckBreakPoints()
|
||||
NOTICE_LOG_FMT(MEMMAP,
|
||||
"BP {:08x} {}({:08x} {:08x} {:08x} {:08x} {:08x} {:08x} {:08x} {:08x} {:08x} "
|
||||
"{:08x}) LR={:08x}",
|
||||
m_ppc_state.pc, g_symbolDB.GetDescription(m_ppc_state.pc), m_ppc_state.gpr[3],
|
||||
m_ppc_state.pc, m_symbol_db.GetDescription(m_ppc_state.pc), m_ppc_state.gpr[3],
|
||||
m_ppc_state.gpr[4], m_ppc_state.gpr[5], m_ppc_state.gpr[6], m_ppc_state.gpr[7],
|
||||
m_ppc_state.gpr[8], m_ppc_state.gpr[9], m_ppc_state.gpr[10], m_ppc_state.gpr[11],
|
||||
m_ppc_state.gpr[12], LR(m_ppc_state));
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Core/PowerPC/ConditionRegister.h"
|
||||
#include "Core/PowerPC/Gekko.h"
|
||||
#include "Core/PowerPC/PPCCache.h"
|
||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||
|
||||
class CPUCoreBase;
|
||||
class PointerWrap;
|
||||
@ -299,6 +300,8 @@ public:
|
||||
const MemChecks& GetMemChecks() const { return m_memchecks; }
|
||||
PPCDebugInterface& GetDebugInterface() { return m_debug_interface; }
|
||||
const PPCDebugInterface& GetDebugInterface() const { return m_debug_interface; }
|
||||
PPCSymbolDB& GetSymbolDB() { return m_symbol_db; }
|
||||
const PPCSymbolDB& GetSymbolDB() const { return m_symbol_db; }
|
||||
Core::BranchWatch& GetBranchWatch() { return m_branch_watch; }
|
||||
const Core::BranchWatch& GetBranchWatch() const { return m_branch_watch; }
|
||||
|
||||
@ -316,6 +319,7 @@ private:
|
||||
|
||||
BreakPoints m_breakpoints;
|
||||
MemChecks m_memchecks;
|
||||
PPCSymbolDB m_symbol_db;
|
||||
PPCDebugInterface m_debug_interface;
|
||||
Core::BranchWatch m_branch_watch;
|
||||
|
||||
|
@ -52,7 +52,8 @@ struct System::Impl
|
||||
m_memory(system), m_pixel_engine{system}, m_power_pc(system),
|
||||
m_mmu(system, m_memory, m_power_pc), m_processor_interface(system),
|
||||
m_serial_interface(system), m_system_timers(system), m_video_interface(system),
|
||||
m_interpreter(system, m_power_pc.GetPPCState(), m_mmu, m_power_pc.GetBranchWatch()),
|
||||
m_interpreter(system, m_power_pc.GetPPCState(), m_mmu, m_power_pc.GetBranchWatch(),
|
||||
m_power_pc.GetSymbolDB()),
|
||||
m_jit_interface(system), m_fifo_player(system), m_fifo_recorder(system), m_movie(system)
|
||||
{
|
||||
}
|
||||
@ -287,6 +288,11 @@ PowerPC::PowerPCState& System::GetPPCState() const
|
||||
return m_impl->m_power_pc.GetPPCState();
|
||||
}
|
||||
|
||||
PPCSymbolDB& System::GetPPCSymbolDB() const
|
||||
{
|
||||
return m_impl->m_power_pc.GetSymbolDB();
|
||||
}
|
||||
|
||||
ProcessorInterface::ProcessorInterfaceManager& System::GetProcessorInterface() const
|
||||
{
|
||||
return m_impl->m_processor_interface;
|
||||
|
@ -92,6 +92,7 @@ class MMU;
|
||||
class PowerPCManager;
|
||||
struct PowerPCState;
|
||||
} // namespace PowerPC
|
||||
class PPCSymbolDB;
|
||||
namespace ProcessorInterface
|
||||
{
|
||||
class ProcessorInterfaceManager;
|
||||
@ -184,6 +185,7 @@ public:
|
||||
PixelShaderManager& GetPixelShaderManager() const;
|
||||
PowerPC::PowerPCManager& GetPowerPC() const;
|
||||
PowerPC::PowerPCState& GetPPCState() const;
|
||||
PPCSymbolDB& GetPPCSymbolDB() const;
|
||||
ProcessorInterface::ProcessorInterfaceManager& GetProcessorInterface() const;
|
||||
SerialInterface::SerialInterfaceManager& GetSerialInterface() const;
|
||||
Sram& GetSRAM() const;
|
||||
|
Reference in New Issue
Block a user